From 76eb4ca3cc172c13400f83a3e61d93ee080ec0d9 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 10 May 2018 08:53:32 +0800 Subject: [PATCH 001/111] translated --- ...a lost root password in under 5 minutes.md | 82 ------------------- ...a lost root password in under 5 minutes.md | 81 ++++++++++++++++++ 2 files changed, 81 insertions(+), 82 deletions(-) delete mode 100644 sources/tech/20180430 Reset a lost root password in under 5 minutes.md create mode 100644 translated/tech/20180430 Reset a lost root password in under 5 minutes.md diff --git a/sources/tech/20180430 Reset a lost root password in under 5 minutes.md b/sources/tech/20180430 Reset a lost root password in under 5 minutes.md deleted file mode 100644 index 4521901e58..0000000000 --- a/sources/tech/20180430 Reset a lost root password in under 5 minutes.md +++ /dev/null @@ -1,82 +0,0 @@ -translating---geekpi - -Reset a lost root password in under 5 minutes -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum) - -A system administrator can easily reset passwords for users who have forgotten theirs. But what happens if the system administrator forgets the root password, or leaves the company? This guide will show you how to reset a lost or forgotten root password on a Red Hat-compatible system, including Fedora and CentOS, in less than 5 minutes. - -Please note, if the entire system hard disk has been encrypted with LUKS, you would need to provide the LUKS password when prompted. Also, this procedure is applicable to systems running systemd which has been the default init system since Fedora 15, CentOS 7.14.04, and Red Hat Enterprise Linux 7.0. - -First, you need to interrupt the boot process, so you'll need to turn the system on or restart it if it’s already powered on. The first step is tricky because the GRUB menu tends to flash very quickly on the screen. You may need to try this a few times until you are able to do it. - -Press **e** on your keyboard when you see this screen: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub0.png?itok=cz9nk5BT) - -If you've done this correctly, you should see a screen similar to this one: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub1.png?itok=3ZY5uiGq) - -Use your arrow keys to move to the Linux16 line: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub2_0.png?itok=8epRyqOl) - -Using your **del** key or your **backspace** key, remove `rhgb quiet` and replace with the following: - -`rd.break enforcing=0` - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub3.png?itok=JDdMXnUb) - -Setting `enforcing=0` will allow you to avoid performing a complete system SELinux relabeling. Once the system is rebooted, you'll only have to restore the correct SELinux context for the `/etc/shadow` file. I'll show you how to do this too. - -Press **Ctrl-x** to start. - -**The system will now be in emergency mode.** - -Remount the hard drive with read-write access: -``` -# mount –o remount,rw /sysroot - -``` - -Run `chroot` to access the system: -``` -# chroot /sysroot - -``` - -You can now change the root password: -``` -# passwd - -``` - -Type the new root password twice when prompted. If you are successful, you should see a message that reads " **all authentication tokens updated successfully**. " - -Type **exit** twice to reboot the system. - -Log in as root and restore the SELinux label to the `/etc/shadow` file. -``` -# restorecon -v /etc/shadow - -``` - -Turn SELinux back to enforcing mode: -``` -# setenforce 1 - -``` --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/reset-lost-root-password - -作者:[Curt Warfield][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/rcurtiswarfield diff --git a/translated/tech/20180430 Reset a lost root password in under 5 minutes.md b/translated/tech/20180430 Reset a lost root password in under 5 minutes.md new file mode 100644 index 0000000000..b8f292a5f2 --- /dev/null +++ b/translated/tech/20180430 Reset a lost root password in under 5 minutes.md @@ -0,0 +1,81 @@ +在 5 分钟内重置丢失的 root 密码 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum) + +系统管理员可以轻松地为忘记密码的用户重置密码。但是如果系统管理员忘记 root 密码或离开公司,会发生什么情况?本指南将向你介绍如何在不到 5 分钟的时间内在 Red Hat 兼容系统(包括 Fedora 和 CentOS)上重置丢失或忘记的 root 密码。 + +请注意,如果整个系统硬盘已用 LUKS 加密,则需要在出现提示时提供 LUKS 密码。此外,此过程适用于运行 systemd 的系统,该系统自 Fedora 15、CentOS 7.14.04 和 Red Hat Enterprise Linux 7.0 以来一直是缺省的初始系统。。 + +首先你需要终端启动的过程,因此你需要启动或者如果已经启动就重启它。第一步可能有点棘手因为 GRUB 菜单会在屏幕上快速地闪烁过去。你可能需要尝试几次,直到你能够做到这一点。 + +当你看到这个屏幕时,按下键盘上的 **e** 键: + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub0.png?itok=cz9nk5BT) + +如果你正确地做了这点,你应该看到一个类似于这个的屏幕: + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub1.png?itok=3ZY5uiGq) + +使用箭头键移动到 Linux16 这行: + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub2_0.png?itok=8epRyqOl) + +使用你的 **del** 键或你的 **backspace** 键,删除 `rhgb quiet` 并替换为以下内容: + +`rd.break enforcing=0` + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub3.png?itok=JDdMXnUb) + +设置 `enforcing=0` 可以避免执行完整的系统 SELinux 重标记。一旦系统重新启动,你只需要为 `/etc/shadow` 恢复正确的 SELinux 上下文。我会告诉你如何做到这一点。 + +按下 **Ctrl-x** 启动。 + +**系统现在将处于紧急模式。** + +以读写权限重新挂载硬盘驱动器: +``` +# mount –o remount,rw /sysroot + +``` + +运行 `chroot` 来访问系统: +``` +# chroot /sysroot + +``` + +你现在可以更改 root 密码: +``` +# passwd + +``` + +出现提示时,输入新的 root 密码两次。如果成功,你应该看到一条消息显示 “**all authentication tokens updated successfully**”。 + +输入 **exit** 两次以重新启动系统。 + +Log in as root and restore the SELinux label to the `/etc/shadow` file. +以 root 身份登录并将 SELinux 标签恢复到 `/etc/shadow` 。 +``` +# restorecon -v /etc/shadow + +``` + +将 SELinux 回到 enforce 模式: +``` +# setenforce 1 + +``` +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/reset-lost-root-password + +作者:[Curt Warfield][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/rcurtiswarfield From 6936285bb4c0e346a357e2e1d07ef6b312c3fe54 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 10 May 2018 09:01:53 +0800 Subject: [PATCH 002/111] translating --- sources/tech/20180426 Continuous Profiling of Go programs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180426 Continuous Profiling of Go programs.md b/sources/tech/20180426 Continuous Profiling of Go programs.md index ee91150b53..8d474b7124 100644 --- a/sources/tech/20180426 Continuous Profiling of Go programs.md +++ b/sources/tech/20180426 Continuous Profiling of Go programs.md @@ -1,3 +1,5 @@ +translating----geekpi + Continuous Profiling of Go programs ============================================================ From d5bcb42be934085459c3386be7fff0b72a0a9de3 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 10 May 2018 10:28:10 +0800 Subject: [PATCH 003/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Improv?= =?UTF-8?q?e=20Application=20Startup=20Time=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...prove Application Startup Time In Linux.md | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 sources/tech/20180507 How To Improve Application Startup Time In Linux.md diff --git a/sources/tech/20180507 How To Improve Application Startup Time In Linux.md b/sources/tech/20180507 How To Improve Application Startup Time In Linux.md new file mode 100644 index 0000000000..708835c82f --- /dev/null +++ b/sources/tech/20180507 How To Improve Application Startup Time In Linux.md @@ -0,0 +1,90 @@ +How To Improve Application Startup Time In Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/05/Preload-720x340.png) +Most Linux distributions are fast enough by default. However, we can still make them a little bit faster using some additional applications and methods. One such application we are about to see is **Preload**. It monitors the most frequently-used applications by the user and adds them to the memory, so that the applications will load little bit faster than before. Because, as you might already know, reading from the RAM is always faster than from the hard drive. Preload runs as a daemon on the background all the time and records the statistics about usage of files by more frequently-used programs. It then fetches those binaries and their dependencies into memory to improve the application loading time. In a nutshell, once preload is installed, you should be able to load the often-used applications much faster. + +In this brief tutorial, we are going to see how to install and use Preload to improve an application startup time in Linux. + +### Improve Application Startup Time In Linux Using Preload + +Preload is available in [**AUR**][1]. So you can install it using AUR helper programs in any Arch-based systems such as Antergos, Manjaro Linux. + +Using [**Pacaur**][2]: +``` +$ pacaur -S preload + +``` + +Using [**Packer**][3]: +``` +$ packer -S preload + +``` + +Using [**Trizen**][4]: +``` +$ trizen -S preload + +``` + +Using [**Yay**][5]: +``` +$ yay -S preload + +``` + +Using [**Yaourt**][6]: +``` +$ yaourt -S preload + +``` + +On Debian, Ubuntu, Linux Mint, Preload is available in the default repositories. So you can install it using APT package manager like below. +``` +$ sudo apt-get install preload + +``` + +Once Preload installed, reboot your system. From now on, Preload monitors the frequently-used applications and adds their binaries and libraries into the Memory for faster startup time. For example, if you often use Firefox, Chrome or LibreOffice, Preload will then add those binaries and libraries into RAM, so those applications will start faster. Good thing is it doesn’t need any configuration. It will just work out of the box. If you, however, wants to tweak the configuration, you can do it by editing the default configuration file **/etc/preload.conf**. + +### Preload isn’t for everyone! + +Here are some drawbacks of Preload and why it is not that effective for everyone, discussed in this [**thread**][7]. + + 1. I do have a decent specification system with 8GB RAM. So my system is generally fast. Also, I will open heavy memory-consuming applications, such as Firefox, Chrome, VirtualBox, Gimp etc., one or two times per day. They remain open all the time, hence their binaries and libraries are preloaded into memory and occupying the RAM all day. I rarely close and open those applications, so the RAM usage is simply waste. + 2. If you’re using modern systems with SSD, Preload is obviously useless. Because SSDs access time is much faster than normal hard drives, so using Preload is pointless. + 3. Preload significantly affects the boot time. Because the more applications are preloaded into RAM, the longer it takes to get your system up and running. + + + +You will only the see the real difference only if you’re reloading applications a LOT of time per day. So Preload will be ideal for the developers and testers who open and close the applications several times everyday. + +For more details about what exactly preload is and how it works, read the complete [**Preload thesis**][8] paper submitted by the author. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-improve-application-startup-time-in-linux/ + +作者:[SK][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.ostechnix.com/author/sk/ +[1]:https://aur.archlinux.org/packages/preload/ +[2]:https://www.ostechnix.com/install-pacaur-arch-linux/ +[3]:https://www.ostechnix.com/install-packer-arch-linux-2/ +[4]:https://www.ostechnix.com/trizen-lightweight-aur-package-manager-arch-based-systems/ +[5]:https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ +[7]:https://askubuntu.com/questions/110335/drawbacks-of-using-preload-why-isnt-it-included-by-default +[8]:https://cs.uwaterloo.ca/~brecht/courses/702/Possible-Readings/prefetching-to-memory/preload-thesis.pdf From b56d8c2e404ef460c81e6596b6e25a120e1f1fc6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 11:01:09 +0800 Subject: [PATCH 004/111] PRF:20180206 Why Linux is better than Windows or macOS for security.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 初校 @fuzheng1998 --- ...tter than Windows or macOS for security.md | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/translated/talk/20180206 Why Linux is better than Windows or macOS for security.md b/translated/talk/20180206 Why Linux is better than Windows or macOS for security.md index aa71a676b7..a223594d82 100644 --- a/translated/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/translated/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -2,29 +2,31 @@ 为什么 Linux 比 Windows 和 macOS 的安全性好 ====== +> 多年前做出的操作系统选型终将影响到如今的企业安全。在三大主流操作系统当中,有一个能被称作最安全的。 + ![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg) -企业投入了大量时间、精力和金钱来保障系统的安全性。最强的安全意识可能就是有一个安全的运营中心。他们肯定用了防火墙以及反病毒软件。他们可能花费大量时间监控他们的网络,寻找可能表明违规的信号异常。与 IDS、SIEM 和 NGFW 一样,他们部署了一个名副其实的防御字母表。 +企业投入了大量时间、精力和金钱来保障系统的安全性。最强的安全意识可能就是有一个安全运营中心,肯定用上了防火墙以及反病毒软件,可能花费大量时间监控他们的网络,寻找可能表明违规的异常信号,就像 IDS、SIEM 和 NGFW 一样,他们部署了一个名副其实的防御阵列。 -然而又有多少人想过数字化操作的基础之一:部署在员工的个人电脑上的操作系统?选择桌面操作系统的安全性是一个考虑的因素吗? +然而又有多少人想过数字化操作的基础之一:部署在员工的个人电脑上的操作系统?当选择桌面操作系统时,安全性是一个考虑的因素吗? 这就产生了一个 IT 人士都应该能回答的问题:一般部署哪种操作系统最安全呢? -我们问了一些专家他们对于以下三种选项的看法:Windows,最复杂的平台也是最受欢迎的桌面操作系统;macOS X,基于 FreeBSD 的 Unix 操作系统,驱动着苹果的 Macintosh 系列运行;还有 Linux,这里我们指的是所有的 Linux 发行版以及与基于 Unix 的操作系统相关的系统。 +我们问了一些专家他们对于以下三种选项的看法:Windows,最复杂的平台也是最受欢迎的桌面操作系统;macOS X,基于 FreeBSD 的 Unix 操作系统,驱动着苹果的 Macintosh 系统运行;还有 Linux,这里我们指的是所有的 Linux 发行版以及与基于 Unix 的操作系统相关的系统。 -### 我们怎么会这样 +### 怎么会这样 -企业可能没有评估他们部署到工作人员的操作系统的安全性的一个原因是,他们多年前就已经做出了选择。退一步讲,所有操作系统都还算安全,因为侵入他们,窃取数据或安装恶意软件的业务还处于起步阶段。而且一旦选择了操作系统,就很难再想改变。很少有 IT 组织希望将全球分散的员工队伍转移到全新的操作系统上。唉,他们已经受够了把用户搬到一个选好的新版本操作系统时的负面反响。 +企业可能没有评估他们部署到工作人员的操作系统的安全性的一个原因是,他们多年前就已经做出了选择。退一步讲,所有操作系统都还算安全,因为侵入它们,窃取数据或安装恶意软件的业务还处于起步阶段。而且一旦选择了操作系统,就很难再想改变。很少有 IT 组织希望将全球分散的员工队伍转移到全新的操作系统上。唉,他们已经受够了把用户搬到一个选好的新版本操作系统时的负面反响。 还有,重新考虑它是高明的吗?这三款领先的桌面操作系统在安全方面的差异是否足以值得我们去做出改变呢? -当然商业系统面临的威胁近几年已经改变了。攻击变得成熟多了。曾经支配了公众想象力的独自的青少年黑客已经被组织良好的犯罪分子网络以及具有庞大计算资源的政府资助组织的网络所取代。 +当然商业系统面临的威胁近几年已经改变了。攻击变得成熟多了。曾经支配了公众想象力的单枪匹马的青少年黑客已经被组织良好的犯罪分子网络以及具有庞大计算资源的政府资助组织的网络所取代。 -像你们许多人一样,我已经有了很多那儿的亲身经历:我曾经在许多 Windows 电脑上被恶意软件和病毒感染,我甚至被 Mac 文件的宏病毒感染了。最近,一个广泛传播的自动黑客绕开了网站的保护程序并用恶意软件感染了它。这种恶意软件的影响一开始是隐形的,甚至有些东西你没注意,直到恶意软件最终深深地植入系统以至于它的性能开始变差。一件有关病毒蔓延的震惊之事是我从未被不法之徒特定针对过;当今世界,用僵尸网络攻击 100,000 台电脑容易得就像一次攻击几台电脑一样。 +像你们许多人一样,我有过很多那时的亲身经历:我曾经在许多 Windows 电脑上被恶意软件和病毒感染,我甚至被 宏病毒感染了 Mac 上的文件。最近,一个广泛传播的自动黑客绕开了网站的保护程序并用恶意软件感染了它。这种恶意软件的影响一开始是隐形的,甚至有些东西你没注意,直到恶意软件最终深深地植入系统以至于它的性能开始变差。一件有关病毒蔓延的震惊之事是不法之徒从来没有特定针对过我;当今世界,用僵尸网络攻击 100,000 台电脑容易得就像一次攻击几台电脑一样。 ### 操作系统真的很重要吗? -给你的用户部署的那个操作系统确实对你的安全态度产生了影响,但那并不是一个可靠的安全措施。首先,现在的攻击很可能会发生,因为攻击者探测了你的用户,而不是你的系统。一项对参与过 DEFCON 会议黑客的[调查][1]表明“84%的人使用社交工程作为攻击策略的一部分。”部署安全操作系统只是一个重要的起点,但如果没有用户培训,强大的防火墙和持续的警惕性,即使是最安全的网络也会受到入侵。当然,用户下载的软件,扩展程序,实用程序,插件和其他软件的风险始终良好,但却成为恶意软件出现在系统上的一种途径. +给你的用户部署的那个操作系统确实对你的安全态度产生了影响,但那并不是一个可靠的安全措施。首先,现在的攻击很可能会发生,因为攻击者探测了你的用户,而不是你的系统。一项对参与过 DEFCON 会议黑客的[调查][1]表明“84%的人使用社交工程作为攻击策略的一部分。”部署安全操作系统只是一个重要的起点,但如果没有用户培训,强大的防火墙和持续的警惕性,即使是最安全的网络也会受到入侵。当然,用户下载的软件,扩展程序,实用程序,插件和其他看起来还好的软件总是有风险的,成为了恶意软件出现在系统上的一种途径. 无论你选择哪种平台,保持你系统安全最好的方法之一就是确保立即应用了软件更新。一旦补丁正式发布,黑客就可以对其进行反向工程并找到一种新的漏洞,以便在下一波攻击中使用。 @@ -32,55 +34,53 @@ 因为底线是您对系统做出的每一个决定都会影响您的安全性,即使您的用户工作使用的操作系统也是如此。 -**[ 若要给这个故事写评论, 请访问 [Computerworld's 的 Facebook 主页][3]. ]** - ### Windows,流行之选 -若你是一个安全管理人员,很可能文章中提出的问题就会变成这样:是否我们远离微软的 Windows 会更安全呢?说 Windows 主导商业市场都是低估事实了。[NetMarketShare][4] 估计互联网上 88% 的电脑令人震惊地运行着 Windows 的版本之一。 +若你是一个安全管理人员,很可能文章中提出的问题就会变成这样:是否我们远离微软的 Windows 会更安全呢?说 Windows 主导商业市场都是低估事实了。[NetMarketShare][4] 估计互联网上 88% 的电脑令人震惊地运行着 Windows 的某个版本。 -如果你的系统在这 88% 之中,你可能知道微软会继续加强 Windows 系统的安全性。改进重写了或者重新改写了他的代码库,增加了它的反病毒软件系统,改进了防火墙以及实现了沙箱架构,这样在沙箱里的程序就不能访问系统的内存空间或者其他应用程序。 +如果你的系统在这 88% 之中,你可能知道微软会继续加强 Windows 系统的安全性。不断重写其改进或者重新改写了其代码库,增加了它的反病毒软件系统,改进了防火墙以及实现了沙箱架构,这样在沙箱里的程序就不能访问系统的内存空间或者其他应用程序。 -但可能 Windows 的流行本身就是个问题操作系统的安全性可能很大程度上依赖于装机用户量的规模。对于恶意软件作者来说,Windows 提供了大的施展平台。专注其中可以让他们的努力发挥最大作用。 +但可能 Windows 的流行本身就是个问题,操作系统的安全性可能很大程度上依赖于装机用户量的规模。对于恶意软件作者来说,Windows 提供了大的施展平台。专注其中可以让他们的努力发挥最大作用。 -像 Troy Wilkinson,Axiom Cyber Solutions 的 CEO 解释的的那样,“Windows 总是因为很多原因安全性保障来的最晚,主要是因为消费者的采用率。由于市场上大量基于 Windows 的个人电脑,黑客历来最有针对性地将这些系统作为目标。” +像 Troy Wilkinson,Axiom Cyber Solutions 的 CEO 解释的那样,“Windows 总是因为很多原因而导致安全性保障来的最晚,主要是因为消费者的采用率。由于市场上大量基于 Windows 的个人电脑,黑客历来最有针对性地将这些系统作为目标。” -可以肯定地说,从梅丽莎病毒到 WannaCry 或者更强的,许多世界上可见的恶意软件早已对准了 Windows 系统. +可以肯定地说,从梅丽莎病毒到 WannaCry 或者更强的,许多世界上已知的恶意软件早已对准了 Windows 系统. ### macOS X 以及通过隐匿实现的安全 -如果最流行的操作系统总是成为大目标,那么用一个不流行的操作系统能确保安全吗?这个主意是老法新用——而且是完全不可信的概念——“通过隐匿实现的安全,” 这保持了软件专有的持续内部运作因此不为人知是抵御攻击的最好方法。 +如果最流行的操作系统总是成为大目标,那么用一个不流行的操作系统能确保安全吗?这个主意是老法新用——而且是完全不可信的概念——“通过隐匿实现的安全”,这秉承了让软件内部运作保持专有,从而不为人知是抵御攻击的最好方法的理念。 -Wilkinson 坦言,macOS X “比 Windows 更安全”,但他急于补充说,“macOS 曾被认为是一个安全漏洞很小的完全安全的操作系统,但近年来,我们看到黑客制造了额外的漏洞攻击苹果系统。” +Wilkinson 坦言,macOS X “比 Windows 更安全”,但他急于补充说,“macOS 曾被认为是一个安全漏洞很小的完全安全的操作系统,但近年来,我们看到黑客制造了攻击苹果系统的额外漏洞。” 换句话说,攻击者会扩大活动范围而不会无视 Mac 领域。 -Comparitech 的安全研究员 Lee Muson 说,在选择更安全的操作系统时,“macOS很可能是被挑选的一员”,但他提醒说,这一想法并不令人费解。它的优势在于“它仍然受益于通过隐匿实现的安全感和微软提供的更大的目标。” +Comparitech 的安全研究员 Lee Muson 说,在选择更安全的操作系统时,“macOS 很可能是被选中的目标”,但他提醒说,这一想法并不令人费解。它的优势在于“它仍然受益于通过隐匿实现的安全感和微软提供的更大的目标。” Wolf Solutions 公司的 Joe Moore 给予了苹果更多的信任,称“现成的 macOS X 在安全方面有着良好的记录,部分原因是它不像 Windows 那么广泛,而且部分原因是苹果公司在安全问题上干的不错。” -### 最终胜者是 … +### 最终胜者是 …… -你可能一开始就知道它:专家们的明确共识是 Linux 是最安全的操作系统。然而,尽管它是服务器的首选操作系统,但将其部署在桌面上的企业却很少。 +你可能一开始就知道它:专家们的明确共识是 Linux 是最安全的操作系统。然而,尽管它是服务器的首选操作系统,而将其部署在桌面上的企业很少。 如果你确定 Linux 是要选择的系统,你仍然需要决定选择哪种 Linux 系统,并且事情会变得更加复杂。 用户需要一个看起来很熟悉的用户界面,而你需要最安全的操作系统。 -像 Moore 解释的那样,“Linux 有可能是最安全的,但要求用户是很强大的用户。”所以,它不是针对所有人的。 +像 Moore 解释的那样,“Linux 有可能是最安全的,但要求用户是资深用户。”所以,它不是针对所有人的。 将安全性作为主要功能的 Linux 发行版包括 Parrot Linux,这是一个基于 Debian 的发行版,Moore 说,它提供了许多与安全相关开箱即用的工具。 当然,一个重要的区别是 Linux 是开源的。Simplex Solutions 的 CISO Igor Bidenko 说,编码人员可以阅读和评论彼此工作的现实看起来像是一场安全噩梦,但这确实是让 Linux 如此安全的重要原因。 “Linux 是最安全的操作系统,因为它的源代码是开放的。任何人都可以查看它,并确保没有错误或后门。” -Wilkinson 阐述说:“Linux 和基于 Unix 的操作系统具有较少的信息安全领域已知的可利用的安全缺陷。技术社区对 Linux 代码进行了审查,该代码有助于提高安全性:通过进行这么多的监督,易受攻击之处、漏洞和威胁就会减少。” +Wilkinson 阐述说:“Linux 和基于 Unix 的操作系统具有较少的信息安全领域已知的、可利用的安全缺陷。技术社区对 Linux 代码进行了审查,该代码有助于提高安全性:通过进行这么多的监督,易受攻击之处、漏洞和威胁就会减少。” 这是一个微妙的而违反直觉的解释,但是通过让数十人(有时甚至数百人)通读操作系统中的每一行代码,代码实际上更加健壮,并且发布漏洞错误的机会减少了。这与 PC World 为何出来说 Linux 更安全有很大关系。正如 Katherine Noyes 解释的那样,“微软可能吹捧它的大型付费开发者团队,但团队不太可能与基于全球的 Linux 用户开发者进行比较。 安全只能通过所有额外的关注获益。” -另一个被 PC 世界(一个由 [IDG](https://zh.wikipedia.org/wiki/%E5%9B%BD%E9%99%85%E6%95%B0%E6%8D%AE%E9%9B%86%E5%9B%A2) 发行的电脑杂志)举例的原因是 Linux 更好的用户特权模式:Windows 用户“一般被默认授予管理员权限,那意味着他们几乎可以访问系统中的一切,”Noye 的文章讲到。Linux,反而很好地限制了“root”权限。 +另一个被 《PC World》举例的原因是 Linux 更好的用户特权模式:Windows 用户“一般被默认授予管理员权限,那意味着他们几乎可以访问系统中的一切,”Noye 的文章讲到。Linux,反而很好地限制了“root”权限。 -Noyes 还指出,Linux 环境下的多样性可能比典型的 Windows 单一文化更好地对抗攻击:Linux 有很多不同的发行版。其中一些以其特别的安全关注点进行差异化。Comparitech 的安全研究员 Lee Muson 为 Linux 发行版提供了这样的建议:“Qubes OS 对于 Linux 来说是一个很好的出发点,现在你可以发现,爱德华斯诺登的认可大大地掩盖了它自己极其卑劣的主张。”其他安全性专家指向专门的安全 Linux 发行版,如 Tails Linux,它旨在直接从 USB 闪存驱动器或类似的外部设备安全地匿名运行。 +Noyes 还指出,Linux 环境下的多样性可能比典型的 Windows 单一文化更好地对抗攻击:Linux 有很多不同的发行版。其中一些以其特别的安全关注点进行差异化。Comparitech 的安全研究员 Lee Muson 为 Linux 发行版提供了这样的建议:“Qubes OS 对于 Linux 来说是一个很好的出发点,现在你可以发现,爱德华·斯诺登的认可大大地掩盖了它自己极其不起眼的主张。”其他安全性专家指出了专门的安全 Linux 发行版,如 Tails Linux,它旨在直接从 USB 闪存驱动器或类似的外部设备安全地匿名运行。 ### 构建安全趋势 -惯性是一股强大的力量。虽然人们有明确的共识,认为 Linux 是桌面系统的最安全选择,但并没有出现让 Windows 和 Mac 机器倾倒的倾向。尽管如此,Linux 采用率的小幅增长却可能会产生对所有人都更加安全的计算,因为市场份额的丧失是确定能获得微软和苹果公司关注的一个方式。换句话说,如果有足够的用户在桌面上切换到 Linux,Windows 和 Mac PC 很可能成为更安全的平台。 +惯性是一股强大的力量。虽然人们有明确的共识,认为 Linux 是桌面系统的最安全选择,但并没有出现对 Windows 和 Mac 机器压倒性的倾向。尽管如此,Linux 采用率的小幅增长却可能会产生对所有人都更加安全的计算,因为市场份额的丧失是确定能获得微软和苹果公司关注的一个方式。换句话说,如果有足够的用户在桌面上切换到 Linux,Windows 和 Mac PC 很可能成为更安全的平台。 -------------------------------------------------------------------------------- @@ -88,7 +88,7 @@ via: https://www.computerworld.com/article/3252823/linux/why-linux-is-better-tha 作者:[Dave Taylor][a] 译者:[fuzheng1998](https://github.com/fuzheng1998) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b84ba554ed221f7bb969749707cf5fef266ab14d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 11:16:17 +0800 Subject: [PATCH 005/111] PRF:20180412 How To Check User Created Date On Linux.md @geekpi --- ...How To Check User Created Date On Linux.md | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/translated/tech/20180412 How To Check User Created Date On Linux.md b/translated/tech/20180412 How To Check User Created Date On Linux.md index 55d97384ec..2aed7a468e 100644 --- a/translated/tech/20180412 How To Check User Created Date On Linux.md +++ b/translated/tech/20180412 How To Check User Created Date On Linux.md @@ -1,5 +1,6 @@ 如何在 Linux 上查看用户的创建日期 ====== + 你知道吗,如何在 Linux 系统上查看帐户的创建日期?如果知道,那么有些什么办法。 你成功了么?如果是的话,该怎么做? @@ -12,19 +13,18 @@ 可以使用以下 7 种方法进行验证。 - * 使用 /var/log/secure - * 使用 aureport 工具 - * 使用 .bash_logout - * 使用 chage 命令 - * 使用 useradd 命令 - * 使用 passwd 命令 - * 使用 last 命令 - - + * 使用 `/var/log/secure` + * 使用 `aureport` 工具 + * 使用 `.bash_logout` + * 使用 `chage` 命令 + * 使用 `useradd` 命令 + * 使用 `passwd` 命令 + * 使用 `last` 命令 ### 方式 1:使用 /var/log/secure -它存储所有安全相关的消息,包括身份验证失败和授权特权。它还会通过系统安全守护进程跟踪 sudo 登录、SSH 登录和其他错误记录。 +它存储所有安全相关的消息,包括身份验证失败和授权特权。它还会通过系统安全守护进程跟踪 `sudo` 登录、SSH 登录和其他错误记录。 + ``` # grep prakash /var/log/secure Apr 12 04:07:18 centos.2daygeek.com useradd[21263]: new group: name=prakash, GID=501 @@ -32,24 +32,24 @@ Apr 12 04:07:18 centos.2daygeek.com useradd[21263]: new user: name=prakash, UID= Apr 12 04:07:34 centos.2daygeek.com passwd: pam_unix(passwd:chauthtok): password changed for prakash Apr 12 04:08:32 centos.2daygeek.com sshd[21269]: Accepted password for prakash from 103.5.134.167 port 60554 ssh2 Apr 12 04:08:32 centos.2daygeek.com sshd[21269]: pam_unix(sshd:session): session opened for user prakash by (uid=0) - ``` ### 方式 2:使用 aureport 工具 -aureport 工具可以根据记录在审计日志中的事件记录生成汇总和柱状报告。默认情况下,它会查询 /var/log/audit/ 目录中的所有 audit.log 文件来创建报告。 +`aureport` 工具可以根据记录在审计日志中的事件记录生成汇总和柱状报告。默认情况下,它会查询 `/var/log/audit/` 目录中的所有 `audit.log` 文件来创建报告。 + ``` # aureport --auth | grep prakash 46. 04/12/2018 04:08:32 prakash 103.5.134.167 ssh /usr/sbin/sshd yes 288 47. 04/12/2018 04:08:32 prakash 103.5.134.167 ssh /usr/sbin/sshd yes 291 - ``` ### 方式 3:使用 .bash_logout -家目录中的 .bash_logout 对 bash 有特殊的含义,它提供了一种在用户退出系统时执行命令的方式。 +家目录中的 `.bash_logout` 对 bash 有特殊的含义,它提供了一种在用户退出系统时执行命令的方式。 + +我们可以查看用户家目录中 `.bash_logout` 的更改日期。该文件是在用户第一次注销时创建的。 -我们可以查看用户家目录中 .bash_logout 的更改日期。该文件是在用户第一次注销时创建的。 ``` # stat /home/prakash/.bash_logout File: `/home/prakash/.bash_logout' @@ -59,14 +59,14 @@ Access: (0644/-rw-r--r--) Uid: ( 501/ prakash) Gid: ( 501/ prakash) Access: 2017-03-22 20:15:00.000000000 -0400 Modify: 2017-03-22 20:15:00.000000000 -0400 Change: 2018-04-12 04:07:18.283000323 -0400 - ``` ### 方式 4:使用 chage 命令 -chage 代表 change age。该命令让用户管理密码过期信息。chage 命令更改密码更改时和上次密码更改日期之间的天数。 +`chage` 意即 “change age”。该命令让用户管理密码过期信息。`chage` 命令可以修改上次密码更改日期后需要更改密码的天数。 系统使用此信息来确定用户何时必须更改其密码。如果用户自帐户创建日期以来没有更改密码,这个就有用。 + ``` # chage --list prakash Last password change : Apr 12, 2018 @@ -76,45 +76,44 @@ Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 99999 Number of days of warning before password expires : 7 - ``` ### 方式 5:使用 useradd 命令 -useradd 命令用于在 Linux 中创建新帐户。默认情况下,它不会添加用户创建日期,我们必须使用 “Comment” 选项添加日期。 +`useradd` 命令用于在 Linux 中创建新帐户。默认情况下,它不会添加用户创建日期,我们必须使用 “备注” 选项添加日期。 + ``` # useradd -m prakash -c `date +%Y/%m/%d` # grep prakash /etc/passwd prakash:x:501:501:2018/04/12:/home/prakash:/bin/bash - ``` ### 方式 6:使用 passwd 命令 -passwd 命令用于将密码分配给本地帐户或用户。如果用户在帐户创建后没有修改密码,那么可以使用 passwd 命令查看最后一次密码修改的日期。 +`passwd` 命令用于将密码分配给本地帐户或用户。如果用户在帐户创建后没有修改密码,那么可以使用 `passwd` 命令查看最后一次密码修改的日期。 + ``` # passwd -S prakash prakash PS 2018-04-11 0 99999 7 -1 (Password set, MD5 crypt.) - ``` ### 方式 7:使用 last 命令 -last 命令读取 /var/log/wtmp,并显示自该文件创建以来所有登录(和退出)用户的列表。 +`last` 命令读取 `/var/log/wtmp`,并显示自该文件创建以来所有登录(和退出)用户的列表。 + ``` # last | grep "prakash" prakash pts/2 103.5.134.167 Thu Apr 12 04:08 still logged in - ``` -------------------------------------------------------------------------------- via: https://www.2daygeek.com/how-to-check-user-created-date-on-linux/ 作者:[Prakash Subramanian][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From cdf0dd92718062dd31ec6413d1b16415470752d5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 11:16:39 +0800 Subject: [PATCH 006/111] PUB:20180412 How To Check User Created Date On Linux.md @geekpi --- .../20180412 How To Check User Created Date On Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180412 How To Check User Created Date On Linux.md (100%) diff --git a/translated/tech/20180412 How To Check User Created Date On Linux.md b/published/20180412 How To Check User Created Date On Linux.md similarity index 100% rename from translated/tech/20180412 How To Check User Created Date On Linux.md rename to published/20180412 How To Check User Created Date On Linux.md From 3fc426473e94e28117e3a9b31b838c13c8bc50b8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 11:51:47 +0800 Subject: [PATCH 007/111] PRF:20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md @geekpi --- ...NG GO PROJECTS WITH DOCKER ON GITLAB CI.md | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md b/translated/tech/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md index 765dd14f33..f9ab95d57f 100644 --- a/translated/tech/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md +++ b/translated/tech/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md @@ -1,11 +1,11 @@ -在 GITLAB CI 中使用 DOCKER 构建 GO 项目 +在 GitKab CI 中使用 Docker 构建 Go 项目 =============================================== ### 介绍 -这篇文章是我在 CI 的 Docker 容器中构建 Go 项目的研究总结(特别是在 Gitlab 中)。我发现很难解决私有依赖问题(来自 Node/.NET 背景),因此这是我写这篇文章的主要原因。如果 Docker 镜像上存在任何问题或提交请求,请随时与我们联系。 +这篇文章是我在 CI 环境(特别是在 Gitlab 中)的 Docker 容器中构建 Go 项目的研究总结。我发现很难解决私有依赖问题(来自 Node/.NET 背景),因此这是我写这篇文章的主要原因。如果 Docker 镜像上存在任何问题或提交请求,请随时与我们联系。 -### Dep +### dep 由于 dep 是现在管理 Go 依赖关系的最佳选择,因此在构建前之前运行 `dep ensure`。 @@ -18,50 +18,43 @@ 我第一次尝试使用  `golang:1.10`,但这个镜像没有: * curl - * git - * make - * dep - * golint -我已经为我将不断更新的构建创建好了镜像([github][2] / [dockerhub][3]) - 但我不提供任何保证,因此你应该创建并管理自己的 Dockerhub。 +我已经创建好了用于构建的镜像([github][2] / [dockerhub][3]),我会保持更新,但我不提供任何担保,因此你应该创建并管理自己的 Dockerhub。 ### 内部依赖关系 -我们完全有能力创建一个有公共依赖关系的项目。但是如果你的项目依赖于另一个私人 gitlab 仓库呢? +我们完全有能力创建一个有公共依赖关系的项目。但是如果你的项目依赖于另一个私人 Gitlab 仓库呢? 在本地运行 `dep ensure` 应该可以和你的 git 设置一起工作,但是一旦在 CI 上不适用,构建就会失败。 -### Gitlab 权限模型 +#### Gitlab 权限模型 -这是在[ Gitlab 8.12 中添加的][4],我们关心的最有用的功能是在构建期提供的 `CI_JOB_TOKEN` 环境变量。 +这是在 [Gitlab 8.12 中添加的][4],这个我们最关心的有用的功能是在构建期提供的 `CI_JOB_TOKEN` 环境变量。 -这基本上意味着我们可以像这样克隆[依赖仓库][5] +这基本上意味着我们可以像这样克隆[依赖仓库][5]: ``` git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/myuser/mydependentrepo - ``` -然而,我们希望使这更友好一点,因为 dep 在试图拉取代码时不会奇迹般地添加凭据。 +然而,我们希望使这更友好一点,因为 `dep` 在试图拉取代码时不会奇迹般地添加凭据。 我们将把这一行添加到 `.gitlab-ci.yml` 的 `before_script` 部分。 ``` before_script: - echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc - ``` 使用 `.netrc` 文件可以指定哪个凭证用于哪个服务器。这种方法可以避免每次从 Git 中拉取(或推送)时输入用户名和密码。密码以明文形式存储,因此你不应在自己的计算机上执行此操作。这实际用于 Git 在背后使用  `cURL`。 [在这里阅读更多][6]。 -项目文件 -============================================================ +### 项目文件 -### Makefile +#### Makefile 虽然这是可选的,但我发现它使事情变得更容易。 @@ -93,7 +86,7 @@ lint-all: ``` -### .gitlab-ci.yml +#### .gitlab-ci.yml 这是 Gitlab CI 魔术发生的地方。你可能想使用自己的镜像。 @@ -132,7 +125,7 @@ build: ### 缺少了什么 -我通常会用我的二进制文件构建 Docker 镜像,并将其推送到 Gitlab 容器注册器中。 +我通常会用我的二进制文件构建 Docker 镜像,并将其推送到 Gitlab 容器注册库中。 你可以看到我正在构建二进制文件并退出,你至少需要将该二进制文件(例如生成文件)存储在某处。 @@ -140,9 +133,9 @@ build: via: https://seandrumm.co.uk/blog/building-go-projects-with-docker-on-gitlab-ci/ -作者:[ SEAN DRUMM][a] +作者:[SEAN DRUMM][a] 译者:[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/) 荣誉推出 From a7b3702e552649b246e9a0bf9b57cfd94f1a406f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 11:52:10 +0800 Subject: [PATCH 008/111] PUB:20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md @geekpi --- .../20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md (100%) diff --git a/translated/tech/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md b/published/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md similarity index 100% rename from translated/tech/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md rename to published/20180412 BUILDING GO PROJECTS WITH DOCKER ON GITLAB CI.md From 90cf3183adf2fdb55887905ab5e1aa925f2e5f35 Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Thu, 10 May 2018 12:13:45 +0800 Subject: [PATCH 009/111] Update 20180502 zzupdate - Single Command To Upgrade Ubuntu.md --- .../20180502 zzupdate - Single Command To Upgrade Ubuntu.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md b/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md index b3c1e2f480..0cdb325a1f 100644 --- a/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md +++ b/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md @@ -1,3 +1,5 @@ +Translating by XiatianSummer@Github + zzupdate - Single Command To Upgrade Ubuntu ====== Ubuntu 18.04 was already out and got good feedback from multiple community because Ubuntu 18.04 is the most exciting release of Ubuntu in years. From 2a3087f63b450c0dd500690a00159bfd44e3e5b7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 12:25:47 +0800 Subject: [PATCH 010/111] PRF:20171220 Containers without Docker at Red Hat.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @pinewall 翻译的很好! --- ...20 Containers without Docker at Red Hat.md | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/translated/tech/20171220 Containers without Docker at Red Hat.md b/translated/tech/20171220 Containers without Docker at Red Hat.md index b123109967..6cb741069e 100644 --- a/translated/tech/20171220 Containers without Docker at Red Hat.md +++ b/translated/tech/20171220 Containers without Docker at Red Hat.md @@ -1,71 +1,72 @@ Red Hat 的去 Docker 化容器实践 ====== -最近几年,开源项目Docker (已更名为[Moby][1]) 在容器普及化方面建树颇多。然而,它的功能特性不断集中到一个单一、庞大的系统,该系统由具有 root 权限运行的守护进程 `dockerd` 管控,这引发了人们的焦虑。对这些焦虑的阐述,具有代表性的是 Red Hat 公司的容器团队负责人 Dan Walsh 在 [KubeCon \+ CloudNativecon][3] 会议中的[演讲][2]。Walsh讲述了他的容器团队目前的工作方向,即使用一系列更小、可协同工作的组件替代 Docker。他的战斗口号是”拒绝臃肿的守护进程“,理由是与公认的 Unix 哲学相违背。 +最近几年,开源项目 Docker (已更名为[Moby][1]) 在容器普及化方面建树颇多。然而,它的功能特性不断集中到一个单一、庞大的系统,该系统由具有 root 权限运行的守护进程 `dockerd` 管控,这引发了人们的焦虑。对这些焦虑的阐述,具有代表性的是 Red Hat 公司的容器团队负责人 Dan Walsh 在 [KubeCon + CloudNativecon][3] 会议中的[演讲][2]。Walsh 讲述了他的容器团队目前的工作方向,即使用一系列更小、可协同工作的组件替代 Docker。他的战斗口号是“拒绝臃肿的守护进程”,理由是与公认的 Unix 哲学相违背。 ### Docker 模块化实践 -就像我们在[早期文献][4]中看到的那样,容器的基础操作不复杂:你首先拉取一个容器镜像,利用该镜像创建一个容器,最后启动这个容器。除此之外,你要懂得如何构建镜像并推送至镜像仓库。大多数人在上述这些步骤中使用 Docker,但其实 Docker 并不是唯一的选择,目前的可替换选择是 `rkt`。rkt引发了一系列标准的创建,包括运行时标准 CRI,镜像标准 OCI 及网络标准 CNI 等。遵守这些标准的后端,如 [CRI-O][5] 和 Docker,可以与 [Kubernetes][6] 为代表的管理软件协同工作。 +就像我们在[早期文献][4]中看到的那样,容器的基础操作不复杂:你首先拉取一个容器镜像,利用该镜像创建一个容器,最后启动这个容器。除此之外,你要懂得如何构建镜像并推送至镜像仓库。大多数人在上述这些步骤中使用 Docker,但其实 Docker 并不是唯一的选择,目前的可替换选择是 `rkt`。rkt 引发了一系列标准的创建,包括运行时标准 CRI,镜像标准 OCI 及网络标准 CNI 等。遵守这些标准的后端,如 [CRI-O][5] 和 Docker,可以与 [Kubernetes][6] 为代表的管理软件协同工作。 -这些标准促使 Red Hat 公司开发了一系列部分实现标准的”核心应用“供 Kubernetes 使用,例如 CRI-O 运行时。但 Kubernetes 提供的功能不足以满足 Red Hat公司的 [OpenShift][7] 项目所需。开发者可能需要构建容器并推送至镜像仓库,实现这些操作需要额外的一整套方案。 +这些标准促使 Red Hat 公司开发了一系列实现了部分标准的“核心应用”供 Kubernetes 使用,例如 CRI-O 运行时。但 Kubernetes 提供的功能不足以满足 Red Hat 公司的 [OpenShift][7] 项目所需。开发者可能需要构建容器并推送至镜像仓库,实现这些操作需要额外的一整套方案。 -事实上,目前市面上已有多种构建容器的工具。来自 Sysdig 公司的 Michael Ducy 在[分会场][8]中回顾了 Docker 本身之外的8种镜像构建工具,而这也很可能不是全部的工具。Ducy 将理想的构建工具定义如下:可以用可重现的方式创建最小化镜像。最小化镜像并不包含操作系统,只包含应用本身及其依赖。Ducy 认为 [Distroless][9], [Smith][10] 及 [Source-to-Image][11] 都是很好的工具,可用于构建最小化镜像。Ducy 将最小化镜像称为”微容器“。 +事实上,目前市面上已有多种构建容器的工具。来自 Sysdig 公司的 Michael Ducy 在[分会场][8]中回顾了 Docker 本身之外的 8 种镜像构建工具,而这也很可能不是全部。Ducy 将理想的构建工具定义如下:可以用可重现的方式创建最小化镜像。最小化镜像并不包含操作系统,只包含应用本身及其依赖。Ducy 认为 [Distroless][9], [Smith][10] 及 [Source-to-Image][11] 都是很好的工具,可用于构建最小化镜像。Ducy 将最小化镜像称为“微容器”。 -可重现镜像是指构建多次结果保持不变的镜像。为达到这个目标,Ducy 表示应该使用“宣告式”而不是“命令式”的方式。考虑到 Ducy 来自 Chef 配置管理工具领域,你应该能理解他的意思。Ducy 给出了符合标准的几个不错的实现,包括 [Ansible 容器][12], [Habitat][13], [nixos-容器][14]和 [Simth][10] 等,但你需要了解这些项目对应的编程语言。Ducy 额外指出 Habitat 构建的容器自带管理功能,如果你已经使用了systemd, Docker 或 Kubernetes 等外部管理工具,Habitat 的管理功能可能是冗余的。除此之外,我们还要提从 Docker 和 [Buildah][16] 项目诞生的新项目 [BuildKit][15], 它是 Red Hat 公司 [Atomic 工程][17]的一个组件。 +可重现镜像reproducible container是指构建多次结果保持不变的镜像。为达到这个目标,Ducy 表示应该使用“宣告式”而不是“命令式”的方式。考虑到 Ducy 来自 Chef 配置管理工具领域,你应该能理解他的意思。Ducy 给出了符合标准的几个不错的实现,包括 [Ansible 容器][12]、 [Habitat][13]、 [nixos-容器][14]和 [Simth][10] 等,但你需要了解这些项目对应的编程语言。Ducy 额外指出 Habitat 构建的容器自带管理功能,如果你已经使用了 systemd、 Docker 或 Kubernetes 等外部管理工具,Habitat 的管理功能可能是冗余的。除此之外,我们还要提到从 Docker 和 [Buildah][16] 项目诞生的新项目 [BuildKit][15], 它是 Red Hat 公司 [Atomic 工程][17]的一个组件。 -### 使用Buildah构建容器 +### 使用 Buildah 构建容器 -![\[Buildah logo\]][18] Buildah 名称显然来自于 Walsh 风趣的 [Boston 口音][19]; 该工具的品牌宣传中充满了 Boston 风格,例如 logo 使用了 Boston 梗犬(如图所示)。该项目的实现思路与 Ducy 不同:为了构建容器,与其被迫使用宣告式配置管理的方案,不如构建一些简单工具,结合你最喜欢的配置管理工具使用。这样你可以如愿的使用命令行,例如使用 `cp` 命令代替 Docker 的自定义指令 `COPY` 。除此之外,你可以使用如下工具为容器提供内容:1) 配置管理工具,例如Ansible 或 Puppet;2) 操作系统相关或编程语言相关的安装工具,例如 APT 和 pip; 3) 其它系统。下面展示了基于通用 shell 命令的容器构建场景,其中只需要使用 `make` 命令即可为容器安装可执行文件。 +![\[Buildah logo\]][18] + +Buildah 名称显然来自于 Walsh 风趣的 [波士顿口音][19]; 该工具的品牌宣传中充满了波士顿风格,例如 logo 使用了波士顿梗犬(如图所示)。该项目的实现思路与 Ducy 不同:为了构建容器,与其被迫使用宣告式配置管理的方案,不如构建一些简单工具,结合你最喜欢的配置管理工具使用。这样你可以如愿的使用命令行,例如使用 `cp` 命令代替 Docker 的自定义指令 `COPY` 。除此之外,你可以使用如下工具为容器提供内容:1) 配置管理工具,例如Ansible 或 Puppet;2) 操作系统相关或编程语言相关的安装工具,例如 APT 和 pip; 3) 其它系统。下面展示了基于通用 shell 命令的容器构建场景,其中只需要使用 `make` 命令即可为容器安装可执行文件。 ``` - # 拉取基础镜像, 类似 Dockerfile 中的 FROM 命令 - buildah from redhat +# 拉取基础镜像, 类似 Dockerfile 中的 FROM 命令 +buildah from redhat - # 挂载基础镜像, 在其基础上工作 - crt=$(buildah mount) - ap foo $crt - make install DESTDIR=$crt - - # 下一步,生成快照 - buildah commit +# 挂载基础镜像, 在其基础上工作 +crt=$(buildah mount) +ap foo $crt +make install DESTDIR=$crt +# 下一步,生成快照 +buildah commit ``` 有趣的是,基于这个思路,你可以复用主机环境中的构建工具,无需在镜像中安装这些依赖,故可以构建非常微小的镜像。通常情况下,构建容器镜像时需要在容器中安装目标应用的构建依赖。例如,从源码构建需要容器中有编译器工具链,这是因为构建并不在主机环境进行。大量的容器也包含了 `ps` 和 `bash` 这样的 Unix 命令,对微容器而言其实是多余的。开发者经常忘记或无法从构建好的容器中移除一些依赖,增加了不必要的开销和攻击面。 -Buildah的模块化方案能够以非 root 方式进行部分构建;但`mount` 命令仍然需要 `CAP_SYS_ADMIN` 或 `等同 root 访问权限` 的能力,有一个 [issue][20] 试图解决该问题。但 Buildah 与 Docker [都有][21]同样的限制[22],即无法在容器内构建容器。对于 Docker,你需要使用“特权”模式运行容器,一些特殊的环境很难满足这个条件,例如 [GitLab 持续集成][23];即使满足该条件,配置也特别[繁琐][24]。 +Buildah 的模块化方案能够以非 root 方式进行部分构建;但`mount` 命令仍然需要 `CAP_SYS_ADMIN`,有一个 [工单][20] 试图解决该问题。但 Buildah 与 Docker [都有][21]同样的[限制][22],即无法在容器内构建容器。对于 Docker,你需要使用“特权”模式运行容器,一些特殊的环境很难满足这个条件,例如 [GitLab 持续集成][23];即使满足该条件,配置也特别[繁琐][24]。 手动提交的步骤可以对创建容器快照的时间节点进行细粒度控制。Dockerfile 每一行都会创建一个新的快照;相比而言,Buildah 的提交检查点都是事先选择好的,这可以减少不必要的快照并节省磁盘空间。这也有利于隔离私钥或密码等敏感信息,避免其出现在公共镜像中。 -Docker 构建的镜像是非标准的、仅供其自身使用;相比而言,Buildah 提供[多种输出格式][25],其中包括符合 OCI 标准的镜像。为向后兼容,Buildah 提供 一个 `使用Dockerfile构建` 的命令,即 [`buildah bud`][26], 它可以解析标准的 Dockerfile。Buildah 提供 `enter` 命令直接查看镜像内部信息,`run` 命令启动一个容器。实现这些功能仅使用了 `runc` 在内的标准工具,无需在后台运行一个“臃肿的守护进程”。 +Docker 构建的镜像是非标准的、仅供其自身使用;相比而言,Buildah 提供[多种输出格式][25],其中包括符合 OCI 标准的镜像。为向后兼容,Buildah 提供了一个“使用 Dockerfile 构建”的命令,即 [`buildah bud`][26], 它可以解析标准的 Dockerfile。Buildah 提供 `enter` 命令直接查看镜像内部信息,`run` 命令启动一个容器。实现这些功能仅使用了 `runc` 在内的标准工具,无需在后台运行一个“臃肿的守护进程”。 -Ducy 对 Buildah 表示质疑,认为采用非宣告性不利于可重现性。如果允许使用 shell 命令,可能产生很多预想不到的情况;例如,一个 shell 脚本下载了任意的可执行程序,但后续无法追溯文件的来源。shell 命令的执行受环境变量影响,执行结果可能大相径庭。与基于 shell 的工具相比,Puppet 或 Chef 这样的配置管理系统在理论上更加可靠,因为他们的设计初衷就是收敛于最终配置;事实上,可以通过配置管理系统调用 shell 命令。但 Walsh 对此提出反驳,认为已有的配置管理工具可以在 Buildah 的基础上工作,用户可以选择是否使用配置管理;这样更加符合“机制与策略分离”的经典 Unix 哲学。 +Ducy 对 Buildah 表示质疑,认为采用非宣告性不利于可重现性。如果允许使用 shell 命令,可能产生很多预想不到的情况;例如,一个 shell 脚本下载了任意的可执行程序,但后续无法追溯文件的来源。shell 命令的执行受环境变量影响,执行结果可能大相径庭。与基于 shell 的工具相比,Puppet 或 Chef 这样的配置管理系统在理论上更加可靠,因为它们的设计初衷就是收敛于最终配置;事实上,可以通过配置管理系统调用 shell 命令。但 Walsh 对此提出反驳,认为已有的配置管理工具可以在 Buildah 的基础上工作,用户可以选择是否使用配置管理;这样更加符合“机制与策略分离”的经典 Unix 哲学。 -目前 Buildah 处于测试阶段,Red Hat 公司正努力将其集成到 OpenShift。我写这篇文章时已经测试过 Buildah,它缺少一些主题的文档,但基本可以稳定运行。尽管在错误处理方面仍有待提高,但它确实是一款值得你关注的容器工具。 +目前 Buildah 处于测试阶段,Red Hat 公司正努力将其集成到 OpenShift。我写这篇文章时已经测试过 Buildah,它缺少一些文档,但基本可以稳定运行。尽管在错误处理方面仍有待提高,但它确实是一款值得你关注的容器工具。 ### 替换其它 Docker 命令行 -Walsh 在其演讲中还简单介绍了 Redhat 公司 正在开发的另一个暂时叫做 [libpod][24] 的项目。项目名称来源于 Kubernetes 中的 “pod”, 在 Kubernetes 中 “pod” 用于分组主机内的容器,分享名字空间等。 +Walsh 在其演讲中还简单介绍了 Red hat 公司 正在开发的另一个暂时叫做 [libpod][24] 的项目。项目名称来源于 Kubernetes 中的 “pod”, 在 Kubernetes 中 “pod” 用于分组主机内的容器,分享名字空间等。 Libpod 提供 `kpod` 命令,用于直接检查和操作容器存储。Walsh 分析了该命令发挥作用的场景,例如 `dockerd` 停止响应或 Kubernetes 集群崩溃。基本上,`kpod` 独立地再次实现了 `docker` 命令行工具。`kpod ps` 返回运行中的容器列表,`kpod images` 返回镜像列表。事实上,[命令转换速查手册][28] 中给出了每一条 Docker 命令对应的 `kpod` 命令。 -这种模块化实现的一个好处是,当你使用 `kpod run` 运行容器时,容器直接作为当前 shell 而不是 `dockerd` 的子进程启动。理论上,可以直接使用 systemd 启动容器,这样可以消除 `dockerd` 引入的冗余。这让[由套接字激活的容器][29]成为可能,但暂时基于 Docker 实现该特性[并不容易][30],[即使借助 Kubernetes][31] 也是如此。但我在测试过程中发现,使用 `kpod` 启动的容器有一些基础功能性缺失,具体而言是网络功能(!),相关实现在[活跃开发][32]过程中。 +这种模块化实现的一个好处是,当你使用 `kpod run` 运行容器时,容器直接作为当前 shell 而不是 `dockerd` 的子进程启动。理论上,可以直接使用 systemd 启动容器,这样可以消除 `dockerd` 引入的冗余。这让[由套接字激活的容器][29]成为可能,但暂时基于 Docker 实现该特性[并不容易][30],[即使借助 Kubernetes][31] 也是如此。但我在测试过程中发现,使用 `kpod` 启动的容器有一些基础功能性缺失,具体而言是网络功能(!),相关实现在[活跃开发][32]过程中。 -我们最后提到的命令是 `push`。虽然上述命令已经足以满足本地使用容器的需求,但没有提到远程仓库,借助远程仓库开发者可以活跃地进行应用打包协作。仓库也是持续部署框架的核心组件。[skopeo][33] 项目用于填补这个空白,它是另一个 Atomic 成员项目,按其 `README` 文件描述,“包含容器镜像及镜像库的多种操作”。该项目的设计初衷是,在不用类似 `docker pull` 那样实际下载可能体积庞大的镜像的前提下,检查容器镜像的内容。Docker [拒绝加入][34] 检查功能,建议通过一个额外的工具实现该功能,这促成了 Skopeo 项目。除了`pull`,`push`,Skopeo现在还可以完成很多其它操作,例如在,不产生本地副本的情况下将镜像在不同的仓库中复制和转换。由于部分功能比较基础,可供其它项目使用,目前很大一部分 Skopeo 代码位于一个叫做 [containers/image][35] 的基础库。[Pivotal][36], Google的 [container-diff][37] ,`kpod push` 及 `buildah push` 都使用了该库。 +我们最后提到的命令是 `push`。虽然上述命令已经足以满足本地使用容器的需求,但没有提到远程仓库,借助远程仓库开发者可以活跃地进行应用打包协作。仓库也是持续部署框架的核心组件。[skopeo][33] 项目用于填补这个空白,它是另一个 Atomic 成员项目,按其 `README` 文件描述,“包含容器镜像及镜像库的多种操作”。该项目的设计初衷是,在不用类似 `docker pull` 那样实际去下载可能体积庞大的镜像的前提下,检查容器镜像的内容。Docker [拒绝加入][34] 检查功能,建议通过一个额外的工具实现该功能,这促成了 Skopeo 项目。除了 `pull`、`push`,Skopeo 现在还可以完成很多其它操作,例如在,不产生本地副本的情况下将镜像在不同的仓库中复制和转换。由于部分功能比较基础,可供其它项目使用,目前很大一部分 Skopeo 代码位于一个叫做 [containers/image][35] 的基础库。[Pivotal][36]、 Google 的 [container-diff][37] 、`kpod push` 及 `buildah push` 都使用了该库。 -`kpod` 与 Kubernetes 并没有紧密的联系,故未来可能会更换名称(事实上,在本文刊发过程中,已经更名为 [`podman`][38]),毕竟 Red Hat 法务部门还没有明确其名称。该团队希望实现更多 pod 级别的命令,这样可以对多个容器进行操作,有点类似于 [`docker compose`][39] 实现的功能。但在这方面,[Kompose][40] 是更好的工具,可以通过 [复合 YAML 文件][41] 在 Kubernetes 集群中运行容器。按计划,我们不会实现类似于 [`swarm`] 的 Docker 命令,这部分功能最好由 Kubernetes 本身完成。 +`kpod` 与 Kubernetes 并没有紧密的联系,故未来可能会更换名称(事实上,在本文刊发过程中,已经更名为 [`podman`][38]),毕竟 Red Hat 法务部门还没有明确其名称。该团队希望实现更多 pod 级别的命令,这样可以对多个容器进行操作,有点类似于 [`docker compose`][39] 实现的功能。但在这方面,[Kompose][40] 是更好的工具,可以通过 [复合 YAML 文件][41] 在 Kubernetes 集群中运行容器。按计划,我们不会实现类似于 [`swarm`] 的 Docker 命令,这部分功能最好由 Kubernetes 本身完成。 -目前看来,已经持续数年的 Docker 模块化努力终将硕果累累。但目前 `kpod` 处于快速迭代过程中,不太适合用于生产环境,但那些工具的众不同的设计理念让人很感兴趣,而且其中大部分的工具已经可以用于开发环境。目前只能通过编译源码的方式安装 libpod,但最终会提供各个发行版的二进制包。 +目前看来,已经持续数年的 Docker 模块化努力终将硕果累累。但目前 `kpod` 处于快速迭代过程中,不太适合用于生产环境,不过那些工具的与众不同的设计理念让人很感兴趣,而且其中大部分的工具已经可以用于开发环境。目前只能通过编译源码的方式安装 libpod,但最终会提供各个发行版的二进制包。 > 本文[最初发表][43]于 [Linux Weekly News][44]。 -------------------------------------------------------------------------------- -链接: https://anarc.at/blog/2017-12-20-docker-without-docker/ +via: https://anarc.at/blog/2017-12-20-docker-without-docker/ -作者:[À propos de moi][a] +作者:[Anarcat][a] 译者:[pinewall](https://github.com/pinewall) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a52d3225490dd5f0951927805d0e219ae4809222 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 12:26:16 +0800 Subject: [PATCH 011/111] PUB:20171220 Containers without Docker at Red Hat.md @pinewall https://linux.cn/article-9626-1.html --- .../20171220 Containers without Docker at Red Hat.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171220 Containers without Docker at Red Hat.md (100%) diff --git a/translated/tech/20171220 Containers without Docker at Red Hat.md b/published/20171220 Containers without Docker at Red Hat.md similarity index 100% rename from translated/tech/20171220 Containers without Docker at Red Hat.md rename to published/20171220 Containers without Docker at Red Hat.md From d1c516b2d40b3c119f65da4e055c665d53a1e0d6 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 10 May 2018 12:54:45 +0800 Subject: [PATCH 012/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Person=20with=20d?= =?UTF-8?q?iabetes=20finds=20open=20source=20and=20builds=20her=20own=20me?= =?UTF-8?q?dical=20device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ource and builds her own medical device.md | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 sources/talk/20180508 Person with diabetes finds open source and builds her own medical device.md diff --git a/sources/talk/20180508 Person with diabetes finds open source and builds her own medical device.md b/sources/talk/20180508 Person with diabetes finds open source and builds her own medical device.md new file mode 100644 index 0000000000..f5377736d0 --- /dev/null +++ b/sources/talk/20180508 Person with diabetes finds open source and builds her own medical device.md @@ -0,0 +1,84 @@ +Person with diabetes finds open source and builds her own medical device +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/health_heartbeat.png?itok=P-GXea-p) +Dana Lewis is the 2018 Women in [Open Source Community Award][1] winner! Here is her story about how open source improved her health in a big way. + +Dana has Type 1 diabetes and commercially available medical devices were failing her. The continuous glucose monitor (CGM) alarm she was using to manage her blood sugar was not loud enough to wake her up. The product design put her in danger every time she went to sleep. + +"I went to a bunch of manufacturers and asked what they could do, and I was told, 'It’s loud enough for most people.' I was told that 'it’s not a problem for most people, and we're working on it. It'll be out in a future version.’' That was all really frustrating to hear, but at the same time, I didn’t feel like I could do anything about it because it’s an FDA-approved medical device. You can’t change it." + +These obstacles aside, Dana thought that if she could get her data from the device, she could use her phone to make a louder alarm. Toward the end of 2013, she saw a tweet that provided an answer to her problem. The author of the tweet, who is the parent of a child with diabetes, had reverse-engineered a CGM to get the data off his child’s device so that he could monitor his child’s blood sugar remotely. + +She realized that if he was willing to share, she could use the same code to build a louder alarm system. + +"I didn’t understand that it was perfectly normal to ask people to share code. That was my first introduction to open source." + +The system evolved from a louder alarm to a web page where she could share data with her loved ones. Together with her now-husband, Scott Leibrand, she iteratively added features to the page, eventually including an algorithm that could not only monitor glucose levels in real time but also proactively predict future highs and lows. + +As Dana got more involved with the open source diabetes community, she met Ben West. He had spent years figuring out how to communicate with the insulin pump Dana used. Unlike a CGM, which tells the user if their blood sugar is high or low, an insulin pump is a separate device used to continuously infuse insulin throughout the day. + +"A light bulb went off. We said, 'Oh, if we take this code to communicate with the pump with what we’ve done to access the data from the CGM in real time and our algorithm, we can actually process data from both devices in real time and create a closed-loop system.'" + +The result was a do-it-yourself artificial pancreas system (DIY APS). + +Using the algorithm to process data from the insulin pump and CGM, the DIY APS forecasts predicted blood glucose levels and automates adjustments to the insulin delivery, making small changes to keep blood sugar within the target range. This makes life much easier for people with diabetes because they no longer have to calibrate insulin delivery manually several times per day. + +"Because we had been using open source software, we knew that the right thing to do was to turn around and make what we had done open source as well so that other people could leverage it." And thus, OpenAPS (the Open Source Artificial Pancreas System) was born. + +The OpenAPS community has since grown to more than 600 users of various DIY "closed-loop" systems. OpenAPS contributors have embraced the hashtag #WeAreNotWaiting as a mantra to express their belief that patient communities should not have to wait for the healthcare industry to create something that works for them. + +"Yes, you may choose to adopt a commercial solution in the future—that’s totally fine, and you should have the freedom do to that. Waiting should be a choice and not the status quo. To me, what’s amazing about this movement of open source in healthcare is that waiting is now a choice. You can choose not to DIY. You can choose to wait for a commercial solution. But if you don’t want to wait, you don’t have to. There are a plethora of options to take advantage of. A lot of problems have been solved by people in the community." + +The OpenAPS community is made up of people with diabetes, their loved ones, parents of children with diabetes, and people who want to use their skills for good. By helping lead the community, Dana has learned about the many ways of contributing to an open source project. She sees many valuable contributions to OpenAPS come from non-technical contributors on Facebook or [Gitter][2]. + +"There are a lot of different ways that people contribute, and it’s important that we recognize all of those because they’re all equally valuable. And they often involve different interests and different skill sets, but together, that’s what makes a community project in open source succeed." + +She knows firsthand how discouraging it can be for contributions to go unrecognized by others in a community. She also isn’t shy about discussing people’s tendency to discount the contributions of women. She first wrote about her experience being treated differently in a [2014 blog post][3] and [reflected on it again][4] when she learned she was a Women in Open Source Award finalist. + +In her first blog post, she and Scott shared the differences in the way they were treated by members of the community. They both noticed that, in subtle ways, Dana was constantly battling to be taken seriously. People often directed technical questions to him instead of her, even after Scott tried to redirect them to Dana. By calling out these behaviors, the post opened up a highly productive discussion in the community. + +"People would talk about the project initially as 'Scott’s thing' instead of 'Dana and Scott’s thing.' It was death by a thousand paper cuts in terms of frustration. I wrote the blog post to call it out. I said, 'Look, for some of you it’s conscious, but for some of you, it’s unconscious. We need to think that if we want this community to grow and support and allow many diverse participants, we need to talk about how we’re behaving.' To their credit, a lot of people in the community stopped and had serious conversations. They said, 'OK, here’s what I’m going to do to change. Call me out if I do it unconsciously.' It was phenomenal." + +She added that if it weren’t for the support of Scott as another active developer in the community, as well as that of other women in the community she could talk to and get encouragement from, she might have stopped. + +"I think that might have totally changed what happened in diabetes in open source if I had just thrown up my hands. I know that happens to other people, and it’s unfortunate. They leave open source because they don’t feel welcome or valued. My hope is that we continue to have the conversation about it and recognize that even if you’re not consciously trying to discourage people, we can all always do better at being more welcoming and engaging and recognizing contributions." + +Communication and sharing about OpenAPS are examples of non-technical contributions that have been critical to the success of the community. Dana’s background in public relations and communications certainly contributed to getting the word out. She has written and spoken extensively about the community on the [DIYPS blog][5], in a [TEDx Talk][6], at [OSCON][7], and more. + +"Not every project that is really impactful to a patient community has made it into the mainstream the way OpenAPS has. The diabetes community has done a really good job communicating about various projects, which brings more people with diabetes in and also gets the attention of people who want to help." + +Her goal now is to help bring to light to other patient community projects. Specifically, she wants to share tools or skills community members have learned with other patient communities looking to take projects to the next level, facilitate research, or work with companies. + +"I also realize that a lot of patients in these projects are told, 'You should patent that. You should create a company. You should create a non-profit.' But all those are huge things. They’re very time-consuming. They take away from your day job or require you to totally switch professions. People like me, we don’t always want to do that, and we shouldn’t have to do that in order to scale projects like this and help other people." + +To this end, she also wants to find other pathways people can take that aren’t all-consuming—for example, writing a children’s book. Dana took on this challenge in 2017 to help her nieces and nephews understand their aunt’s diabetes devices. When her niece asked her what "the thing on her arm was" (her CGM), she realized she didn’t have a point of reference to explain to a young child what it meant to be a person with diabetes. Her solution was [Carolyn’s Robot Relative][8]. + +"I wanted to talk to my nieces and nephews in a way that was age-appropriate that also normalizes that people are different in different ways. I was like, 'I wish there was a kid’s book that talks about this. Well, why don’t I write my own?'" + +She wrote the book and published it on Amazon because true to her open source values, she wanted it to be available to others. She followed up by also writing a [blog post about self-publishing a book on Amazon][9] in the hopes that others would publish books that speak to their own experiences. + +Books like Carolyn’s Robot Relative and awards like the Women in Open Source Award speak to the greater need for representation of different kinds of people in many areas of life, including open source. + +"Things are always better when the communities are more diverse." + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/dana-lewis-women-open-source-community-award-winner-2018 + +作者:[Taylor Greene][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/tgreene +[1]:https://www.redhat.com/en/about/women-in-open-source +[2]:https://gitter.im/ +[3]:https://diyps.org/2014/08/25/being-female-a-patient-and-co-designing-diyps-means-often-being-discounted/ +[4]:https://diyps.org/2018/02/01/women-in-open-source-make-a-difference/ +[5]:https://diyps.org/ +[6]:https://www.youtube.com/watch?v=kgu-AYSnyZ8 +[7]:https://www.youtube.com/watch?v=eQGWrdgu_fE +[8]:https://www.amazon.com/gp/product/1977641415/ref=as_li_tl?ie=UTF8&tag=diyps-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=1977641415&linkId=96bb65e21b5801901586e9fabd12c860 +[9]:https://diyps.org/2017/11/01/makers-gonna-make-a-book-about-diabetes-devices-kids-book-written-by-danamlewis/ From 887631f0fade9ae1df2971edeac9a02ca7130c15 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 10 May 2018 15:35:52 +0800 Subject: [PATCH 013/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=204MLinux=20Revives?= =?UTF-8?q?=20Your=20Older=20Computer=20[Review]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ux Revives Your Older Computer [Review].md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 sources/tech/20180509 4MLinux Revives Your Older Computer [Review].md diff --git a/sources/tech/20180509 4MLinux Revives Your Older Computer [Review].md b/sources/tech/20180509 4MLinux Revives Your Older Computer [Review].md new file mode 100644 index 0000000000..c016466414 --- /dev/null +++ b/sources/tech/20180509 4MLinux Revives Your Older Computer [Review].md @@ -0,0 +1,114 @@ +4MLinux Revives Your Older Computer [Review] +====== +**Brief:** 4MLinux is a lightweight Linux distribution that can turn your old computer into a functional one with multimedia support, maintenance tools and classic games. + +As more and more [Linux distributions drop the support for 32-bit systems][1], you may wonder what would you do with that old computer of yours. Thankfully, there are plenty of [lightweight Linux distributions][2] that could put those old computers for some regular computing tasks such as playing small games, watching movies, listening to music and surfing web. + +[4MLinux][3] is one such Linux distribution that requires fewer system resources and can even run on 128 MB of RAM. The desktop edition comes only for 32-bit architecture while the server edition is of 64-bit. + +4MLinux can also be used as a rescue CD along with serving as a full-fledged working system or as a mini-server. + +![4MLinux Review][4] + +It is named 4MLinux because it focuses mainly on four points, called the “4 M”: + + * Maintenance – You can use 4MLinux as a rescue Live CD. + * Multimedia – There is inbuilt support for almost every multimedia format, be it for Image, Audio and Video. + * Miniserver – A 64-bit server is included running LAMP suite, which can be enabled from the Application Menu. + * Mystery – Includes a collection of classic Linux games. + + + +Most of the Linux distributions are either based on Debian with DEB packages or Fedora with RPM. 4MLinux, on the other hand, does not rely on these package management systems, is pretty damn fast and works quite well on older systems. + +### 4MLinux + +The 4MLinux Desktop comes with a variety of [lightweight applications][5] so that it could work on older hardware. [JWM][6] – Joe’s Windows Manager, which is a lightweight stacking windows manager for [X Window System][7]. For managing the desktop wallpapers, a lightweight and powerful [feh][8] is used. It uses [PCMan File Manager][9] which is a standard file manager for [LXDE][10] too. + +#### Installing 4MLinux is quick + +I grabbed the ISO from 4MLinux website and used [MultiBootUSB][11] to create a bootable drive and live booted with it. + +4MLinux do not use the grub or grub2 bootloader but uses **LI** nux **LO** ader ([LILO][12]) bootloader. The main advantage of LILO is that it allows fast boot-ups for a Linux system. + +Now to install the 4MLinux, you will have to manually create a partition. Go to **Maintenance - > Partitions -> GParted**. Click on **Device - > Create Partition Table**. Once done, click on **New** , leave the settings to default and click on **Add**. Click on **Apply** to save the settings and close it. + +Next step is to go to 4MLinux -> Installer and it will launch a text-based installer. + +![][13] + +Identify the partition you have created for the default partition to install 4MLinux and follow the instructions to complete the installation. + +Surprisingly, the installation took less than a minute. Restart your system and remove the live USB and you will be greeted with this desktop. + +![][14] + +#### Experiencing 4MLinux + +The default desktop screen has a dock at the top with most common applications pinned. There is a taskbar, a [Conky theme][15] with option to turn it on/off in the dock and a clock at the bottom right corner. Left click on the desktop opens the application menu. + +The CPU usage was too minimal with less than 2% and RAM was less than 100 MB. + +4MLinux comes with a number of applications tabbed under different sections. There is Transmission for torrent downloads, Tor is included by default and Bluetooth support is there. + +Under Maintenance, there are options to backup the system and recover using TestDisk and GNUddrescue, CD burning tools are available along with partitioning tools. There are a number of Monitoring tools and Clam Antivirus. + +Multimedia section includes various video and music players and mixers, image viewers and editors and tools for digital cameras. + +Mystery section is interesting. It includes a number of [console games][16] like Snake, Tetris, Mines, Casino etc. + +Under Settings, you can select your preferences for display and others, networking, Desktop and choose default applications. The default desktop resolution was 1024×768 at the highest, so that might disappoint you. + +Some of the applications are not installed by default. Launching it gives you an option to install it. But that’s about it. Since there is no package manager here, you are limited to the available applications. If you want more software that are not available in the system, you’ll have to [install it from source code][17]. + +This is by design because 4MLinux is focused on providing only essential desktop experience. A small handful selection of lightweight applications fit in its ecosystem. + +#### Download 4M Linux + +The Download section features the 32-bit stable 4MLinux and its beta version, 64bit 4MServer and a 4MRescueKit. Although the ISO size is over 1GB, 4mlinux is very light in its design. + +[Download 4MLinux][18] + +There is a [separate page to downloaded additional drivers][19]. For any other missing drivers, while you launch an application, 4MLinux asks you to download and install it. + +#### Final thoughts on 4MLinux + +4MLinux has look and feel of an old-school Linux system but the desktop is super fast. I was able to run it on an Intel Dual Core processor desktop with ease and most of the things worked. WiFi was connecting fine; the application section included most of the software I use on daily basis and the retro games section was pretty cool. + +The one negative point was the limitation of available application. If you can manage with the handful of applications, 4MLinux can be seen as one of the best Linux distribution for older systems and for the people who don’t prefer going in the technicality even for once. + +Fast boot makes it an ideal rescue disc! + +Let us know in the comment section. What do you think of 4MLinux? Are you willing to give it a try? Let us know in the comments. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/4mlinux-review/ + +作者:[Ambarish Kumar][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://itsfoss.com/author/ambarish/ +[1]:https://itsfoss.com/32-bit-os-list/ +[2]:https://itsfoss.com/lightweight-linux-beginners/ +[3]:http://4mlinux.com/ +[4]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/05/4minux-review-feature-800x450.jpeg +[5]:https://itsfoss.com/lightweight-alternative-applications-ubuntu/ +[6]:https://joewing.net/projects/jwm/ +[7]:https://en.wikipedia.org/wiki/X_Window_System +[8]:https://feh.finalrewind.org/ +[9]:https://wiki.lxde.org/en/PCManFM +[10]:https://lxde.org/ +[11]:https://itsfoss.com/multiple-linux-one-usb/ +[12]:https://en.wikipedia.org/wiki/LILO_(boot_loader) +[13]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/05/4MLinux-installer.png +[14]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/05/2-800x600.jpg +[15]:https://itsfoss.com/conky-gui-ubuntu-1304/ +[16]:https://itsfoss.com/best-command-line-games-linux/ +[17]:https://itsfoss.com/install-software-from-source-code/ +[18]:http://4mlinux.com/index.php?page=download +[19]:http://sourceforge.net/projects/linux4m/files/24.0/drivers/ From 603e64510b43647e7848faab6f2bca1e126582e9 Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Thu, 10 May 2018 16:15:19 +0800 Subject: [PATCH 014/111] Create 20180502 zzupdate - Single Command To Upgrade Ubuntu.md --- ...date - Single Command To Upgrade Ubuntu.md | 366 ++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 translated/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md diff --git a/translated/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md b/translated/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md new file mode 100644 index 0000000000..e9ed956d9e --- /dev/null +++ b/translated/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md @@ -0,0 +1,366 @@ +zzupdate —— 升级 Ubuntu 的简单命令 +====== +Ubuntu 18.04 版本已经发布,并得到各个社区的一致好评,因为 Ubuntu 18.04 可能是 Ubuntu 多年来最令人兴奋的版本。 + +通常情况下,Ubuntu 及其衍生版可以使用命令从一个版本升级到最新版本或者其它版本,这也是官方推荐的升级方式。 + +### Ubuntu 18.04 特性/亮点 + +这次更新包含大量改进和新功能,这里只列举的几个主要的。如果您想要更详细的更新信息,请访问 [Ubuntu 18.04 官方][1] 页面。 + + - 使用 Linux 4.15 内核,提供了从上游继承的新功能 + - 它具有最新版本的 GNOME 3.28 + - 它提供了与 RHEL 相似的最简安装选项,该选项可安装只包含一个 web 浏览器和核心系统程序的基本桌面环境 + - 对于新安装,交换文件将取代默认的交换分区 + - 您可以启用 Livepatch 安装内核更新而无需重新启动 + - 笔记本电脑在使用电池供电时会在无操作 20 分钟后自动待机 + - 不再提供 32 位的 Ubuntu 桌面安装程序映像 + + +**注意:** +1. 不要忘记备份重要数据。如果升级出现问题,我们将重新安装并恢复数据。 +2. 安装所需时间取决于您的网络状况和安装的程序。 + +### zzupdate 是什么? + +我们可以通过使用 [zzupdate][2] 工具中的单个命令将 Ubuntu PC/Server 从一个版本升级到另一个版本。它是一个免费的开源工具,使用它不需要任何脚本知识,因为它只需要配置文件即可运行。 + +工具中提供两个默认 shell 文件。`setup.sh` 自动安装、更新代码,将脚本转换为一个简单的 zzupdate shell 命令。`zzupdate.sh` 将执行版本间的升级。 + +### 如何安装 zzipdate? + +要安装 zzupdate,只需执行以下命令。 +``` +$ curl -s https://raw.githubusercontent.com/TurboLabIt/zzupdate/master/setup.sh | sudo sh +. +. +Installing... +------------- +Cloning into 'zzupdate'... +remote: Counting objects: 57, done. +remote: Total 57 (delta 0), reused 0 (delta 0), pack-reused 57 +Unpacking objects: 100% (57/57), done. +Checking connectivity... done. +Already up-to-date. + +Setup completed! +---------------- +See https://github.com/TurboLabIt/zzupdate for the quickstart guide. + +``` + +将 Ubuntu 系统从一个版本升级到另一个版本,您不需要输入很多命令,也不需要重新启动,只需要运行下面的 zzupdate 命令并坐下喝杯咖啡就可以了。 + +请注意,当您远程升级系统时,建议您使用以下的工具来帮助您在任何断开连接时重新连接会话。 + +**建议阅读:** [如何让一个进程/命令在 SSH 连接断开后继续运行][3] + +### 如何配置 zzupdate(可选) + +默认情况下,zzupdate 可以直接使用,不需要配置任何东西。当然,如果您想要自己配置一些内容,可以的。复制提供的实例配置文件 `zzupdate.default.conf` 到 `zzupdate.conf` 并在 `zzupdate.conf` 中配置您的首选项。 +``` +$ sudo cp /usr/local/turbolab.it/zzupdate/zzupdate.default.conf /etc/turbolab.it/zzupdate.conf + +``` + +打开文件,默认配置如下。 +``` +$ sudo nano /etc/turbolab.it/zzupdate.conf + +REBOOT=1 +REBOOT_TIMEOUT=15 +VERSION_UPGRADE=1 +VERSION_UPGRADE_SILENT=0 +COMPOSER_UPGRADE=1 +SWITCH_PROMPT_TO_NORMAL=0 + +``` + + * **`REBOOT=1 :`**系统在更新完成后自动重启 + * **`REBOOT_TIMEOUT=15 :`**重启的默认超时值 + * **`VERSION_UPGRADE=1 :`**执行从一个版本到另一个版本的版本升级 + * **`VERSION_UPGRADE_SILENT=0 :`**禁用自动升级 + * **`COMPOSER_UPGRADE=1 :`**自动升级 + * **`SWITCH_PROMPT_TO_NORMAL=0 :`**如果值为 `0`,将寻找相同种类的版本升级。例如您正在运行 LTS 的版本,那么将寻找 LTS 的版本升级,而不是用于正常版本升级。如果值为 `1`,那么无论您是运行 LTS 还是正常版本,都会查找最新版本 + + + +我现在使用 Ubuntu 17.10 并查看详细信息。 +``` +$ cat /etc/*-release +DISTRIB_ID=Ubuntu +DISTRIB_RELEASE=17.10 +DISTRIB_CODENAME=artful +DISTRIB_DESCRIPTION="Ubuntu 17.10" +NAME="Ubuntu" +VERSION="17.10 (Artful Aardvark)" +ID=ubuntu +ID_LIKE=debian +PRETTY_NAME="Ubuntu 17.10" +VERSION_ID="17.10" +HOME_URL="https://www.ubuntu.com/" +SUPPORT_URL="https://help.ubuntu.com/" +BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" +PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" +VERSION_CODENAME=artful +UBUNTU_CODENAME=artful + +``` + +要升级 Ubuntu 到最新版本,只需要执行以下命令。 +``` +$ sudo zzupdate + +O===========================================================O + zzupdate - Wed May 2 17:31:16 IST 2018 +O===========================================================O + +Self-update and update of other zzScript +---------------------------------------- +. +. +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. + +Updating... +---------- +Already up-to-date. + +Setup completed! +---------------- +See https://github.com/TurboLabIt/zzupdate for the quickstart guide. + +Channel switching is disabled: using pre-existing setting +--------------------------------------------------------- + +Cleanup local cache +------------------- + +Update available packages informations +-------------------------------------- +Hit:1 https://download.docker.com/linux/ubuntu artful InRelease +Ign:2 http://dl.google.com/linux/chrome/deb stable InRelease +Hit:3 http://security.ubuntu.com/ubuntu artful-security InRelease +Hit:4 http://in.archive.ubuntu.com/ubuntu artful InRelease +Hit:5 http://dl.google.com/linux/chrome/deb stable Release +Hit:6 http://in.archive.ubuntu.com/ubuntu artful-updates InRelease +Hit:7 http://in.archive.ubuntu.com/ubuntu artful-backports InRelease +Hit:9 http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu artful InRelease +Hit:10 http://ppa.launchpad.net/papirus/papirus/ubuntu artful InRelease +Hit:11 http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu artful InRelease +. +. +UPGRADE PACKAGES +---------------- +Reading package lists... +Building dependency tree... +Reading state information... +Calculating upgrade... +The following packages were automatically installed and are no longer required: +. +. +Interactively upgrade to a new release, if any +---------------------------------------------- + +Reading cache + +Checking package manager +Reading package lists... Done +Building dependency tree +Reading state information... Done +Ign http://dl.google.com/linux/chrome/deb stable InRelease +Hit https://download.docker.com/linux/ubuntu artful InRelease +Hit http://security.ubuntu.com/ubuntu artful-security InRelease +Hit http://dl.google.com/linux/chrome/deb stable Release +Hit http://in.archive.ubuntu.com/ubuntu artful InRelease +Hit http://in.archive.ubuntu.com/ubuntu artful-updates InRelease +Hit http://in.archive.ubuntu.com/ubuntu artful-backports InRelease +Hit http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu artful InRelease +Hit http://ppa.launchpad.net/papirus/papirus/ubuntu artful InRelease +Hit http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu artful InRelease +Fetched 0 B in 6s (0 B/s) +Reading package lists... Done +Building dependency tree +Reading state information... Done + +``` + +我们需要按下 `Enter` 按钮禁用 `Third Party` 仓库以继续升级。 +``` +Updating repository information + +Third party sources disabled + +Some third party entries in your sources.list were disabled. You can +re-enable them after the upgrade with the 'software-properties' tool +or your package manager. + +To continue please press [ENTER] +. +. +Get:35 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [2,180 B] +Get:36 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [1,644 B] +Fetched 38.2 MB in 6s (1,276 kB/s) + +Checking package manager +Reading package lists... Done +Building dependency tree +Reading state information... Done + +Calculating the changes + +Calculating the changes + +``` + +开始下载 `Ubuntu 18.04 LTS` 软件包,所需时间取决于您的网络状况,一般情况下这将需要几分钟。 +``` +Do you want to start the upgrade? + + +63 installed packages are no longer supported by Canonical. You can +still get support from the community. + +4 packages are going to be removed. 175 new packages are going to be +installed. 1307 packages are going to be upgraded. + +You have to download a total of 999 M. This download will take about +12 minutes with your connection. + +Installing the upgrade can take several hours. Once the download has +finished, the process cannot be canceled. + +Continue [yN] Details [d]y +Fetching +Get:1 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 base-files amd64 10.1ubuntu2 [58.2 kB] +Get:2 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 debianutils amd64 4.8.4 [85.7 kB] +Get:3 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 bash amd64 4.4.18-2ubuntu1 [614 kB] +Get:4 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 locales all 2.27-3ubuntu1 [3,612 kB] +. +. +Get:1477 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 liblouisutdml-bin amd64 2.7.0-1 [9,588 B] +Get:1478 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 libtbb2 amd64 2017~U7-8 [110 kB] +Get:1479 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libyajl2 amd64 2.1.0-2build1 [20.0 kB] +Get:1480 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 usb-modeswitch amd64 2.5.2+repack0-2ubuntu1 [53.6 kB] +Get:1481 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 usb-modeswitch-data all 20170806-2 [30.7 kB] +Get:1482 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 xbrlapi amd64 5.5-4ubuntu2 [61.8 kB] +Fetched 999 MB in 6s (721 kB/s) + +``` + +安装新软件包时,很少有服务需要重新启动。 点击 `Yes` 按钮,它会自动重启所需的服务。 +``` +Upgrading +Inhibiting until Ctrl+C is pressed... +Preconfiguring packages ... +Preconfiguring packages ... +Preconfiguring packages ... +Preconfiguring packages ... +(Reading database ... 441375 files and directories currently installed.) +Preparing to unpack .../base-files_10.1ubuntu2_amd64.deb ... +Warning: Stopping motd-news.service, but it can still be activated by: + motd-news.timer +Unpacking base-files (10.1ubuntu2) over (9.6ubuntu102) ... +Setting up base-files (10.1ubuntu2) ... +Installing new version of config file /etc/debian_version ... +Installing new version of config file /etc/issue ... +Installing new version of config file /etc/issue.net ... +Installing new version of config file /etc/lsb-release ... +motd-news.service is a disabled or a static unit, not starting it. +(Reading database ... 441376 files and directories currently installed.) +. +. +Progress: [ 80%] + +Progress: [ 85%] + +Progress: [ 90%] + +Progress: [ 95%] + +``` + +现在删除旧版的、系统不再需要的包。点击 `y` 以删除。 +``` +Searching for obsolete software + ing package lists... 97% + ding package lists... 98% +Reading package lists... Done +Building dependency tree +Reading state information... Done +Reading state information... 23% +Reading state information... 47% +Reading state information... 71% +Reading state information... 94% +Reading state information... Done + +Remove obsolete packages? + + +88 packages are going to be removed. + +Continue [yN] Details [d]y +. +. +. +done +Removing perlmagick (8:6.9.7.4+dfsg-16ubuntu6) ... +Removing snapd-login-service (1.23-0ubuntu1) ... +Processing triggers for libc-bin (2.27-3ubuntu1) ... +Processing triggers for man-db (2.8.3-2) ... +Processing triggers for dbus (1.12.2-1ubuntu1) ... +Fetched 0 B in 0s (0 B/s) + +``` + +升级成功,需要重启系统。点击 `Y` 以重启系统。 +``` +System upgrade is complete. + +Restart required + +To finish the upgrade, a restart is required. +If you select 'y' the system will be restarted. + +Continue [yN]y + +``` + +**注意:** 少数情况下,会要求您确认配置文件替换以继续安装。 + +查看升级后的系统详情。 +``` +$ cat /etc/*-release +DISTRIB_ID=Ubuntu +DISTRIB_RELEASE=18.04 +DISTRIB_CODENAME=bionic +DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS" +NAME="Ubuntu" +VERSION="18.04 LTS (Bionic Beaver)" +ID=ubuntu +ID_LIKE=debian +PRETTY_NAME="Ubuntu 18.04 LTS" +VERSION_ID="18.04" +HOME_URL="https://www.ubuntu.com/" +SUPPORT_URL="https://help.ubuntu.com/" +BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" +PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" +VERSION_CODENAME=bionic +UBUNTU_CODENAME=bionic + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/zzupdate-single-command-to-upgrade-ubuntu-18-04/ + +作者:[PRAKASH SUBRAMANIAN][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[XiatianSummer](https://github.com/XiatianSummer) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com/author/prakash/ +[1]:https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes +[2]:https://github.com/TurboLabIt/zzupdate +[3]:https://www.2daygeek.com/how-to-keep-a-process-command-running-after-disconnecting-ssh-session/ From bfafb93d8d383ae486727bf4642e9c601690959e Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Thu, 10 May 2018 16:15:50 +0800 Subject: [PATCH 015/111] Delete 20180502 zzupdate - Single Command To Upgrade Ubuntu.md --- ...date - Single Command To Upgrade Ubuntu.md | 369 ------------------ 1 file changed, 369 deletions(-) delete mode 100644 sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md diff --git a/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md b/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md deleted file mode 100644 index 0cdb325a1f..0000000000 --- a/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md +++ /dev/null @@ -1,369 +0,0 @@ -Translating by XiatianSummer@Github - -zzupdate - Single Command To Upgrade Ubuntu -====== -Ubuntu 18.04 was already out and got good feedback from multiple community because Ubuntu 18.04 is the most exciting release of Ubuntu in years. - -By default Ubuntu and it’s derivatives can be upgraded from one version to another version using standard commands, which is official and recommended way to upgrade the system to latest version. - -### Ubuntu 18.04 Features/Highlights - -This release is contains vast of improvement and features and i picked only major things. Navigate to [Ubuntu 18.04 official][1] release page, if you want to know more detailed release information. - - * It ships with Linux kernel 4.15, which delivers new features inherited from upstream. - * It feature the latest GNOME 3.28 - * It offers minimal install option similar to RHEL, this allow users to install basic desktop environment with a web browser and core system utilities. - * For new installs, a swap file will be used by default instead of a swap partition. - * You can enable Livepatch to install Kernel updates without rebooting. - * laptops will automatically suspend after 20 minutes of inactivity while on battery power - * 32-bit installer images are no longer provided for Ubuntu Desktop - - - -**Note :** -1) Don’t forget to take backup of your important/valuable data. If something goes wrong we will install freshly and restore the data. -2) Upgrade will take time based on your Internet connection and application which you have installed. - -### What Is zzupdate? - -We can upgrade Ubuntu PC/Server from one version to another version with just a single command using [zzupdate][2] utility. It’s a free and open source utility and it doesn’t required any scripting knowledge to work on this because it’s purely configfile-driven script. - -There were two shell files are available in the utility, which make the utility to do the work as expected. The provided setup.sh auto-installs/updates the code and makes the script available as a new, simple shell command (zzupdate). The zzupdate.sh will do the actual upgrade from one version to next available version. - -### How To Install zzupdate? - -To install zzupdate, just execute the following command. -``` -$ curl -s https://raw.githubusercontent.com/TurboLabIt/zzupdate/master/setup.sh | sudo sh -. -. -Installing... -------------- -Cloning into 'zzupdate'... -remote: Counting objects: 57, done. -remote: Total 57 (delta 0), reused 0 (delta 0), pack-reused 57 -Unpacking objects: 100% (57/57), done. -Checking connectivity... done. -Already up-to-date. - -Setup completed! ----------------- -See https://github.com/TurboLabIt/zzupdate for the quickstart guide. - -``` - -To upgrade the Ubuntu system from one version to another version, you don’t want to run multiple commands and also no need to initiate the reboot. Just fire the below zzupdate command and sit back rest it will take care. - -Make a note, When you are upgrading the remote system, i would advise you to use any of the one below utility because it will help you to reconnect the session in case of any disconnection. - -**Suggested Read :** [How To Keep A Process/Command Running After Disconnecting SSH Session][3] - -### How To Configure zzupdate [optional] - -By default zzupdate works out of the box and no need to configure anything. It’s optional and if you want to configure something yes, you can. To do so, copy the provided sample configuration file `zzupdate.default.conf` to your own `zzupdate.conf` and set your preference. -``` -$ sudo cp /usr/local/turbolab.it/zzupdate/zzupdate.default.conf /etc/turbolab.it/zzupdate.conf - -``` - -Open the file and the default values are below. -``` -$ sudo nano /etc/turbolab.it/zzupdate.conf - -REBOOT=1 -REBOOT_TIMEOUT=15 -VERSION_UPGRADE=1 -VERSION_UPGRADE_SILENT=0 -COMPOSER_UPGRADE=1 -SWITCH_PROMPT_TO_NORMAL=0 - -``` - - * **`REBOOT=1 :`**System will automatically reboot once upgrade is done. - * **`REBOOT_TIMEOUT=15 :`**Default time out value for reboot. - * **`VERSION_UPGRADE=1 :`**It perform version upgrade from one version to another. - * **`VERSION_UPGRADE_SILENT=0 :`**It disable automatic upgrade perform version upgrade from one version to another. - * **`COMPOSER_UPGRADE=1 :`**This will automatically upgrade the composer. - * **`SWITCH_PROMPT_TO_NORMAL=0 :`**If it’s “0” then it looks for same kind of version upgrade. If you are running on LTS version then it will looking for LTS version upgrade and not for the normal release upgrade. If it’s “1” then it looks for the latest release whether you are running an LTS or a normal release. - - - -I’m currently running Ubuntu 17.10 and see the details. -``` -$ cat /etc/*-release -DISTRIB_ID=Ubuntu -DISTRIB_RELEASE=17.10 -DISTRIB_CODENAME=artful -DISTRIB_DESCRIPTION="Ubuntu 17.10" -NAME="Ubuntu" -VERSION="17.10 (Artful Aardvark)" -ID=ubuntu -ID_LIKE=debian -PRETTY_NAME="Ubuntu 17.10" -VERSION_ID="17.10" -HOME_URL="https://www.ubuntu.com/" -SUPPORT_URL="https://help.ubuntu.com/" -BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" -PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" -VERSION_CODENAME=artful -UBUNTU_CODENAME=artful - -``` - -To upgrade the Ubuntu to latest release, just execute the below command. -``` -$ sudo zzupdate - -O===========================================================O - zzupdate - Wed May 2 17:31:16 IST 2018 -O===========================================================O - -Self-update and update of other zzScript ----------------------------------------- -. -. -0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. - -Updating... ----------- -Already up-to-date. - -Setup completed! ----------------- -See https://github.com/TurboLabIt/zzupdate for the quickstart guide. - -Channel switching is disabled: using pre-existing setting ---------------------------------------------------------- - -Cleanup local cache -------------------- - -Update available packages informations --------------------------------------- -Hit:1 https://download.docker.com/linux/ubuntu artful InRelease -Ign:2 http://dl.google.com/linux/chrome/deb stable InRelease -Hit:3 http://security.ubuntu.com/ubuntu artful-security InRelease -Hit:4 http://in.archive.ubuntu.com/ubuntu artful InRelease -Hit:5 http://dl.google.com/linux/chrome/deb stable Release -Hit:6 http://in.archive.ubuntu.com/ubuntu artful-updates InRelease -Hit:7 http://in.archive.ubuntu.com/ubuntu artful-backports InRelease -Hit:9 http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu artful InRelease -Hit:10 http://ppa.launchpad.net/papirus/papirus/ubuntu artful InRelease -Hit:11 http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu artful InRelease -. -. -UPGRADE PACKAGES ----------------- -Reading package lists... -Building dependency tree... -Reading state information... -Calculating upgrade... -The following packages were automatically installed and are no longer required: -. -. -Interactively upgrade to a new release, if any ----------------------------------------------- - -Reading cache - -Checking package manager -Reading package lists... Done -Building dependency tree -Reading state information... Done -Ign http://dl.google.com/linux/chrome/deb stable InRelease -Hit https://download.docker.com/linux/ubuntu artful InRelease -Hit http://security.ubuntu.com/ubuntu artful-security InRelease -Hit http://dl.google.com/linux/chrome/deb stable Release -Hit http://in.archive.ubuntu.com/ubuntu artful InRelease -Hit http://in.archive.ubuntu.com/ubuntu artful-updates InRelease -Hit http://in.archive.ubuntu.com/ubuntu artful-backports InRelease -Hit http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu artful InRelease -Hit http://ppa.launchpad.net/papirus/papirus/ubuntu artful InRelease -Hit http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu artful InRelease -Fetched 0 B in 6s (0 B/s) -Reading package lists... Done -Building dependency tree -Reading state information... Done - -``` - -We need to disable `Third Party` repository by hitting the `Enter` button to move forward the upgrade. -``` -Updating repository information - -Third party sources disabled - -Some third party entries in your sources.list were disabled. You can -re-enable them after the upgrade with the 'software-properties' tool -or your package manager. - -To continue please press [ENTER] -. -. -Get:35 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [2,180 B] -Get:36 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [1,644 B] -Fetched 38.2 MB in 6s (1,276 kB/s) - -Checking package manager -Reading package lists... Done -Building dependency tree -Reading state information... Done - -Calculating the changes - -Calculating the changes - -``` - -Start Downloading the `Ubuntu 18.04 LTS` packages, It will take a while based on your Internet connection. Its time to have a cup of coffee. -``` -Do you want to start the upgrade? - - -63 installed packages are no longer supported by Canonical. You can -still get support from the community. - -4 packages are going to be removed. 175 new packages are going to be -installed. 1307 packages are going to be upgraded. - -You have to download a total of 999 M. This download will take about -12 minutes with your connection. - -Installing the upgrade can take several hours. Once the download has -finished, the process cannot be canceled. - -Continue [yN] Details [d]y -Fetching -Get:1 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 base-files amd64 10.1ubuntu2 [58.2 kB] -Get:2 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 debianutils amd64 4.8.4 [85.7 kB] -Get:3 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 bash amd64 4.4.18-2ubuntu1 [614 kB] -Get:4 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 locales all 2.27-3ubuntu1 [3,612 kB] -. -. -Get:1477 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 liblouisutdml-bin amd64 2.7.0-1 [9,588 B] -Get:1478 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 libtbb2 amd64 2017~U7-8 [110 kB] -Get:1479 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libyajl2 amd64 2.1.0-2build1 [20.0 kB] -Get:1480 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 usb-modeswitch amd64 2.5.2+repack0-2ubuntu1 [53.6 kB] -Get:1481 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 usb-modeswitch-data all 20170806-2 [30.7 kB] -Get:1482 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 xbrlapi amd64 5.5-4ubuntu2 [61.8 kB] -Fetched 999 MB in 6s (721 kB/s) - -``` - -Few services need to be restart, While installing new packages. Hit `Yes` button, it will automatically restart the required services. -``` -Upgrading -Inhibiting until Ctrl+C is pressed... -Preconfiguring packages ... -Preconfiguring packages ... -Preconfiguring packages ... -Preconfiguring packages ... -(Reading database ... 441375 files and directories currently installed.) -Preparing to unpack .../base-files_10.1ubuntu2_amd64.deb ... -Warning: Stopping motd-news.service, but it can still be activated by: - motd-news.timer -Unpacking base-files (10.1ubuntu2) over (9.6ubuntu102) ... -Setting up base-files (10.1ubuntu2) ... -Installing new version of config file /etc/debian_version ... -Installing new version of config file /etc/issue ... -Installing new version of config file /etc/issue.net ... -Installing new version of config file /etc/lsb-release ... -motd-news.service is a disabled or a static unit, not starting it. -(Reading database ... 441376 files and directories currently installed.) -. -. -Progress: [ 80%] - -Progress: [ 85%] - -Progress: [ 90%] - -Progress: [ 95%] - -``` - -It’s time to remove obsolete (Which is anymore needed for system) packages. Hit `y` to remove it. -``` -Searching for obsolete software - ing package lists... 97% - ding package lists... 98% -Reading package lists... Done -Building dependency tree -Reading state information... Done -Reading state information... 23% -Reading state information... 47% -Reading state information... 71% -Reading state information... 94% -Reading state information... Done - -Remove obsolete packages? - - -88 packages are going to be removed. - -Continue [yN] Details [d]y -. -. -. -done -Removing perlmagick (8:6.9.7.4+dfsg-16ubuntu6) ... -Removing snapd-login-service (1.23-0ubuntu1) ... -Processing triggers for libc-bin (2.27-3ubuntu1) ... -Processing triggers for man-db (2.8.3-2) ... -Processing triggers for dbus (1.12.2-1ubuntu1) ... -Fetched 0 B in 0s (0 B/s) - -``` - -Upgrade is successfully completed and need to restart the system. Hit `Y` to restart the system. -``` -System upgrade is complete. - -Restart required - -To finish the upgrade, a restart is required. -If you select 'y' the system will be restarted. - -Continue [yN]y - -``` - -**`Note :`** Few times, it will ask you to confirm the configuration file replacement to move forward the installation. - -See the upgraded system details. -``` -$ cat /etc/*-release -DISTRIB_ID=Ubuntu -DISTRIB_RELEASE=18.04 -DISTRIB_CODENAME=bionic -DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS" -NAME="Ubuntu" -VERSION="18.04 LTS (Bionic Beaver)" -ID=ubuntu -ID_LIKE=debian -PRETTY_NAME="Ubuntu 18.04 LTS" -VERSION_ID="18.04" -HOME_URL="https://www.ubuntu.com/" -SUPPORT_URL="https://help.ubuntu.com/" -BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" -PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" -VERSION_CODENAME=bionic -UBUNTU_CODENAME=bionic - -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/zzupdate-single-command-to-upgrade-ubuntu-18-04/ - -作者:[PRAKASH SUBRAMANIAN][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.2daygeek.com/author/prakash/ -[1]:https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes -[2]:https://github.com/TurboLabIt/zzupdate -[3]:https://www.2daygeek.com/how-to-keep-a-process-command-running-after-disconnecting-ssh-session/ From 01482411bbe0a092a94d209de82619d74e26e9eb Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 22:48:51 +0800 Subject: [PATCH 016/111] PRF:20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md @geekpi --- ...Android Studio in Ubuntu And Linux Mint.md | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md b/translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md index cb8cabe4e8..6ff17f74c9 100644 --- a/translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md +++ b/translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md @@ -1,5 +1,6 @@ 在 Ubuntu 和 Linux Mint 中轻松安装 Android Studio ====== + [Android Studio][1] 是谷歌自己的 Android 开发 IDE,是带 ADT 插件的 Eclipse 的不错替代品。Android Studio 可以通过源代码安装,但在这篇文章中,我们将看到**如何在 Ubuntu 18.04、16.04 和相应的 Linux Mint 变体**中安装 Android Studio。 在继续安装 Android Studio 之前,请确保你已经[在 Ubuntu 中安装了 Java][2]。 @@ -13,28 +14,31 @@ ![Install Android Studio in Ubuntu from Software Center][4] 如果你在软件中心安装 Android Studio 时看到错误,则可以使用[ Snap 命令][5] 安装 Android Studio。 + ``` sudo snap install android-studio --classic - ``` 非常简单! ### 另一种方式 1:在 Ubuntu 中使用 umake 安装 Android Studio -你也可以使用 Ubuntu Developer Tools Center,现在称为 [Ubuntu Make][6],轻松安装 Android Studio。Ubuntu Make 提供了一个命令行工具来安装各种开发工具、IDE等。Ubuntu Make 在 Ubuntu 仓库中就有。 +你也可以使用 Ubuntu Developer Tools Center,现在称为 [Ubuntu Make][6],轻松安装 Android Studio。Ubuntu Make 提供了一个命令行工具来安装各种开发工具和 IDE 等。Ubuntu Make 在 Ubuntu 仓库中就有。 要安装 Ubuntu Make,请在终端中使用以下命令: -`sudo apt-get install ubuntu-make` +``` +sudo apt-get install ubuntu-make +``` 安装 Ubuntu Make 后,请使用以下命令在 Ubuntu 中安装 Android Studio: + ``` umake android - ``` 在安装过程中它会给你的几个选项。我认为你可以处理。如果你决定卸载 Android Studio,则可以按照以下方式使用相同的 umake 工具: + ``` umake android --remove @@ -45,11 +49,11 @@ umake android --remove 感谢 [Paolo Ratolo][7],我们有一个 PPA,可用于 Ubuntu 16.04、14.04、Linux Mint 和其他基于 Ubuntu 的发行版中轻松安装 Android Studio。请注意,它将下载大约 650MB 的数据。请注意你的互联网连接以及数据费用(如果有的话)。 打开一个终端并使用以下命令: + ``` sudo apt-add-repository ppa:paolorotolo/android-studio sudo apt-get update sudo apt-get install android-studio - ``` 这不容易吗?虽然从源代码安装程序很有趣,但拥有这样的 PPA 总是不错的。我们看到了如何安装 Android Studio,现在来看看如何卸载它。 @@ -57,17 +61,16 @@ sudo apt-get install android-studio ### 卸载 Android Studio: 如果你还没有安装 PPA Purge: + ``` sudo apt-get install ppa-purge - ``` 现在使用 PPA Purge 来清除已安装的 PPA: + ``` sudo apt-get remove android-studio - sudo ppa-purge ppa:paolorotolo/android-studio - ``` 就是这些了。我希望这能够帮助你**在 Ubuntu 和 Linux Mint 上安装 Android Studio**。在运行 Android Studio 之前,请确保[在 Ubuntu 中安装了Java][8]。在类似的文章中,我建议你阅读[如何安装和配置 Ubuntu SDK ][9]和[如何在 Ubuntu 中轻松安装 Microsoft Visual Studio][10]。 @@ -81,7 +84,7 @@ via: https://itsfoss.com/install-android-studio-ubuntu-linux/ 作者:[Abhishek Prakash][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[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/) 荣誉推出 From 21fe1ddbdac3162cf2fdc64d797aa168774b9573 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 10 May 2018 22:49:13 +0800 Subject: [PATCH 017/111] OUB:20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md @geekpi --- ...0403 Easily Install Android Studio in Ubuntu And Linux Mint.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md (100%) diff --git a/translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md b/published/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md similarity index 100% rename from translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md rename to published/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md From 16f86457271c2cce9b2917f501ecbf650ca4552a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 11 May 2018 00:24:52 +0800 Subject: [PATCH 018/111] PRF:20141106 System Calls Make the World Go Round.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @qhwdw 我删除了两条译注,因为根据查看原文,hyperspace 作者是指内核,该词汇用了删除号,所以并非指 RING -3 。请斟酌。 --- ...06 System Calls Make the World Go Round.md | 173 +++++++++++------- 1 file changed, 103 insertions(+), 70 deletions(-) diff --git a/translated/tech/20141106 System Calls Make the World Go Round.md b/translated/tech/20141106 System Calls Make the World Go Round.md index e2841b6d4b..64db43f3da 100644 --- a/translated/tech/20141106 System Calls Make the World Go Round.md +++ b/translated/tech/20141106 System Calls Make the World Go Round.md @@ -1,118 +1,151 @@ -# 系统调用,让世界转起来! +系统调用,让世界转起来! +===================== -我其实不想将它分解开给你看,一个用户应用程序在整个系统中就像一个可怜的孤儿一样无依无靠: + +我其实不想将它分解开给你看,用户应用程序其实就是一个可怜的瓮中大脑brain in a vat: ![](https://manybutfinite.com/img/os/appInVat.png) -它与外部世界的每个交流都要在内核的帮助下通过系统调用才能完成。一个应用程序要想保存一个文件、写到终端、或者打开一个 TCP 连接,内核都要参与。应用程序是被内核高度怀疑的:认为它到处充斥着 bugs,而最糟糕的是那些充满邪恶想法的天才大脑(写的恶意程序)。 +它与外部世界的*每个*交流都要在内核的帮助下通过**系统调用**才能完成。一个应用程序要想保存一个文件、写到终端、或者打开一个 TCP 连接,内核都要参与。应用程序是被内核高度怀疑的:认为它到处充斥着 bug,甚至是个充满邪恶想法的脑子。 -这些系统调用是从一个应用程序到内核的函数调用。它们因为安全考虑使用一个特定的机制,实际上你只是调用了内核的 API。“系统调用”这个术语指的是调用由内核提供的特定功能(比如,系统调用 open())或者是调用途径。你也可以简称为:syscall。 +这些系统调用是从一个应用程序到内核的函数调用。出于安全考虑,它们使用了特定的机制,实际上你只是调用了内核的 API。“系统调用system call”这个术语指的是调用由内核提供的特定功能(比如,系统调用 `open()`)或者是调用途径。你也可以简称为:**syscall**。 -这篇文章讲解系统调用,系统调用与调用一个库有何区别,以及在操作系统/应用程序接口上的刺探工具。如果想彻底了解应用程序借助操作系统都发生的哪些事情?那么就可以将一个不可能解决的问题转变成一个快速而有趣的难题。 +这篇文章讲解系统调用,系统调用与调用一个库有何区别,以及在操作系统/应用程序接口上的刺探工具。如果彻底了解了应用程序借助操作系统发生的哪些事情,那么就可以将一个不可能解决的问题转变成一个快速而有趣的难题。 -因此,下图是一个运行着的应用程序,一个用户进程: +那么,下图是一个运行着的应用程序,一个用户进程: ![](https://manybutfinite.com/img/os/sandbox.png) -它有一个私有的 [虚拟地址空间][2]—— 它自己的内存沙箱。整个系统都在地址空间中,程序的二进制文件加上它所需要的库全部都 [被映射到内存中][3]。内核自身也映射为地址空间的一部分。 +它有一个私有的 [虚拟地址空间][2]—— 它自己的内存沙箱。整个系统都在它的地址空间中(即上面比喻的那个“瓮”),程序的二进制文件加上它所使用的库全部都 [被映射到内存中][3]。内核自身也映射为地址空间的一部分。 -下面是我们程序的代码和 PID,进程的 PID 可以通过 [getpid(2)][4]: +下面是我们程序 `pid` 的代码,它通过 [getpid(2)][4] 直接获取了其进程 id: -pid.c [download][1] -| -​``` -123456789 -​``` - | -​``` -#include #include #include int main(){ pid_t p = getpid(); printf("%d\n", p);} -​``` - | +``` +#include +#include +#include + +int main() +{ + pid_t p = getpid(); + printf("%d\n", p); +} +``` + +*pid.c [download][1]* -**(致校对:本文的所有代码部分都出现了排版错误,请与原文核对确认!!)** 在 Linux 中,一个进程并不是一出生就知道它的 PID。要想知道它的 PID,它必须去询问内核,因此,这个询问请求也是一个系统调用: ![](https://manybutfinite.com/img/os/syscallEnter.png) -它的第一步是开始于调用一个 C 库的 [getpid()][5],它是系统调用的一个封装。当你调用一些功能时,比如,open(2)、read(2)、以及相关的一些支持时,你就调用了这些封装。其实,对于大多数编程语言在这一块的原生方法,最终都是在 libc 中完成的。 +它的第一步是开始于调用 C 库的 [getpid()][5],它是系统调用的一个*封装*。当你调用一些函数时,比如,`open(2)`、`read(2)` 之类,你是在调用这些封装。其实,对于大多数编程语言在这一块的原生方法,最终都是在 libc 中完成的。 -极简设计的操作系统都提供了方便的 API 封装,这样可以保持内核的简洁。所有的内核代码运行在特权模式下,有 bugs 的内核代码行将会产生致命的后果。在用户模式下做的任何事情都是在用户模式中完成的。由库来提供友好的方法和想要的参数处理,像 printf(3) 这样。 +封装为这些基本的操作系统 API 提供了方便,这样可以保持内核的简洁。*所有的内核代码*运行在特权模式下,有 bug 的内核代码行将会产生致命的后果。能在用户模式下做的任何事情都应该在用户模式中完成。由库来提供友好的方法和想要的参数处理,像 `printf(3)` 这样。 -我们拿一个 web APIs 进行比较,内核的封装方式与构建一个简单易行的 HTTP 接口去提供服务是类似的,然后使用特定语言的守护方法去提供特定语言的库。或者也可能有一些缓存,它是库的 getpid() 完成的内容:首次调用时,它真实地去执行了一个系统调用,然后,它缓存了 PID,这样就可以避免后续调用时的系统调用开销。 +我们拿一个 web API 进行比较,内核的封装方式可以类比为构建一个尽可能简单的 HTTP 接口去提供服务,然后提供特定语言的库及辅助方法。或者也可能有一些缓存,这就是 libc 的 `getpid()` 所做的:首次调用时,它真实地去执行了一个系统调用,然后,它缓存了 PID,这样就可以避免后续调用时的系统调用开销。 -一旦封装完成,它做的第一件事就是进入了超空间(hyperspace)的内核(译者注:一个快速而安全的计算环境,独立于操作系统而存在)。这种转换机制因处理器架构设计不同而不同。(译者注:就是前一段时间爆出的存在于处理器硬件中的运行于 Ring -3 的操作系统,比如,Intel 的 ME)在 Intel 处理器中,参数和 [系统调用号][6] 是 [加载到寄存器中的][7],然后,运行一个 [指令][8] 将 CPU 置于 [特权模式][9] 中,并立即将控制权转移到内核中的全局系统调用 [入口][10]。如果你对这些细节感兴趣,David Drysdale 在 LWN 上有两篇非常好的文章([第一篇][11],[第二篇][12])。 +一旦封装完成,它做的第一件事就是进入了~~超空间~~hyperspace:内核。这种转换机制因处理器架构设计不同而不同。在 Intel 处理器中,参数和 [系统调用号][6] 是 [加载到寄存器中的][7],然后,运行一个 [指令][8] 将 CPU 置于 [特权模式][9] 中,并立即将控制权转移到内核中的全局系统调用 [入口][10]。如果你对这些细节感兴趣,David Drysdale 在 LWN 上有两篇非常好的文章([其一][11],[其二][12])。 -内核然后使用这个系统调用号作为进入 [sys_call_table][14] 的一个 [索引][13],它是一个函数指针到每个系统调用实现的数组。在这里,调用 了 [sys_getpid][15]: +内核然后使用这个系统调用号作为进入 [`sys_call_table`][14] 的一个 [索引][13],它是一个函数指针到每个系统调用实现的数组。在这里,调用了 [`sys_getpid`][15]: ![](https://manybutfinite.com/img/os/syscallExit.png) -在 Linux 中,系统调用大多数都实现为独立的 C 函数,有时候这样做 [很琐碎][16],但是通过内核优秀的设计,系统调用被严格隔离。它们是工作在一般数据结构中的普通代码。关于这些争论的验证除了完全偏执的以外,其它的还是非常好的。 +在 Linux 中,系统调用大多数都实现为架构无关的 C 函数,有时候这样做 [很琐碎][16],但是通过内核优秀的设计,系统调用机制被严格隔离。它们是工作在一般数据结构中的普通代码。嗯,除了*完全偏执*的参数校验以外。 -一旦它们的工作完成,它们就会正常返回,然后,根据特定代码转回到用户模式,封装将在那里继续做一些后续处理工作。在我们的例子中,[getpid(2)][17] 现在缓存了由内核返回的 PID。如果内核返回了一个错误,另外的封装可以去设置全局 errno 变量。让你知道 GNU 所关心的一些小事。 +一旦它们的工作完成,它们就会正常*返回*,然后,架构特定的代码会接手转回到用户模式,封装将在那里继续做一些后续处理工作。在我们的例子中,[getpid(2)][17] 现在缓存了由内核返回的 PID。如果内核返回了一个错误,另外的封装可以去设置全局 `errno` 变量。这些细节可以让你知道 GNU 是怎么处理的。 -如果你想看未处理的原生内容,glibc 提供了 [syscall(2)][18] 函数,它可以不通过封装来产生一个系统调用。你也可以通过它来做一个你自己的封装。这对一个 C 库来说,并不神奇,也不是保密的。 +如果你想要原生的调用,glibc 提供了 [syscall(2)][18] 函数,它可以不通过封装来产生一个系统调用。你也可以通过它来做一个你自己的封装。这对一个 C 库来说,既不神奇,也不特殊。 -这种系统调用的设计影响是很深远的。我们从一个非常有用的 [strace(1)][19] 开始,这个工具可以用来监视 Linux 进程的系统调用(在 Mac 上,看 [dtruss(1m)][20] 和神奇的 [dtrace][21];在 Windows 中,看 [sysinternals][22])。这里在 pid 上的跟踪: - -| -​``` -1234567891011121314151617181920 -​``` - | -​``` -~/code/x86-os$ strace ./pidexecve("./pid", ["./pid"], [/* 20 vars */]) = 0brk(0) = 0x9aa0000access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7767000access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3fstat64(3, {st_mode=S_IFREG|0644, st_size=18056, ...}) = 0mmap2(NULL, 18056, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7762000close(3) = 0[...snip...]getpid() = 14678fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 1), ...}) = 0mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7766000write(1, "14678\n", 614678) = 6exit_group(6) = ? -​``` - | - -输出的每一行都显示了一个系统调用 、它的参数、以及返回值。如果你在一个循环中将 getpid(2) 运行 1000 次,你就会发现始终只有一个 getpid() 系统调用,因为,它的 PID 已经被缓存了。我们也可以看到在格式化输出字符串之后,printf(3) 调用了 write(2)。 - -strace 可以开始一个新进程,也可以附加到一个已经运行的进程上。你可以通过不同程序的系统调用学到很多的东西。例如,sshd 守护进程一天都干了什么? - -| -​``` -1234567891011121314151617181920212223242526272829 -​``` - | -​``` -~/code/x86-os$ ps ax | grep sshd12218 ? Ss 0:00 /usr/sbin/sshd -D~/code/x86-os$ sudo strace -p 12218Process 12218 attached - interrupt to quitselect(7, [3 4], NULL, NULL, NULL[ ... nothing happens ... No fun, it's just waiting for a connection using select(2) If we wait long enough, we might see new keys being generated and so on, but let's attach again, tell strace to follow forks (-f), and connect via SSH]~/code/x86-os$ sudo strace -p 12218 -f[lots of calls happen during an SSH login, only a few shown][pid 14692] read(3, "-----BEGIN RSA PRIVATE KEY-----\n"..., 1024) = 1024[pid 14692] open("/usr/share/ssh/blacklist.RSA-2048", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)[pid 14692] open("/etc/ssh/blacklist.RSA-2048", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)[pid 14692] open("/etc/ssh/ssh_host_dsa_key", O_RDONLY|O_LARGEFILE) = 3[pid 14692] open("/etc/protocols", O_RDONLY|O_CLOEXEC) = 4[pid 14692] read(4, "# Internet (IP) protocols\n#\n# Up"..., 4096) = 2933[pid 14692] open("/etc/hosts.allow", O_RDONLY) = 4[pid 14692] open("/lib/i386-linux-gnu/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 4[pid 14692] stat64("/etc/pam.d", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0[pid 14692] open("/etc/pam.d/common-password", O_RDONLY|O_LARGEFILE) = 8[pid 14692] open("/etc/pam.d/other", O_RDONLY|O_LARGEFILE) = 4 -​``` - | - -看懂 SSH 的调用是块难啃的骨头,但是,如果搞懂它你就学会了跟踪。也可以用它去看一个应用程序打开的哪个文件是有用的(“这个配置是从哪里来的?”)。如果你有一个出现错误的进程,你可以跟踪它,然后去看它通过系统调用做了什么?当一些应用程序没有提供适当的错误信息而意外退出时,你可以去检查它是否是一个系统调用失败。你也可以使用过滤器,查看每个调用的次数,等等: - -| +这种系统调用的设计影响是很深远的。我们从一个非常有用的 [strace(1)][19] 开始,这个工具可以用来监视 Linux 进程的系统调用(在 Mac 上,参见 [dtruss(1m)][20] 和神奇的 [dtrace][21];在 Windows 中,参见 [sysinternals][22])。这是对 `pid` 程序的跟踪: ``` +~/code/x86-os$ strace ./pid +execve("./pid", ["./pid"], [/* 20 vars */]) = 0 +brk(0) = 0x9aa0000 +access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) +mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7767000 +access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) +open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +fstat64(3, {st_mode=S_IFREG|0644, st_size=18056, ...}) = 0 +mmap2(NULL, 18056, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7762000 +close(3) = 0 + +[...snip...] + +getpid() = 14678 +fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 1), ...}) = 0 +mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7766000 +write(1, "14678\n", 614678 +) = 6 +exit_group(6) = ? ``` -123456789 +输出的每一行都显示了一个系统调用、它的参数,以及返回值。如果你在一个循环中将 `getpid(2)` 运行 1000 次,你就会发现始终只有一个 `getpid()` 系统调用,因为,它的 PID 已经被缓存了。我们也可以看到在格式化输出字符串之后,`printf(3)` 调用了 `write(2)`。 + +`strace` 可以开始一个新进程,也可以附加到一个已经运行的进程上。你可以通过不同程序的系统调用学到很多的东西。例如,`sshd` 守护进程一天都在干什么? ``` +~/code/x86-os$ ps ax | grep sshd +12218 ? Ss 0:00 /usr/sbin/sshd -D +~/code/x86-os$ sudo strace -p 12218 +Process 12218 attached - interrupt to quit +select(7, [3 4], NULL, NULL, NULL + +[ + ... nothing happens ... + No fun, it's just waiting for a connection using select(2) + If we wait long enough, we might see new keys being generated and so on, but + let's attach again, tell strace to follow forks (-f), and connect via SSH +] + +~/code/x86-os$ sudo strace -p 12218 -f + +[lots of calls happen during an SSH login, only a few shown] + +[pid 14692] read(3, "-----BEGIN RSA PRIVATE KEY-----\n"..., 1024) = 1024 +[pid 14692] open("/usr/share/ssh/blacklist.RSA-2048", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) +[pid 14692] open("/etc/ssh/blacklist.RSA-2048", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) +[pid 14692] open("/etc/ssh/ssh_host_dsa_key", O_RDONLY|O_LARGEFILE) = 3 +[pid 14692] open("/etc/protocols", O_RDONLY|O_CLOEXEC) = 4 +[pid 14692] read(4, "# Internet (IP) protocols\n#\n# Up"..., 4096) = 2933 +[pid 14692] open("/etc/hosts.allow", O_RDONLY) = 4 +[pid 14692] open("/lib/i386-linux-gnu/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 4 +[pid 14692] stat64("/etc/pam.d", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 +[pid 14692] open("/etc/pam.d/common-password", O_RDONLY|O_LARGEFILE) = 8 +[pid 14692] open("/etc/pam.d/other", O_RDONLY|O_LARGEFILE) = 4 ``` - | -​``` -~/code/x86-os$ strace -T -e trace=recv curl -silent www.google.com. > /dev/nullrecv(3, "HTTP/1.1 200 OK\r\nDate: Wed, 05 N"..., 16384, 0) = 4164 <0.000007>recv(3, "fl a{color:#36c}a:visited{color:"..., 16384, 0) = 2776 <0.000005>recv(3, "adient(top,#4d90fe,#4787ed);filt"..., 16384, 0) = 4164 <0.000007>recv(3, "gbar.up.spd(b,d,1,!0);break;case"..., 16384, 0) = 2776 <0.000006>recv(3, "$),a.i.G(!0)),window.gbar.up.sl("..., 16384, 0) = 1388 <0.000004>recv(3, "margin:0;padding:5px 8px 0 6px;v"..., 16384, 0) = 1388 <0.000007>recv(3, "){window.setTimeout(function(){v"..., 16384, 0) = 1484 <0.000006> -​``` - | +看懂 SSH 的调用是块难啃的骨头,但是,如果搞懂它你就学会了跟踪。能够看到应用程序打开的是哪个文件是有用的(“这个配置是从哪里来的?”)。如果你有一个出现错误的进程,你可以 `strace` 它,然后去看它通过系统调用做了什么?当一些应用程序意外退出而没有提供适当的错误信息时,你可以去检查它是否有系统调用失败。你也可以使用过滤器,查看每个调用的次数,等等: -我鼓励你去浏览在你的操作系统中的这些工具。使用它们会让你觉得自己像个超人一样强大。 +``` +~/code/x86-os$ strace -T -e trace=recv curl -silent www.google.com. > /dev/null -但是,足够有用的东西,往往要让我们深入到它的设计中。我们可以看到那些用户空间中的应用程序是被严格限制在它自己的虚拟地址空间中,它的虚拟地址空间运行在 Ring 3(非特权模式)中。一般来说,只涉及到计算和内存访问的任务是不需要请求系统调用的。例如,像 [strlen(3)][23] 和 [memcpy(3)][24] 这样的 C 库函数并不需要内核去做什么。这些都是在应用程序内部发生的事。 +recv(3, "HTTP/1.1 200 OK\r\nDate: Wed, 05 N"..., 16384, 0) = 4164 <0.000007> +recv(3, "fl a{color:#36c}a:visited{color:"..., 16384, 0) = 2776 <0.000005> +recv(3, "adient(top,#4d90fe,#4787ed);filt"..., 16384, 0) = 4164 <0.000007> +recv(3, "gbar.up.spd(b,d,1,!0);break;case"..., 16384, 0) = 2776 <0.000006> +recv(3, "$),a.i.G(!0)),window.gbar.up.sl("..., 16384, 0) = 1388 <0.000004> +recv(3, "margin:0;padding:5px 8px 0 6px;v"..., 16384, 0) = 1388 <0.000007> +recv(3, "){window.setTimeout(function(){v"..., 16384, 0) = 1484 <0.000006> +``` -一个 C 库函数的 man 页面节上(在圆括号 2 和 3 中)也提供了线索。节 2 是用于系统调用封装,而节 3 包含了其它 C 库函数。但是,正如我们在 printf(3) 中所看到的,一个库函数可以最终产生一个或者多个系统调用。 +我鼓励你在你的操作系统中的试验这些工具。把它们用好会让你觉得自己有超能力。 -如果你对此感到好奇,这里是 [Linux][25] ( [Filippo's list][26])和 [Windows][27] 的全部系统调用列表。它们各自有 ~310 和 ~460 个系统调用。看这些系统调用是非常有趣的,因为,它们代表了软件在现代的计算机上能够做什么。另外,你还可能在这里找到与进程间通讯和性能相关的“宝藏”。这是一个“不懂 Unix 的人注定最终还要重新发明一个蹩脚的 Unix ” 的地方。(译者注:“Those who do not understand Unix are condemned to reinvent it,poorly。”这句话是 [Henry Spencer][35] 的名言,反映了 Unix 的设计哲学,它的一些理念和文化是一种技术发展的必须结果,看似糟糕却无法超越。) +但是,足够有用的东西,往往要让我们深入到它的设计中。我们可以看到那些用户空间中的应用程序是被严格限制在它自己的虚拟地址空间里,运行在 Ring 3(非特权模式)中。一般来说,只涉及到计算和内存访问的任务是不需要请求系统调用的。例如,像 [strlen(3)][23] 和 [memcpy(3)][24] 这样的 C 库函数并不需要内核去做什么。这些都是在应用程序内部发生的事。 -与 CPU 周期相比,许多系统调用花很长的时间去执行任务,例如,从一个硬盘驱动器中读取内容。在这种情况下,调用进程在底层的工作完成之前一直处于休眠状态。因为,CPUs 运行的非常快,一般的程序都因为 I/O 的限制在它的生命周期的大部分时间处于休眠状态,等待系统的调用。相反,如果你跟踪一个计算密集型任务,你经常会看到没有任何的系统调用参与其中。在这种情况下,[top(1)][29] 将显示大量的 CPU 使用。 +C 库函数的 man 页面所在的节(即圆括号里的 `2` 和 `3`)也提供了线索。节 2 是用于系统调用封装,而节 3 包含了其它 C 库函数。但是,正如我们在 `printf(3)` 中所看到的,库函数最终可以产生一个或者多个系统调用。 -在一个系统调用中的开销可能会是一个问题。例如,固态硬盘比普通硬盘要快很多,但是,操作系统的开销可能比 I/O 操作本身的开销 [更加昂贵][30]。执行大量读写操作的程序可能就是操作系统开销的瓶颈所在。[向量化 I/O][31] 对此有一些帮助。因此要做 [文件的内存映射][32],它允许一个程序仅访问内存就可以读或写磁盘文件。类似的映射也存在于像视频卡这样的地方。最终,经济性俱佳的云计算可能导致内核在用户模式/内核模式的切换消失或者最小化。 +如果你对此感到好奇,这里是 [Linux][25] (也有 [Filippo 的列表][26])和 [Windows][27] 的全部系统调用列表。它们各自有大约 310 和 460 个系统调用。看这些系统调用是非常有趣的,因为,它们代表了*软件*在现代的计算机上能够做什么。另外,你还可能在这里找到与进程间通讯和性能相关的“宝藏”。这是一个“不懂 Unix 的人注定最终还要重新发明一个蹩脚的 Unix ” 的地方。(LCTT 译注:原文 “Those who do not understand Unix are condemned to reinvent it,poorly。” 这句话是 [Henry Spencer][35] 的名言,反映了 Unix 的设计哲学,它的一些理念和文化是一种技术发展的必须结果,看似糟糕却无法超越。) -最终,系统调用还有益于系统安全。一是,无论看起来多么模糊的一个二进制程序,你都可以通过观察它的系统调用来检查它的行为。这种方式可能用于去检测恶意程序。例如,我们可以记录一个未知程序的系统调用的策略,并对它的偏差进行报警,或者对程序调用指定一个白名单,这样就可以让漏洞利用变得更加困难。在这个领域,我们有大量的研究,和许多工具,但是没有“杀手级”的解决方案。 +与 CPU 周期相比,许多系统调用花[很长的时间][28]去执行任务,例如,从一个硬盘驱动器中读取内容。在这种情况下,调用进程在底层的工作完成之前一直*处于休眠状态*。因为,CPU 运行的非常快,一般的程序都因为 **I/O 的限制**在它的生命周期的大部分时间处于休眠状态,等待系统调用返回。相反,如果你跟踪一个计算密集型任务,你经常会看到没有任何的系统调用参与其中。在这种情况下,[top(1)][29] 将显示大量的 CPU 使用。 + +在一个系统调用中的开销可能会是一个问题。例如,固态硬盘比普通硬盘要快很多,但是,操作系统的开销可能比 I/O 操作本身的开销 [更加昂贵][30]。执行大量读写操作的程序可能就是操作系统开销的瓶颈所在。[向量化 I/O][31] 对此有一些帮助。因此要做 [文件的内存映射][32],它允许一个程序仅访问内存就可以读或写磁盘文件。类似的映射也存在于像视频卡这样的地方。最终,云计算的经济性可能导致内核消除或最小化用户模式/内核模式的切换。 + +最终,系统调用还有益于系统安全。一是,无论如何来历不明的一个二进制程序,你都可以通过观察它的系统调用来检查它的行为。这种方式可能用于去检测恶意程序。例如,我们可以记录一个未知程序的系统调用的策略,并对它的异常行为进行报警,或者对程序调用指定一个白名单,这样就可以让漏洞利用变得更加困难。在这个领域,我们有大量的研究,和许多工具,但是没有“杀手级”的解决方案。 这就是系统调用。很抱歉这篇文章有点长,我希望它对你有用。接下来的时间,我将写更多(短的)文章,也可以在 [RSS][33] 和 [Twitter][34] 关注我。这篇文章献给 glorious Clube Atlético Mineiro。 @@ -122,7 +155,7 @@ via:https://manybutfinite.com/post/system-calls/ 作者:[Gustavo Duarte][a] 译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e3a8a839247e43ce46373ff672feccd7c72a0f4e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 11 May 2018 00:25:13 +0800 Subject: [PATCH 019/111] PUB:20141106 System Calls Make the World Go Round.md @qhwdw https://linux.cn/article-9628-1.html --- .../20141106 System Calls Make the World Go Round.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20141106 System Calls Make the World Go Round.md (100%) diff --git a/translated/tech/20141106 System Calls Make the World Go Round.md b/published/20141106 System Calls Make the World Go Round.md similarity index 100% rename from translated/tech/20141106 System Calls Make the World Go Round.md rename to published/20141106 System Calls Make the World Go Round.md From c90438398d59c83f7a652f0f487b83c54a101147 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 11 May 2018 08:44:25 +0800 Subject: [PATCH 020/111] translated --- ...h And Install Google Web Fonts In Linux.md | 89 ------------------- ...h And Install Google Web Fonts In Linux.md | 87 ++++++++++++++++++ 2 files changed, 87 insertions(+), 89 deletions(-) delete mode 100644 sources/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md create mode 100644 translated/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md diff --git a/sources/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md b/sources/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md deleted file mode 100644 index 4e3ce41b65..0000000000 --- a/sources/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md +++ /dev/null @@ -1,89 +0,0 @@ -translating---geekpi - -Easily Search And Install Google Web Fonts In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/04/Font-Finder-720x340.png) -**Font Finder** is the Rust implementation of good old [**Typecatcher**][1], which is used to easily search and install Google web fonts from [**Google’s font archive**][2]. It helps you to install hundreds of free and open source fonts in your Linux desktop. In case you’re looking for beautiful fonts for your web projects and apps and whatever else, Font Finder can easily get them for you. It is free, open source GTK3 application written in Rust programming language. Unlike Typecatcher, which is written using Python, Font Finder can filter fonts by their categories, has zero Python runtime dependencies, and has much better performance and resource consumption. - -In this brief tutorial, we are going to see how to install and use Font Finder in Linux. - -### Install Font Finder - -Since Fond Finder is written using Rust programming language, you need to install Rust in your system as described below. - -After installing Rust, run the following command to install Font Finder: -``` -$ cargo install fontfinder - -``` - -Font Finder is also available as [**flatpak app**][3]. First install Flatpak in your system as described in the link below. - -Then, install Font Finder using command: -``` -$ flatpak install flathub io.github.mmstick.FontFinder - -``` - -### Search And Install Google Web Fonts In Linux Using Font Finder - -You can launch font finder either from the application launcher or run the following command to launch it. -``` -$ flatpak run io.github.mmstick.FontFinder - -``` - -This is how Font Finder default interface looks like. - -![][5] - -As you can see, Font Finder user interface is very simple. All Google web fonts are listed in the left pane and the preview of the respective font is given at the right pane. You can type any words in the preview box to view how the words will look like in the selected font. There is also a search box on the top left which allows you to quickly search for a font of your choice. - -By default, Font Finder displays all type of fonts. You can, however, display the fonts by category-wise from the category drop-down box above the the search box. - -![][6] - -To install a font, just choose it and click the **Install** button on the top. - -![][7] - -You can test the newly installed fonts in any text processing applications. - -![][8] - -Similarly, to remove a font, just choose it from the Font Finder dashboard and click the **Uninstall** button. It’s that simple! - -The Settings button (the gear button) on the top left corner provides the option to switch to dark preview. - -![][9] - -As you can see, Font Finder is very simple and does the job exactly as advertised in its home page. If you’re looking for an application to install Google web fonts, Font Finder is one such application. - -And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/font-finder-easily-search-and-install-google-web-fonts-in-linux/ - -作者:[SK][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.ostechnix.com/author/sk/ -[1]:https://www.ostechnix.com/install-google-web-fonts-ubuntu/ -[2]:https://fonts.google.com/ -[3]:https://flathub.org/apps/details/io.github.mmstick.FontFinder -[4]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[5]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-1.png -[6]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-2.png -[7]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-3.png -[8]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-5.png -[9]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-4.png diff --git a/translated/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md b/translated/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md new file mode 100644 index 0000000000..f0aa5369fc --- /dev/null +++ b/translated/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md @@ -0,0 +1,87 @@ +在 Linux 中轻松搜索和安装 Google Web 字体 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/04/Font-Finder-720x340.png) +**Font Finder** 是旧的 [**Typecatcher**][1] 的 Rust 实现,用于从[**Google 的字体存档**][2]中轻松搜索和安装 Google Web 字体。它可以帮助你在 Linux 桌面上安装数百种免费和开源字体。如果你正在为你的 Web 项目和应用以及其他任何地方寻找好看的字体,Font Finder 可以轻松地为你提供。它是用 Rust 编程语言编写的免费开源 GTK3 应用程序。与使用 Python 编写的 Typecatcher 不同,Font Finder 可以按类别过滤字体,没有 Python 运行时依赖关系,并且有更好的性能和资源消耗。 + +在这个简短的教程中,我们将看到如何在 Linux 中安装和使用 Font Finder。 + +### 安装 Font Finder + +由于 Fond Finder 是使用 Rust 语言编写的,因此你需要向下面描述的那样在系统中安装 Rust。 + +安装 Rust 后,运行以下命令安装 Font Finder: +``` +$ cargo install fontfinder + +``` + +Font Finder 也可以从 [**flatpak app**][3] 安装。首先在你的系统中安装 Flatpak,如下面的链接所述。 + +然后,使用命令安装 Font Finder: +``` +$ flatpak install flathub io.github.mmstick.FontFinder + +``` + +### 在 Linux 中使用 Font Finder 搜索和安装 Google Web 字体 + +你可以从程序启动器启动 Font Finder,也可以运行以下命令启动它。 +``` +$ flatpak run io.github.mmstick.FontFinder + +``` + +这是 Font Finder 默认界面的样子。 + +![][5] + +正如你所看到的,Font Finder 的用户界面非常简单。所有 Google Web 字体都列在左侧窗格中,相应字体的预览显示在右侧窗格中。你可以在预览框中输入任何单词以查看单词在所选字体中的外观。在左上方还有一个搜索框,可以让你快速搜索你选择的字体。 + +默认情况下,Font Finder 显示所有类型的字体。但是,你可以通过搜索框上方的类别下拉框中的分类显示字体。 + +![][6] + +要安装字体,只需选择它并点击顶部的 **Install** 按钮即可。 + +![][7] + +你可以在任何文本处理程序中测试新安装的字体。 + +![][8] + +同样,要删除字体,只需从 Font Finder 面板中选择它并单击 **Uninstall** 按钮。就这么简单! + +左上角的设置按钮(齿轮按钮)提供了切换到暗色预览的选项。 + +![][9] + +如你所见,Font Finder 非常简单,完全可以像在主页上宣传的那样完成工作。如果你正在寻找安装 Google Web 字体的程序,Font Finder 就是这样的一个程序。 + +今天就是这些。希望这有帮助。还有更好的东西。敬请关注! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/font-finder-easily-search-and-install-google-web-fonts-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/install-google-web-fonts-ubuntu/ +[2]:https://fonts.google.com/ +[3]:https://flathub.org/apps/details/io.github.mmstick.FontFinder +[4]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[5]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-1.png +[6]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-2.png +[7]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-3.png +[8]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-5.png +[9]:http://www.ostechnix.com/wp-content/uploads/2018/04/font-finder-4.png From a9bd8476dd3ec982d9e086e50268ba1ac6479f74 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 11 May 2018 08:47:58 +0800 Subject: [PATCH 021/111] translating --- ...ly Run And Integrate AppImage Files With AppImageLauncher.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md b/sources/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md index 23d9b35e1e..2c9e87be5d 100644 --- a/sources/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md +++ b/sources/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md @@ -1,3 +1,5 @@ +translating---geekpi + Easily Run And Integrate AppImage Files With AppImageLauncher ====== Did you ever download an AppImage file and you didn't know how to use it? Or maybe you know how to use it but you have to navigate to the folder where you downloaded the .AppImage file every time you want to run it, or manually create a launcher for it. From ff9e02744b2530f077dce36e85ff31263567a101 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 11 May 2018 09:23:59 +0800 Subject: [PATCH 022/111] PRF:20180317 How To Edit Multiple Files Using Vim Editor.md @jessie-pang --- ...To Edit Multiple Files Using Vim Editor.md | 139 +++++++++--------- 1 file changed, 68 insertions(+), 71 deletions(-) diff --git a/translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md b/translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md index acb042fcbb..b890cbe282 100644 --- a/translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md +++ b/translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md @@ -1,41 +1,40 @@ -如何使用 Vim 编辑器编辑多个文件 +如何使用 Vim 编辑多个文件 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/Edit-Multiple-Files-Using-Vim-Editor-720x340.png) - -有时候,您可能需要修改多个文件,或要将一个文件的内容复制到另一个文件中。在图形用户界面中,您可以在任何图形文本编辑器(如 gedit)中打开文件,并使用 CTRL + C 和 CTRL + V 复制和粘贴内容。在命令行模式下,您不能使用这种编辑器。不过别担心,只要有 vim 编辑器就有办法。在本教程中,我们将学习使用 Vim 编辑器同时编辑多个文件。相信我,很有意思哒。 +有时候,您可能需要修改多个文件,或要将一个文件的内容复制到另一个文件中。在图形用户界面中,您可以在任何图形文本编辑器(如 gedit)中打开文件,并使用 `CTRL + C` 和 `CTRL + V` 复制和粘贴内容。在命令行模式下,您不能使用这种编辑器。不过别担心,只要有 `vim` 编辑器就有办法。在本教程中,我们将学习使用 `vim` 编辑器同时编辑多个文件。相信我,很有意思哒。 ### 安装 Vim Vim 编辑器可在大多数 Linux 发行版的官方软件仓库中找到,所以您可以用默认的软件包管理器来安装它。例如,在 Arch Linux 及其变体上,您可以使用如下命令: + ``` $ sudo pacman -S vim - ``` 在 Debian 和 Ubuntu 上: + ``` $ sudo apt-get install vim - ``` 在 RHEL 和 CentOS 上: + ``` $ sudo yum install vim - ``` 在 Fedora 上: + ``` $ sudo dnf install vim - ``` 在 openSUSE 上: + ``` $ sudo zypper install vim - ``` ### 使用 Linux 的 Vim 编辑器同时编辑多个文件 @@ -44,7 +43,8 @@ $ sudo zypper install vim #### 方法一 -有两个文件,即 **file1.txt** 和 **file2.txt**,带有一堆随机单词: +有两个文件,即 `file1.txt` 和 `file2.txt`,带有一堆随机单词: + ``` $ cat file1.txt ostechnix @@ -59,53 +59,52 @@ line2 line3 line4 line5 - ``` 现在,让我们同时编辑这两个文件。请运行: + ``` $ vim file1.txt file2.txt - ``` Vim 将按顺序显示文件的内容。首先显示第一个文件的内容,然后显示第二个文件,依此类推。 ![][2] -**在文件中切换** +##### 在文件中切换 要移至下一个文件,请键入: + ``` :n - ``` ![][3] 要返回到前一个文件,请键入: + ``` :N - ``` 如果有任何未保存的更改,Vim 将不允许您移动到下一个文件。要保存当前文件中的更改,请键入: + ``` ZZ - ``` -请注意,是两个大写字母 ZZ(SHIFT + zz)。 +请注意,是两个大写字母 `ZZ`(`SHIFT + zz`)。 要放弃更改并移至上一个文件,请键入: + ``` :N! - ``` 要查看当前正在编辑的文件,请键入: + ``` :buffers - ``` ![][4] @@ -114,57 +113,59 @@ ZZ ![][5] -要切换到下一个文件,请输入 **:buffer**,后跟缓冲区编号。例如,要切换到第一个文件,请键入: +要切换到下一个文件,请输入 `:buffer`,后跟缓冲区编号。例如,要切换到第一个文件,请键入: + ``` :buffer 1 - ``` ![][6] -**打开其他文件进行编辑** +##### 打开其他文件进行编辑 -目前我们正在编辑两个文件,即 file1.txt 和 file2.txt。我想打开另一个名为 **file3.txt** 的文件进行编辑。 +目前我们正在编辑两个文件,即 `file1.txt` 和 `file2.txt`。我想打开另一个名为 `file3.txt` 的文件进行编辑。 + +您会怎么做?这很容易。只需键入 `:e`,然后输入如下所示的文件名即可: -您会怎么做?这很容易。只需键入 **:e**,然后输入如下所示的文件名即可: ``` :e file3.txt - ``` ![][7] -现在你可以编辑 file3.txt 了。 +现在你可以编辑 `file3.txt` 了。 要查看当前正在编辑的文件数量,请键入: + ``` :buffers - ``` ![][8] -请注意,对于使用 **:e** 打开的文件,您无法使用 **:n** 或 **:N** 进行切换。要切换到另一个文件,请输入 **:buffer**,然后输入文件缓冲区编号。 +请注意,对于使用 `:e` 打开的文件,您无法使用 `:n` 或 `:N` 进行切换。要切换到另一个文件,请输入 `:buffer`,然后输入文件缓冲区编号。 -**将一个文件的内容复制到另一个文件中** +##### 将一个文件的内容复制到另一个文件中 -您已经知道了如何同时打开和编辑多个文件。有时,您可能想要将一个文件的内容复制到另一个文件中。这也是可以做到的。切换到您选择的文件,例如,假设您想将 file1.txt 的内容复制到 file2.txt 中: +您已经知道了如何同时打开和编辑多个文件。有时,您可能想要将一个文件的内容复制到另一个文件中。这也是可以做到的。切换到您选择的文件,例如,假设您想将 `file1.txt` 的内容复制到 `file2.txt` 中: + + +首先,请切换到 `file1.txt`: -首先,请切换到 file1.txt: ``` :buffer 1 - ``` -将光标移动至在想要复制的行的前面,并键入**yy** 以抽出(复制)该行。然后,移至 file2.txt: +将光标移动至在想要复制的行的前面,并键入`yy` 以抽出(复制)该行。然后,移至 `file2.txt`: + ``` :buffer 2 - ``` -将光标移至要从 file1.txt 粘贴复制行的位置,然后键入 **p**。例如,您想要将复制的行粘贴到 line2 和 line3 之间,请将鼠标光标置于行前并键入 **p**。 +将光标移至要从 `file1.txt` 粘贴复制行的位置,然后键入 `p`。例如,您想要将复制的行粘贴到 `line2` 和 `line3` 之间,请将鼠标光标置于行前并键入 `p`。 输出示例: + ``` line1 line2 @@ -172,54 +173,54 @@ ostechnix line3 line4 line5 - ``` ![][9] 要保存当前文件中所做的更改,请键入: + ``` ZZ - ``` -再次提醒,是两个大写字母 ZZ(SHIFT + z)。 +再次提醒,是两个大写字母 ZZ(`SHIFT + z`)。 保存所有文件的更改并退出 vim 编辑器,键入: + ``` :wq - ``` 同样,您可以将任何文件的任何行复制到其他文件中。 -**将整个文件内容复制到另一个文件中** +##### 将整个文件内容复制到另一个文件中 -我们知道如何复制一行,那么整个文件的内容呢?也是可以的。比如说,您要将 file1.txt 的全部内容复制到 file2.txt 中。 +我们知道如何复制一行,那么整个文件的内容呢?也是可以的。比如说,您要将 `file1.txt` 的全部内容复制到 `file2.txt` 中。 + +先打开 `file2.txt`: -先打开 file2.txt: ``` $ vim file2.txt - ``` -如果文件已经加载,您可以通过输入以下命令切换到 file2.txt: +如果文件已经加载,您可以通过输入以下命令切换到 `file2.txt`: + ``` :buffer 2 - ``` -将光标移动到您想要粘贴 file1.txt 内容的位置。我想在 file2.txt 的第 5 行之后粘贴 file1.txt 的内容,所以我将光标移动到第 5 行。然后,键入以下命令并按回车键: +将光标移动到您想要粘贴 `file1.txt` 的内容的位置。我想在 `file2.txt` 的第 5 行之后粘贴 `file1.txt` 的内容,所以我将光标移动到第 5 行。然后,键入以下命令并按回车键: + ``` :r file1.txt - ``` ![][10] -这里,**r** 代表 **read**。 +这里,`r` 代表 “read”。 + +现在您会看到 `file1.txt` 的内容被粘贴在 `file2.txt` 的第 5 行之后。 -现在您会看到 file1.txt 的内容被粘贴在 file2.txt 的第 5 行之后。 ``` line1 line2 @@ -231,107 +232,103 @@ open source technology linux unix - ``` ![][11] 要保存当前文件中的更改,请键入: + ``` ZZ ``` 要保存所有文件的所有更改并退出 vim 编辑器,请输入: + ``` :wq - ``` #### 方法二 -另一种同时打开多个文件的方法是使用 **-o** 或 **-O** 标志。 +另一种同时打开多个文件的方法是使用 `-o` 或 `-O` 标志。 要在水平窗口中打开多个文件,请运行: + ``` $ vim -o file1.txt file2.txt - ``` ![][12] -要在窗口之间切换,请按 **CTRL-w w**(即按 **CTRL + w** 并再次按 **w**)。或者,您可以使用以下快捷方式在窗口之间移动: - - * **CTRL-w k** – 上面的窗口 - * **CTRL-w j** – 下面的窗口 - +要在窗口之间切换,请按 `CTRL-w w`(即按 `CTRL + w` 并再次按 `w`)。或者,您可以使用以下快捷方式在窗口之间移动: + * `CTRL-w k` – 上面的窗口 + * `CTRL-w j` – 下面的窗口 要在垂直窗口中打开多个文件,请运行: + ``` $ vim -O file1.txt file2.txt file3.txt - ``` ![][13] -要在窗口之间切换,请按 **CTRL-w w**(即按 **CTRL + w** 并再次按 **w**)。或者,使用以下快捷方式在窗口之间移动: - - * **CTRL-w l** – 左面的窗口 - * **CTRL-w h** – 右面的窗口 - +要在窗口之间切换,请按 `CTRL-w w`(即按 `CTRL + w` 并再次按 `w`)。或者,使用以下快捷方式在窗口之间移动: + * `CTRL-w l` – 左面的窗口 + * `CTRL-w h` – 右面的窗口 其他的一切都与方法一的描述相同。 例如,要列出当前加载的文件,请运行: + ``` :buffers - ``` 在文件之间切换: + ``` :buffer 1 - ``` 打开其他文件,请键入: + ``` :e file3.txt - ``` 将文件的全部内容复制到另一个文件中: + ``` :r file1.txt ``` -方法二的唯一区别是,只要您使用 **ZZ** 保存对当前文件的更改,文件将自动关闭。然后,您需要依次键入 **:wq ** 来关闭文件。但是,如果您按照方法一进行操作,输入 **:wq** 时,所有更改将保存在所有文件中,并且所有文件将立即关闭。 +方法二的唯一区别是,只要您使用 `ZZ` 保存对当前文件的更改,文件将自动关闭。然后,您需要依次键入 `:wq` 来关闭文件。但是,如果您按照方法一进行操作,输入 `:wq` 时,所有更改将保存在所有文件中,并且所有文件将立即关闭。 有关更多详细信息,请参阅手册页。 + ``` $ man vim - ``` -**建议阅读:** +### 建议阅读 您现在掌握了如何在 Linux 中使用 vim 编辑器编辑多个文件。正如您所见,编辑多个文件并不难。Vim 编辑器还有更强大的功能。我们接下来会提供更多关于 Vim 编辑器的内容。 再见! - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-edit-multiple-files-using-vim-editor/ 作者:[SK][a] 译者:[jessie-pang](https://github.com/jessie-pang) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f3b17a2f6c18f9a410178f27b25bd0eb5d3049e9 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 11 May 2018 09:24:29 +0800 Subject: [PATCH 023/111] PUB:20180317 How To Edit Multiple Files Using Vim Editor.md @jessie-pang https://linux.cn/article-9629-1.html --- .../20180317 How To Edit Multiple Files Using Vim Editor.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180317 How To Edit Multiple Files Using Vim Editor.md (100%) diff --git a/translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md b/published/20180317 How To Edit Multiple Files Using Vim Editor.md similarity index 100% rename from translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md rename to published/20180317 How To Edit Multiple Files Using Vim Editor.md From b11c4bfc183f39311ea88e72fe6b5710a97ddec6 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Fri, 11 May 2018 13:25:30 +0800 Subject: [PATCH 024/111] Transalted by qhwdw --- ...ital pinhole camera with a Raspberry Pi.md | 150 ----------------- ...ital pinhole camera with a Raspberry Pi.md | 151 ++++++++++++++++++ 2 files changed, 151 insertions(+), 150 deletions(-) delete mode 100644 sources/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md create mode 100644 translated/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md diff --git a/sources/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md b/sources/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md deleted file mode 100644 index 21f64eb3f0..0000000000 --- a/sources/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md +++ /dev/null @@ -1,150 +0,0 @@ -Translating by qhwdw -How to build a digital pinhole camera with a Raspberry Pi -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rasp-pi-pinhole-howto.png?itok=ubmevVZB) -At the tail end of 2015, the Raspberry Pi Foundation surprised the world by releasing the diminutive [Raspberry Pi Zero][1]. What's more, they [gave it away for free][2] on the cover of the MagPi magazine. I immediately rushed out and trawled around several newsagents until I found the last two copies in the area. I wasn't sure what I would use them for, but I knew their small size would allow me to do interesting projects that a full-sized Pi could not satisfy. - - -![Raspberry Pi Zero][4] - -Raspberry Pi Zero from MagPi magazine. CC BY-SA.4.0. - -Because of my interest in astrophotography, I had previously modified a Microsoft LifeCam Cinema HD webcam, stripping its case, lens, and infrared cut filter to expose the bare [CCD chip][5]. I used it with a custom-built case in place of an eyepiece in my Celestron telescope for astrophotography. It has captured incredible views of Jupiter, close-ups of craters on the Moon, and sunspots on the Sun (with suitable Baader safety film protection). - -Even before that, I had turned my film SLR camera into a [pinhole camera][6] by drilling a hole in a body cap (the cap that protects a camera's internal workings when it doesn't have a lens attached) and covering it in a thin disc cut from a soda can, pierced with a needle to provide a pinhole. Quite by chance, one day this pinhole body cap was sitting on my desk next to the modified astrophotography webcam. I wondered whether the webcam had good enough low-light performance to capture an image from behind the pinhole body cap. It only took a minute with the [GNOME Cheese][7] application to verify that a pinhole webcam was indeed a viable idea. - -From this seed of an idea, I had a way to use one of my Raspberry Pi Zeros! The pinhole cameras that people build are typically minimalistic, offering no controls other than the exposure duration and film's ISO rating. Digital cameras, by contrast, have 20 or more buttons and hundreds more settings buried in menus. My goal for the digital pinhole webcam was to stay true to pinhole photography traditions and build a minimalist device with no controls at all, not even exposure time. - -The digital pinhole camera, created from a Raspberry Pi Zero, HD webcam, and empty powder compact, was the [first project][8] in an [ongoing series][9] of pinhole cameras I built. Here's how I made it. - -### Hardware - -Since I already had the Raspberry Pi Zero in hand, I needed a webcam for this project. Given that the Pi Zero retails for £4 in the UK, I wanted other parts of the project to be priced similarly. Spending £30 on a camera to use with a £4 computer board just feels unbalanced. The obvious answer was to head over to a well-known internet auction site and bid on some secondhand webcams. Soon, I'd acquired a generic HD resolution webcam for a mere £1 plus shipping. After a quick test to ensure it operated correctly with Fedora, I went about stripping the case to examine the size of the electronics. - - -![Hercules DualPix HD webcam][11] - -Hercules DualPix HD webcam, which would be gutted to extract the circuit board and CCD imaging sensor. CC BY-SA 4.0. - -Next, I needed a case to house the camera. The Raspberry Pi Zero circuit board is a mere 65mm x 30mm x 5mm. The webcam's circuit board is even smaller, although it has a plastic mounting around the CCD chip to hold the lens in place. I looked around the house for a container that would fit the two tiny circuit boards. I discovered that my wife's powder compact was just wide enough to fit the Pi Zero circuit board. With a little fiddling, it looked as though I could squeeze the webcam board inside, too. - -![Powder compact][13] - -Powder compact that became the case for the pinhole camera. CC BY-SA 4.0. - -I set out to strip the case off of the webcam by removing a handful of tiny screws to get at the innards. The size of a webcam's case gives little clue about the size of the circuit board inside or where the CCD is positioned. I was lucky that this webcam was small with a convenient layout. Since I was making a pinhole camera, I had to remove the lens to expose the bare CCD chip. - -The plastic mounting was about 1cm high, which would be too tall to fit inside the powder compact. I could remove it entirely with a couple more screws on the rear of the circuit board, but I thought it would be useful to keep it to block light coming from gaps in the case, so I trimmed it down to 4mm high using a craft knife, then reattached it. I bent the legs on the LED to reduce its height. Finally, I chopped off a second plastic tube mounted over the microphone that funneled the sound, since I didn't intend to capture audio. - -![Bare CCD chip][15] - -With the lens removed, the bare CCD chip is visible. The cylindrical collar holds the lens in place and prevents light from the power LED from spoiling the image. CC BY-SA 4.0. - -The webcam had a long USB cable with a full-size plug, while the Raspberry Pi Zero uses a Micro-USB socket, so I needed a USB-to-Micro-USB adapter. But, with the adapter plugged in, the Pi wouldn't fit inside the powder compact, nor would the 1m of USB cable. So I took a sharp knife to the Micro-USB adapter, cutting off its USB socket entirely and stripping plastic to reveal the metal tracks leading to the Micro-USB plug. I also cut the webcam's USB cable down to about 6cm and removed its outer sheaf and foil wrap to expose the four individual cable strands. I soldered them directly to the tracks on the Micro-USB plug. Now the webcam could be plugged into the Pi Zero, and the pair would still fit inside the powder compact case. - -![Modified USB plugs][17] - -The stripped-down Micro-USB plug with the webcam USB cable strands directly soldered onto the individual contact strips. The plug now protrudes only about 1cm from the Raspberry Pi Zero when attached. CC BY-SA 4.0. - -Originally I thought this would be the end of my electrical design, but after testing, I realized I couldn't tell if the camera was capturing images or even powered on. I decided to use the Pi's GPIO pins to drive indicator LEDs. A yellow LED illuminates when the camera control software is running, and a green LED illuminates when the webcam is capturing an image. I connected BCM pins 17 and 18 to the positive leg of the LEDs via 300ohm current-limiting resistors, then connected both negative legs to a common ground pin. - -![LEDs][19] - -The LEDs are connected to GPIO pins BCM 17 and BCM 18, with a 300ohm resistor in series and a common ground. CC BY-SA 4.0. - -Next, it was time to modify the powder compact. First, I removed the inner tray that holds the powder to free up space inside the case by cutting it off with a knife at its hinge. I was planning to run the Pi Zero on a portable USB power-bank battery, which wouldn't fit inside the case, so I cut a hole in the side of the case for the USB cable connector. The LEDs needed to be visible outside the case, so I used a 3mm drill bit to make two holes in the lid. - -Then I used a 6mm drill bit to make a hole in the center of the bottom of the case, which I covered with a thin piece of metal and used a sewing needle to pierce a pinhole in its center. I made sure that only the very tip of the needle poked through, as inserting the entire needle would make the hole far too large. I used fine wet/dry sandpaper to smooth out the pinhole, then re-pierced it from the other side, again using only the tip of the needle. The goal with a pinhole camera is to get a clean, round hole with no deformations or ridges and that just barely lets light through. The smaller the hole, the sharper the images. - -![Bottom of the case with the pinhole aperture][21] - -The bottom of the case with the pinhole aperture. CC BY-SA 4.0. - -All that remained was assembling the finished device. First I fixed the webcam circuit board in the case, using blue putty to hold it in position so the CCD was directly over the pinhole. Using putty allows me to easily reposition the CCD when I need to clean dust spots (and as insurance in case I put it in the wrong place). I placed the Raspberry Pi Zero board directly on top of the webcam board. To protect against electrical short circuits between the two boards, I covered the back of the Pi in several layers of electrical tape. - -The [Raspberry Pi Zero][22] was such a perfect fit for the powder compact that it didn't need anything else to hold it in position, besides the USB cable for the battery that sticks out through the hole in the case. Finally, I poked the LEDs through the previously drilled holes and glued them into place. I added more electrical tape on the legs of the LEDs to prevent short circuits against the Pi Zero board when the lid is closed. - -![Raspberry Pi Zero slotted into the case][24] - -The Raspberry Pi Zero slotted into the case with barely 1mm of clearance at the edge. The hacked up Micro-USB plug connected to the webcam is next to the Micro-USB plug from the battery. CC BY-SA 4.0. - -### Software - -Computer hardware is useless without software to control it, of course. The Raspberry Pi Zero can run the same software as a full-sized Pi, but booting up a traditional [Raspbian OS][25] image is a very time-consuming process due to the Zero's slow CPU speed. A camera that takes more than a minute to turn on is a camera that will not get much real-world use. Furthermore, almost nothing that a full Raspbian OS runs is useful to this camera. Even if I disable all the redundant services launched at boot, it still takes unreasonably long to boot. I decided the only stock software I would use is a [U-Boot][26] bootloader and the Linux kernel. A custom written `init` binary mounts the root filesystem from the microSD card, loads the kernel modules needed to drive the webcam, populates `/dev`, and runs the application binary. - -The application binary is another custom C program that does the core job of controlling the camera. First, it waits for the kernel driver to initialize the webcam, opens it, and initializes it via low-level `v4l ioctl` calls. The GPIO pins are configured to drive the LEDs by poking registers via `/dev/mem`. - -With initialization out of the way, the camera goes into a loop. Each iteration captures a single frame from the webcam in JPEG format using default exposure settings, saves the image straight to the SD card, then sleeps for three seconds. This loop runs forever until the battery is unplugged. This nicely achieves the original goal, which was to create a digital camera with the simplicity on par with a typical analog pinhole camera. - -[The code][27] for this custom userspace is made available under [GPLv3][28] or any later version. The Raspberry Pi Zero requires an ARMv6 binary, so I built it from an x86_64 host using the [QEMU ARM][29] emulator to run compilers from a `chroot` populated with the toolchain for the [Pignus][30] distro (a Fedora 23 port/rebuild for ARMv6). Both binaries were statically linked with [glibc][31], so they are self-contained. I built a custom RAMDisk containing the binaries and a few required kernel modules and copied it to the SD card, where the bootloader can find them. - -![Completed camera][33] - -The finished camera is entirely hidden inside the powder compact case. The only hint of something unusual is the USB cable coming out of the side. CC BY-SA 4.0. - -### Taking photos - -With both the hardware and software complete, it was time to see what the camera was capable of. Everyone is familiar with the excellent quality of images produced by modern digital cameras, whether professional DSLRs or mobile phones. It is important to reset expectations here to a more realistic level. The HD webcam captures 1280x1024 resolution (~1 megapixel). The CCD struggles to capture an image from the tiny amount of light allowed through the pinhole. The webcam automatically increases gain and exposure time to compensate, which results in very noisy images. The images also suffer from a very narrow dynamic range, as evidenced by a squashed histogram, which has to be stretched in post-processing to get true blacks and whites. - -The best results are achieved by capturing images outside in daylight, as most interiors have insufficient illumination to register any kind of usable image. The CCD is only about 1cm in diameter, and it's just a few millimeters away from the pinhole, which creates a relatively narrow field of view. For example, in a selfie taken by holding the camera at arm's length, the person's head fills the entire frame. Finally, the images are in very soft focus, which is a defining characteristic of all pinhole cameras. - -![Picture of houses taken with pinhole webcam][35] - -Terraced houses in the street, London. CC BY-SA 4.0. - -![Airport photo][37] - -Farnborough airport, former terminal building. CC BY-SA 4.0. - -Initially, I just used the camera to capture small numbers of still images. I later reduced the loop delay from three seconds to one second and used the camera used to capture sequences of images over many minutes. I rendered the images into time-lapse videos using [GStreamer.][38] - -Here's a video I created with this process: - -[][38] - -Video of the walk from Bank to Waterloo along the Thames to unwind after a day's work. 1200 frames captured at 40 frames per minute animated at 20 frames per second. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-build-digital-pinhole-camera-raspberry-pi - -作者:[Daniel Berrange][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/berrange -[1]:https://www.raspberrypi.org/products/raspberry-pi-zero/ -[2]:https://opensource.com/users/node/24776 -[3]:https://opensource.com/file/390776 -[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-raspberrypizero.jpg?itok=1ry7Kx9m (Raspberry Pi Zero) -[5]:https://en.wikipedia.org/wiki/Charge-coupled_device -[6]:https://en.wikipedia.org/wiki/Pinhole_camera -[7]:https://help.gnome.org/users/cheese/stable/ -[8]:https://pinholemiscellany.berrange.com/motivation/m-arcturus/ -[9]:https://pinholemiscellany.berrange.com/ -[10]:https://opensource.com/file/390756 -[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-hercules_dualpix_hd.jpg?itok=r858OM9_ (Hercules DualPix HD webcam) -[12]:https://opensource.com/file/390771 -[13]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-powdercompact.jpg?itok=RZSwqCY7 (Powder compact) -[14]:https://opensource.com/file/390736 -[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-bareccdchip.jpg?itok=IQzjZmED (Bare CCD chip) -[17]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-usbs.jpg?itok=QJBkbI1F (Modified USB plugs) -[19]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-_pi-zero-led.png?itok=oH4c2oCn (LEDs) -[21]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-casebottom.jpg?itok=QjDMaWLi (Bottom of the case with the pinhole aperture) -[22]:https://opensource.com/users/node/34916 -[24]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-pizeroincase.jpg?itok=cyUIvjjt (Raspberry Pi Zero slotted into the case) -[25]:https://www.raspberrypi.org/downloads/raspbian/ -[26]:https://www.denx.de/wiki/U-Boot -[27]:https://gitlab.com/berrange/pinholemiscellany/ -[28]:https://www.gnu.org/licenses/gpl-3.0.en.html -[29]:https://wiki.qemu.org/Documentation/Platforms/ARM -[30]:https://pignus.computer/ -[31]:https://www.gnu.org/software/libc/ -[33]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-completedcamera.jpg?itok=VYFaT-kA (Completed camera) -[35]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-housesimage.jpg?itok=-_gtwn9N (Picture of houses taken with pinhole webcam) -[37]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-farnboroughairportimage.jpg?itok=E829gg4F (Airport photo) -[38]:https://gstreamer.freedesktop.org/modules/gst-ffmpeg.html diff --git a/translated/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md b/translated/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md new file mode 100644 index 0000000000..8a7debab66 --- /dev/null +++ b/translated/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md @@ -0,0 +1,151 @@ + + +如何使用树莓派制作一个数字针孔摄像头 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rasp-pi-pinhole-howto.png?itok=ubmevVZB) +在 2015 年底的时候,树莓派基金会发布了一个非常小的 [Raspberry Pi Zero][1],这让大家感到很意外。更夸张的是,他们随 MagPi 杂志一起 [免费赠送][2]。我看到这个消息后立即冲出去到处找报刊亭,直到我在这一区域的某处找到最后两份。实际上我还没有想好如何去使用它们,但是我知道,因为它们非常小,所以,它们可以做很多全尺寸树莓派没法做的一些项目。 + + +![Raspberry Pi Zero][4] + +从 MagPi 杂志上获得的树莓派 Zero。CC BY-SA.4.0。 + +因为我对天文摄影非常感兴趣,我以前还改过一台微软出的 LifeCam Cinema 高清网络摄像头,拆掉了它的外壳、镜头、以及红外滤镜,露出了它的 [CCD 芯片][5]。我把它定制为我的 Celestron 天文望远镜的目镜。用它我捕获到了令人难以置信的木星照片、月球上的陨石坑、以及太阳黑子的特写镜头(使用了适当的 Baader 安全保护膜)。 + +在那之前,我甚至还在我的使用胶片的 SLR 摄像机上,通过在镜头盖(这个盖子就是在摄像机上没有安装镜头时,用来保护摄像机的内部元件的那个盖子)上钻一个小孔来变成一个 [针孔摄像头][6],将这个钻了小孔的盖子,盖到一个汽水罐上切下来的小圆盘上,以提供一个针孔。碰巧有一天,在我的桌子上发现了一个可以用来做针孔体的盖子,随后我将它改成了用于天文摄像的网络摄像头。我很好奇这个网络摄像头是否有从针孔盖子后面捕获低照度图像的能力。我花了一些时间使用 [GNOME Cheese][7] 应用程序,去验证这个针孔摄像头确实是个可行的创意。 + +自从有了这个想法,我就有了树莓派 Zero 的一个用法!针孔摄像机一般都非常小,除了曝光时间和胶片的 ISO 速率外,一般都不提供其它的控制选项。数字摄像机就不一样了,它至少有 20 多个按钮和成百上千的设置菜单。我的数字针孔摄像头的目标是真实反映天文摄像的传统风格,设计一个没有控制选项的极简设备,甚至连曝光时间控制也没有。 + +用树莓派 Zero、高清网络镜头和空粉盒设计的数字针孔摄像头,是我设计的 [一系列][9] 针孔摄像头的 [第一个项目][8]。现在,我们开始来制作它。 + +### 硬件 + +因为我手头已经有了一个树莓派 Zero,为完成这个项目我还需要一个网络摄像头。这个树莓派 Zero 在英国的零售价是 4 英磅,这个项目其它部件的价格,我希望也差不多是这样的价格水平。花费 30 英磅买来的摄像头安装在一个 4 英磅的计算机主板上,让我感觉有些不平衡。显而易见的答案是前往一个知名的拍卖网站上,去找到一些二手的网络摄像头。不久之后,我仅花费了 1 英磅再加一些运费,获得了一个普通的高清摄像头。之后,在 Fedora 上做了一些测试操作,以确保它是可用正常使用的,我拆掉了它的外壳,以检查它的电子元件的大小是否适合我的项目。 + + +![Hercules DualPix HD webcam][11] + +Hercules DualPix 高清网络摄像头,它将被解剖以提取它的电路板和 CCD 图像传感器。CC BY-SA 4.0. + +接下来,我需要一个安放摄像头的外壳。树莓派 Zero 电路板大小仅仅为 65mm x 30mm x 5mm。虽然网络摄像头的 CCD 芯片周围有一个用来安装镜头的塑料支架,但是,实际上它的电路板尺寸更小。我在家里找了一圈,希望能够找到一个适合盛放这两个极小的电路板的容器。最后,我发现我妻子的粉盒足够去安放树莓派的电路板。稍微做一些小调整,似乎也可以将网络摄像头的电路板放进去。 + +![Powder compact][13] + +变成我的针孔摄像头外壳的粉盒。CC BY-SA 4.0. + +我拆掉了网络摄像头外壳上的一些螺丝,取出了它的内部元件。网络摄像头外壳的大小反映了它的电路板的大小或 CCD 的位置。我很幸运,这个网络摄像头很小而且它的电路板的布局也很方便。因为我要做一个针孔摄像头,我需要取掉镜像,露出 CCD 芯片。 + +它的塑料外壳大约有 1 厘米高,它太高了没有办法放进粉盒里。我拆掉了电路板后面的螺丝,将它完全拆开,我认为将它放在盒子里有助于阻挡从缝隙中来的光线,因此,我用一把工艺刀将它修改成 4 毫米高,然后将它重新安装。我折弯了 LED 的支脚以降低它的高度。最后,我切掉了安装麦克风的塑料管,因为我不想采集声音。 + +![Bare CCD chip][15] + +取下镜头以后,就可以看到裸露的 CCD 芯片了。圆柱形的塑料柱将镜头固定在合适的位置上,并阻挡 LED 光进入镜头破坏图像。CC BY-SA 4.0 + +网络摄像头有一个很长的带全尺寸插头的 USB 线缆,而树莓派 Zero 使用的是一个 Micro-USB 插座,因此,我需要一个 USB-to-Micro-USB 适配器。但是,使用适配器插入,这个树莓派将放不进这个粉盒中,更不用说还有将近一米长的 USB 线缆。因此,我用刀将 Micro-USB 适配器削开,切掉了它的 USB 插座并去掉这些塑料,露出连接到 Micro-USB 插头上的金属材料。同时也切掉了网络摄像头上大约 6 厘米长的 USB 电缆,并剥掉裹在它外面的锡纸,露出它的四根电线。我把它们直接焊接到 Micro-USB 插头上。现在网络摄像头可以插入到树莓派 Zero 上了,并且电线也可以放到粉盒中了。 + +![Modified USB plugs][17] + +网络摄像头使用的 Micro-USB 插头已经剥掉了线,并直接焊接到触点上。这个插头现在插入到树莓派 Zero 后大约仅高出树莓派 1 厘米。CC BY-SA 4.0 + +最初,我认为到此为止,已经全部完成了电子设计部分,但是在测试之后,我意识到,如果摄像头没有捕获图像或者甚至没有加电我都不知道。我决定使用树莓派的 GPIO 针脚去驱动 LED 指示灯。一个黄色的 LED 表示网络摄像头控制软件已经运行,而一个绿色的 LED 表示网络摄像头正在捕获图像。我在 BCM 的 17 号和 18 号针脚上各自串接一个 300 欧姆的电阻,并将它们各自连接到 LED 的正极上,然后将 LED 的负极连接到一起并接入到公共地针脚上。 + +![LEDs][19] + +LED 使用一个 300 欧姆的电阻连接到 GPIO 的 BCM 17 号和 BCM 18 号针脚上,负极连接到公共地针脚。CC BY-SA 4.0. + +接下来,该去修改粉盒了。首先,我去掉了卡在粉盒上的托盘以腾出更多的空间,并且用刀将连接处切开。我打算在一个便携式充电宝上运行树莓派 Zero,充电宝肯定是放不到这个盒子里面,因此,我挖了一个孔,这样就可以引出 USB 连接头。LED 的光需要能够从盒子外面看得见,因此,我在盖子上钻了两个 3 毫米的小孔。 + +然后,我使用一个 6 毫米的钻头在盖子的底部中间处钻了一个孔,并找了一个薄片盖在它上面,然后用针在它的中央扎了一个小孔。一定要确保针尖很细,因为如果插入整个针会使孔太大。我使用干/湿砂纸去打磨这个针孔,以让它更光滑,然后从另一面再次打孔,再强调一次仅使用针尖。使用针孔摄像头的目的是为了得到一个规则的、没有畸形或凸起的圆孔,并且勉强让光通过。孔越小,图像越锐利。 + +![Bottom of the case with the pinhole aperture][21] + +带针孔的盒子底部。CC BY-SA 4.0 + +剩下的工作就是将这些已经改造完成的设备封装起来。首先我使用蓝色腻子将摄像头的电路板固定在盒子中合适的位置,这样针孔就直接处于 CCD 之上了。使用蓝色腻子的好处是,如果我需要清理污渍(或者如果放错了位置)时,就可以很容易地重新安装 CCD 了。将树莓派 Zero 直接放在摄像头电路板上面。为防止这两个电路板之间可能出现的短路情况,我在这两个电路板之间放了几层防静电袋。 + +[树莓派 Zero][22] 非常适合放到这个粉盒中,并且不需要任何固定,而从小孔中穿出去连接充电宝的 USB 电缆需要将它粘住固定。最后,我将 LED 塞进了前面在盒子上钻的孔中,并用胶水将它们固定住。我在 LED 的针脚之中放了一些防静电袋,以防止盒子盖上时,它与树莓派电路板接触而发生短路。 + +![Raspberry Pi Zero slotted into the case][24] + +树莓派 Zero 塞入到这个盒子中后,周围的空隙不到 1mm。从盒子中引出的连接到网络摄像头上的 Micro-USB 插头,接下来需要将它连接到充电宝上。CC BY-SA 4.0 + +### 软件 + +当然,计算机硬件离开控制它的软件是不能使用的。树莓派 Zero 同样可以运行全尺寸树莓派能够运行的软件,但是,因为树莓派 Zero 的 CPU 速度比较慢,让它去引导传统的 [Raspbian OS][25] 镜像非常耗时。打开摄像头都要花费差不多一分钟的时间,这样的速度在现实中是没有什么用处的。而且,一个完整的树莓派操作系统对我的这个摄像头项目来说也没有必要。甚至是,我禁用了引导时启动的所有可禁用的服务,启动仍然需要很长的时间。因此,我决定仅使用需要的软件,我将用一个 [U-Boot][26] 引导加载器和 Linux 内核。自定义 `init` 二进制文件从 microSD 卡上加载 root 文件系统,读入驱动网络摄像头所需要的内核模块,并将它放在 `/dev` 目录下,然后运行二进制的应用程序。 + +这个二进制的应用程序是另一个定制的 C 程序,它做的核心工作就是管理摄像头。首先,它等待内核驱动程序去初始化网络摄像头、打开它、以及通过低级的 `v4l ioctl` 调用去初始化它。GPIO 针是通过 `/dev/mem` 寄存器被配置为驱动 LED。 + +初始化完成之后,摄像头进入一个 loop 循环。每个图像捕获循环是摄像头使用缺省配置,以 JPEG 格式捕获一个单一的图像帧、保存这个图像帧到 SD 卡、然后休眠三秒。这个循环持续运行直到断电为止。这已经很完美地实现了我的最初目标,那就是用一个传统的模拟的针孔摄像头设计一个简单的数字摄像头。 + +定制的用户空间 [代码][27] 在遵守 [GPLv3][28] 或者更新版许可下自由使用。树莓派 Zero 需要 ARMv6 的二进制文件,因此,我使用了 [QEMU ARM][29] 模拟器在一台 x86_64 主机上进行编译,它使用了 [Pignus][30] 发行版(一个针对 ARMv6 移植/重构建的 Fedora 23 版本)下的工具链,在 `chroot` 下进行编译。所有的二进制文件都静态链接了 [glibc][31],因此,它们都是自包含的。我构建了一个定制的 RAMDisk 去包含这些二进制文件和所需的内核模块,并将它拷贝到 SD 卡,这样引导加载器就可以找到它们了。 + +![Completed camera][33] + +最终完成的摄像机完全隐藏在这个粉盒中了。唯一露在外面的东西就是 USB 电缆。CC BY-SA 4.0 + +### 照像 + +软件和硬件已经完成了,是该去验证一下它能做什么了。每个人都熟悉用现代的数字摄像头拍摄的高质量图像,不论它是用专业的 DSLRs 还是移动电话拍的。但是,这个高清的 1280x1024 分辨率的网络摄像头(差不多是一百万像素),在这里可能会让你失望。这个 CCD 从一个光通量极小的针孔中努力捕获图像。网络摄像头自动提升增益和曝光时间来进行补偿,最后的结果是一幅噪点很高的图像。图像的动态范围也非常窄,从一个非常拥挤的柱状图就可以看出来,这可以通过后期处理来拉长它,以得到更真实的亮部和暗部。 + +在户外阳光充足时捕获的图像达到了最佳效果,因此在室内获得的图像大多数都是不可用的图像。它的 CCD 直径仅有大约 1cm,并且是从一个几毫米的针孔中来捕获图像的,它的视界相当窄。比如,在自拍时,手臂拿着相机尽可能伸长,所获得的图像也就是充满整个画面的人头。最后,图像都是失焦的,所有的针孔摄像机都是这样的。 + +![Picture of houses taken with pinhole webcam][35] + +在伦敦,大街上的屋顶。CC BY-SA 4.0 + +![Airport photo][37] + +范堡罗机场的老航站楼。CC BY-SA 4.0 + +最初,我只是想使用摄像头去捕获一些静态图像。后面,我降低了 loop 循环的延迟时间,从三秒改为一秒,然后用它捕获一段时间内的一系列图像。我使用 [GStreamer][38] 将这些图像做成了延时视频。 + +以下是我创建视频的过程: + +[][38] + +视频是我在某天下班之后,从银行沿着泰晤式河到滑铁卢的画面。以每分钟 40 帧捕获的 1200 帧图像被我制作成了每秒 20 帧的动画。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/how-build-digital-pinhole-camera-raspberry-pi + +作者:[Daniel Berrange][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者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/berrange +[1]:https://www.raspberrypi.org/products/raspberry-pi-zero/ +[2]:https://opensource.com/users/node/24776 +[3]:https://opensource.com/file/390776 +[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-raspberrypizero.jpg?itok=1ry7Kx9m "Raspberry Pi Zero" +[5]:https://en.wikipedia.org/wiki/Charge-coupled_device +[6]:https://en.wikipedia.org/wiki/Pinhole_camera +[7]:https://help.gnome.org/users/cheese/stable/ +[8]:https://pinholemiscellany.berrange.com/motivation/m-arcturus/ +[9]:https://pinholemiscellany.berrange.com/ +[10]:https://opensource.com/file/390756 +[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-hercules_dualpix_hd.jpg?itok=r858OM9_ "Hercules DualPix HD webcam" +[12]:https://opensource.com/file/390771 +[13]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-powdercompact.jpg?itok=RZSwqCY7 "Powder compact" +[14]:https://opensource.com/file/390736 +[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-bareccdchip.jpg?itok=IQzjZmED "Bare CCD chip" +[17]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-usbs.jpg?itok=QJBkbI1F "Modified USB plugs" +[19]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-_pi-zero-led.png?itok=oH4c2oCn "LEDs" +[21]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-casebottom.jpg?itok=QjDMaWLi "Bottom of the case with the pinhole aperture" +[22]:https://opensource.com/users/node/34916 +[24]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-pizeroincase.jpg?itok=cyUIvjjt "Raspberry Pi Zero slotted into the case" +[25]:https://www.raspberrypi.org/downloads/raspbian/ +[26]:https://www.denx.de/wiki/U-Boot +[27]:https://gitlab.com/berrange/pinholemiscellany/ +[28]:https://www.gnu.org/licenses/gpl-3.0.en.html +[29]:https://wiki.qemu.org/Documentation/Platforms/ARM +[30]:https://pignus.computer/ +[31]:https://www.gnu.org/software/libc/ +[33]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-completedcamera.jpg?itok=VYFaT-kA "Completed camera" +[35]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-housesimage.jpg?itok=-_gtwn9N "Picture of houses taken with pinhole webcam" +[37]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pinhole-farnboroughairportimage.jpg?itok=E829gg4F "Airport photo" +[38]:https://gstreamer.freedesktop.org/modules/gst-ffmpeg.html From 158ccb0d723e18f3b340a3c674bb4d918f9987c8 Mon Sep 17 00:00:00 2001 From: paperzhang <31605464+paperzhang@users.noreply.github.com> Date: Fri, 11 May 2018 13:35:27 +0800 Subject: [PATCH 025/111] Delete 20180501 How To Use Vim Editor To Input Text Anywhere.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除源文件 --- ...o Use Vim Editor To Input Text Anywhere.md | 100 ------------------ 1 file changed, 100 deletions(-) delete mode 100644 sources/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md diff --git a/sources/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/sources/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md deleted file mode 100644 index 368d1b1dbc..0000000000 --- a/sources/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md +++ /dev/null @@ -1,100 +0,0 @@ -How To Use Vim Editor To Input Text Anywhere -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-720x340.png) - -Howdy Vim users! Today, I have come up with a good news to all of you. Say hello to **Vim-anywhere** , a simple script that allows you to use the Vim editor to input text anywhere in your Linux box. That means you can simply invoke your favorite Vim editor, type whatever you want and paste the text on any application or on a website. The text will be available in your clipboard until you restart your system. This utility is absolutely useful for those who love to use the Vim keybindings often in non-vim environment. - -### Install Vim-anywhere in Linux - -The Vim-anywhere utility will work on any GNOME based (or derivatives) Linux distributions. Also, make sure you have installed the following prerequisites. - - * Curl - * Git - * gVim - * xclip - - - -For instance, you can those utilities in Ubuntu as shown below. -``` -$ sudo apt install curl git vim-gnome xclip - -``` - -Then, run the following command to install Vim-anywhere: -``` -$ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash - -``` - -Vim-anywhere has been installed. Now let us see how to use it. - -### Use Vim Editor To Input Text Anywhere - -Let us say you need to create a word document. But you’re much more comfortable using Vim editor than LibreOffice writer. No problem, this is where Vim-anywhere comes in handy. It automates the entire process. It simply invokes the Vim editor, so you can write whatever you want in it and paste it in the .doc file. - -Let me show you an example. Open LibreOffice writer or any graphical text editor of your choice. Then, open Vim-anywhere. To do so, simply press **CTRL+ALT+V**. It will open the gVim editor. Press “i” to switch to interactive mode and input the text. Once done, save and close it by typing **:wq**. - -![][2] - -The text will be available in the clipboard until you restart the system. After you closed the editor, your previous application is refocused. Just press **CTRL+P** to paste the text in it. - -![][3] - -It’s just an example. You can even use Vim-anywhere to write something on an annoying web form or any other applications. Once Vim-anywhere invoked, it will open a buffer. Close it and its contents are automatically copied to your clipboard and your previous application is refocused. - -The vim-anywhere utility will create a temporary file in **/tmp/vim-anywhere** when invoked. These temporary files stick around until you restart your system, giving you a temporary history. -``` -$ ls /tmp/vim-anywhere - -``` - -You can re-open your most recent file using command: -``` -$ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 ) - -``` - -**Update Vim-anywhere** - -Run the following command to update Vim-anywhere: -``` -$ ~/.vim-anywhere/update - -``` - -**Change keyboard shotcut** - -The default keybinding to invoke Vim-anywhere is CTRL+ALT+V. You can change it to any custom keybinding using gconf tool. -``` -$ gconftool -t str --set /desktop/gnome/keybindings/vim-anywhere/binding - -``` - -**Uninstall Vim-anywhere** - -Some of you might think that opening Vim editor each time to input text and paste the text back to another application might be pointless and completely unnecessary. - -If you don’t find this utility useful, simply uninstall it using command: -``` -$ ~/.vim-anywhere/uninstall - -``` - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ - -作者:[SK][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.ostechnix.com/author/sk/ -[2]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-1-1.png -[3]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-2.png From 8e506ab9e4c985ce464f1273b474dff40c33b24b Mon Sep 17 00:00:00 2001 From: paperzhang <31605464+paperzhang@users.noreply.github.com> Date: Fri, 11 May 2018 13:36:20 +0800 Subject: [PATCH 026/111] Add files via upload --- ...o Use Vim Editor To Input Text Anywhere.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md diff --git a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md new file mode 100644 index 0000000000..3bcd192040 --- /dev/null +++ b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md @@ -0,0 +1,104 @@ +如何在任何地方使用Vim编辑器输入文本 +====== +![](https://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-720x340.png) + +各位Vim使用者大家好!今天,我这里有个好消息告诉大家。我会向大家介绍**Vim-anywhere**,这是一个简单的脚本,它允许你使用Vim编辑器在Linux中的任何地方输入文本。这意味着你能简单地调用自己最爱的Vim编辑器,输入任何你所想的,并将这些文本粘贴到任意的应用和网站中。这些文本将在剪贴板可用,直到你重启了系统。这个工具对那些喜欢在非Vim环境中使用Vim键位绑定的人来说十分有用。 + +### 在Linux中安装Vim-anywhere +Vim-anywhere工具可以运行在任何基本GNOME(或其他衍生品)的Linux发行版上。另外,确保你已经安装了下面的依赖。 + + * Curl + * Git + * gVim + * xclip + + +比如,你可以用下面的命令在Ubuntu中安装这些工具: +``` +$ sudo apt install curl git vim-gnome xclip + +``` +然后运行如下的命令来安装Vim-anywhere: +``` +$ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash + +``` +Vim-anywhere到此已经安装完成。现在我们来看看如何使用它。 +### 在任何地方使用Vim编辑器输入文本 +假如你需要创建一个word文档。但是你更愿意使用Vim编辑器,而不是LibreOffice。没问题,这里Vim-anywhere就派上用场了。Vim-anywhere自动化了整个流程。它仅仅简单地调用Vim编辑器,所以你能写任何你所想的,然后将之粘贴到 .doc 文件中。 + +让我给你展示一个用例。打开LibreOffice或者你选的任何图形文本编辑器。然后打开Vim-anywhere。你只需要按下**CTRL+ALT+V**即可。它将会打开gVim编辑器。按下"i"切换到交互模式然后输入文本。完成之后,键入**:wq**关闭并保存文件。 + +![][2] + +这些文本会在剪贴板中可用,直到你重启了系统。在你关闭编辑器之后,你之前的应用会重新占据主界面。你只需按下**CTRL+P**将文本粘贴进去。 + +![][3] + +这仅仅只是一个例子。你甚至可以使用Vim-anywhere在烦人的web表单或者其他应用上进行输入。一旦Vim-anywhere被调用,它将会打开一个缓冲区。关闭Vim-anywhere之后,缓冲器内的内容会自动复制到你的剪贴板中,之前的应用会重新占据主界面。 + +Vim-anywhere在被调用的时候会在**/tmp/vim-anywhere**中创建一个临时文件。这些临时文件会一致保存着,直到你重启了系统,并为你提供临时的历史记录。 +``` +$ ls /tmp/vim-anywhere + +``` +你可以用下面的命令重新打开最近的文件: +``` +$ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 ) + +``` +**更新Vim-anywhere** + +运行下面的命令来更新Vim-anywhere: +``` +$ ~/.vim-anywhere/update + +``` + +**更改快捷键** + +默认调用Vim-anywhere的键位是CTRL+ALT+V。你可以用gconf工具将其更改为任何自定义的键位绑定。 +``` +$ gconftool -t str --set /desktop/gnome/keybindings/vim-anywhere/binding + +``` + +**卸载Vim-anywhere** + + +可能有些人觉得每次打开Vim编辑器,输入一些文本,然后将文本复制到其他应用中是没有意义也毫无必要的。 + +如果你不觉得这个工具有用,只需使用下面的命令来卸载它: +``` +$ ~/.vim-anywhere/uninstall + +``` + + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[paperzhang](https://github.com/paperzhang) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[2]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-1-1.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-2.png + + + + + + + + + + + From 65d3308ceaf52f82f9af8546823bed30c090c9e0 Mon Sep 17 00:00:00 2001 From: paperzhang <31605464+paperzhang@users.noreply.github.com> Date: Fri, 11 May 2018 13:37:50 +0800 Subject: [PATCH 027/111] Update 20180501 How To Use Vim Editor To Input Text Anywhere.md --- ... How To Use Vim Editor To Input Text Anywhere.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md index 3bcd192040..706026a296 100644 --- a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md +++ b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md @@ -75,8 +75,6 @@ $ ~/.vim-anywhere/uninstall ``` - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ @@ -91,14 +89,3 @@ via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ [a]:https://www.ostechnix.com/author/sk/ [2]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-1-1.png [3]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-2.png - - - - - - - - - - - From 2974bac2ef450d5feb590ed7719d96c4579c8d0e Mon Sep 17 00:00:00 2001 From: paperzhang <31605464+paperzhang@users.noreply.github.com> Date: Fri, 11 May 2018 13:50:32 +0800 Subject: [PATCH 028/111] Delete 20180501 How To Use Vim Editor To Input Text Anywhere.md --- ...o Use Vim Editor To Input Text Anywhere.md | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100644 translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md diff --git a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md deleted file mode 100644 index 706026a296..0000000000 --- a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md +++ /dev/null @@ -1,91 +0,0 @@ -如何在任何地方使用Vim编辑器输入文本 -====== -![](https://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-720x340.png) - -各位Vim使用者大家好!今天,我这里有个好消息告诉大家。我会向大家介绍**Vim-anywhere**,这是一个简单的脚本,它允许你使用Vim编辑器在Linux中的任何地方输入文本。这意味着你能简单地调用自己最爱的Vim编辑器,输入任何你所想的,并将这些文本粘贴到任意的应用和网站中。这些文本将在剪贴板可用,直到你重启了系统。这个工具对那些喜欢在非Vim环境中使用Vim键位绑定的人来说十分有用。 - -### 在Linux中安装Vim-anywhere -Vim-anywhere工具可以运行在任何基本GNOME(或其他衍生品)的Linux发行版上。另外,确保你已经安装了下面的依赖。 - - * Curl - * Git - * gVim - * xclip - - -比如,你可以用下面的命令在Ubuntu中安装这些工具: -``` -$ sudo apt install curl git vim-gnome xclip - -``` -然后运行如下的命令来安装Vim-anywhere: -``` -$ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash - -``` -Vim-anywhere到此已经安装完成。现在我们来看看如何使用它。 -### 在任何地方使用Vim编辑器输入文本 -假如你需要创建一个word文档。但是你更愿意使用Vim编辑器,而不是LibreOffice。没问题,这里Vim-anywhere就派上用场了。Vim-anywhere自动化了整个流程。它仅仅简单地调用Vim编辑器,所以你能写任何你所想的,然后将之粘贴到 .doc 文件中。 - -让我给你展示一个用例。打开LibreOffice或者你选的任何图形文本编辑器。然后打开Vim-anywhere。你只需要按下**CTRL+ALT+V**即可。它将会打开gVim编辑器。按下"i"切换到交互模式然后输入文本。完成之后,键入**:wq**关闭并保存文件。 - -![][2] - -这些文本会在剪贴板中可用,直到你重启了系统。在你关闭编辑器之后,你之前的应用会重新占据主界面。你只需按下**CTRL+P**将文本粘贴进去。 - -![][3] - -这仅仅只是一个例子。你甚至可以使用Vim-anywhere在烦人的web表单或者其他应用上进行输入。一旦Vim-anywhere被调用,它将会打开一个缓冲区。关闭Vim-anywhere之后,缓冲器内的内容会自动复制到你的剪贴板中,之前的应用会重新占据主界面。 - -Vim-anywhere在被调用的时候会在**/tmp/vim-anywhere**中创建一个临时文件。这些临时文件会一致保存着,直到你重启了系统,并为你提供临时的历史记录。 -``` -$ ls /tmp/vim-anywhere - -``` -你可以用下面的命令重新打开最近的文件: -``` -$ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 ) - -``` -**更新Vim-anywhere** - -运行下面的命令来更新Vim-anywhere: -``` -$ ~/.vim-anywhere/update - -``` - -**更改快捷键** - -默认调用Vim-anywhere的键位是CTRL+ALT+V。你可以用gconf工具将其更改为任何自定义的键位绑定。 -``` -$ gconftool -t str --set /desktop/gnome/keybindings/vim-anywhere/binding - -``` - -**卸载Vim-anywhere** - - -可能有些人觉得每次打开Vim编辑器,输入一些文本,然后将文本复制到其他应用中是没有意义也毫无必要的。 - -如果你不觉得这个工具有用,只需使用下面的命令来卸载它: -``` -$ ~/.vim-anywhere/uninstall - -``` - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[paperzhang](https://github.com/paperzhang) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[2]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-1-1.png -[3]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-2.png From 5e9986f553ecf22cb513ced1c2a11993e24bda4d Mon Sep 17 00:00:00 2001 From: paperzhang <31605464+paperzhang@users.noreply.github.com> Date: Fri, 11 May 2018 13:50:50 +0800 Subject: [PATCH 029/111] Add files via upload --- ...o Use Vim Editor To Input Text Anywhere.md | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md diff --git a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md new file mode 100644 index 0000000000..1f013e6566 --- /dev/null +++ b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md @@ -0,0 +1,102 @@ +如何在任何地方使用 Vim 编辑器输入文本 +====== +![](https://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-720x340.png) + +各位Vim使用者大家好!今天,我这里有个好消息告诉大家。我会向大家介绍 **Vim-anywhere**,这是一个简单的脚本,它允许你使用 Vim 编辑器在 Linux 中的任何地方输入文本。这意味着你能简单地调用自己最爱的 Vim 编辑器,输入任何你所想的,并将这些文本粘贴到任意的应用和网站中。这些文本将在剪贴板可用,直到你重启了系统。这个工具对那些喜欢在非 Vim 环境中使用 Vim 键位绑定的人来说十分有用。 + +### 在 Linux 中安装 Vim-anywhere +Vim-anywhere 工具可以运行在任何基本 GNOME(或其他衍生品)的 Linux 发行版上。另外,确保你已经安装了下面的依赖。 + + * Curl + * Git + * gVim + * xclip + + +比如,你可以用下面的命令在 Ubuntu 中安装这些工具: +``` +$ sudo apt install curl git vim-gnome xclip + +``` +然后运行如下的命令来安装 Vim-anywhere: +``` +$ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash + +``` +Vim-anywhere 到此已经安装完成。现在我们来看看如何使用它。 +### 在任何地方使用 Vim 编辑器输入文本 +假如你需要创建一个 word 文档。但是你更愿意使用 Vim 编辑器,而不是 LibreOffice。没问题,这里 Vim-anywhere 就派上用场了。Vim-anywhere 自动化了整个流程。它仅仅简单地调用 Vim 编辑器,所以你能写任何你所想的,然后将之粘贴到 .doc 文件中。 + +让我给你展示一个用例。打开 LibreOffice 或者你选的任何图形文本编辑器。然后打开 Vim-anywhere。你只需要按下 **CTRL+ALT+V** 即可。它将会打开 gVim 编辑器。按下"i"切换到交互模式然后输入文本。完成之后,键入 **:wq** 关闭并保存文件。 + +![][2] + +这些文本会在剪贴板中可用,直到你重启了系统。在你关闭编辑器之后,你之前的应用会重新占据主界面。你只需按下 **CTRL+P** 将文本粘贴进去。 + +![][3] + +这仅仅只是一个例子。你甚至可以使用 Vim-anywhere 在烦人的 web 表单或者其他应用上进行输入。一旦 Vim-anywhere被调用,它将会打开一个缓冲区。关闭 Vim-anywhere之后,缓冲器内的内容会自动复制到你的剪贴板中,之前的应用会重新占据主界面。 + +Vim-anywhere 在被调用的时候会在 **/tmp/vim-anywhere** 中创建一个临时文件。这些临时文件会一致保存着,直到你重启了系统,并为你提供临时的历史记录。 +``` +$ ls /tmp/vim-anywhere + +``` +你可以用下面的命令重新打开最近的文件: +``` +$ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 ) + +``` +**更新 Vim-anywhere ** + +运行下面的命令来更新 Vim-anywhere: +``` +$ ~/.vim-anywhere/update + +``` + +**更改快捷键** + +默认调用 Vim-anywhere 的键位是 CTRL+ALT+V。你可以用 gconf 工具将其更改为任何自定义的键位绑定。 +``` +$ gconftool -t str --set /desktop/gnome/keybindings/vim-anywhere/binding + +``` + +**卸载 Vim-anywhere** + +可能有些人觉得每次打开Vim编辑器,输入一些文本,然后将文本复制到其他应用中是没有意义也毫无必要的。 + +如果你不觉得这个工具有用,只需使用下面的命令来卸载它: +``` +$ ~/.vim-anywhere/uninstall + +``` + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[paperzhang](https://github.com/paperzhang) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[2]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-1-1.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-2.png + + + + + + + + + + + From de7f16908ddd78495a95b2cf587ee62a07bc7fd8 Mon Sep 17 00:00:00 2001 From: paperzhang <31605464+paperzhang@users.noreply.github.com> Date: Fri, 11 May 2018 13:53:32 +0800 Subject: [PATCH 030/111] Update 20180501 How To Use Vim Editor To Input Text Anywhere.md translated by paperzhang --- ...01 How To Use Vim Editor To Input Text Anywhere.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md index 1f013e6566..0ece2dfb4c 100644 --- a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md +++ b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md @@ -89,14 +89,3 @@ via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ [a]:https://www.ostechnix.com/author/sk/ [2]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-1-1.png [3]:http://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-2.png - - - - - - - - - - - From 8aa4db62a04d79e016973597f9d58093fc00ba4b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 08:36:56 +0800 Subject: [PATCH 031/111] PRF:20170628 Notes on BPF and eBPF.md @qhwdw --- .../tech/20170628 Notes on BPF and eBPF.md | 52 ++++++------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/translated/tech/20170628 Notes on BPF and eBPF.md b/translated/tech/20170628 Notes on BPF and eBPF.md index b7fad29ba1..f4dc3852a0 100644 --- a/translated/tech/20170628 Notes on BPF and eBPF.md +++ b/translated/tech/20170628 Notes on BPF and eBPF.md @@ -7,17 +7,16 @@ 我想在讨论的基础上去写一些笔记,因为,我觉得它超级棒! -这是 [幻灯片][9] 和一个 [pdf][10]。这个 pdf 非常好,结束的位置有一些链接,在 PDF 中你可以直接点击这个链接。 +开始前,这里有个 [幻灯片][9] 和一个 [pdf][10]。这个 pdf 非常好,结束的位置有一些链接,在 PDF 中你可以直接点击这个链接。 ### 什么是 BPF? -在 BPF 出现之前,如果你想去做包过滤,你必须拷贝所有进入用户空间的包,然后才能去过滤它们(使用 “tap”)。 +在 BPF 出现之前,如果你想去做包过滤,你必须拷贝所有的包到用户空间,然后才能去过滤它们(使用 “tap”)。 这样做存在两个问题: -1. 如果你在用户空间中过滤,意味着你将拷贝所有进入用户空间的包,拷贝数据的代价是很昂贵的。 - -2. 使用的过滤算法很低效 +1. 如果你在用户空间中过滤,意味着你将拷贝所有的包到用户空间,拷贝数据的代价是很昂贵的。 +2. 使用的过滤算法很低效。 问题 #1 的解决方法似乎很明显,就是将过滤逻辑移到内核中。(虽然具体实现的细节并没有明确,我们将在稍后讨论) @@ -35,12 +34,11 @@ ### 为什么 BPF 要工作在内核中 -这里的关键点是,包仅仅是个字节的数组。BPF 程序是运行在这些字节的数组上。它们不允许有循环(loops),但是,它们 _可以_  有聪明的办法知道 IP 包头(IPv6 和 IPv4 长度是不同的)以及基于它们的长度来找到 TCP 端口 +这里的关键点是,包仅仅是个字节的数组。BPF 程序是运行在这些字节的数组之上。它们不允许有循环(loop),但是,它们 _可以_  有聪明的办法知道 IP 包头(IPv6 和 IPv4 长度是不同的)以及基于它们的长度来找到 TCP 端口: ``` x = ip_header_length port = *(packet_start + x + port_offset) - ``` (看起来不一样,其实它们基本上都相同)。在这个论文/幻灯片上有一个非常详细的虚拟机的描述,因此,我不打算解释它。 @@ -48,13 +46,9 @@ port = *(packet_start + x + port_offset) 当你运行 `tcpdump host foo` 后,这时发生了什么?就我的理解,应该是如下的过程。 1. 转换 `host foo` 为一个高效的 DAG 规则 - 2. 转换那个 DAG 规则为 BPF 虚拟机的一个 BPF 程序(BPF 字节码) - 3. 发送 BPF 字节码到 Linux 内核,由 Linux 内核验证它 - -4. 编译这个 BPF 字节码程序为一个原生(native)代码。例如, [在 ARM 上是 JIT 代码][1] 以及为 [x86][2] 的机器码 - +4. 编译这个 BPF 字节码程序为一个原生native代码。例如,这是个[ARM 上的 JIT 代码][1] 以及 [x86][2] 的机器码 5. 当包进入时,Linux 运行原生代码去决定是否过滤这个包。对于每个需要去处理的包,它通常仅需运行 100 - 200 个 CPU 指令就可以完成,这个速度是非常快的! ### 现状:eBPF @@ -63,19 +57,15 @@ port = *(packet_start + x + port_offset) 关于 eBPF 的一些事实是: -* eBPF 程序有它们自己的字节码语言,并且从那个字节码语言编译成内核原生代码,就像 BPF 程序 - +* eBPF 程序有它们自己的字节码语言,并且从那个字节码语言编译成内核原生代码,就像 BPF 程序一样 * eBPF 运行在内核中 - -* eBPF 程序不能随心所欲的访问内核内存。而是通过内核提供的函数去取得一些受严格限制的所需要的内容的子集。 - +* eBPF 程序不能随心所欲的访问内核内存。而是通过内核提供的函数去取得一些受严格限制的所需要的内容的子集 * 它们  _可以_  与用户空间的程序通过 BPF 映射进行通讯 - * 这是 Linux 3.18 的 `bpf` 系统调用 ### kprobes 和 eBPF -你可以在 Linux 内核中挑选一个函数(任意函数),然后运行一个你写的每次函数被调用时都运行的程序。这样看起来是不是很神奇。 +你可以在 Linux 内核中挑选一个函数(任意函数),然后运行一个你写的每次该函数被调用时都运行的程序。这样看起来是不是很神奇。 例如:这里有一个 [名为 disksnoop 的 BPF 程序][12],它的功能是当你开始/完成写入一个块到磁盘时,触发它执行跟踪。下图是它的代码片断: @@ -92,45 +82,37 @@ b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start") ``` -从根本上来说,它声明一个 BPF 哈希(它的作用是当请求开始/完成时,这个程序去触发跟踪),一个名为 `trace_start` 的函数将被编译进 BPF 字节码,然后附加 `trace_start` 到内核函数 `blk_start_request` 上。 +本质上它声明一个 BPF 哈希(它的作用是当请求开始/完成时,这个程序去触发跟踪),一个名为 `trace_start` 的函数将被编译进 BPF 字节码,然后附加 `trace_start` 到内核函数 `blk_start_request` 上。 -这里使用的是 `bcc` 框架,它可以使你写的 Python 化的程序去生成 BPF 代码。你可以在 [https://github.com/iovisor/bcc][13] 找到它(那里有非常多的示例程序)。 +这里使用的是 `bcc` 框架,它可以让你写 Python 式的程序去生成 BPF 代码。你可以在 [https://github.com/iovisor/bcc][13] 找到它(那里有非常多的示例程序)。 ### uprobes 和 eBPF -因为我知道你可以附加 eBPF 程序到内核函数上,但是,我不知道你能否将 eBPF 程序附加到用户空间函数上!那会有更多令人激动的事情。这是 [在 Python 中使用一个 eBPF 程序去计数 malloc 调用的示例][14]。 +因为我知道可以附加 eBPF 程序到内核函数上,但是,我不知道能否将 eBPF 程序附加到用户空间函数上!那会有更多令人激动的事情。这是 [在 Python 中使用一个 eBPF 程序去计数 malloc 调用的示例][14]。 ### 附加 eBPF 程序时应该考虑的事情 * 带 XDP 的网卡(我之前写过关于这方面的文章) - * tc egress/ingress (在网络栈上) - * kprobes(任意内核函数) - -* uprobes(很明显,任意用户空间函数??像带符号的任意 C 程序) - +* uprobes(很明显,任意用户空间函数??像带调试符号的任意 C 程序) * probes 是为 dtrace 构建的名为 “USDT probes” 的探针(像 [这些 mysql 探针][3])。这是一个 [使用 dtrace 探针的示例程序][4] - * [JVM][5] - * 跟踪点 - * seccomp / landlock 安全相关的事情 - -* 更多的事情 +* 等等 ### 这个讨论超级棒 -在幻灯片里有很多非常好的链接,并且在  iovisor 仓库里有个 [LINKS.md][15]。现在已经很晚了,但是,很快我将写我的第一个 eBPF 程序了! +在幻灯片里有很多非常好的链接,并且在  iovisor 仓库里有个 [LINKS.md][15]。虽然现在已经很晚了,但是我马上要去写我的第一个 eBPF 程序了! -------------------------------------------------------------------------------- via: https://jvns.ca/blog/2017/06/28/notes-on-bpf---ebpf/ -作者:[Julia Evans ][a] +作者:[Julia Evans][a] 译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 696eb5adb3d0b8fc95d58419cd418a96b4d3a7a8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 08:37:18 +0800 Subject: [PATCH 032/111] PUB:20170628 Notes on BPF and eBPF.md @qhwdw https://linux.cn/article-9630-1.html --- {translated/tech => published}/20170628 Notes on BPF and eBPF.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170628 Notes on BPF and eBPF.md (100%) diff --git a/translated/tech/20170628 Notes on BPF and eBPF.md b/published/20170628 Notes on BPF and eBPF.md similarity index 100% rename from translated/tech/20170628 Notes on BPF and eBPF.md rename to published/20170628 Notes on BPF and eBPF.md From fd214e9846f332b07f402792c16f0ed4097395a8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 08:49:58 +0800 Subject: [PATCH 033/111] PRF:20180409 A Kernel Module That Forcibly Shutdown Your System.md @geekpi --- ...dule That Forcibly Shutdown Your System.md | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180409 A Kernel Module That Forcibly Shutdown Your System.md b/translated/tech/20180409 A Kernel Module That Forcibly Shutdown Your System.md index ca368372c2..1b3ecc3724 100644 --- a/translated/tech/20180409 A Kernel Module That Forcibly Shutdown Your System.md +++ b/translated/tech/20180409 A Kernel Module That Forcibly Shutdown Your System.md @@ -1,98 +1,103 @@ -强制关闭系统的内核模块 +强制关闭你的系统的内核模块 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/04/kgotobed-720x340.png) + 我知道熬夜对健康不利。但谁在乎?多年来我一直是一只夜猫子。我通常在 12 点以后睡觉,有时在凌晨 1 点以后睡觉。第二天早上,我至少推迟三次闹钟,醒来后又累又有脾气。每天,我向自己保证早点睡觉,但最终会像平常一样晚睡。而且,这个循环还在继续!如果你和我一样,这有一个好消息。一个同学通宵开发了一个名为 **“Kgotobed”** 的内核模块,它迫使你在特定的时间上床睡觉。也就是说它会强制关闭你的系统。 -我为什么要用这个?我有很多其他的选择。我可以设置一个 cron 作业来安排在特定时间关闭系统。我可以设置提醒或闹钟。我可以使用浏览器插件或软件。你可能会问!但是,它们都可以轻易忽略或绕过。Kgotobed 是你不能忽视的东西。**即使您是 root 用户也无法禁用**。是的,它会在指定的时间强制关闭你的系统。没有推迟选项。你不能推迟关机过程,也不能取消它。无论如何,系统都会在指定的时间停止运行。你被警告了!! +你可能会问!我为什么要用这个?我有很多其他的选择。我可以设置一个 cron 作业来安排在特定时间关闭系统。我可以设置提醒或闹钟。我可以使用浏览器插件或软件。但是,它们都可以轻易忽略或绕过。Kgotobed 是你不能忽视的东西。**即使您是 root 用户也无法禁用**。是的,它会在指定的时间强制关闭你的系统。没有推迟选项。你不能推迟关机过程,也不能取消它。无论如何,系统都会在指定的时间停止运行。你被警告了!! ### 安装 Kgotobed -确保你已经安装了 **dkms**。它在大多数 Linux 发行版的默认仓库中都有。 +确保你已经安装了 `dkms`。它在大多数 Linux 发行版的默认仓库中都有。 例如在 Fedora 上,你可以使用以下命令安装它: + ``` $ sudo dnf install kernel-devel-$(uname -r) dkms - ``` 在 Debian、Ubuntu、linux Mint 上: + ``` $ sudo apt install dkms - ``` -安装完成后,git clone Kgotobed 项目。 +安装完成后,`git clone` Kgotobed 项目。 + ``` $ git clone https://github.com/nikital/kgotobed.git - ``` -该命令会在当前工作目录中将所有 Kgotobed 仓库的内容克隆到名为 “kgotobed” 的文件夹中。cd 到该目录: +该命令会在当前工作目录中将所有 Kgotobed 仓库的内容克隆到名为 `kgotobed` 的文件夹中。进入到该目录: + ``` $ cd kgotobed/ - ``` 接着,使用命令安装 Kgotobed 驱动: + ``` $ sudo make install - ``` -上面的命令将 **kgotobed.ko** 模块注册到 **DKMS**(这样它会为每个你运行的内核重建)并在 **/usr/local/bin/** 目录下安装 **gotobed**,然后注册、启用并启动 kgotobed 服务。 +上面的命令将 `kgotobed.ko` 模块注册到 **DKMS**(这样它会为每个你运行的内核重建)并在 `/usr/local/bin/` 目录下安装 `gotobed`,然后注册、启用并启动 kgotobed 服务。 ### 如何运行 默认情况下,Kgotobed 将睡前时间设置为 **1:00 AM**。也就是说,无论你在做什么,你的电脑都会在凌晨 1 点关机。 要查看当前的睡前时间,请运行: + ``` $ gotobed Current bedtime is 2018-04-10 01:00:00 - ``` 要提前睡眠时间,例如 22:00(晚上 10 点),请运行: + ``` $ sudo gotobed 22:00 [sudo] password for sk: Current bedtime is 2018-04-10 00:58:00 Setting bedtime to 2018-04-09 22:00:00 Bedtime will be in 2 hours 16 minutes - ``` 当你想早点睡觉时,这会很有帮助! 但是,你不能设置更晚的时间也就是凌晨 1 点以后。你无法卸载模块,并且调整系统时钟也无济于事。唯一的出路是重启! -要设置不同的默认时间,您需要自定义 **kgotobed.service**(通过编辑或使用 systemd 工具)。 +要设置不同的默认时间,您需要自定义 `kgotobed.service`(通过编辑或使用 systemd 工具)。 ### 卸载 Kgotobed -对 Kgotobed 不满意?别担心!进入我们先前克隆的 “kgotobed” 文件夹,然后运行以下命令将其卸载。 +对 Kgotobed 不满意?别担心!进入我们先前克隆的 `kgotobed` 文件夹,然后运行以下命令将其卸载。 + ``` $ sudo make uninstall - ``` 再一次,我警告你,即使你是 root 用户,也没有办法推迟或取消关机过程。你的系统将在指定的时间强制关闭。这并不适合每个人!当你在做一项重要任务时,它可能会让你疯狂。在这种情况下,请确保你已经不时地保存工作,或使用下面链接中的一些高级工具来帮助你在特定时间自动关闭、重启、暂停和休眠系统。 +- [在特定时间自动关闭、重启、暂停和休眠系统](https://www.ostechnix.com/auto-shutdown-reboot-suspend-hibernate-linux-system-specific-time/) + 就是这些了。希望你觉得这个指南有帮助。还有更好的东西。敬请关注! 干杯! +### 资源 +- [Kgotobed GitHub 仓库](https://github.com/nikital/kgotobed) -------------------------------------------------------------------------------- via: https://www.ostechnix.com/kgotobed-a-kernel-module-that-forcibly-shutdown-your-system/ 作者:[SK][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From abf6008bb4596e71aecef5c89b574e0217ef8ace Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 08:50:25 +0800 Subject: [PATCH 034/111] PUB:20180409 A Kernel Module That Forcibly Shutdown Your System.md @geekpi --- ...20180409 A Kernel Module That Forcibly Shutdown Your System.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180409 A Kernel Module That Forcibly Shutdown Your System.md (100%) diff --git a/translated/tech/20180409 A Kernel Module That Forcibly Shutdown Your System.md b/published/20180409 A Kernel Module That Forcibly Shutdown Your System.md similarity index 100% rename from translated/tech/20180409 A Kernel Module That Forcibly Shutdown Your System.md rename to published/20180409 A Kernel Module That Forcibly Shutdown Your System.md From ae7d71dd59edbe282ec35f04f792e893210a1ebb Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 10:48:40 +0800 Subject: [PATCH 035/111] PRF:20180208 Python Global, Local and Nonlocal variables (With Examples).md @Flowsnow --- ... and Nonlocal variables (With Examples).md | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/translated/tech/20180208 Python Global, Local and Nonlocal variables (With Examples).md b/translated/tech/20180208 Python Global, Local and Nonlocal variables (With Examples).md index 6a0c9da971..679fb486de 100644 --- a/translated/tech/20180208 Python Global, Local and Nonlocal variables (With Examples).md +++ b/translated/tech/20180208 Python Global, Local and Nonlocal variables (With Examples).md @@ -1,13 +1,14 @@ -Python全局,局部和非局部变量(带示例) +初识 Python:全局、局部和非局部变量(带示例) ====== ### 全局变量 -在Python中,在函数之外或在全局范围内声明的变量被称为全局变量。 这意味着,全局变量可以在函数内部或外部访问。 +在 Python 中,在函数之外或在全局范围内声明的变量被称为全局变量。 这意味着,全局变量可以在函数内部或外部访问。 -我们来看一个关于如何在Python中创建一个全局变量的示例。 +我们来看一个关于如何在 Python 中创建一个全局变量的示例。 + +#### 示例 1:创建全局变量 -#### 示例1:创建全局变量 ```python x = "global" @@ -19,14 +20,15 @@ foo() ``` 当我们运行代码时,将会输出: + ``` x inside : global x outside: global ``` -在上面的代码中,我们创建了x作为全局变量,并定义了一个`foo()`来打印全局变量x。 最后,我们调用`foo()`来打印x的值。 +在上面的代码中,我们创建了 `x` 作为全局变量,并定义了一个 `foo()` 来打印全局变量 `x`。 最后,我们调用 `foo()` 来打印x的值。 -倘若你想改变一个函数内的x的值该怎么办? +倘若你想改变一个函数内的 `x` 的值该怎么办? ```python x = "global" @@ -38,19 +40,20 @@ foo() ``` 当我们运行代码时,将会输出: + ``` UnboundLocalError: local variable 'x' referenced before assignment ``` -输出显示一个错误,因为Python将x视为局部变量,x也没有`foo()`内部定义。 +输出显示一个错误,因为 Python 将 `x` 视为局部变量,而 `x` 没有在 `foo()` 内部定义。 -为了运行正常,我们使用`global`关键字,访问[PythonGlobal关键字][1]以便了解更多。 +为了运行正常,我们使用 `global` 关键字,查看 [PythonGlobal 关键字][1]以便了解更多。 ### 局部变量 在函数体内或局部作用域内声明的变量称为局部变量。 -#### 示例2:访问作用域外的局部变量 +#### 示例 2:访问作用域外的局部变量 ```python def foo(): @@ -61,17 +64,19 @@ print(y) ``` 当我们运行代码时,将会输出: + ``` NameError: name 'y' is not defined ``` -输出显示了一个错误,因为我们试图在全局范围内访问局部变量y,而局部变量只能在`foo() `函数内部或局部作用域内有效。 +输出显示了一个错误,因为我们试图在全局范围内访问局部变量 `y`,而局部变量只能在 `foo()` 函数内部或局部作用域内有效。 -我们来看一个关于如何在Python中创建一个局部变量的例子。 +我们来看一个关于如何在 Python 中创建一个局部变量的例子。 -#### 示例3:创建一个局部变量 +#### 示例 3:创建一个局部变量 通常,我们在函数内声明一个变量来创建一个局部变量。 + ```python def foo(): y = "local" @@ -81,17 +86,19 @@ foo() ``` 当我们运行代码时,将会输出: + ``` local ``` -让我们来看看前面的问题,其中x是一个全局变量,我们想修改`foo()`内部的x。 +让我们来看看前面的问题,其中x是一个全局变量,我们想修改 `foo()` 内部的 `x`。 ### 全局变量和局部变量 在这里,我们将展示如何在同一份代码中使用全局变量和局部变量。 -#### 示例4:在同一份代码中使用全局变量和局部变量 +#### 示例 4:在同一份代码中使用全局变量和局部变量 + ```python x = "global" @@ -105,17 +112,18 @@ def foo(): foo() ``` -当我们运行代码时,将会输出(译者注:原文中输出结果的两个global有空格,正确的是没有空格): +当我们运行代码时,将会输出(LCTT 译注:原文中输出结果的两个 `global` 有空格,正确的是没有空格): ``` globalglobal local ``` -在上面的代码中,我们将x声明为全局变量,将y声明为`foo()`中的局部变量。 然后,我们使用乘法运算符`*`来修改全局变量x,并打印x和y。 +在上面的代码中,我们将 `x` 声明为全局变量,将 `y` 声明为 `foo()` 中的局部变量。 然后,我们使用乘法运算符 `*` 来修改全局变量 `x`,并打印 `x` 和 `y`。 -在调用`foo()`之后,x的值变成`globalglobal`了(译者注:原文同样有空格,正确的是没有空格),因为我们使用`x * 2`打印两次`global`。 之后,我们打印局部变量y的值,即`local`。 +在调用 `foo()` 之后,`x` 的值变成 `globalglobal`了(LCTT 译注:原文同样有空格,正确的是没有空格),因为我们使用 `x * 2` 打印两次 `global`。 之后,我们打印局部变量y的值,即 `local` 。 + +#### 示例 5:具有相同名称的全局变量和局部变量 -#### 示例5:具有相同名称的全局变量和局部变量 ```python x = 5 @@ -128,26 +136,28 @@ print("global x:", x) ``` 当我们运行代码时,将会输出: + ``` local x: 10 global x: 5 ``` -在上面的代码中,我们对全局变量和局部变量使用了相同的名称x。 当我们打印相同的变量时却得到了不同的结果,因为这两个作用域内都声明了变量,即`foo()`内部的局部作用域和`foo()`外面的全局作用域。 +在上面的代码中,我们对全局变量和局部变量使用了相同的名称 `x`。 当我们打印相同的变量时却得到了不同的结果,因为这两个作用域内都声明了变量,即 `foo()` 内部的局部作用域和 `foo()` 外面的全局作用域。 -当我们在`foo()`内部打印变量时,它输出`local x: 10`,这被称为变量的局部作用域。 +当我们在 `foo()` 内部打印变量时,它输出 `local x: 10`,这被称为变量的局部作用域。 -同样,当我们在`foo()`外部打印变量时,它输出`global x: 5`,这被称为变量的全局作用域。 +同样,当我们在 `foo()` 外部打印变量时,它输出 `global x: 5`,这被称为变量的全局作用域。 ### 非局部变量 非局部变量用于局部作用域未定义的嵌套函数。 这意味着,变量既不能在局部也不能在全局范围内。 -我们来看一个关于如何在Python中创建一个非局部变量的例子。(译者注:原文为创建全局变量,疑为笔误) +我们来看一个关于如何在 Python 中创建一个非局部变量的例子。(LCTT 译者注:原文为创建全局变量,疑为笔误) -我们使用`nonlocal`关键字来创建非局部变量。 +我们使用 `nonlocal` 关键字来创建非局部变量。 + +#### 例 6:创建一个非局部变量 -#### 例6:创建一个非局部变量 ```python def outer(): x = "local" @@ -164,12 +174,13 @@ outer() ``` 当我们运行代码时,将会输出: + ``` inner: nonlocal outer: nonlocal ``` -在上面的代码中有一个嵌套函数`inner()`。 我们使用`nonlocal`关键字来创建非局部变量。`inner()`函数是在另一个函数`outer()`的作用域中定义的。 +在上面的代码中有一个嵌套函数 `inner()`。 我们使用 `nonlocal` 关键字来创建非局部变量。`inner()` 函数是在另一个函数 `outer()` 的作用域中定义的。 注意:如果我们改变非局部变量的值,那么变化就会出现在局部变量中。 @@ -179,7 +190,7 @@ via: https://www.programiz.com/python-programming/global-local-nonlocal-variable 作者:[programiz][a] 译者:[Flowsnow](https://github.com/Flowsnow) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 829a7bc7f435cd580b2f79acc4703fd0aeb5cb83 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 10:49:11 +0800 Subject: [PATCH 036/111] PUB:20180208 Python Global, Local and Nonlocal variables (With Examples).md @Flowsnow https://linux.cn/article-9632-1.html --- ...Python Global, Local and Nonlocal variables (With Examples).md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180208 Python Global, Local and Nonlocal variables (With Examples).md (100%) diff --git a/translated/tech/20180208 Python Global, Local and Nonlocal variables (With Examples).md b/published/20180208 Python Global, Local and Nonlocal variables (With Examples).md similarity index 100% rename from translated/tech/20180208 Python Global, Local and Nonlocal variables (With Examples).md rename to published/20180208 Python Global, Local and Nonlocal variables (With Examples).md From 09341b1e784a2a2d51e528242a93fe7bfad13b62 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 11:49:58 +0800 Subject: [PATCH 037/111] PRF:20180220 How slowing down made me a better leader.md @MjSeven --- ...0 How slowing down made me a better leader.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/translated/talk/20180220 How slowing down made me a better leader.md b/translated/talk/20180220 How slowing down made me a better leader.md index cfca276cf9..e03f969652 100644 --- a/translated/talk/20180220 How slowing down made me a better leader.md +++ b/translated/talk/20180220 How slowing down made me a better leader.md @@ -1,6 +1,8 @@ -放慢速度是如何使我变得更好的领导者 +放慢速度如何使我变成更好的领导者 ====== +> 开放式领导和耐心、倾听一样重要,它们都是关于执行的。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_leadership_brand.png?itok=YW1Syk4S) 在我职业生涯的早期,我认为我能做的最重要的事情就是行动。如果我的老板说跳,我的回答是“跳多高?” @@ -9,15 +11,15 @@ 实行开放式领导需要培养耐心和倾听技能,我需要在[最佳行动计划上进行合作,而不仅仅是最快的计划][2]。它还为我提供了一些工具,以解释 [为什么我会对某人说“不”][3] (或者,也许是“不是现在”),这样我就能以透明和自信的方式领导。 -如果你正在进行软件开发和实践 scrum 中,那么下面的观点可能会引起你的共鸣:在 sprint 计划和 sprint 演示中,耐心和倾听经理的表现和它的技能一样重要。(译注: scrum 是迭代式增量软件开发过程,通常用于敏捷软件开发。 sprint 计划和 sprint 演示是其中的两个术语。)忘掉它们,你会减少你能够产生的影响。 +如果你正在进行软件开发和实践 scrum 中,那么下面的观点可能会引起你的共鸣:在 sprint 计划和 sprint 演示中,耐心和倾听经理的表现和它的技能一样重要。(LCTT 译注: scrum 是迭代式增量软件开发过程,通常用于敏捷软件开发。 sprint 计划和 sprint 演示是其中的两个术语。)忘掉它们,你会减少你能够产生的影响。 ### 专注于耐心 -专注和耐心并不总是容易的。通常,我发现自己正坐在会议上,用行动项目填满我的笔记本时,我一般会思考:“我们可以简单地对 x 和 y 进行改进”。然后我记得事情不是那么线性的。(译者注:这句话感觉翻译得并不通顺) +专注和耐心并不总是容易的。通常,我发现自己正坐在会议上,用行动项目填满我的笔记本时,我一般会思考:“我们只要做了某事,另外一件事就会得到改善”。然后我记得事物不是那么线性发展的。 -我需要考虑可能影响情况的其他因素。暂停下来从多个人和资源中获取数据可以帮我充实策略,以确保出组织长期成功。它还帮助我确定那些短期的里程碑,这些里程碑应该会让我负责生产的业务完成交付。 +我需要考虑可能影响情况的其他因素。暂停下来从多个人和资源中获取数据可以帮我充实策略,以确保组织长期成功。它还帮助我确定那些短期的里程碑,这些里程碑应该可以让我负责生产的业务完成交付。 -这里有一个很好的例子,以前耐心不是我认为应该拥有的东西,而这又是如何影响了我的表现。当我在北卡罗来纳州工作时,我与一个在亚利桑那州的人共事。我们没有使用视频会议技术,所以当我们交谈时我没有看到她的肢体语言。然而当我负责为我领导的项目交付结果时,她是确保我获得足够支持的两个人之一。 +这里有一个很好的例子,以前耐心不是我认为应该拥有、以及影响我的表现的东西。当我在北卡罗来纳州工作时,我与一个在亚利桑那州的人共事。我们没有使用视频会议技术,所以当我们交谈时我没有看到她的肢体语言。然而当我负责为我领导的项目交付结果时,她是确保我获得足够支持的两个人之一。 无论出于何种原因,当我与她交谈时,当她要求我做某件事时,我做了。她会为我的绩效评估提供意见,所以我想确保她高兴。那时,我还不够成熟不懂得其实没必要非要讨她开心;我的重点应该放在其他绩效指标上。我本应该花更多的时间倾听并与她合作,而不是在她还在说话的时候拿起第一个“行动项目”并开始工作。 @@ -35,7 +37,7 @@ 我最终对她有一些反馈。 下次我们一起工作时,我不想在六个月后听到反馈意见。 我想早些时候和更频繁地听到反馈意见,以便我能够尽早从错误中学习。 关于这项工作的持续讨论是任何团队都应该发生的事情。 -当我成为一名管理者和领导者时,我坚持要求我的团队达到相同的标准:计划,制定计划并反思。 重复。 不要让外力造成的麻烦让你偏离你需要实施的计划。 将工作分成小的增量,以便反思和调整计划。 正如 Daniel Goleman 写道:“把注意力放在需要的地方是领导力的一个主要任务。” 不要害怕面对这个挑战。 +当我成为一名管理者和领导者时,我坚持要求我的团队达到相同的标准:计划,执行计划并反思。 重复。 不要让外力造成的麻烦让你偏离你需要实施的计划。 将工作分成小的增量,以便反思和调整计划。 正如 Daniel Goleman 写道:“把注意力放在需要的地方是领导力的一个主要任务。” 不要害怕面对这个挑战。 -------------------------------------------------------------------------------- @@ -43,7 +45,7 @@ via: [https://opensource.com/open-organization/18/2/open-leadership-patience-lis 作者:[Angela Robertson][a] 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From ea8238599157ad15ec5729271c6f9f0c495c8070 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 12 May 2018 11:50:40 +0800 Subject: [PATCH 038/111] PUB:20180220 How slowing down made me a better leader.md @MjSeven https://linux.cn/article-9633-1.html --- .../20180220 How slowing down made me a better leader.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180220 How slowing down made me a better leader.md (100%) diff --git a/translated/talk/20180220 How slowing down made me a better leader.md b/published/20180220 How slowing down made me a better leader.md similarity index 100% rename from translated/talk/20180220 How slowing down made me a better leader.md rename to published/20180220 How slowing down made me a better leader.md From fec8816ad3a210059cb375ff2d4a9e3468ca0569 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sat, 12 May 2018 14:29:27 +0800 Subject: [PATCH 039/111] Update 20180128 Being open about data privacy.md Translating by FelixYFZ --- sources/talk/20180128 Being open about data privacy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md index 2deb88922b..22581d4c17 100644 --- a/sources/talk/20180128 Being open about data privacy.md +++ b/sources/talk/20180128 Being open about data privacy.md @@ -1,4 +1,4 @@ -Being open about data privacy +Translating by FelixYFZ Being open about data privacy ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/GOV_opendata.png?itok=M8L2HGVx) From bc4bc51d8856b2573b9ac032f83015dd08e48668 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 13 May 2018 07:38:40 +0800 Subject: [PATCH 040/111] PRF:20171129 5 best practices for getting started with DevOps.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @aiwhj 翻译的不错。 --- ...actices for getting started with DevOps.md | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/translated/tech/20171129 5 best practices for getting started with DevOps.md b/translated/tech/20171129 5 best practices for getting started with DevOps.md index 3fa96176d5..d161d20f8c 100644 --- a/translated/tech/20171129 5 best practices for getting started with DevOps.md +++ b/translated/tech/20171129 5 best practices for getting started with DevOps.md @@ -1,55 +1,55 @@ 5 个最佳实践开始你的 DevOps 之旅 ============================================================ -### 想要实现 DevOps 但是不知道如何开始吗?试试这 5 个最佳实践吧。 - +> 想要实现 DevOps 但是不知道如何开始吗?试试这 5 个最佳实践吧。 ![5 best practices for getting started with DevOps](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops-gears.png?itok=rUejbLQX "5 best practices for getting started with DevOps") Image by : [Andrew Magill][8]. Modified by Opensource.com. [CC BY 4.0][9] -想要采用 DevOps 的人通常会过早的被它的歧义性给吓跑,更不要说更加深入的使用了。当一些人开始使用 DevOps 的时候都会问:“如何开始使用呢?”,”怎么才算使用了呢?“。这 5 个最佳实践是很好的路线图来指导你的 DevOps 之旅。 +想要采用 DevOps 的人通常会过早的被它的歧义性给吓跑,更不要说更加深入的使用了。当一些人开始使用 DevOps 的时候都会问:“如何开始使用呢?”,”怎么才算使用了呢?“。这 5 个最佳实践是指导你的 DevOps 之旅的很好的路线图。 -### 1\. 衡量所有的事情 +### 1、 衡量所有的事情 -除非你能量化输出结果,否则你并不能确认你的努力能否使事情变得更好。新功能能否快速的输出给客户?有更少的漏洞泄漏给他们吗?出错了能快速应对和恢复吗? +除非你能够量化输出结果,否则你并不能确认你的努力能否使事情变得更好。新功能能否快速的输出给客户?带给他们的缺陷更少吗?出错了能快速应对和恢复吗? 在你开始做任何修改之前,思考一下你切换到 DevOps 之后想要一些什么样的输出。随着你的 DevOps 之旅,将享受到服务的所有内容的丰富的实时报告,从这两个指标考虑一下: -* **上架时间** 衡量端到端,通常是面向客户的业务经验。这通常从一个功能被正式提出而开始,客户在产品中开始使用这个功能而结束。上架时间不是团队的主要指标;更加重要的是,当开发出一个有价值的新功能时,它表明了你完成业务的效率,为系统改进提供了一个机会。 +* **上架时间** 衡量端到端,通常是面向客户的业务经验。这通常从一个功能被正式提出而开始,客户在产品中开始使用这个功能而结束。上架时间不是工程团队的主要指标;更加重要的是,当开发出一个有价值的新功能时,它表明了你完成业务的效率,为系统改进提供了一个机会。 -* **时间周期** 衡量工程团队的进度。从开始开发一个新功能开始,到在产品中运行需要多久?这个指标对于你理解团队的效率是非常有用的,为团队等级的提升提供了一个机会。 +* **时间周期** 衡量工程团队的进度。从开始开发一个新功能开始,到在产品环境中运行需要多久?这个指标对于你了解团队的效率是非常有用的,为团队层面的提升提供了一个机会。 -### 2\. 放飞你的流程 +### 2、 放飞你的流程 -DevOps 的成功需要团队布置一个定期流程并且持续提升它。这不总是有效的,但是必须是一个定期(希望有效)的流程。通常它有一些敏捷开发的味道,就像 Scrum 或者 Scrumban 一样;一些时候它也像精益开发。不论你用的什么方法,挑选一个正式的流程,开始使用它,并且做好这些基础。 +DevOps 的成功需要团队布置一个定期(但愿有效)流程并且持续提升它。这不总是有效的,但是必须是一个定期的流程。通常它有一些敏捷开发的味道,就像 Scrum 或者 Scrumban 一样;一些时候它也像精益开发。不论你用的什么方法,挑选一个正式的流程,开始使用它,并且做好这些基础。 -定期检查和调整流程是 DevOps 成功的关键,抓住相关演示,团队回顾,每日会议的机会来提升你的流程。 +定期检查和调整流程是 DevOps 成功的关键,抓住相关演示、团队回顾、每日会议的机会来提升你的流程。 DevOps 的成功取决于大家一起有效的工作。团队的成员需要在一个有权改进的公共流程中工作。他们也需要定期找机会分享从这个流程中上游或下游的其他人那里学到的东西。 -随着你构建成功。好的流程规范能帮助你的团队以很快的速度体会到 DevOps 其他的好处 +随着你构建成功,好的流程规范能帮助你的团队以很快的速度体会到 DevOps 其他的好处 尽管更多面向开发的团队采用 Scrum 是常见的,但是以运营为中心的团队(或者其他中断驱动的团队)可能选用一个更短期的流程,例如 Kanban。 -### 3\. 可视化工作流程 +### 3、 可视化工作流程 + 这是很强大的,能够看到哪个人在给定的时间做哪一部分工作,可视化你的工作流程能帮助大家知道接下来应该做什么,流程中有多少工作以及流程中的瓶颈在哪里。 在你看到和衡量之前你并不能有效的限制流程中的工作。同样的,你也不能有效的排除瓶颈直到你清楚的看到它。 全部工作可视化能帮助团队中的成员了解他们在整个工作中的贡献。这样可以促进跨组织边界的关系建设,帮助您的团队更有效地协作,实现共同的成就感。 -### 4\. 持续化所有的事情 +### 4、 持续化所有的事情 -DevOps 应该是强制自动化的。然而罗马不是一日建成的。你应该注意的第一个事情应该是努力的持续集成(CI),但是不要停留到这里;紧接着的是持续交付(CD)以及最终的持续部署。 +DevOps 应该是强制自动化的。然而罗马不是一日建成的。你应该注意的第一个事情应该是努力的[持续集成(CI)][10],但是不要停留到这里;紧接着的是[持续交付(CD)][11]以及最终的持续部署。 -持续部署的过程中是个注入自动测试的好时机。这个时候新代码刚被提交,你的持续部署应该运行测试代码来测试你的代码和构建成功的加工品。这个加工品经受流程的考验被产出直到最终被客户看到。 +持续部署的过程中是个注入自动测试的好时机。这个时候新代码刚被提交,你的持续部署应该运行测试代码来测试你的代码和构建成功的加工品。这个加工品经受流程的考验被产出,直到最终被客户看到。 -另一个“持续”是不太引人注意的持续改进。一个简单的场景是每天询问你旁边的同事:“今天做些什么能使工作变得更好?”,随着时间的推移,这些日常的小改进融合到一起会引起很大的结果,你将很惊喜!但是这也会让人一直思考着如何改进。 +另一个“持续”是不太引人注意的持续改进。一个简单的场景是每天询问你旁边的同事:“今天做些什么能使工作变得更好?”,随着时间的推移,这些日常的小改进融合到一起会带来很大的结果,你将很惊喜!但是这也会让人一直思考着如何改进。 -### 5\. Gherkinize +### 5、 Gherkinize -促进组织间更有效的沟通对于成功的 DevOps 的系统思想至关重要。在程序员和业务员之间直接使用共享语言来描述新功能的需求文档对于沟通是个好办法。一个好的产品经理能在一天内学会 [Gherkin][12] 然后使用它构造出明确的英语来描述需求文档,工程师会使用 Gherkin 描述的需求文档来写功能测试,之后开发功能代码直到代码通过测试。这是一个简化的 [验收测试驱动开发][13](ATDD),这样就开始了你的 DevOps 文化和开发实践。 +促进组织间更有效的沟通对于成功的 DevOps 的系统思想至关重要。在程序员和业务员之间直接使用共享语言来描述新功能的需求文档对于沟通是个好办法。一个好的产品经理能在一天内学会 [Gherkin][12] 然后使用它以平实的英语构造出明确的描述需求文档,工程师会使用 Gherkin 描述的需求文档来写功能测试,之后开发功能代码直到代码通过测试。这是一个简化的 [验收测试驱动开发][13](ATDD),能够帮助你开始你的 DevOps 文化和开发实践。 ### 开始你旅程 @@ -60,15 +60,15 @@ DevOps 应该是强制自动化的。然而罗马不是一日建成的。你应 [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot_4.jpg?itok=jntfDCfX)][14] - Magnus Hedemark - Magnus 在IT行业已有20多年,并且一直热衷于技术。他目前是 nitedHealth Group 的 DevOps 工程师。在业余时间,Magnus 喜欢摄影和划独木舟。 + Magnus Hedemark - Magnus 在 IT 行业已有 20 多年,并且一直热衷于技术。他目前是 nitedHealth Group 的 DevOps 工程师。在业余时间,Magnus 喜欢摄影和划独木舟。 -------------------------------------------------------------------------------- via: https://opensource.com/article/17/11/5-keys-get-started-devops -作者:[Magnus Hedemark ][a] +作者:[Magnus Hedemark][a] 译者:[aiwhj](https://github.com/aiwhj) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 4b71e9e537b6e3b94140a2068afd8bb2cf478f5e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 13 May 2018 07:39:10 +0800 Subject: [PATCH 041/111] PUB:20171129 5 best practices for getting started with DevOps.md @aiwhj https://linux.cn/article-9634-1.html --- .../20171129 5 best practices for getting started with DevOps.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171129 5 best practices for getting started with DevOps.md (100%) diff --git a/translated/tech/20171129 5 best practices for getting started with DevOps.md b/published/20171129 5 best practices for getting started with DevOps.md similarity index 100% rename from translated/tech/20171129 5 best practices for getting started with DevOps.md rename to published/20171129 5 best practices for getting started with DevOps.md From 6bd200dd0de34419bebd69f94c116bfbfe19dc7d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 13 May 2018 07:49:03 +0800 Subject: [PATCH 042/111] PRF:20180407 The Shuf Command Tutorial With Examples For Beginners.md @geekpi --- ...nd Tutorial With Examples For Beginners.md | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/translated/tech/20180407 The Shuf Command Tutorial With Examples For Beginners.md b/translated/tech/20180407 The Shuf Command Tutorial With Examples For Beginners.md index e6db75de31..b938920e2e 100644 --- a/translated/tech/20180407 The Shuf Command Tutorial With Examples For Beginners.md +++ b/translated/tech/20180407 The Shuf Command Tutorial With Examples For Beginners.md @@ -1,12 +1,14 @@ -给初学者看的 Shuf 命令教程 +给初学者看的 shuf 命令教程 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/04/shuf-command-720x340.png) -Shuf 命令用于在类 Unix 操作系统中生成随机排列。使用 shuf 命令,我们可以随机打乱给定输入文件的行。Shuf 命令是 GNU Coreutils 的一部分,因此你不必担心安装问题。在这个简短的教程中,让我向你展示一些 shuf 命令的例子。 -### 带例子的 Shuf 命令教程 +`shuf` 命令用于在类 Unix 操作系统中生成随机排列。使用 `shuf` 命令,我们可以随机打乱给定输入文件的行。`shuf` 命令是 GNU Coreutils 的一部分,因此你不必担心安装问题。在这个简短的教程中,让我向你展示一些 `shuf` 命令的例子。 + +### 带例子的 shuf 命令教程 + +我有一个名为 `ostechnix.txt` 的文件,内容如下: -我有一个名为 **ostechnix.txt** 的文件,内容如下。 ``` $ cat ostechnix.txt line1 @@ -19,10 +21,10 @@ line7 line8 line9 line10 - ``` 现在让我们以随机顺序显示上面的行。为此,请运行: + ``` $ shuf ostechnix.txt line2 @@ -35,24 +37,24 @@ line4 line6 line9 line3 - ``` -看到了吗?上面的命令将名为 “ostechnix.txt” 中的行随机排列并输出了结果。 +看到了吗?上面的命令将名为 `ostechnix.txt` 中的行随机排列并输出了结果。 + +你可能想将输出写入另一个文件。例如,我想将输出保存到 `output.txt` 中。为此,请先创建 `output.txt`: -你可能想将输出写入另一个文件。例如,我想将输出保存到 **output.txt** 中。为此,请先创建 output.txt: ``` $ touch output.txt - ``` -然后,像下面使用 **-o** 标志将输出写入该文件。 +然后,像下面使用 `-o` 标志将输出写入该文件: + ``` $ shuf ostechnix.txt -o output.txt - ``` -上面的命令将随机随机打乱 ostechnix.txt 的内容并将输出写入 output.txt。你可以使用命令查看 output.txt 的内容: +上面的命令将随机随机打乱 `ostechnix.txt` 的内容并将输出写入 `output.txt`。你可以使用命令查看 `output.txt` 的内容: + ``` $ cat output.txt @@ -66,17 +68,17 @@ line7 line6 line4 line5 - ``` 我只想显示文件中的任意一行。我该怎么做?很简单! + ``` $ shuf -n 1 ostechnix.txt line6 - ``` -同样,我们可以选择前 “n” 个随机条目。以下命令将只显示前五个随机条目。 +同样,我们可以选择前 “n” 个随机条目。以下命令将只显示前五个随机条目: + ``` $ shuf -n 5 ostechnix.txt line10 @@ -84,10 +86,10 @@ line4 line5 line9 line3 - ``` -如下所示,我们可以直接使用 **-e** 标志传入输入,而不是从文件中读取行。 +如下所示,我们可以直接使用 `-e` 标志传入输入,而不是从文件中读取行: + ``` $ shuf -e line1 line2 line3 line4 line5 line1 @@ -95,10 +97,10 @@ line3 line5 line4 line2 - ``` 你也可以传入数字: + ``` $ shuf -e 1 2 3 4 5 3 @@ -106,25 +108,25 @@ $ shuf -e 1 2 3 4 5 1 4 2 - ``` -要快速在给定范围选择一个,请改用此命令。 +要快速在给定范围选择一个,请改用此命令: + ``` $ shuf -n 1 -e 1 2 3 4 5 - ``` -或者,选择下面的任意三个随机数字。 +或者,选择下面的任意三个随机数字: + ``` $ shuf -n 3 -e 1 2 3 4 5 3 5 1 - ``` 我们也可以在特定范围内生成随机数。例如,要显示 1 到 10 之间的随机数,只需使用: + ``` $ shuf -i 1-10 1 @@ -137,29 +139,26 @@ $ shuf -i 1-10 3 10 5 - ``` 有关更多详细信息,请参阅手册页。 + ``` $ man shuf - ``` 今天就是这些。还有更多更好的东西。敬请关注! 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/the-shuf-command-tutorial-with-examples-for-beginners/ 作者:[SK][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2156d27709484f6ae42c56f065cabeb0f014ef8a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 13 May 2018 07:49:23 +0800 Subject: [PATCH 043/111] PUB:20180407 The Shuf Command Tutorial With Examples For Beginners.md @geekpi https://linux.cn/article-9635-1.html --- ...80407 The Shuf Command Tutorial With Examples For Beginners.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180407 The Shuf Command Tutorial With Examples For Beginners.md (100%) diff --git a/translated/tech/20180407 The Shuf Command Tutorial With Examples For Beginners.md b/published/20180407 The Shuf Command Tutorial With Examples For Beginners.md similarity index 100% rename from translated/tech/20180407 The Shuf Command Tutorial With Examples For Beginners.md rename to published/20180407 The Shuf Command Tutorial With Examples For Beginners.md From 757f53f2447cf4872b8f7764ce3602f1463b2c8d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 13 May 2018 07:57:07 +0800 Subject: [PATCH 044/111] PRF:20180420 How to start developing on Java in Fedora.md @geekpi --- ...w to start developing on Java in Fedora.md | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/translated/tech/20180420 How to start developing on Java in Fedora.md b/translated/tech/20180420 How to start developing on Java in Fedora.md index b606a74a5d..80724f7441 100644 --- a/translated/tech/20180420 How to start developing on Java in Fedora.md +++ b/translated/tech/20180420 How to start developing on Java in Fedora.md @@ -2,38 +2,39 @@ ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/04/java-getting-started-816x345.jpg) -Java 是世界上最流行的编程语言之一。它广泛用于开发物联网设备、Android 程序,Web 和企业应用。本文将提供使用 [OpenJDK][1] 安装和配置工作站的指南。 + +Java 是世界上最流行的编程语言之一。它广泛用于开发物联网设备、Android 程序、Web 和企业应用。本文将提供使用 [OpenJDK][1] 安装和配置工作站的指南。 ### 安装编译器和工具 -在 Fedora 中安装编译器或 Java Development Kit(JDK)很容易。在写这篇文章时,可以用 v8 和 v9。只需打开一个终端并输入: +在 Fedora 中安装编译器或 Java Development Kit(JDK)很容易。在写这篇文章时,可以用 v8 和 v9 版本。只需打开一个终端并输入: + ``` sudo dnf install java-1.8.0-openjdk-devel - ``` 这安装 JDK v8。对于 v9,请输入: + ``` sudo dnf install java-9-openjdk-devel - ``` 对于需要其他工具和库(如 Ant 和 Maven)的开发人员,可以使用 **Java Development** 组。要安装套件,请输入: + ``` sudo dnf group install "Java Development" - ``` 要验证编译器是否已安装,请运行: + ``` javac -version - ``` 输出显示编译器版本,如下所示: + ``` javac 1.8.0_162 - ``` ### 编译程序 @@ -41,49 +42,48 @@ javac 1.8.0_162 你可以使用任何基本的文本编辑器(如 nano、vim 或 gedit)编写程序。这个例子提供了一个简单的 “Hello Fedora” 程序。 打开你最喜欢的文本编辑器并输入以下内容: + ``` public class HelloFedora { -       public static void main (String[] args) {               System.out.println("Hello Fedora!");       } } - ``` -将文件保存为 HelloFedora.java。在终端切换到包含该文件的目录并执行以下操作: +将文件保存为 `HelloFedora.java`。在终端切换到包含该文件的目录并执行以下操作: + ``` javac HelloFedora.java - ``` 如果编译器遇到任何语法错误,它会发出错误。否则,它只会在下面显示 shell 提示符。 -你现在应该有一个名为 HelloFedora 的文件,它是编译好的程序。使用以下命令运行它: +你现在应该有一个名为 `HelloFedora` 的文件,它是编译好的程序。使用以下命令运行它: + ``` java HelloFedora - ``` 输出将显示: + ``` Hello Fedora! - ``` ### 安装集成开发环境(IDE) 有些程序可能更复杂,IDE 可以帮助顺利进行。Java 程序员有很多可用的 IDE,其中包括: -+ Geany,一个加载快速的基本 IDE,并提供内置模板 ++ Geany,一个快速加载的基本 IDE,并提供内置模板 + Anjuta -+ GNOME Builder,已经在 Builder 的文章中介绍过 - 这是一个专门面向 GNOME 程序开发人员的新 IDE ++ GNOME Builder,已经在 [Builder - 这是一个专门面向 GNOME 程序开发人员的新 IDE][6] 的文章中介绍过 然而,主要用 Java 编写的最流行的开源 IDE 之一是 [Eclipse][2]。 Eclipse 在官方仓库中有。要安装它,请运行以下命令: + ``` sudo dnf install eclipse-jdt - ``` 安装完成后,Eclipse 的快捷方式会出现在桌面菜单中。 @@ -93,9 +93,9 @@ sudo dnf install eclipse-jdt ### 浏览器插件 如果你正在开发 Web 小程序并需要一个用于浏览器的插件,则可以使用 [IcedTea-Web][4]。像 OpenJDK 一样,它是开源的并易于在 Fedora 中安装。运行这个命令: + ``` sudo dnf install icedtea-web - ``` 从 Firefox 52 开始,Web 插件不再有效。有关详细信息,请访问 Mozilla 支持网站 [https://support.mozilla.org/en-US/kb/npapi-plugins?as=u&utm_source=inproduct][5]。 @@ -110,7 +110,7 @@ via: https://fedoramagazine.org/start-developing-java-fedora/ 作者:[Shaun Assam][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[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/) 荣誉推出 @@ -120,3 +120,4 @@ via: https://fedoramagazine.org/start-developing-java-fedora/ [3]:http://help.eclipse.org/oxygen/nav/0 [4]:https://icedtea.classpath.org/wiki/IcedTea-Web [5]:https://support.mozilla.org/en-US/kb/npapi-plugins?as=u&utm_source=inproduct +[6]:https://fedoramagazine.org/builder-a-new-ide-specifically-for-gnome-app-developers-2/ \ No newline at end of file From 0cd2c9d418b542daafad0d3d66151238ea65581a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 13 May 2018 07:57:32 +0800 Subject: [PATCH 045/111] PUB:20180420 How to start developing on Java in Fedora.md @geekpi https://linux.cn/article-9636-1.html --- .../20180420 How to start developing on Java in Fedora.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180420 How to start developing on Java in Fedora.md (100%) diff --git a/translated/tech/20180420 How to start developing on Java in Fedora.md b/published/20180420 How to start developing on Java in Fedora.md similarity index 100% rename from translated/tech/20180420 How to start developing on Java in Fedora.md rename to published/20180420 How to start developing on Java in Fedora.md From 57fe85b21f243b822ad8d46ef21449753652917e Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 14 May 2018 08:56:24 +0800 Subject: [PATCH 046/111] translated --- ... to build container images with Buildah.md | 137 ------------------ ... to build container images with Buildah.md | 135 +++++++++++++++++ 2 files changed, 135 insertions(+), 137 deletions(-) delete mode 100644 sources/tech/20180503 How to build container images with Buildah.md create mode 100644 translated/tech/20180503 How to build container images with Buildah.md diff --git a/sources/tech/20180503 How to build container images with Buildah.md b/sources/tech/20180503 How to build container images with Buildah.md deleted file mode 100644 index 9c1489f120..0000000000 --- a/sources/tech/20180503 How to build container images with Buildah.md +++ /dev/null @@ -1,137 +0,0 @@ -translating---geekpi - -How to build container images with Buildah -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/04/buildah-816x345.png) - -Project Atomic, through their efforts on the Open Container Initiative (OCI), have created a great tool called [Buildah][1]. Buildah helps with creating, building and updating container images supporting Docker formatted images as well as OCI compliant images. - -Buildah handles building container images without the need to have a full container runtime or daemon installed. This particularly shines for setting up a continuous integration and continuous delivery pipeline for building containers. - -Buildah makes the container’s filesystem directly available to the build host. Meaning that the build tooling is available on the host and not needed in the container image, keeping the build faster and the image smaller and safer. There are Buildah packages for CentOS, Fedora, and Debian. - -### Installing Buildah - -Since Fedora 26 Buildah can be installed using dnf. -``` -$ sudo dnf install buildah -y - -``` - -The current version of buildah is 0.16, which can be displayed by the following command. -``` -$ buildah --version - -``` - -### Basic commands - -The first step needed to build a container image is to get a base image, this is done by the FROM statement in a Dockerfile. Buildah does handle this in a similar way. -``` -$ sudo buildah from fedora - -``` - -This command pulls the Fedora based image and stores it on the host. It is possible to inspect the images available on the host, by running the following. -``` -$ sudo buildah images -IMAGE ID IMAGE NAME CREATED AT SIZE -9110ae7f579f docker.io/library/fedora:latest Mar 7, 2018 20:51 234.7 MB - -``` - -After pulling the base image, a running container instance of this image is available, this is a “working-container”. - -The following command displays the running containers. -``` -$ sudo buildah containers -CONTAINER ID BUILDER IMAGE ID IMAGE NAME -CONTAINER NAME -6112db586ab9 * 9110ae7f579f docker.io/library/fedora:latest fedora-working-container - -``` - -Buildah also provides a very useful command to stop and remove all the containers that are currently running. -``` -$ sudo buildah rm --all - -``` - -The full list of command is available using the –help option. -``` -$ buildah --help - -``` - -### Building an Apache web server container image - -Let’s see how to use Buildah to install an Apache web server on a Fedora base image, then copy a custom index.html to be served by the server. - -First let’s create the custom index.html. -``` -$ echo "Hello Fedora Magazine !!!" > index.html - -``` - -Then install the httpd package inside the running container. -``` -$ sudo buildah from fedora -$ sudo buildah run fedora-working-container dnf install httpd -y - -``` - -Let’s copy index.html to /var/www/html/. -``` -$ sudo buildah copy fedora-working-container index.html /var/www/html/index.html - -``` - -Then configure the container entrypoint to start httpd. -``` -$ sudo buildah config --entrypoint "/usr/sbin/httpd -DFOREGROUND" fedora-working-container - -``` - -Now to make the “working-container” available, the commit command saves the container to an image. -``` -$ sudo buildah commit fedora-working-container hello-fedora-magazine - -``` - -The hello-fedora-magazine image is now available, and can be pushed to a registry to be used. -``` -$ sudo buildah images -IMAGE ID IMAGE NAME CREATED -AT SIZE -9110ae7f579f docker.io/library/fedora:latest -Mar 7, 2018 22:51 234.7 MB -49bd5ec5be71 docker.io/library/hello-fedora-magazine:latest -Apr 27, 2018 11:01 427.7 MB - -``` - -It is also possible to use Buildah to test this image by running the following steps. -``` -$ sudo buildah from --name=hello-magazine docker.io/library/hello-fedora-magazine - -$ sudo buildah run hello-magazine - -``` - -Accessing will display “Hello Fedora Magazine !!!“ - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/daemon-less-container-management-buildah/ - -作者:[Ashutosh Sudhakar Bhakare][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://fedoramagazine.org/author/ashutoshbhakare/ -[1]:https://github.com/projectatomic/buildah diff --git a/translated/tech/20180503 How to build container images with Buildah.md b/translated/tech/20180503 How to build container images with Buildah.md new file mode 100644 index 0000000000..ee008f431e --- /dev/null +++ b/translated/tech/20180503 How to build container images with Buildah.md @@ -0,0 +1,135 @@ +如何使用 Buildah 构建容器镜像 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/04/buildah-816x345.png) + +Project Atomic 通过他们在 Open Container Initiative(OCI)上的努力创造了一个名为 [Buildah][1] 的伟大工具。Buildah 能帮助创建、构建和更新,它支持 Docker 容器镜像以及 OCI 兼容镜像。 + +Buildah 处理构建容器镜像时无需安装完整的容器运行时或守护进程。这对建立容器的持续集成和持续交付管道尤其有用。 + +Buildah 使容器的文件系统可以直接供构建主机使用。这意味着构建工具在主机上可用,并且在容器镜像中不需要,从而使构建更快速,镜像更小,更安全。Buildah 有 CentOS、Fedora 和 Debian 的软件包。 + +### 安装 Buildah + +从 Fedora 26 开始 Buildah 可以使用 dnf 进行安装。 +``` +$ sudo dnf install buildah -y + +``` + +buildah 的当前版本为 0.16,可以通过以下命令显示。 +``` +$ buildah --version + +``` + +### 基本命令 + +构建容器镜像的第一步是获取基础镜像,这是通过 Dockerfile 中的 FROM 语句完成的。Buildah 以类似的方式处理这个。 +``` +$ sudo buildah from fedora + +``` + +该命令将拉取 Fedora 的基础镜像并存储在主机上。通过执行以下操作可以检查主机上可用的镜像。 +``` +$ sudo buildah images +IMAGE ID IMAGE NAME CREATED AT SIZE +9110ae7f579f docker.io/library/fedora:latest Mar 7, 2018 20:51 234.7 MB + +``` + +在拉取基础镜像后,有一个该镜像的运行容器实例,这是一个“工作容器”。 + +以下命令显示正在运行的容器。 +``` +$ sudo buildah containers +CONTAINER ID BUILDER IMAGE ID IMAGE NAME +CONTAINER NAME +6112db586ab9 * 9110ae7f579f docker.io/library/fedora:latest fedora-working-container + +``` + +Buildah 还提供了一个非常有用的命令来停止和删除当前正在运行的所有容器。 +``` +$ sudo buildah rm --all + +``` + +完整的命令列表可以使用 -help 选项。 +``` +$ buildah --help + +``` + +### 构建一个 Apache Web 服务器容器镜像 + +让我们看看如何使用 Buildah 在 Fedora 基础镜像上安装 Apache Web 服务器,然后复制一个可供服务的自定义 index.html。 + +首先让我们创建自定义的 index.html。 +``` +$ echo "Hello Fedora Magazine !!!" > index.html + +``` + +然后在正在运行的容器中安装 httpd 包。 +``` +$ sudo buildah from fedora +$ sudo buildah run fedora-working-container dnf install httpd -y + +``` + +让我们将 index.html 复制到 /var/www/html/。 +``` +$ sudo buildah copy fedora-working-container index.html /var/www/html/index.html + +``` + +然后配置容器入口点以启动 httpd。 +``` +$ sudo buildah config --entrypoint "/usr/sbin/httpd -DFOREGROUND" fedora-working-container + +``` + +现在为了使“工作容器”可用,commit 命令将容器保存到镜像。 +``` +$ sudo buildah commit fedora-working-container hello-fedora-magazine + +``` + +hello-fedora-magazine 镜像现在可用,并且可以推送到仓库以供使用。 +``` +$ sudo buildah images +IMAGE ID IMAGE NAME CREATED +AT SIZE +9110ae7f579f docker.io/library/fedora:latest +Mar 7, 2018 22:51 234.7 MB +49bd5ec5be71 docker.io/library/hello-fedora-magazine:latest +Apr 27, 2018 11:01 427.7 MB + +``` + +通过运行以下步骤,还可以使用 Buildah 来测试此镜像。 +``` +$ sudo buildah from --name=hello-magazine docker.io/library/hello-fedora-magazine + +$ sudo buildah run hello-magazine + +``` + +访问 将显示 “Hello Fedora Magazine !!!” + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/daemon-less-container-management-buildah/ + +作者:[Ashutosh Sudhakar Bhakare][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/ashutoshbhakare/ +[1]:https://github.com/projectatomic/buildah From 0c27ba7fd8b81eef57f4563c207ffbe209b90500 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 14 May 2018 09:36:18 +0800 Subject: [PATCH 047/111] translating --- ...ollege student reflects on getting started in open source.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180328 College student reflects on getting started in open source.md b/sources/talk/20180328 College student reflects on getting started in open source.md index 4e757fe2f9..4ebf6ec2e8 100644 --- a/sources/talk/20180328 College student reflects on getting started in open source.md +++ b/sources/talk/20180328 College student reflects on getting started in open source.md @@ -1,3 +1,5 @@ +translating----geekpi + College student reflects on getting started in open source ====== From 9516bf96cb22ec4c682738a97a57d9b022be0e6b Mon Sep 17 00:00:00 2001 From: icecoobe Date: Tue, 8 May 2018 13:36:29 +0800 Subject: [PATCH 048/111] [Translated] 20180427 How to Compile a Linux Kernel.md --- .../20180427 How to Compile a Linux Kernel.md | 146 ------------------ .../20180427 How to Compile a Linux Kernel.md | 137 ++++++++++++++++ 2 files changed, 137 insertions(+), 146 deletions(-) delete mode 100644 sources/tech/20180427 How to Compile a Linux Kernel.md create mode 100644 translated/tech/20180427 How to Compile a Linux Kernel.md diff --git a/sources/tech/20180427 How to Compile a Linux Kernel.md b/sources/tech/20180427 How to Compile a Linux Kernel.md deleted file mode 100644 index 47f26a90eb..0000000000 --- a/sources/tech/20180427 How to Compile a Linux Kernel.md +++ /dev/null @@ -1,146 +0,0 @@ -icecoobe translating - -How to Compile a Linux Kernel -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/chester-alvarez-644-unsplash.jpg?itok=aFxG9kUZ) - -Once upon a time the idea of upgrading the Linux kernel sent fear through the hearts of many a user. Back then, the process of upgrading the kernel involved a lot of steps and even more time. Now, installing a new kernel can be easily handled with package managers like apt. With the addition of certain repositories, you can even easily install experimental or specific kernels (such as real-time kernels for audio production) without breaking a sweat. - -Considering how easy it is to upgrade your kernel, why would you bother compiling one yourself? Here are a few possible reasons: - - * You simply want to know how it’s done. - - * You need to enable or disable specific options into a kernel that simply aren’t available via the standard options. - - * You want to enable hardware support that might not be found in the standard kernel. - - * You’re using a distribution that requires you compile the kernel. - - * You’re a student and this is an assignment. - - - - -Regardless of why, knowing how to compile a Linux kernel is very useful and can even be seen as a right of passage. When I first compiled a new Linux kernel (a long, long time ago) and managed to boot from said kernel, I felt a certain thrill coursing through my system (which was quickly crushed the next time I attempted and failed). -With that said, let’s walk through the process of compiling a Linux kernel. I’ll be demonstrating on Ubuntu 16.04 Server. After running through a standard sudo apt upgrade, the installed kernel is 4.4.0-121. I want to upgrade to kernel 4.17. Let’s take care of that. - -A word of warning: I highly recommend you practice this procedure on a virtual machine. By working with a VM, you can always create a snapshot and back out of any problems with ease. DO NOT upgrade the kernel this way on a production machine… not until you know what you’re doing. - -### Downloading the kernel - -The first thing to do is download the kernel source file. This can be done by finding the URL of the kernel you want to download (from [Kernel.org][1]). Once you have the URL, download the source file with the following command (I’ll demonstrate with kernel 4.17 RC2): -``` -wget https://git.kernel.org/torvalds/t/linux-4.17-rc2.tar.gz - -``` - -While that file is downloading, there are a few bits to take care of. - -### Installing requirements - -In order to compile the kernel, we’ll need to first install a few requirements. This can be done with a single command: -``` -sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison - -``` - -Do note: You will need at least 12GB of free space on your local drive to get through the kernel compilation process. So make sure you have enough space. - -### Extracting the source - -From within the directory housing our newly downloaded kernel, extract the kernel source with the command: -``` -tar xvzf linux-4.17-rc2.tar.gz - -``` - -Change into the newly created directory with the command cd linux-4.17-rc2. - -### Configuring the kernel - -Before we actually compile the kernel, we must first configure which modules to include. There is actually a really easy way to do this. With a single command, you can copy the current kernel’s config file and then use the tried and true menuconfig command to make any necessary changes. To do this, issue the command: -``` -cp /boot/config-$(uname -r) .config - -``` - -Now that you have a configuration file, issue the command make menuconfig. This command will open up a configuration tool (Figure 1) that allows you to go through every module available and enable or disable what you need or don’t need. - - -![menuconfig][3] - -Figure 1: The make menuconfig in action. - -[Used with permission][4] - -It is quite possible you might disable a critical portion of the kernel, so step through menuconfig with care. If you’re not sure about an option, leave it alone. Or, better yet, stick with the configuration we just copied from the running kernel (as we know it works). Once you’ve gone through the entire list (it’s quite long), you’re ready to compile! - -### Compiling and installing - -Now it’s time to actually compile the kernel. The first step is to compile using the make command. So issue make and then answer the necessary questions (Figure 2). The questions asked will be determined by what kernel you’re upgrading from and what kernel you’re upgrading to. Trust me when I say there’s a ton of questions to answer, so give yourself plenty of time here. - - -![make][6] - -Figure 2: Answering the questions for the make command. - -[Used with permission][4] - -After answering the litany of questions, you can then install the modules you’ve enabled with the command: -``` -make modules_install - -``` - -Once again, this command will take some time, so either sit back and watch the output, or go do something else (as it will not require your input). Chances are, you’ll want to undertake another task (unless you really enjoy watching output fly by in a terminal). - -Now we install the kernel with the command: -``` -sudo make install - -``` - -Again, another command that’s going to take a significant amount of time. In fact, the make install command will take even longer than the make modules_install command. Go have lunch, configure a router, install Linux on a few servers, or take a nap. - -### Enable the kernel for boot - -Once the make install command completes, it’s time to enable the kernel for boot. To do this, issue the command: -``` -sudo update-initramfs -c -k 4.17-rc2 - -``` - -Of course, you would substitute the kernel number above for the kernel you’ve compiled. When that command completes, update grub with the command: -``` -sudo update-grub - -``` - -You should now be able to restart your system and select the newly installed kernel. - -### Congratulations! - -You’ve compiled a Linux kernel! It’s a process that may take some time; but, in the end, you’ll have a custom kernel for your Linux distribution, as well as an important skill that many Linux admins tend to overlook. - -Learn more about Linux through the free ["Introduction to Linux" ][7] course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/4/how-compile-linux-kernel-0 - -作者:[Jack Wallen][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/jlwallen -[1]:https://www.kernel.org/ -[2]:/files/images/kernelcompile1jpg -[3]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kernel_compile_1.jpg?itok=ZNybYgEt (menuconfig) -[4]:/licenses/category/used-permission -[5]:/files/images/kernelcompile2jpg -[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kernel_compile_2.jpg?itok=TYfV02wC (make) -[7]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20180427 How to Compile a Linux Kernel.md b/translated/tech/20180427 How to Compile a Linux Kernel.md new file mode 100644 index 0000000000..48926a862d --- /dev/null +++ b/translated/tech/20180427 How to Compile a Linux Kernel.md @@ -0,0 +1,137 @@ +如何编译 Linux 内核 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/chester-alvarez-644-unsplash.jpg?itok=aFxG9kUZ) + +曾经一段时间内,升级 Linux 内核让很多用户打心里有所畏惧。在那个时候,升级内核包含了很多步骤以及更多的时间。现在,内核安装可以轻易地通过像 `apt` 这样的包管理器来处理。通过添加特定的仓库,你能很轻易地安装实验版本的或者指定版本的内核 (比如针对音频产品的实时内核)。 + +考虑一下,既然升级内核如此容易,为什么你不愿意自行编译一个呢?这里列举一些可能的原因: + * 你想要简单了解它 (编译内核) 的过程 + * 你需要启用或者禁用内核中特定的选项,因为它们没有出现在标准选项里 + * 你想要启用标准内核中可能没有添加的硬件支持 + * 你使用的发行版需要你编译内核 + * 你是一个学生,而编译内核是你的任务 + +不管出于什么原因,懂得如何编译内核是非常有用的,而且可以被视作一个通行权。当我第一次编译一个新的 Linux 内核(很久以前),然后尝试从它启动,我从中 (系统快速地崩溃,然后不断地尝试和失败) 感受到一种特定的兴奋。 +既然这样,让我们来实验一下编译内核的过程。我将使用 `Ubuntu 16.04 Server` 来进行演示。在运行一次常规的 `sudo apt upgrade` 之后,当前安装的内核版本是 `4.4.0-121`。我想要升级内核版本到 `4.17`. 我们小心地开始吧。 + +有一个警告:强烈建议你在虚拟机里实验本模块。基于虚拟机,你总能创建一个快照,然后轻松地从任何问题中回退出来。不要在产品机器上使用这种方式升级内核,除非你知道你在做什么。 + +### 下载内核 +我们要做的第一件事是下载内核源码。可以找到所需内核 (在 [Kernel.org][1]) 的 URL 来下载。找到 URL 之后,使用如下命令 (我以 `4.17 RC2` 内核为例) 来下载源码文件: +``` +wget https://git.kernel.org/torvalds/t/linux-4.17-rc2.tar.gz + +``` + +在下载期间,有一些事需要去考虑。 + +### 安装需要的环境 + +为了编译内核,我们首先得安装一些需要的环境。这可以通过一个命令来完成: +``` +sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison + +``` + +务必注意: 你将需要至少 128GB 的本地可用磁盘空间来完成内核的编译过程。因此你必须确保有足够的空间。 + +### 解压源码 + +在新下载的内核所在的文件夹下,使用该命令来解压内核: +``` +tar xvzf linux-4.17-rc2.tar.gz + +``` + +使用命令 `cd linux-4.17-rc2` 进入新生成的文件夹。 + +### 配置内核 + +在正式编译内核之前,我们首先必须配置需要包含哪些模块。实际上,有一些非常简单的方式来配置。使用一个命令,你能拷贝当前内核的配置文件,然后使用可靠的 `menuconfig` 命令来做任何必要的更改。使用如下命令来完成: +``` +cp /boot/config-$(uname -r) .config + +``` + +现在你有一个配置文件了,输入命令 `make menuconfig`。该命令将打开一个配置工具 (图 1),它可以让你遍历每个可用模块,然后启用或者禁用你需要或者不需要的模块。 + + +![menuconfig][3] + +图 1: 运行中的 `make menuconfig`. + +[Used with permission][4] + +很有可能你会禁用掉内核中的一个重要部分,所以在 `menuconfig` 期间小心地一步步进行。如果你对某个选项不确定,不要去管它。或者更好的方法是使用我们拷贝的当前运行的内核的配置文件 (因为我们知道它可以工作)。一旦你已经遍历了整个配置列表 (它非常长),你就准备好开始编译了。 + +### 编译和安装 + +现在是时候去实际地编译内核了。第一步是使用 `make` 命令去编译。那么调用 `make` 命令然后回答必要的问题 (图 2)。这些问题取决于你将升级的现有内核以及升级后的内核。相信我,将会有非常多的问题要回答,因此你得预留大量的时间。 + +![make][6] + +图 2: 回答 `make` 命令的问题 + +[Used with permission][4] + +回答了长篇累牍的问题之后,你就可以用如下的命令安装那些之前启用的模块: +``` +make modules_install + +``` + +又来了,这个命令将耗费一些时间,所以要么坐下来看着编译输出,或者去做些其他事 (因为编译期间不需要你的输入)。可能的情况是,你想要进行别的任务 (除非你真的喜欢看着终端界面上飞舞的输出)。 + +现在我们使用这个命令来安装内核: +``` +sudo make install + +``` + +又一次,另一个将要耗费大量可观时间的命令。事实上,`make install` 命令将比 `make modules_install` 命令花费更多的时间。去享用午餐,配置一个路由器,将 Linux 安装在一些服务器上,或者小睡一会。 + +### 启用内核作为引导 + +一旦 `make install` 命令完成了,就是时候将内核启用来作为引导。 +使用这个命令来实现: +``` +sudo update-initramfs -c -k 4.17-rc2 + +``` + +当然,你需要将上述内核版本号替换成你编译完的。当命令执行完毕后,使用如下命令来更新 grub: +``` +sudo update-grub + +``` + +现在你可以重启系统并且选择新安装的内核了。 + +### 恭喜! + +你已经编译了一个 Linux 内核!它是一项耗费一些时间的活动;但是,最终你的 Linux 发行版将拥有一个定制的内核,同时你也将拥有一项被许多 Linux 管理员所倾向忽视的重要技能。 + +从 Linux 基金会和 edX 提供的免费 ["Introduction to Linux" ][7] 课程来学习更多的 Linux 知识。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/4/how-compile-linux-kernel-0 + +作者:[Jack Wallen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[icecoobe](https://github.com/icecoobe) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.kernel.org/ +[2]:/files/images/kernelcompile1jpg +[3]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kernel_compile_1.jpg?itok=ZNybYgEt (menuconfig) +[4]:/licenses/category/used-permission +[5]:/files/images/kernelcompile2jpg +[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kernel_compile_2.jpg?itok=TYfV02wC (make) +[7]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux + + From 120c480babc3c05b607ab6e467d7f2fc8f92cbd1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 11:18:40 +0800 Subject: [PATCH 049/111] PRF:20180501 How To Use Vim Editor To Input Text Anywhere.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @paperzhang 恭喜你,完成了第一篇翻译! --- ...o Use Vim Editor To Input Text Anywhere.md | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md index 0ece2dfb4c..e72e86c18d 100644 --- a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md +++ b/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md @@ -1,80 +1,86 @@ 如何在任何地方使用 Vim 编辑器输入文本 ====== + ![](https://www.ostechnix.com/wp-content/uploads/2018/05/vim-anywhere-720x340.png) -各位Vim使用者大家好!今天,我这里有个好消息告诉大家。我会向大家介绍 **Vim-anywhere**,这是一个简单的脚本,它允许你使用 Vim 编辑器在 Linux 中的任何地方输入文本。这意味着你能简单地调用自己最爱的 Vim 编辑器,输入任何你所想的,并将这些文本粘贴到任意的应用和网站中。这些文本将在剪贴板可用,直到你重启了系统。这个工具对那些喜欢在非 Vim 环境中使用 Vim 键位绑定的人来说十分有用。 +各位 Vim 使用者大家好!今天,我这里有个好消息告诉大家。我会向大家介绍 **Vim-anywhere**,这是一个简单的脚本,它允许你使用 Vim 编辑器在 Linux 中的任何地方输入文本。这意味着你能简单地调用自己最爱的 Vim 编辑器,输入任何你所想的,并将这些文本粘贴到任意的应用和网站中。这些文本将在剪贴板可用,直到你重启了系统。这个工具对那些喜欢在非 Vim 环境中使用 Vim 键位绑定的人来说十分有用。 ### 在 Linux 中安装 Vim-anywhere -Vim-anywhere 工具可以运行在任何基本 GNOME(或其他衍生品)的 Linux 发行版上。另外,确保你已经安装了下面的依赖。 + +Vim-anywhere 工具可以运行在任何基于 GNOME(或其他衍生品)的 Linux 发行版上。另外,确保你已经安装了下面的依赖。 * Curl * Git * gVim * xclip - 比如,你可以用下面的命令在 Ubuntu 中安装这些工具: + ``` $ sudo apt install curl git vim-gnome xclip - ``` + 然后运行如下的命令来安装 Vim-anywhere: + ``` $ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash - ``` + Vim-anywhere 到此已经安装完成。现在我们来看看如何使用它。 + ### 在任何地方使用 Vim 编辑器输入文本 + 假如你需要创建一个 word 文档。但是你更愿意使用 Vim 编辑器,而不是 LibreOffice。没问题,这里 Vim-anywhere 就派上用场了。Vim-anywhere 自动化了整个流程。它仅仅简单地调用 Vim 编辑器,所以你能写任何你所想的,然后将之粘贴到 .doc 文件中。 -让我给你展示一个用例。打开 LibreOffice 或者你选的任何图形文本编辑器。然后打开 Vim-anywhere。你只需要按下 **CTRL+ALT+V** 即可。它将会打开 gVim 编辑器。按下"i"切换到交互模式然后输入文本。完成之后,键入 **:wq** 关闭并保存文件。 +让我给你展示一个用例。打开 LibreOffice 或者你选的任何图形文本编辑器。然后打开 Vim-anywhere。你只需要按下 `CTRL+ALT+V` 即可。它将会打开 gVim 编辑器。按下 `i` 切换到交互模式然后输入文本。完成之后,键入 `:wq` 关闭并保存文件。 ![][2] -这些文本会在剪贴板中可用,直到你重启了系统。在你关闭编辑器之后,你之前的应用会重新占据主界面。你只需按下 **CTRL+P** 将文本粘贴进去。 +这些文本会在剪贴板中可用,直到你重启了系统。在你关闭编辑器之后,你之前的应用会重新占据主界面。你只需按下 `CTRL+P` 将文本粘贴进去。 ![][3] -这仅仅只是一个例子。你甚至可以使用 Vim-anywhere 在烦人的 web 表单或者其他应用上进行输入。一旦 Vim-anywhere被调用,它将会打开一个缓冲区。关闭 Vim-anywhere之后,缓冲器内的内容会自动复制到你的剪贴板中,之前的应用会重新占据主界面。 +这仅仅只是一个例子。你甚至可以使用 Vim-anywhere 在烦人的 web 表单或者其他应用上进行输入。一旦 Vim-anywhere 被调用,它将会打开一个缓冲区。关闭 Vim-anywhere 之后,缓冲器内的内容会自动复制到你的剪贴板中,之前的应用会重新占据主界面。 + +Vim-anywhere 在被调用的时候会在 `/tmp/vim-anywhere` 中创建一个临时文件。这些临时文件会一致保存着,直到你重启了系统,并为你提供临时的历史记录。 -Vim-anywhere 在被调用的时候会在 **/tmp/vim-anywhere** 中创建一个临时文件。这些临时文件会一致保存着,直到你重启了系统,并为你提供临时的历史记录。 ``` $ ls /tmp/vim-anywhere - ``` + 你可以用下面的命令重新打开最近的文件: + ``` $ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 ) - ``` -**更新 Vim-anywhere ** + +#### 更新 Vim-anywhere 运行下面的命令来更新 Vim-anywhere: + ``` $ ~/.vim-anywhere/update ``` -**更改快捷键** +#### 更改快捷键 + +默认调用 Vim-anywhere 的键位是 `CTRL+ALT+V`。你可以用 `gconf` 工具将其更改为任何自定义的键位绑定。 -默认调用 Vim-anywhere 的键位是 CTRL+ALT+V。你可以用 gconf 工具将其更改为任何自定义的键位绑定。 ``` $ gconftool -t str --set /desktop/gnome/keybindings/vim-anywhere/binding - ``` -**卸载 Vim-anywhere** +#### 卸载 Vim-anywhere -可能有些人觉得每次打开Vim编辑器,输入一些文本,然后将文本复制到其他应用中是没有意义也毫无必要的。 +可能有些人觉得每次打开 Vim 编辑器,输入一些文本,然后将文本复制到其他应用中是没有意义也毫无必要的。 如果你不觉得这个工具有用,只需使用下面的命令来卸载它: + ``` $ ~/.vim-anywhere/uninstall - ``` - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ @@ -82,7 +88,7 @@ via: https://www.ostechnix.com/how-to-use-vim-editor-to-input-text-anywhere/ 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[paperzhang](https://github.com/paperzhang) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e5d15e66ff78c6946f62066658fc297681be159e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 11:19:23 +0800 Subject: [PATCH 050/111] PUB:20180501 How To Use Vim Editor To Input Text Anywhere.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @paperzhang 首发地址: https://linux.cn/article-9637-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/paperzhang --- .../20180501 How To Use Vim Editor To Input Text Anywhere.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180501 How To Use Vim Editor To Input Text Anywhere.md (100%) diff --git a/translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md b/published/20180501 How To Use Vim Editor To Input Text Anywhere.md similarity index 100% rename from translated/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md rename to published/20180501 How To Use Vim Editor To Input Text Anywhere.md From 60b9f40f8d8556753fcad0b97a66ee90f8685b33 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 12:07:15 +0800 Subject: [PATCH 051/111] PRF:20180328 How To Use Instagram In Terminal.md @geekpi --- ...180328 How To Use Instagram In Terminal.md | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/translated/tech/20180328 How To Use Instagram In Terminal.md b/translated/tech/20180328 How To Use Instagram In Terminal.md index fba319c0a3..cd1276a4ce 100644 --- a/translated/tech/20180328 How To Use Instagram In Terminal.md +++ b/translated/tech/20180328 How To Use Instagram In Terminal.md @@ -1,39 +1,41 @@ 如何在终端中使用 Instagram ====== + ![](https://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-720x340.png) -Instagram 不需要介绍。它是像 Facebook 和 Twitter 之类的流行社交网络平台之一,它可以公开或私下分享照片和视频给确认过的粉丝。它是由两位企业家于 2010 年发起的,分别是 **Kevin Systrom** and **Mike Krieger**。2012 年,社交网络巨头 Facebook 收购了 Instagram。Android 和 iOS 设备上免费提供 Instagram。我们也可以通过网络浏览器在桌面系统中使用它。而且,最酷的是现在你可以在任何类 Unix 操作系统上的终端中使用 Instagram。你兴奋了吗?那么,请阅读以下内容了解如何在终端上查看你的Instagram feed。 + +Instagram 不需要介绍。它是像 Facebook 和 Twitter 之类的流行社交网络平台之一,它可以公开或私下分享照片和视频给确认过的粉丝。它是由两位企业家 **Kevin Systrom** 和 **Mike Krieger**于 2010 年发起的。2012 年,社交网络巨头 Facebook 收购了 Instagram。Android 和 iOS 设备上可以免费下载 Instagram。我们也可以通过网络浏览器在桌面系统中使用它。而且,最酷的是现在你可以在任何类 Unix 操作系统上的终端中使用 Instagram。你兴奋了吗?那么,请阅读以下内容了解如何在终端上查看你的 Instagram feed。 ### 终端中的 Instagram -首先,按照以下链接中的说明安装 **pip3**。 +首先,按照以下链接中的说明安装 `pip3`。 + +然后,git clone 它的脚本仓库。 -然后,git clone “instagram-terminal-news-feed” 脚本仓库。 ``` $ git clone https://github.com/billcccheng/instagram-terminal-news-feed.git - ``` -以上命令会将 instagram 脚本的内容克隆到当前工作目录中名为 “instagram-terminal-news-feed” 的目录中。cd 到该目录: +以上命令会将 instagram 脚本的内容克隆到当前工作目录中名为 `instagram-terminal-news-feed` 的目录中。cd 到该目录: + ``` $ cd instagram-terminal-news-feed/ - ``` -然后,运行以下命令安装 instagram 终端 feed: +然后,运行以下命令安装它: + ``` $ pip3 install -r requirements.txt - ``` 现在,运行以下命令在 Linux 终端中启动 instagram。 + ``` $ python3 start.py - ``` -输入你的 Instagram 用户名和密码,并直接从终端中浏览你的 Instagram feed。你的 instragram 用户名和密码将仅本地存储在名为 **credential.json** 的文件中。所以,你不必担心它。你也可以选择不保存默认保存的凭证。 +输入你的 Instagram 用户名和密码,并直接从终端中浏览你的 Instagram feed。你的 instragram 用户名和密码将仅本地存储在名为 `credential.json` 的文件中。所以,你不必担心它。你也可以选择不保存默认保存的凭证。 -下面是[**我的 Instagram 页面**][1]的一些截图。 +下面是[我的 Instagram 页面][1]的一些截图。 ![][3] @@ -53,9 +55,9 @@ $ python3 start.py via: https://www.ostechnix.com/how-to-use-instagram-in-terminal/ 作者:[SK][a] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From ae149ad218a6c370ce038f76dbdec8043e6ccb54 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 12:07:45 +0800 Subject: [PATCH 052/111] PUB:20180328 How To Use Instagram In Terminal.md @geekpi https://linux.cn/article-9638-1.html --- .../20180328 How To Use Instagram In Terminal.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180328 How To Use Instagram In Terminal.md (100%) diff --git a/translated/tech/20180328 How To Use Instagram In Terminal.md b/published/20180328 How To Use Instagram In Terminal.md similarity index 100% rename from translated/tech/20180328 How To Use Instagram In Terminal.md rename to published/20180328 How To Use Instagram In Terminal.md From 00d60f690ed110fd344ae55b986f4c743ad14414 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 12:51:43 +0800 Subject: [PATCH 053/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20Methods=20To?= =?UTF-8?q?=20Install=20Latest=20Python3=20Package=20On=20CentOS=206=20Sys?= =?UTF-8?q?tem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...test Python3 Package On CentOS 6 System.md | 247 ++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 sources/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md diff --git a/sources/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md b/sources/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md new file mode 100644 index 0000000000..6de6e9e416 --- /dev/null +++ b/sources/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md @@ -0,0 +1,247 @@ +3 Methods To Install Latest Python3 Package On CentOS 6 System +====== +CentOS is RHEL clone and comes with free of cost. It’s a industry standard and cutting edge operating system, this has been used by 90% of webhosting provider since it’s supporting the leading edge server control panel called cPanel/WHM. + +This control panel allowing users to manage everything through control panel without entering into terminal. + +As we already know that RHEL has long term support and doesn’t offer the latest version of packages due to stability. + +If you want to install latest version of packages, which is not available in the default repository and you have to install manually by compiling the source package. + +It’s a high risk because we can’t upgrade the manually installed packages to latest version if they release new version and we have to reinstall manually. + +In this case what will be the solution and suggested method to install latest version of package? Yes, this can be done by adding the necessary third party repository to system. + +There are many third party repositories are available for Enterprise Linux but only few of repositories are suggested to use by CentOS communicant, which doesn’t alter the base packages in large scale. + +They are usually well maintained and provide a substantial number of additional packages to CentOS. + +In this tutorial, we will teach you, how to install latest Python 3 package on CentOS 6 system. + +### Method-1 : Using Software Collections Repository (SCL) + +The SCL repository is now maintained by a CentOS SIG, which rebuilds the Red Hat Software Collections and also provides some additional packages of their own. + +It contains newer versions of various programs that can be installed alongside existing older packages and invoked by using the scl command. + +Run the following command to install Software Collections Repository on CentOS +``` +# yum install centos-release-scl + +``` + +Check the available python 3 version. +``` +# yum info rh-python35 +Loaded plugins: fastestmirror, security +Loading mirror speeds from cached hostfile + * epel: ewr.edge.kernel.org + * remi-safe: mirror.team-cymru.com +Available Packages +Name : rh-python35 +Arch : x86_64 +Version : 2.0 +Release : 2.el6 +Size : 0.0 +Repo : installed +From repo : centos-sclo-rh +Summary : Package that installs rh-python35 +License : GPLv2+ +Description : This is the main package for rh-python35 Software Collection. + +``` + +Run the below command to install latest available python 3 package from scl. +``` +# yum install rh-python35 + +``` + +Run the below special scl command to enable the installed package version at the shell. +``` +# scl enable rh-python35 bash + +``` + +Run the below command to check installed python3 version. +``` +# python --version +Python 3.5.1 + +``` + +Run the following command to get a list of SCL packages have been installed on system. +``` +# scl -l +rh-python35 + +``` + +### Method-2 : Using EPEL Repository (Extra Packages for Enterprise Linux) + +EPEL stands for Extra Packages for Enterprise Linux maintained by Fedora Special Interest Group. + +They creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Linux (OL). + +EPEL packages are usually based on their Fedora counterparts and will never conflict with or replace packages in the base Enterprise Linux distributions. + +**Suggested Read :** [Install / Enable EPEL Repository on RHEL, CentOS, Oracle Linux & Scientific Linux][1] + +EPEL package is included in the CentOS Extras repository and enabled by default so, we can install this by running below command. +``` +# yum install epel-release + +``` + +Check the available python 3 version. +``` +# yum --disablerepo="*" --enablerepo="epel" info python34 +Loaded plugins: fastestmirror, security +Loading mirror speeds from cached hostfile + * epel: ewr.edge.kernel.org +Available Packages +Name : python34 +Arch : x86_64 +Version : 3.4.5 +Release : 4.el6 +Size : 50 k +Repo : epel +Summary : Version 3 of the Python programming language aka Python 3000 +URL : http://www.python.org/ +License : Python +Description : Python 3 is a new version of the language that is incompatible with the 2.x + : line of releases. The language is mostly the same, but many details, especially + : how built-in objects like dictionaries and strings work, have changed + : considerably, and a lot of deprecated features have finally been removed. + + +``` + +Run the below command to install latest available python 3 package from EPEL repository. +``` +# yum --disablerepo="*" --enablerepo="epel" install python34 + +``` + +By default this will not install matching pip & setuptools and we have to install by running below command. +``` +# curl -O https://bootstrap.pypa.io/get-pip.py + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 1603k 100 1603k 0 0 2633k 0 --:--:-- --:--:-- --:--:-- 4816k + +# /usr/bin/python3.4 get-pip.py +Collecting pip + Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl +Collecting setuptools + Downloading https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl (566kB) + 100% |████████████████████████████████| 573kB 4.0MB/s +Collecting wheel + Downloading https://files.pythonhosted.org/packages/1b/d2/22cde5ea9af055f81814f9f2545f5ed8a053eb749c08d186b369959189a8/wheel-0.31.0-py2.py3-none-any.whl (41kB) + 100% |████████████████████████████████| 51kB 8.0MB/s +Installing collected packages: pip, setuptools, wheel +Successfully installed pip-10.0.1 setuptools-39.1.0 wheel-0.31.0 + +``` + +Run the below command to check installed python3 version. +``` +# python3 --version +Python 3.4.5 + +``` + +### Method-3 : Using IUS Community Repository + +IUS Community is a CentOS Community Approved third-party RPM repository which contains latest upstream versions of PHP, Python, MySQL, etc.., packages for Enterprise Linux (RHEL & CentOS) 5, 6 & 7. + +IUS Community Repository have dependency with EPEL Repository so we have to install EPEL repository prior to IUS repository installation. Follow the below steps to install & enable EPEL & IUS Community Repository to RPM systems and install the packages. + +**Suggested Read :** [Install / Enable IUS Community Repository on RHEL & CentOS][2] + +EPEL package is included in the CentOS Extras repository and enabled by default so, we can install this by running below command. +``` +# yum install epel-release + +``` + +Download IUS Community Repository Shell script +``` +# curl 'https://setup.ius.io/' -o setup-ius.sh + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 1914 100 1914 0 0 6563 0 --:--:-- --:--:-- --:--:-- 133k + +``` + +Install/Enable IUS Community Repository. +``` +# sh setup-ius.sh + +``` + +Check the available python 3 version. +``` +# yum --enablerepo=ius info python36u +Loaded plugins: fastestmirror, security +Loading mirror speeds from cached hostfile + * epel: ewr.edge.kernel.org + * ius: mirror.team-cymru.com + * remi-safe: mirror.team-cymru.com +Available Packages +Name : python36u +Arch : x86_64 +Version : 3.6.5 +Release : 1.ius.centos6 +Size : 55 k +Repo : ius +Summary : Interpreter of the Python programming language +URL : https://www.python.org/ +License : Python +Description : Python is an accessible, high-level, dynamically typed, interpreted programming + : language, designed with an emphasis on code readability. + : It includes an extensive standard library, and has a vast ecosystem of + : third-party libraries. + : + : The python36u package provides the "python3.6" executable: the reference + : interpreter for the Python language, version 3. + : The majority of its standard library is provided in the python36u-libs package, + : which should be installed automatically along with python36u. + : The remaining parts of the Python standard library are broken out into the + : python36u-tkinter and python36u-test packages, which may need to be installed + : separately. + : + : Documentation for Python is provided in the python36u-docs package. + : + : Packages containing additional libraries for Python are generally named with + : the "python36u-" prefix. + +``` + +Run the below command to install latest available python 3 package from IUS repository. +``` +# yum --enablerepo=ius install python36u + +``` + +Run the below command to check installed python3 version. +``` +# python3.6 --version +Python 3.6.5 + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/3-methods-to-install-latest-python3-package-on-centos-6-system/ + +作者:[PRAKASH SUBRAMANIAN][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.2daygeek.com/author/prakash/ +[1]:https://www.2daygeek.com/install-enable-epel-repository-on-rhel-centos-scientific-linux-oracle-linux/ +[2]:https://www.2daygeek.com/install-enable-ius-community-repository-on-rhel-centos/ From 050b9bc39251b0d33b20bb64e21d9e4329731623 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 13:00:02 +0800 Subject: [PATCH 054/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Analyzing=20Ansib?= =?UTF-8?q?le=20runs=20using=20ARA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...180510 Analyzing Ansible runs using ARA.md | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 sources/tech/20180510 Analyzing Ansible runs using ARA.md diff --git a/sources/tech/20180510 Analyzing Ansible runs using ARA.md b/sources/tech/20180510 Analyzing Ansible runs using ARA.md new file mode 100644 index 0000000000..c3f22ad914 --- /dev/null +++ b/sources/tech/20180510 Analyzing Ansible runs using ARA.md @@ -0,0 +1,119 @@ +Analyzing Ansible runs using ARA +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) +[Ansible][1] is a versatile platform that has become popular for managing servers and server configurations. Today, Ansible is used heavily to deploy and test through continuous integration (CI). + +In the world of automated continuous integration, it’s not uncommon to have hundreds, if not thousands, of jobs running every day for testing, building, compiling, deploying, and more. + +### The Ansible Run Analysis (ARA) tool + +Ansible runs generate a large amount of console data, and keeping up with high volumes of Ansible output in the context of CI is challenging. The Ansible Run Analysis (ARA) tool makes this verbose output readable and more representative of the job status and debug information. ARA organizes recorded playbook data so you can search and find what you’re interested in as quickly and as easily as possible. + +Note that ARA doesn't run your playbooks for you; rather, it integrates with Ansible as a callback plugin wherever it is. A callback plugin enables adding new behaviors to Ansible when responding to events. It can perform custom actions in response to Ansible events such as a play starting or a task completing on a host. + +Compared to [AWX][2] and [Tower][3], which are tools that control the entire workflow, with features like inventory management, playbook execution, editing features, and more, the scope of ARA is comparatively narrow: It records data and provides an intuitive interface. It is a relatively simple application that is easy to install and configure. + +#### Installation + +There are two ways to install ARA on your system: + + * Using the Ansible role hosted on your [GitHub account][4]. Clone the repo and do: + + +``` +ansible-playbook Playbook.yml + +``` + +If the playbook run is successful, you will get: +``` +TASK [ara : Display ara UI URL] ************************ + +   ok: [localhost] => {} + +   "msg": "Access playbook records at http://YOUR_IP:9191" + +``` + +Note: It picks the IP address from `ansible_default_ipv4` fact gathered by Ansible. If there is no such fact gathered, replace it with your IP in `main.yml` file in the `roles/ara/tasks/` folder. + + * ARA is an open source project available on [GitHub][5] under the Apache v2 license. Installation instructions are in the Quickstart chapter. The [documentation][6] and [FAQs][7] are available on [readthedocs.io][6]. + + + +#### What can ARA do? + +The image below shows the ARA landing page launched from the browser: + + +![ara landing page][9] + +The ARA landing page + +It provides summaries of task results per host or per playbook: + + +![task summaries][11] + +ARA displays task summaries + +It allows you to filter task results by playbook, play, host, task, or status: + + +![playbook runs filtered by hosts][13] + +Playbook runs, filtered by host + +With ARA, you can easily drill down from the summary view to find the results you’re interested in, whether it’s a particular host or a specific task: + + +![summary of each task][15] + +A detailed summary of each task + +ARA supports recording and viewing multiple runs in the same database. + + +![show gathered facts][17] + +Displaying gathered facts + +#### Wrapping up + +ARA is a useful resource that has helped me get more out of Ansible run logs and outputs. I highly recommend it to all Ansible ninjas out there. + +Feel free to share this, and please let me know about your experience using ARA in the comments. + +**[See our related story,[Tips for success when getting started with Ansible][18].]** + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/analyzing-ansible-runs-using-ara + +作者:[Ajinkya Bapat][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/iamajinkya +[1]:https://www.ansible.com/ +[2]:https://www.ansible.com/products/awx-project +[3]:https://www.ansible.com/products/tower +[4]:https://github.com/AjinkyaBapat/Ansible-Run-Analyser +[5]:https://github.com/dmsimard/ara +[6]:http://ara.readthedocs.io/en/latest/ +[7]:http://ara.readthedocs.io/en/latest/faq.html +[8]:/file/395716 +[9]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/ara_landing_page.png?itok=PoB7KfhB (ara landing page) +[10]:/file/395726 +[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/task_summaries.png?itok=8EBP9sTG (task summaries) +[12]:/file/395731 +[13]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/playbook_filtered_by_hosts.png?itok=Lol0K_My (playbook runs filtered by hosts) +[14]:/file/395736 +[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/summary_of_each_task.png?itok=KJnLHEZC (summary of each task) +[16]:/file/395741 +[17]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/showing_gathered_facts.png?itok=FVDc6oA0 (show gathered facts) +[18]:/article/18/2/tips-success-when-getting-started-ansible From 3087be2c4f6f81cfb97e0e305b1b8aab6069704c Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 13:03:46 +0800 Subject: [PATCH 055/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Displa?= =?UTF-8?q?y=20Images=20In=20The=20Terminal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 How To Display Images In The Terminal.md | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 sources/tech/20180510 How To Display Images In The Terminal.md diff --git a/sources/tech/20180510 How To Display Images In The Terminal.md b/sources/tech/20180510 How To Display Images In The Terminal.md new file mode 100644 index 0000000000..e4ea138a27 --- /dev/null +++ b/sources/tech/20180510 How To Display Images In The Terminal.md @@ -0,0 +1,128 @@ +How To Display Images In The Terminal +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/05/fim-2-720x340.png) +There are plenty of GUI picture viewers available for Linux. But I haven’t heard or used any applications which displays pictures in the Terminal itself. Luckily, I have just found a CLI image viewer named **FIM** that can be used to display images images in Terminal. The FIM utility draw my attention, because it is very lightweight compared to most GUI picture viewer applications. Without further ado, lets us go ahead and see what it is capable of. + +### Display Images In the Terminal Using FIM + +**FIM** stands for **F** bi **IM** proved. For those who don’t know, **Fbi** is a linux **f** rame **b** uffer **i** mageviewer. It uses the system’s framebuffer to display images directly from the command line. By default, it displays bmp, gif, jpeg, PhotoCD, png, ppm, tiff, and xwd from the Terminal itself. For other formats, it will try to use ImageMagick’s convert. + +FIM is based on Fbi and it is a highly customizable and scriptable image viewer targeted at the users who are comfortable with software like the Vim text editor or the Mutt mail user agent. It displays the images in full screen and the images can be controlled (such as resize, flip, zoom) using keyboard shortcuts. Unlike fbi, the FIM utility is universal: it can open many file formats and it can display pictures in the following video modes: + + * Graphically, with the Linux framebuffer device. + * Graphically, under X/Xorg, using the SDL library. + * Graphically, under X/Xorg, using the Imlib2 library. + * Rendered as ASCII Art in any textual console, using the AAlib library. + + + +FIM is completely free and open source. + +### Install FIM + +The FIM image viewer is available in the default repositories of DEB-based systems such as Ubuntu, Linux Mint. So, you can install fbi using command: +``` +$ sudo apt-get install fim + +``` + +If it is not available in the default repositories of your Linux distribution, you can download, compile and install from source as shown below. +``` +wget http://download.savannah.nongnu.org/releases/fbi-improved/fim-0.6-trunk.tar.gz +wget http://download.savannah.nongnu.org/releases/fbi-improved/fim-0.6-trunk.tar.gz.sig +gpg --search 'dezperado autistici org' +# import the key from a trusted keyserver by following on screen instructions +gpg --verify fim-0.6-trunk.tar.gz.sig + +tar xzf fim-0.6-trunk.tar.gz +cd fim-0.6-trunk +./configure --help=short +# read the ./configure --help=short output: you can give options to ./configure +./configure +make +su -c "make install" + +``` + +### FIM Usage + +Once installed, you can display an image with “auto zoom” option using command: +``` +$ fim -a dog.jpg + +``` + +Here is the sample output from my Ubuntu box. + +![][1] + +As you can see in the above screenshot, FIM didn’t use any external GUI picture viewers. Instead, it uses our system’s framebuffer to display the image. + +If you have multiple .jpg files in the current directory, you could use wildcard to open all of them as shown below. +``` +$ fim -a *.jpg + +``` + +To open all images in a directory, for example **Pictures** , run: +``` +$ fim Pictures/ + +``` + +We can also open the images recursively in a folder and its sub-folder and then sorting the list like below. +``` +$ fim -R Pictures/ --sort + +``` + +To render the image in ASCII format, you can use **-t** flag. +``` +$ fim -t dog.jpg + +``` + +To quit Fim, press **ESC** or **q**. + +**Keyboard shortcuts** + +You can use various keyboard shortcuts to manage the images. For example, to load next image and previous images, press PgUp/PgDown keys. Ton Zoom in or out, use +/- keys. Here is the common keys used to control images in FIM. + + * **PageUp/Down** : Prev/Next image + * **+/-** : Zoom in/out + * **a** : Autoscale + * **w** : Fit to width + * **h** : Fit to height + * **j/k** : Pan down/up + * **f/m** : flip/mirror + * **r/R** : Rotate (Clock wise and ant-clock wise) + * **ESC/q** : Quit + + + +For complete details, refer man pages. +``` +$ man fim + +``` + +And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-display-images-in-the-terminal/ + +作者:[SK][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.ostechnix.com/author/sk/ +[1]:http://www.ostechnix.com/wp-content/uploads/2018/05/fim-1.png From 537bbabd3f36aca9d385bbdc2a142aaa4de810a0 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 13:05:50 +0800 Subject: [PATCH 056/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20MidnightBSD=20Cou?= =?UTF-8?q?ld=20Be=20Your=20Gateway=20to=20FreeBSD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ghtBSD Could Be Your Gateway to FreeBSD.md | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 sources/tech/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md diff --git a/sources/tech/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md b/sources/tech/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md new file mode 100644 index 0000000000..229ea0eb6e --- /dev/null +++ b/sources/tech/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md @@ -0,0 +1,179 @@ +MidnightBSD Could Be Your Gateway to FreeBSD +====== +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/midnight_4_0.jpg?itok=T2gpLVui) + +[FreeBSD][1] is an open source operating system that descended from the famous [Berkeley Software Distribution][2]. The first version of FreeBSD was released in 1993 and is still going strong. Around 2007, Lucas Holt wanted to create a fork of FreeBSD that made use of the [GnuStep][3] implementation of the OpenStep (now Cocoa) Objective-C frameworks, widget toolkit, and application development tools. To that end, he began development of the MidnightBSD desktop distribution. + +MidnightBSD (named after Lucas’s cat, Midnight) is still in active (albeit slow) development. The latest stable release (0.8.6) has been available since August, 2017. Although the BSD distributions aren’t what you might call user-friendly, getting up to speed on their installation is a great way to familiarize yourself with how to deal with an ncurses installation and with finalizing an install via the command line. + +In the end, you’ll wind up with desktop distribution of a very reliable fork of FreeBSD. It’ll take a bit of work, but if you’re a Linux user looking to stretch your skills… this is a good place to start. + +I want to walk you through the process of installing MidnightBSD, how to add a graphical desktop environment, and then how to install applications. + +### Installation + +As I mentioned, this is an ncurses installation process, so there is no point-and-click to be found. Instead, you’ll be using your keyboard Tab and arrow keys. Once you’ve downloaded the [latest release][4], burn it to a CD/DVD or USB drive and boot your machine (or create a virtual machine in [VirtualBox][5]). The installer will open and give you three options (Figure 1). Select Install (using your keyboard arrow keys) and hit Enter. + + +![MidnightBSD installer][7] + +Figure 1: Launching the MidnightBSD installer. + +[Used with permission][8] + +At this point, there are quite a lot of screens to go through. Many of those screens are self-explanatory: + + 1. Set non-default key mapping (yes/no) + + 2. Set hostname + + 3. Add optional system components (documentation, games, 32-bit compatibility, system source code) + + 4. Partitioning hard drive + + 5. Administrator password + + 6. Configure networking interface + + 7. Select region (for timezone) + + 8. Enable services (such as secure shell) + + 9. Add users (Figure 2) + + + + +![Adding a user][10] + +Figure 2: Adding a user to the system. + +[Used with permission][8] + +After you’ve added the user(s) to the system, you will then be dropped to a window (Figure 3), where you can take care of anything you might have missed or you want to re-configure. If you don’t need to make any changes, select Exit, and your configurations will be applied. + +In the next window, when prompted, select No, and the system will reboot. Once MidnightBSD reboots, you’re ready for the next phase of the installation. + +### Post install + +When your newly installed MidnightBSD boots, you’ll find yourself at a command prompt. At this point, there is no graphical interface to be found. To install applications, MidnightBSD relies on the mport tool. Let’s say you want to install the Xfce desktop environment. To do this, log into MidnightBSD and issue the following commands: +``` +sudo mport index + +sudo mport install xorg + +``` + +You now have the Xorg window server installed, which will allow you to install the desktop environment. Installing Xfce is handled with the command: +``` +sudo mport install xfce + +``` + +Xfce is now installed. However, we must enable it to run with the command startx. To do this, let’s first install the nano editor. Issue the command: +``` +sudo mport install nano + +``` + +With nano installed, issue the command: +``` +nano ~/.xinitrc + +``` + +That file need only contain a single line: +``` +exec startxfce4 + +``` + +Save and close that file. If you now issue the command startx, the Xfce desktop environment will start. You should start to feel a bit more at home (Figure 4). + +![ Xfce][12] + +Figure 4: The Xfce desktop interface is ready to serve. + +[Used with permission][8] + +Since you don’t want to always have to issue the command startx, you’ll want to enable the login daemon. However, it’s not installed. To install this subsystem, issue the command: +``` +sudo mport install mlogind + +``` + +When the installation completes, enable mlogind at boot by adding an entry to the /etc/rc.conf file. At the bottom of the rc.conf file, add the following: +``` +mlogind_enable=”YES” + +``` + +Save and close that file. Now, when you boot (or reboot) the machine, you should be greeted by the graphical login screen. At the time of writing, after logging in, I wound up with a blank screen and the dreaded X cursor. Unfortunately, it seems there’s no fix for this at the moment. So, to gain access to your desktop environment, you must make use of the startx command. + +### Installing + +Out of the box, you won’t find much in the way of applications. If you attempt to install applications (using mport), you’ll quickly find yourself frustrated, as very few applications can be found. To get around this, we need to check out the list of available mport software, using the svnlite command. Go back to the terminal window and issue the command: +``` +svnlite co http://svn.midnightbsd.org/svn/mports/trunk mports + +``` + +Once you do that, you should see a new directory named ~/mports. Change into that directory (with the command cd ~/.mports. Issue the ls command and you should see a number of categories (Figure 5). + +![applications][14] + +Figure 5: The categories of applications now available for mport. + +[Used with permission][8] + +Say you want to install Firefox? If you look in the www directory, you’ll see a listing for linux-firefox. Issue the command: +``` +sudo mport install linux-firefox + +``` + +You should now see an entry for Firefox in the Xfce desktop menu. Go through all of the categories and install all of the software you need, using the mport command. + +### A sad caveat + +One sad little caveat is that the only version of an office suite to be found for mport (via svnlite) is OpenOffice 3. That’s quite out of date. And although Abiword is found in the ~/mports/editors directory, it seems it’s not available for installation. Even after installing OpenOffice 3, it errors out with an Exec format error. In other words, you won’t be doing much in the way of office productivity with MidnightBSD. But, hey, if you have an old Palm Pilot lying around, you can always install pilot-link. In other words, the available software doesn’t make for an incredibly useful desktop distribution… at least not for the average user. However, if you want to develop on MidnightBSD, you’ll find plenty of available tools, ready to install (check out the ~/mports/devel directory). You could even install Drupal with the command: + +sudo mport install drupal7 + +Of course, after that you’ll need to create a database (MySQL is already installed), install Apache (sudo mport install apache24) and configure the necessary Apache directives. + +Clearly, what is installed and what can be installed is a bit of a hodgepodge of applications, systems, and servers. But with enough work, you could wind up with a distribution that could serve a specific purpose. + +### Enjoy the *BSD Goodness + +And that is how you can get MidnightBSD up and running into a somewhat useful desktop distribution. It’s not as quick and easy as many other Linux distributions, but if you want a distribution that’ll make you think, this could be exactly what you’re looking for. Although much of the competition has quite a bit more available software titles ready for installation, MidnightBSD is certainly an interesting challenge that every Linux enthusiast or admin should try. + +Learn more about Linux through the free ["Introduction to Linux" ][15]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +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) +译者:[译者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://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]:/files/images/midnight1jpg +[7]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/midnight_1.jpg?itok=BRfGIEk_ (MidnightBSD installer) +[8]:/licenses/category/used-permission +[9]:/files/images/midnight2jpg +[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/midnight_2.jpg?itok=xhxHlNJr (Adding a user) +[11]:/files/images/midnight4jpg +[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/midnight_4.jpg?itok=DNqA47s_ ( Xfce) +[13]:/files/images/midnight5jpg +[14]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/midnight_5.jpg?itok=LpavDHQP (applications) +[15]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 99b7ff560876dd6b86c85acde171d5ed66ae83e6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 14:50:24 +0800 Subject: [PATCH 057/111] PRF:20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md @Dotcra --- ...sh Scripts Way More Robust And Reliable.md | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/translated/tech/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md b/translated/tech/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md index b70bf03f54..18cc5179bc 100644 --- a/translated/tech/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md +++ b/translated/tech/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md @@ -1,7 +1,7 @@ -"Exit Traps" 让你的 Bash 脚本更稳固可靠 +“Exit Trap” 让你的 Bash 脚本更稳固可靠 ============================================================ -有个简单实用的方针可以让你的 bash 脚本更稳健 -- 确保总是执行必要的收尾工作,哪怕是在发生异常的时候。要做到这一点,秘诀就是 bash 提供的一个叫做 EXIT 的伪信号,你可以 trap 它,当脚本因为任何原因退出时,相应的命令或函数就会执行。我们来看看它是如何工作的。 +有个简单实用的技巧可以让你的 bash 脚本更稳健 -- 确保总是执行必要的收尾工作,哪怕是在发生异常的时候。要做到这一点,秘诀就是 bash 提供的一个叫做 EXIT 的伪信号,你可以 [trap][1] 它,当脚本因为任何原因退出时,相应的命令或函数就会执行。我们来看看它是如何工作的。 基本的代码结构看起来像这样: @@ -13,7 +13,7 @@ function finish { trap finish EXIT ``` -你可以把任何你觉得务必要运行的代码放在这个 "finish" 函数里。一个很好的例子是:创建一个临时目录,事后再删除它。 +你可以把任何你觉得务必要运行的代码放在这个 `finish` 函数里。一个很好的例子是:创建一个临时目录,事后再删除它。 ``` #!/bin/bash @@ -24,10 +24,10 @@ function finish { trap finish EXIT ``` -这样,在你的核心代码中,你就可以在这个 `$scratch` 目录里下载、生成、操作中间或临时数据了。[[1]][2] +这样,在你的核心代码中,你就可以在这个 `$scratch` 目录里下载、生成、操作中间或临时数据了。^[注1][2] ``` -# 下载所有版本的 linux 内核…… 为了科学! +# 下载所有版本的 linux 内核…… 为了科学研究! for major in {1..4}; do for minor in {0..99}; do for patchlevel in {0..99}; do @@ -45,7 +45,7 @@ cp "$scratch/frankenstein-linux.tar.bz2" "$1" # 脚本结束, scratch 目录自动被删除 ``` -比较一下如果不用 trap ,你是怎么删除 scratch 目录的: +比较一下如果不用 `trap` ,你是怎么删除 `scratch` 目录的: ``` #!/bin/bash @@ -61,11 +61,10 @@ rm -rf "$scratch" 这有什么问题么?很多: -* 如果运行出错导致脚本提前退出, scratch 目录及里面的内容不会被删除。这会导致资料泄漏,可能引发安全问题。 +* 如果运行出错导致脚本提前退出, `scratch` 目录及里面的内容不会被删除。这会导致资料泄漏,可能引发安全问题。 +* 如果这个脚本的设计初衷就是在脚本末尾以前退出,那么你必须手动复制粘贴 `rm` 命令到每一个出口。 -* 如果这个脚本的设计初衷就是在末尾以前退出,那么你必须手动复制粘贴 rm 命令到每一个出口。 - -* 这也给维护带来了麻烦。如果今后在脚本某处添加了一个 exit ,你很可能就忘了加上删除操作 -- 从而制造潜在的安全漏洞。 +* 这也给维护带来了麻烦。如果今后在脚本某处添加了一个 `exit` ,你很可能就忘了加上删除操作 -- 从而制造潜在的安全漏洞。 ### 无论如何,服务要在线 @@ -93,28 +92,25 @@ function finish { trap finish EXIT # 关闭 mongod 服务 sudo service mongdb stop -# (如果 mongod 配置了 fork ,比如 replica set ,你可能需要执行 "sudo killall --wait /usr/bin/mongod") +# (如果 mongod 配置了 fork ,比如 replica set ,你可能需要执行 “sudo killall --wait /usr/bin/mongod”) ``` ### 控制开销 -有一种情况特别能体现 EXIT trap 的价值:你要在脚本运行过程中创建一些临时的付费资源,结束时要确保把它们释放掉。比如你在 AWS (Amazon Web Services) 上工作,要在脚本中创建一个镜像。 +有一种情况特别能体现 EXIT `trap` 的价值:如果你的脚本运行过程中需要初始化一下成本高昂的资源,结束时要确保把它们释放掉。比如你在 AWS (Amazon Web Services) 上工作,要在脚本中创建一个镜像。 -(名词解释: 在亚马逊云上的运行的服务器叫实例。实例从镜像创建而来,镜像通常被称为 "AMIs" 或 "images" 。AMI 相当于某个特殊时间点的服务器快照。) +(名词解释: 在亚马逊云上的运行的服务器叫“[实例][3]”。实例从亚马逊机器镜像Amazon Machine Image创建而来,通常被称为 “AMI” 或 “镜像” 。AMI 相当于某个特殊时间点的服务器快照。) 我们可以这样创建一个自定义的 AMI : -1. 基于一个基准 AMI 运行(创建)一个实例。 - +1. 基于一个基准 AMI 运行一个实例(例如,启动一个服务器)。 2. 在实例中手动或运行脚本来做一些修改。 - 3. 用修改后的实例创建一个镜像。 - 4. 如果不再需要这个实例,可以将其删除。 最后一步**相当重要**。如果你的脚本没有把实例删除掉,它会一直运行并计费。(到月底你的账单让你大跌眼镜时,恐怕哭都来不及了!) -如果把 AMI 的创建封装在脚本里,我们就可以利用 trap EXIT 来删除实例了。我们还可以用上 EC2 的命令行工具: +如果把 AMI 的创建封装在脚本里,我们就可以利用 `trap` EXIT 来删除实例了。我们还可以用上 EC2 的命令行工具: ``` #!/bin/bash @@ -137,7 +133,7 @@ ec2-run-instances "$ami" > "$scratch/run-instance" instance=$(grep '^INSTANCE' "$scratch/run-instance" | cut -f 2) ``` -脚本执行到这里,实例(EC2 服务器)已经开始运行 [[2]][4]。接下来你可以做任何事情:在实例中安装软件,修改配置文件等,然后为最终版本创建一个镜像。实例会在脚本结束时被删除 -- 即使脚本因错误而提前退出。(请确保实例创建成功后再运行业务代码。) +脚本执行到这里,实例(EC2 服务器)已经开始运行 ^[注2][4]。接下来你可以做任何事情:在实例中安装软件,修改配置文件等,然后为最终版本创建一个镜像。实例会在脚本结束时被删除 -- 即使脚本因错误而提前退出。(请确保实例创建成功后再运行业务代码。) ### 更多应用 @@ -145,22 +141,17 @@ instance=$(grep '^INSTANCE' "$scratch/run-instance" | cut -f 2) ### 尾注 -1. mktemp 的选项 "-t" 在 Linux 上可选,在 OS X 上必需。带上此选项可以让你的脚本有更好的可移植性。 +- 注1. `mktemp` 的选项 `-t` 在 Linux 上是可选的,在 OS X 上是必需的。带上此选项可以让你的脚本有更好的可移植性。 +- 注2. 如果只是为了获取实例 ID ,我们不用创建文件,直接写成 `instance=$(ec2-run-instances "$ami" | grep '^INSTANCE' | cut -f 2)` 就可以。但把输出写入文件可以记录更多有用信息,便于调试 ,代码可读性也更强。 -2. 如果只是为了获取实例 ID ,我们不用创建文件,直接写成 `instance=$(ec2-run-instances "$ami" | grep '^INSTANCE' | cut -f 2)` 就可以。但把输出写入文件可以记录更多有用信息,便于 debug ,代码可读性也更强。 +作者简介:美国加利福尼亚旧金山的作家,软件工程师,企业家。[Powerful Python][5] 的作者,他的 [blog][6]。 -------------------------------------------------------------------------------- - -作者简介: - -美国加利福尼亚旧金山的作家,软件工程师,企业家 - -Author of [Powerful Python][5] and its [blog][6]. via: http://redsymbol.net/articles/bash-exit-traps/ -作者:[aaron maxwell ][a] +作者:[aaron maxwell][a] 译者:[Dotcra](https://github.com/Dotcra) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 3b79b5ef81df57dfd989eb54d589111016022ceb Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 14:57:13 +0800 Subject: [PATCH 058/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Check?= =?UTF-8?q?=20Ubuntu=20Version=20and=20Other=20System=20Information=20Easi?= =?UTF-8?q?ly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ion and Other System Information Easily.md | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 sources/tech/20180508 How To Check Ubuntu Version and Other System Information Easily.md diff --git a/sources/tech/20180508 How To Check Ubuntu Version and Other System Information Easily.md b/sources/tech/20180508 How To Check Ubuntu Version and Other System Information Easily.md new file mode 100644 index 0000000000..9395b7708a --- /dev/null +++ b/sources/tech/20180508 How To Check Ubuntu Version and Other System Information Easily.md @@ -0,0 +1,127 @@ +How To Check Ubuntu Version and Other System Information Easily +====== +**Brief: Wondering which Ubuntu version are you using? Here’s how to check Ubuntu version, desktop environment and other relevant system information.** + +You can easily find the Ubuntu version you are using in the command line or via the graphical interface. Knowing the exact Ubuntu version, desktop environment and other system information helps a lot when you are trying to follow a tutorial from the web or seeking help in various forums. + +In this quick tip, I’ll show you various ways to check [Ubuntu][1] version and other common system information. + +### How to check Ubuntu version in terminal + +This is the best way to find Ubuntu version. I could have mentioned the graphical way first but then I chose this method because this one doesn’t depend on the [desktop environment][2] you are using. You can use it on any Ubuntu variant. + +Open a terminal (Ctrl+Alt+T) and type the following command: +``` +lsb_release -a + +``` + +The output of the above command should be like this: +``` +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 16.04.4 LTS +Release: 16.04 +Codename: xenial + +``` + +![How to check Ubuntu version in command line][3] + +As you can see, the current Ubuntu installed in my system is Ubuntu 16.04 and its code name is Xenial. + +Wait! Why does it say Ubuntu 16.04.4 in Description and 16.04 in the Release? Which one is it, 16.04 or 16.04.4? What’s the difference between the two? + +The short answer is that you are using Ubuntu 16.04. That’s the base image. 16.04.4 signifies the fourth point release of 16.04. A point release can be thought of as a service pack in Windows era. Both 16.04 and 16.04.4 will be the correct answer here. + +What’s Xenial in the output? That’s the codename of the Ubuntu 16.04 release. You can read this [article to know about Ubuntu naming convention][4]. + +#### Some alternate ways to find Ubuntu version + +Alternatively, you can use either of the following commands to find Ubuntu version: +``` +cat /etc/lsb-release + +``` + +The output of the above command would look like this: +``` +DISTRIB_ID=Ubuntu +DISTRIB_RELEASE=16.04 +DISTRIB_CODENAME=xenial +DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS" + +``` + +![How to check Ubuntu version in command line][5] + +You can also use this command to know Ubuntu version +``` +cat /etc/issue + +``` + +The output of this command will be like this: +``` +Ubuntu 16.04.4 LTS \n \l + +``` + +Forget the \n \l. The Ubuntu version is 16.04.4 in this case or simply Ubuntu 16.04. + +### How to check Ubuntu version graphically + +Checking Ubuntu version graphically is no big deal either. I am going to use screenshots from Ubuntu 18.04 GNOME here. Things may look different if you are using Unity or some other desktop environment. This is why I recommend the command line version discussed in the previous sections because that doesn’t depend on the desktop environment. + +I’ll show you how to find the desktop environment in the next section. + +For now, go to System Settings and look under the Details segment. + +![Finding Ubuntu version graphically][6] + +You should see the Ubuntu version here along with the information about the desktop environment you are using, [GNOME][7] being the case here. + +![Finding Ubuntu version graphically][8] + +### How to know the desktop environment and other system information in Ubuntu + +So you just learned how to find Ubuntu version. What about the desktop environment in use? Which Linux kernel version is being used? + +Of course, there are various commands you can use to get all those information but I’ll recommend a command line utility called [Neofetch][9]. This will show you essential system information in the terminal beautifully with the logo of Ubuntu or any other Linux distribution you are using. + +Install Neofetch using the command below: +``` +sudo apt install neofetch + +``` + +Once installed, simply run the command `neofetch` in the terminal and see a beautiful display of system information. + +![System information in Linux terminal][10] + +As you can see, Neofetch shows you the Linux kernel version, Ubuntu version, desktop environment in use along with its version, themes and icons in use etc. + +I hope it helps you to find Ubuntu version and other system information. If you have suggestions to improve this article, feel free to drop it in the comment section. Ciao :) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/how-to-know-ubuntu-unity-version/ + +作者:[Abhishek Prakash][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://itsfoss.com/author/abhishek/ +[1]:https://www.ubuntu.com/ +[2]:https://en.wikipedia.org/wiki/Desktop_environment +[3]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2013/03/check-ubuntu-version-command-line-1-800x216.jpeg +[4]:https://itsfoss.com/linux-code-names/ +[5]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2013/03/check-ubuntu-version-command-line-2-800x185.jpeg +[6]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2013/03/ubuntu-version-system-settings.jpeg +[7]:https://www.gnome.org/ +[8]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2013/03/checking-ubuntu-version-gui.jpeg +[9]:https://itsfoss.com/display-linux-logo-in-ascii/ +[10]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2013/03/ubuntu-system-information-terminal-800x400.jpeg From b7c23a890bcadb2c80a23a9803d1adad62402992 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 14:59:36 +0800 Subject: [PATCH 059/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20kill?= =?UTF-8?q?=20a=20process=20or=20stop=20a=20program=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ll a process or stop a program in Linux.md | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 sources/tech/20180509 How to kill a process or stop a program in Linux.md diff --git a/sources/tech/20180509 How to kill a process or stop a program in Linux.md b/sources/tech/20180509 How to kill a process or stop a program in Linux.md new file mode 100644 index 0000000000..71cefdd8f4 --- /dev/null +++ b/sources/tech/20180509 How to kill a process or stop a program in Linux.md @@ -0,0 +1,121 @@ +How to kill a process or stop a program in Linux +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/x_stop_terminate_program_kill.jpg?itok=9rM8i9x8) +When a process misbehaves, you might sometimes want to terminate or kill it. In this post, we'll explore a few ways to terminate a process or an application from the command line as well as from a graphical interface, using [gedit][1] as a sample application. + +### Using the command line/termination characters + +#### Ctrl + C + +One problem invoking `gedit` from the command line (if you are not using `gedit &`) is that it will not free up the prompt, so that shell session is blocked. In such cases, Ctrl+C (the Control key in combination with 'C') comes in handy. That will terminate `gedit` and all work will be lost (unless the file was saved). Ctrl+C sends the `SIGINT` signal to `gedit`. This is a stop signal whose default action is to terminate the process. It instructs the shell to stop `gedit` and return to the main loop, and you'll get the prompt back. +``` +$ gedit + +^C + +``` + +#### Ctrl + Z + +This is called a suspend character. It sends a `SIGTSTP` signal to process. This is also a stop signal, but the default action is not to kill but to suspend the process. + +It will stop (kill/terminate) `gedit` and return the shell prompt. +``` +   $ gedit + +   ^Z + +   [1]+  Stopped                 gedit + +   $ + +``` + +Once the process is suspended (in this case, `gedit`), it is not possible to write or do anything in `gedit`. In the background, the process becomes a job. This can be verified by the `jobs` command. +``` +  $ jobs + +  [1]+  Stopped                 gedit + +``` + +`jobs` allows you to control multiple processes within a single shell session. You can stop, resume, and move jobs to the background or foreground as needed. + +Let's resume `gedit` in the background and free up a prompt to run other commands. You can do this using the `bg` command, followed by job ID (notice `[1]` from the output of `jobs` above. `[1]` is the job ID). +``` +   $ bg 1 + +   [1]+ gedit & + +``` + +This is similar to starting `gedit` with `&,`: +``` +   $ gedit & + +``` + +### Using kill + +`kill` allows fine control over signals, enabling you to signal a process by specifying either a signal name or a signal number, followed by a process ID, or PID. + +What I like about `kill` is that it can also work with job IDs. Let's start `gedit` in the background using `gedit &`. Assuming I have a job ID of `gedit` from the `jobs` command, let's send `SIGINT` to `gedit`: +``` +   $ kill -s SIGINT %1 + +``` + +Note that the job ID should be prefixed with `%`, or `kill` will consider it a PID. + +`kill` can work without specifying a signal explicitly. In that case, the default action is to send `SIGTERM`, which will terminate the process. Execute `kill -l` to list all signal names, and use the `man kill` command to read the man page. + +### Using killall + +If you don't want to specify a job ID or PID, `killall` lets you specify a process by name. The simplest way to terminate `gedit` using `killall` is: +``` +   $ killall gedit + +``` + +This will kill all the processes with the name `gedit`. Like `kill`, the default signal is `SIGTERM`. It has the option to ignore case using `-I`: +``` +   $ gedit & + +   [1] 14852 + + + +   $ killall -I GEDIT + +   [1]+  Terminated              gedit + +``` + +To learn more about various flags provided by `killall` (such as `-u`, which allows you to kill user-owned processes) check the man page (`man killall`) + +### Using xkill + +Have you ever encountered an issue where a media player, such as [VLC][2], grayed out or hung? Now you can find the PID and kill the application using one of the commands listed above or use `xkill`. + +![Using xkill][3] + +`xkill` allows you to kill a window using a mouse. Simply execute `xkill` in a terminal, which should change the mouse cursor to an **x** or a tiny skull icon. Click **x** on the window you want to close. Be careful using `xkill`, though—as its man page explains, it can be dangerous. You have been warned! + +Refer to the man page of each command for more information. You can also explore commands like `pkill` and `pgrep`. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/how-kill-process-stop-program-linux + +作者:[Sachin Patil][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/psachin +[1]:https://wiki.gnome.org/Apps/Gedit +[2]:https://www.videolan.org/vlc/index.html +[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/xkill_gedit.png?itok=TBvMw0TN (Using xkill) From 41843e10730c6b998b52eb35eb3b005c945eda7a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 15:03:35 +0800 Subject: [PATCH 060/111] PUB:20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md @Dotcra https://linux.cn/article-9639-1.html --- ...aps Can Make Your Bash Scripts Way More Robust And Reliable.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md (100%) diff --git a/translated/tech/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md b/published/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md similarity index 100% rename from translated/tech/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md rename to published/20180101 How Exit Traps Can Make Your Bash Scripts Way More Robust And Reliable.md From 15782dc062bffbf00a464155ec6390fb8b3f7c4f Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 15:10:11 +0800 Subject: [PATCH 061/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=2011=20Methods=20To?= =?UTF-8?q?=20Find=20System/Server=20Uptime=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...s To Find System-Server Uptime In Linux.md | 193 ++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 sources/tech/20180503 11 Methods To Find System-Server Uptime In Linux.md diff --git a/sources/tech/20180503 11 Methods To Find System-Server Uptime In Linux.md b/sources/tech/20180503 11 Methods To Find System-Server Uptime In Linux.md new file mode 100644 index 0000000000..7a30127b07 --- /dev/null +++ b/sources/tech/20180503 11 Methods To Find System-Server Uptime In Linux.md @@ -0,0 +1,193 @@ +11 Methods To Find System/Server Uptime In Linux +====== +Do you want to know, how long your Linux system has been running without downtime? when the system is up and what date. + +There are multiple commands is available in Linux to check server/system uptime and most of users prefer the standard and very famous command called `uptime` to get this details. + +Server uptime is not important for some people but it’s very important for server administrators when the server running with mission-critical applications such as online shopping portal, netbanking portal, etc,. + +It must be zero downtime because if there is a down time then it will impact badly to million users. + +As i told, many commands are available to check server uptime in Linux. In this tutorial we are going teach you how to check this using below 11 methods. + +Uptime means how long the server has been up since its last shutdown or reboot. + +The uptime command the fetch the details from `/proc` files and print the server uptime, the `/proc` file is not directly readable by humans. + +The below commands will print how long the system has been running and up. It also shows some additional information. + +### Method-1 : Using uptime Command + +uptime command will tell how long the system has been running. It gives a one line display of the following information. + +The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes. +``` +# uptime + + 08:34:29 up 21 days, 5:46, 1 user, load average: 0.06, 0.04, 0.00 + +``` + +### Method-2 : Using w Command + +w command provides a quick summary of every user logged into a computer, what each user is currently doing, +and what load all the activity is imposing on the computer itself. The command is a one-command combination of several other Unix programs: who, uptime, and ps -a. +``` +# w + + 08:35:14 up 21 days, 5:47, 1 user, load average: 0.26, 0.09, 0.02 +USER TTY FROM [email protected] IDLE JCPU PCPU WHAT +root pts/1 103.5.134.167 08:34 0.00s 0.01s 0.00s w + +``` + +### Method-3 : Using top Command + +Top command is one of the basic command to monitor real-time system processes in Linux. It display system information and running processes information like uptime, average load, tasks running, number of users logged in, number of CPUs & cpu utilization, Memory & swap information. Run top command then hit E to bring the memory utilization in MB. + +**Suggested Read :** [TOP Command Examples to Monitor Server Performance][1] +``` +# top -c + +top - 08:36:01 up 21 days, 5:48, 1 user, load average: 0.12, 0.08, 0.02 +Tasks: 98 total, 1 running, 97 sleeping, 0 stopped, 0 zombie +Cpu(s): 0.0%us, 0.3%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st +Mem: 1872888k total, 1454644k used, 418244k free, 175804k buffers +Swap: 2097148k total, 0k used, 2097148k free, 1098140k cached + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 1 root 20 0 19340 1492 1172 S 0.0 0.1 0:01.04 /sbin/init + 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kthreadd] + 3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 [migration/0] + 4 root 20 0 0 0 0 S 0.0 0.0 0:34.32 [ksoftirqd/0] + 5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 [stopper/0] + +``` + +### Method-4 : Using who Command + +who command displays a list of users who are currently logged into the computer. The who command is related to the command w, which provides the same information but also displays additional data and statistics. +``` +# who -b + +system boot 2018-04-12 02:48 + +``` + +### Method-5 : Using last Command + +The last command displays a list of last logged in users. Last searches back through the file /var/log/wtmp and displays a list of all users logged in (and out) since that file was created. +``` +# last reboot -F | head -1 | awk '{print $5,$6,$7,$8,$9}' + +Thu Apr 12 02:48:04 2018 + +``` + +### Method-6 : Using /proc/uptime File + +This file contains information detailing how long the system has been on since its last restart. The output of `/proc/uptime` is quite minimal. + +The first number is the total number of seconds the system has been up. The second number is how much of that time the machine has spent idle, in seconds. +``` +# cat /proc/uptime + +1835457.68 1809207.16 + +``` + +# date -d “$(Method-7 : Using tuptime Command + +Tuptime is a tool for report the historical and statistical running time of the system, keeping it between restarts. Like uptime command but with more interesting output. +``` +$ tuptime + +``` + +### Method-8 : Using htop Command + +htop is an interactive process viewer for Linux which was developed by Hisham using ncurses library. Htop have many of features and options compared to top command. + +**Suggested Read :** [Monitor system resources using Htop command][2] +``` +# htop + + CPU[| 0.5%] Tasks: 48, 5 thr; 1 running + Mem[||||||||||||||||||||||||||||||||||||||||||||||||||| 165/1828MB] Load average: 0.10 0.05 0.01 + Swp[ 0/2047MB] Uptime: 21 days, 05:52:35 + + PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command +29166 root 20 0 110M 2484 1240 R 0.0 0.1 0:00.03 htop +29580 root 20 0 11464 3500 1032 S 0.0 0.2 55:15.97 /bin/sh ./OSWatcher.sh 10 1 + 1 root 20 0 19340 1492 1172 S 0.0 0.1 0:01.04 /sbin/init + 486 root 16 -4 10780 900 348 S 0.0 0.0 0:00.07 /sbin/udevd -d + 748 root 18 -2 10780 932 360 S 0.0 0.0 0:00.00 /sbin/udevd -d + +``` + +### Method-9 : Using glances Command + +Glances is a cross-platform curses-based system monitoring tool written in Python. We can say all in one place, like maximum of information in a minimum of space. It uses psutil library to get information from your system. + +Glances capable to monitor CPU, Memory, Load, Process list, Network interface, Disk I/O, Raid, Sensors, Filesystem (and folders), Docker, Monitor, Alert, System info, Uptime, Quicklook (CPU, MEM, LOAD), etc,. + +**Suggested Read :** [Glances (All in one Place)– An Advanced Real Time System Performance Monitoring Tool for Linux][3] +``` +glances + +ubuntu (Ubuntu 17.10 64bit / Linux 4.13.0-37-generic) - IP 192.168.1.6/24 Uptime: 21 days, 05:55:15 + +CPU [|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 90.6%] CPU - 90.6% nice: 0.0% ctx_sw: 4K MEM \ 78.4% active: 942M SWAP - 5.9% LOAD 2-core +MEM [||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 78.0%] user: 55.1% irq: 0.0% inter: 1797 total: 1.95G inactive: 562M total: 12.4G 1 min: 4.35 +SWAP [|||| 5.9%] system: 32.4% iowait: 1.8% sw_int: 897 used: 1.53G buffers: 14.8M used: 749M 5 min: 4.38 + idle: 7.6% steal: 0.0% free: 431M cached: 273M free: 11.7G 15 min: 3.38 + +NETWORK Rx/s Tx/s TASKS 211 (735 thr), 4 run, 207 slp, 0 oth sorted automatically by memory_percent, flat view +docker0 0b 232b +enp0s3 12Kb 4Kb Systemd 7 Services loaded: 197 active: 196 failed: 1 +lo 616b 616b +_h478e48e 0b 232b CPU% MEM% VIRT RES PID USER NI S TIME+ R/s W/s Command + 63.8 18.9 2.33G 377M 2536 daygeek 0 R 5:57.78 0 0 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51 +DefaultGateway 83ms 78.5 10.9 3.46G 217M 2039 daygeek 0 S 21:07.46 0 0 /usr/bin/gnome-shell + 8.5 10.1 2.32G 201M 2464 daygeek 0 S 8:45.69 0 0 /usr/lib/firefox/firefox -new-window +DISK I/O R/s W/s 1.1 8.5 2.19G 170M 2653 daygeek 0 S 2:56.29 0 0 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51 +dm-0 0 0 1.7 7.2 2.15G 143M 2880 daygeek 0 S 7:10.46 0 0 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51 +sda1 9.46M 12K 0.0 4.9 1.78G 97.2M 6125 daygeek 0 S 1:36.57 0 0 /usr/lib/firefox/firefox -contentproc -childID 7 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51 + +``` + +### Method-10 : Using stat Command + +stat command displays the detailed status of a particular file or a file system. +``` +# stat /var/log/dmesg | grep Modify + +Modify: 2018-04-12 02:48:04.027999943 -0400 + +``` + +### Method-11 : Using procinfo Command + +procinfo gathers some system data from the /proc directory and prints it nicely formatted on the standard output device. +``` +# procinfo | grep Bootup + +Bootup: Fri Apr 20 19:40:14 2018 Load average: 0.16 0.05 0.06 1/138 16615 + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/11-methods-to-find-check-system-server-uptime-in-linux/ + +作者:[Magesh Maruthamuthu][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.2daygeek.com/author/magesh/ +[1]:https://www.2daygeek.com/top-command-examples-to-monitor-server-performance/ +[2]:https://www.2daygeek.com/htop-command-examples-to-monitor-system-resources/ +[3]:https://www.2daygeek.com/install-glances-advanced-real-time-linux-system-performance-monitoring-tool-on-centos-fedora-ubuntu-debian-opensuse-arch-linux/ From 5f81999de7a836021afa7b7a56d4ce8e06469490 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 15:17:45 +0800 Subject: [PATCH 062/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Looking=20at=20th?= =?UTF-8?q?e=20Lispy=20side=20of=20Perl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80511 Looking at the Lispy side of Perl.md | 357 ++++++++++++++++++ 1 file changed, 357 insertions(+) create mode 100644 sources/tech/20180511 Looking at the Lispy side of Perl.md diff --git a/sources/tech/20180511 Looking at the Lispy side of Perl.md b/sources/tech/20180511 Looking at the Lispy side of Perl.md new file mode 100644 index 0000000000..1fa51b314c --- /dev/null +++ b/sources/tech/20180511 Looking at the Lispy side of Perl.md @@ -0,0 +1,357 @@ +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 From e22dd3c3f20ec592d12e6ccc43b61d0f15eacc41 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 14 May 2018 15:34:37 +0800 Subject: [PATCH 063/111] fix tech/20180418 Getting started with Anaconda Python for data science.md --- ...8 Getting started with Anaconda Python for data science.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sources/tech/20180418 Getting started with Anaconda Python for data science.md b/sources/tech/20180418 Getting started with Anaconda Python for data science.md index fa55edc325..063324c284 100644 --- a/sources/tech/20180418 Getting started with Anaconda Python for data science.md +++ b/sources/tech/20180418 Getting started with Anaconda Python for data science.md @@ -26,9 +26,7 @@ $ bash Anaconda3-5.1.0-Linux-x86_64.sh ``` -`/home//.bashrc`?" I allowed it and restarted the shell, which I found was necessary for the `.bashrc` environment to work correctly. - -I followed the installation directions exactly, and the well-scripted install took about five minutes to complete. When the installation prompted: "Do you wish the installer to prepend the Anaconda install location to PATH in your?" I allowed it and restarted the shell, which I found was necessary for theenvironment to work correctly. +I followed the installation directions exactly, and the well-scripted install took about five minutes to complete. When the installation prompted: "Do you wish the installer to prepend the Anaconda install location to PATH in your `/home//.bashrc`?" I allowed it and restarted the shell, which I found was necessary for the `.bashrc` environment to work correctly. After completing the install, I launched Anaconda Navigator by entering the following at the command prompt in the shell: ``` From a45195afa3fcc59c47d6db6ad3d27de8844e6dec Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 15:48:27 +0800 Subject: [PATCH 064/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Orbital=20Apps=20?= =?UTF-8?q?=E2=80=93=20A=20New=20Generation=20Of=20Linux=20applications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... A New Generation Of Linux applications.md | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md diff --git a/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md b/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md new file mode 100644 index 0000000000..ada15d4ddd --- /dev/null +++ b/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md @@ -0,0 +1,91 @@ +Orbital Apps – A New Generation Of Linux applications +====== + +![](https://www.ostechnix.com/wp-content/uploads/2016/05/orbital-apps-720x340.jpg) + +Today, we are going to learn about **Orbital Apps** or **ORB** ( **O** pen **R** unnable **B** undle) **apps** , a collection of free, cross-platform, open source applications. All ORB apps are portable. You can either install them on your Linux system or on your USB drive, so that you you can use the same app on any system. There is no need of root privileges, and there are no dependencies. All required dependencies are included in the apps. Just copy the ORB apps to your USB drive and plug it on any Linux system, and start using them in no time. All settings and configurations, and data of the apps will be stored on the USB drive. Since there is no need to install the apps on the local drive, we can run the apps either in online or offline computers. That means we don’t need Internet to download any dependencies. + +ORB apps are compressed up to 60% smaller, so we can store and use them even from the small sized USB drives. All ORB apps are signed with PGP/RSA and distributed via TLS 1.2. All Applications are packaged without any modifications, they are not even re-compiled. Here is the list of currently available portable ORB applications. + + * abiword + * audacious + * audacity + * darktable + * deluge + * filezilla + * firefox + * gimp + * gnome-mplayer + * hexchat + * inkscape + * isomaster + * kodi + * libreoffice + * qbittorrent + * sound-juicer + * thunderbird + * tomahawk + * uget + * vlc + * And more yet to come. + + + +Orb is open source, so If you’re a developer, feel free to collaborate and add more applications. + +### Download and use portable ORB apps + +As I mentioned already, we don’t need to install portable ORB apps. However, ORB team strongly recommends you to use **ORB launcher** to get better experience. ORB launcher is a small installer file (less than 5MB) that will help you to launch the ORB apps with better and smoother experience. + +Let us install ORB launcher first. To do so, [**download the ORB launcher**][1]. You can manually download ORB launcher ISO and mount it on your file manager. Or run any one of the following command in Terminal to install it: +``` +$ wget -O - https://www.orbital-apps.com/orb.sh | bash + +``` + +If you don’t have wget, run: +``` +$ curl https://www.orbital-apps.com/orb.sh | bash + +``` + +Enter the root user password when it asked. + +That’s it. Orbit launcher is installed and ready to use. + +Now, go to the [**ORB portable apps download page**][2], and download the apps of your choice. For the purpose of this tutorial, I am going to download Firefox application. + +Once you downloaded the package, go to the download location and double click ORB app to launch it. Click Yes to confirm. + +![][4] + +Firefox ORB application in action! + +![][5] + +Similarly, you can download and run any applications instantly. + +If you don’t want to use ORB launcher, make the downloaded .orb installer file as executable and double click it to install. However, ORB launcher is recommended and it gives you easier and smoother experience while using orb apps. + +As far as I tested ORB apps, they worked just fine out of the box. Hope this helps. And, that’s all for now. Have a good day! + +Cheers!! + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/orbitalapps-new-generation-ubuntu-linux-applications/ + +作者:[SK][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.ostechnix.com/author/sk/ +[1]:https://www.orbital-apps.com/documentation/orb-launcher-all-installers +[2]:https://www.orbital-apps.com/download/portable_apps_linux/ +[3]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[4]:http://www.ostechnix.com/wp-content/uploads/2016/05/orbital-apps-1-2.png +[5]:http://www.ostechnix.com/wp-content/uploads/2016/05/orbital-apps-2.png From d39c29ee8d9d299f8cb0c28f861d152a8e2b8777 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 15:49:43 +0800 Subject: [PATCH 065/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20UKTools=20-=20Eas?= =?UTF-8?q?y=20Way=20To=20Install=20Latest=20Linux=20Kernel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Easy Way To Install Latest Linux Kernel.md | 419 ++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 sources/tech/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md diff --git a/sources/tech/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md b/sources/tech/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md new file mode 100644 index 0000000000..c85d9c35d4 --- /dev/null +++ b/sources/tech/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md @@ -0,0 +1,419 @@ +UKTools - Easy Way To Install Latest Linux Kernel +====== +There are multiple utilities is available for Ubuntu to upgrade Linux kernel to latest stable version. We had already wrote about those utility in the past such as Linux Kernel Utilities (LKU), Ubuntu Kernel Upgrade Utility (UKUU) and Ubunsys. + +Also few utilities are available and we will be planning to include in the further article like, ubuntu-mainline-kernel.sh and manual method from mainline kernel. + +Today also we are going to teach you the similar utility called UKTools. You can try any one of these utilities to get your Linux kernels to the latest releases. + +Latest kernel release comes with security bug fixes and some improvements so, better to keep latest one to get reliable, secure and better hardware performance. + +Some times the latest kernel version might be buggy and can crash your system so, it’s your own risk. I would like to advise you to not to install on production environment. + +**Suggested Read :** +**(#)** [Linux Kernel Utilities (LKU) – A Set Of Shell Scripts To Compile, Install & Update Latest Kernel In Ubuntu/LinuxMint][1] +**(#)** [Ukuu – An Easy Way To Install/Upgrade Linux Kernel In Ubuntu based Systems][2] +**(#)** [6 Methods To Check The Running Linux Kernel Version On System][3] + +### What Is UKTools + +[UKTools][4] stands for Ubuntu Kernel Tools, that contains two shell scripts `ukupgrade` and `ukpurge`. + +ukupgrade stands for “Ubuntu Kernel Upgrade”, which allows user to upgrade Linux kernel to latest stable version for Ubuntu/Mint and derivatives based on [kernel.ubuntu.com][5]. + +ukpurge stands for “Ubuntu Kernel Purge”, which allows user to remove old Linux kernel images/headers in machine for Ubuntu/ Mint and derivatives. It will keep only three kernel versions. + +There is no GUI for this utility, however it looks very simple and straight forward so, newbie can perform the upgrade without any issues. + +I’m running Ubuntu 17.10 and the current kernel version is below. +``` +$ uname -a +Linux ubuntu 4.13.0-39-generic #44-Ubuntu SMP Thu Apr 5 14:25:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux + +``` + +Run the following command to get the list of installed kernel on your system (Ubuntu and derivatives). Currently i’m holding `seven` kernels. +``` +$ dpkg --list | grep linux-image +ii linux-image-4.13.0-16-generic 4.13.0-16.19 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-4.13.0-17-generic 4.13.0-17.20 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-4.13.0-32-generic 4.13.0-32.35 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-4.13.0-36-generic 4.13.0-36.40 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-4.13.0-37-generic 4.13.0-37.42 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-4.13.0-38-generic 4.13.0-38.43 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-4.13.0-39-generic 4.13.0-39.44 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-16-generic 4.13.0-16.19 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-17-generic 4.13.0-17.20 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-32-generic 4.13.0-32.35 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-36-generic 4.13.0-36.40 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-37-generic 4.13.0-37.42 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-38-generic 4.13.0-38.43 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-39-generic 4.13.0-39.44 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-generic 4.13.0.39.42 amd64 Generic Linux kernel image + +``` + +### How To Install UKTools + +Just run the below commands to install UKTools on Ubuntu and derivatives. + +Run the below command to clone UKTools repository on your system. +``` +$ git clone https://github.com/usbkey9/uktools + +``` + +Navigate to uktools directory. +``` +$ cd uktools + +``` + +Run the Makefile to generate the necessary files. Also this will automatically install latest available kernel. Just reboot the system in order to use the latest kernel. +``` +$ sudo make +[sudo] password for daygeek: +Creating the directories if neccessary +Linking profile.d file for reboot message +Linking files to global sbin directory +Ubuntu Kernel Upgrade - by Mustafa Hasturk +------------------------------------------ +This script is based on the work of Mustafa Hasturk and was reworked by +Caio Oliveira and modified and fixed by Christoph Kepler + +Current Development and Maintenance by Christoph Kepler + +Do you want the Stable Release (if not sure, press y)? (y/n): y +Do you want the Generic kernel? (y/n): y +Do you want to autoremove old kernel? (y/n): y +no crontab for root +Do you want to update the kernel automatically? (y/n): y +Setup complete. Update the kernel right now? (y/n): y +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages were automatically installed and are no longer required: + linux-headers-4.13.0-16 linux-headers-4.13.0-16-generic linux-headers-4.13.0-17 linux-headers-4.13.0-17-generic linux-headers-4.13.0-32 linux-headers-4.13.0-32-generic linux-headers-4.13.0-36 + linux-headers-4.13.0-36-generic linux-headers-4.13.0-37 linux-headers-4.13.0-37-generic linux-image-4.13.0-16-generic linux-image-4.13.0-17-generic linux-image-4.13.0-32-generic linux-image-4.13.0-36-generic + linux-image-4.13.0-37-generic linux-image-extra-4.13.0-16-generic linux-image-extra-4.13.0-17-generic linux-image-extra-4.13.0-32-generic linux-image-extra-4.13.0-36-generic + linux-image-extra-4.13.0-37-generic +Use 'sudo apt autoremove' to remove them. +The following additional packages will be installed: + lynx-common +The following NEW packages will be installed: + lynx lynx-common +0 upgraded, 2 newly installed, 0 to remove and 71 not upgraded. +Need to get 1,498 kB of archives. +After this operation, 5,418 kB of additional disk space will be used. +Get:1 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 lynx-common all 2.8.9dev16-1 [873 kB] +Get:2 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 lynx amd64 2.8.9dev16-1 [625 kB] +Fetched 1,498 kB in 12s (120 kB/s) +Selecting previously unselected package lynx-common. +(Reading database ... 441037 files and directories currently installed.) +Preparing to unpack .../lynx-common_2.8.9dev16-1_all.deb ... +Unpacking lynx-common (2.8.9dev16-1) ... +Selecting previously unselected package lynx. +Preparing to unpack .../lynx_2.8.9dev16-1_amd64.deb ... +Unpacking lynx (2.8.9dev16-1) ... +Processing triggers for mime-support (3.60ubuntu1) ... +Processing triggers for doc-base (0.10.7) ... +Processing 1 added doc-base file... +Processing triggers for man-db (2.7.6.1-2) ... +Setting up lynx-common (2.8.9dev16-1) ... +Setting up lynx (2.8.9dev16-1) ... +update-alternatives: using /usr/bin/lynx to provide /usr/bin/www-browser (www-browser) in auto mode + +Cleaning old downloads in /tmp + +Downloading the kernel's components... +Checksum for linux-headers-4.16.7-041607-generic_4.16.7-041607.201805021131_amd64.deb succeed +Checksum for linux-image-unsigned-4.16.7-041607-generic_4.16.7-041607.201805021131_amd64.deb succeed +Checksum for linux-modules-4.16.7-041607-generic_4.16.7-041607.201805021131_amd64.deb succeed + +Downloading the shared kernel header... +Checksum for linux-headers-4.16.7-041607_4.16.7-041607.201805021131_all.deb succeed + +Installing Kernel and Headers... +Selecting previously unselected package linux-headers-4.16.7-041607. +(Reading database ... 441141 files and directories currently installed.) +Preparing to unpack .../linux-headers-4.16.7-041607_4.16.7-041607.201805021131_all.deb ... +Unpacking linux-headers-4.16.7-041607 (4.16.7-041607.201805021131) ... +Selecting previously unselected package linux-headers-4.16.7-041607-generic. +Preparing to unpack .../linux-headers-4.16.7-041607-generic_4.16.7-041607.201805021131_amd64.deb ... +Unpacking linux-headers-4.16.7-041607-generic (4.16.7-041607.201805021131) ... +Selecting previously unselected package linux-image-unsigned-4.16.7-041607-generic. +Preparing to unpack .../linux-image-unsigned-4.16.7-041607-generic_4.16.7-041607.201805021131_amd64.deb ... +Unpacking linux-image-unsigned-4.16.7-041607-generic (4.16.7-041607.201805021131) ... +Selecting previously unselected package linux-modules-4.16.7-041607-generic. +Preparing to unpack .../linux-modules-4.16.7-041607-generic_4.16.7-041607.201805021131_amd64.deb ... +Unpacking linux-modules-4.16.7-041607-generic (4.16.7-041607.201805021131) ... +Setting up linux-headers-4.16.7-041607 (4.16.7-041607.201805021131) ... +dpkg: dependency problems prevent configuration of linux-headers-4.16.7-041607-generic: + linux-headers-4.16.7-041607-generic depends on libssl1.1 (>= 1.1.0); however: + Package libssl1.1 is not installed. + +Setting up linux-modules-4.16.7-041607-generic (4.16.7-041607.201805021131) ... +Setting up linux-image-unsigned-4.16.7-041607-generic (4.16.7-041607.201805021131) ... +I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.13.0-39-generic +I: /initrd.img.old is now a symlink to boot/initrd.img-4.13.0-39-generic +I: /vmlinuz is now a symlink to boot/vmlinuz-4.16.7-041607-generic +I: /initrd.img is now a symlink to boot/initrd.img-4.16.7-041607-generic +Processing triggers for linux-image-unsigned-4.16.7-041607-generic (4.16.7-041607.201805021131) ... +/etc/kernel/postinst.d/initramfs-tools: +update-initramfs: Generating /boot/initrd.img-4.16.7-041607-generic +/etc/kernel/postinst.d/zz-update-grub: +Generating grub configuration file ... +Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. +Found linux image: /boot/vmlinuz-4.16.7-041607-generic +Found initrd image: /boot/initrd.img-4.16.7-041607-generic +Found linux image: /boot/vmlinuz-4.13.0-39-generic +Found initrd image: /boot/initrd.img-4.13.0-39-generic +Found linux image: /boot/vmlinuz-4.13.0-38-generic +Found initrd image: /boot/initrd.img-4.13.0-38-generic +Found linux image: /boot/vmlinuz-4.13.0-37-generic +Found initrd image: /boot/initrd.img-4.13.0-37-generic +Found linux image: /boot/vmlinuz-4.13.0-36-generic +Found initrd image: /boot/initrd.img-4.13.0-36-generic +Found linux image: /boot/vmlinuz-4.13.0-32-generic +Found initrd image: /boot/initrd.img-4.13.0-32-generic +Found linux image: /boot/vmlinuz-4.13.0-17-generic +Found initrd image: /boot/initrd.img-4.13.0-17-generic +Found linux image: /boot/vmlinuz-4.13.0-16-generic +Found initrd image: /boot/initrd.img-4.13.0-16-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +done + +Thanks for using this script! Hope it helped. +Give it a star: https://github.com/MarauderXtreme/uktools + +``` + +Restart the system to activate the latest kernel. +``` +$ sudo shutdown -r now + +``` + +Once the system back to up, re-check the kernel version. +``` +$ uname -a +Linux ubuntu 4.16.7-041607-generic #201805021131 SMP Wed May 2 15:34:55 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux + +``` + +This make command will drop the below files into `/usr/local/bin` directory. +``` +do-kernel-upgrade +do-kernel-purge + +``` + +To remove old kernels, run the following command. +``` +$ do-kernel-purge + +Ubuntu Kernel Purge - by Caio Oliveira + +This script will only keep three versions: the first and the last two, others will be purge + +---Current version: +Linux Kernel 4.16.7-041607 Generic (linux-image-4.16.7-041607-generic) + +---Versions to remove: +4.13.0-16 +4.13.0-17 +4.13.0-32 +4.13.0-36 +4.13.0-37 + +---Do you want to remove the old kernels/headers versions? (Y/n): y +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages were automatically installed and are no longer required: + linux-headers-4.13.0-17 linux-headers-4.13.0-17-generic linux-headers-4.13.0-32 linux-headers-4.13.0-32-generic linux-headers-4.13.0-36 linux-headers-4.13.0-36-generic linux-headers-4.13.0-37 + linux-headers-4.13.0-37-generic linux-image-4.13.0-17-generic linux-image-4.13.0-32-generic linux-image-4.13.0-36-generic linux-image-4.13.0-37-generic linux-image-extra-4.13.0-17-generic + linux-image-extra-4.13.0-32-generic linux-image-extra-4.13.0-36-generic linux-image-extra-4.13.0-37-generic +Use 'sudo apt autoremove' to remove them. +The following packages will be REMOVED: + linux-headers-4.13.0-16* linux-headers-4.13.0-16-generic* linux-image-4.13.0-16-generic* linux-image-extra-4.13.0-16-generic* +0 upgraded, 0 newly installed, 4 to remove and 71 not upgraded. +After this operation, 318 MB disk space will be freed. +(Reading database ... 465582 files and directories currently installed.) +Removing linux-headers-4.13.0-16-generic (4.13.0-16.19) ... +Removing linux-headers-4.13.0-16 (4.13.0-16.19) ... +Removing linux-image-extra-4.13.0-16-generic (4.13.0-16.19) ... +run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +update-initramfs: Generating /boot/initrd.img-4.13.0-16-generic +run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +run-parts: executing /etc/kernel/postinst.d/update-notifier 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +Generating grub configuration file ... +Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. +Found linux image: /boot/vmlinuz-4.16.7-041607-generic +Found initrd image: /boot/initrd.img-4.16.7-041607-generic +Found linux image: /boot/vmlinuz-4.13.0-39-generic +Found initrd image: /boot/initrd.img-4.13.0-39-generic +Found linux image: /boot/vmlinuz-4.13.0-38-generic +Found initrd image: /boot/initrd.img-4.13.0-38-generic +Found linux image: /boot/vmlinuz-4.13.0-37-generic +Found initrd image: /boot/initrd.img-4.13.0-37-generic +Found linux image: /boot/vmlinuz-4.13.0-36-generic +Found initrd image: /boot/initrd.img-4.13.0-36-generic +Found linux image: /boot/vmlinuz-4.13.0-32-generic +Found initrd image: /boot/initrd.img-4.13.0-32-generic +Found linux image: /boot/vmlinuz-4.13.0-17-generic +Found initrd image: /boot/initrd.img-4.13.0-17-generic +Found linux image: /boot/vmlinuz-4.13.0-16-generic +Found initrd image: /boot/initrd.img-4.13.0-16-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +done +Removing linux-image-4.13.0-16-generic (4.13.0-16.19) ... +Examining /etc/kernel/postrm.d . +run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +update-initramfs: Deleting /boot/initrd.img-4.13.0-16-generic +run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +Generating grub configuration file ... +Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. +Found linux image: /boot/vmlinuz-4.16.7-041607-generic +Found initrd image: /boot/initrd.img-4.16.7-041607-generic +Found linux image: /boot/vmlinuz-4.13.0-39-generic +Found initrd image: /boot/initrd.img-4.13.0-39-generic +Found linux image: /boot/vmlinuz-4.13.0-38-generic +Found initrd image: /boot/initrd.img-4.13.0-38-generic +Found linux image: /boot/vmlinuz-4.13.0-37-generic +Found initrd image: /boot/initrd.img-4.13.0-37-generic +Found linux image: /boot/vmlinuz-4.13.0-36-generic +Found initrd image: /boot/initrd.img-4.13.0-36-generic +Found linux image: /boot/vmlinuz-4.13.0-32-generic +Found initrd image: /boot/initrd.img-4.13.0-32-generic +Found linux image: /boot/vmlinuz-4.13.0-17-generic +Found initrd image: /boot/initrd.img-4.13.0-17-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +done +(Reading database ... 430635 files and directories currently installed.) +Purging configuration files for linux-image-extra-4.13.0-16-generic (4.13.0-16.19) ... +Purging configuration files for linux-image-4.13.0-16-generic (4.13.0-16.19) ... +Examining /etc/kernel/postrm.d . +run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic +Reading package lists... Done +Building dependency tree +Reading state information... Done +. +. +. +. +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages will be REMOVED: + linux-headers-4.13.0-37* linux-headers-4.13.0-37-generic* linux-image-4.13.0-37-generic* linux-image-extra-4.13.0-37-generic* +0 upgraded, 0 newly installed, 4 to remove and 71 not upgraded. +After this operation, 321 MB disk space will be freed. +(Reading database ... 325772 files and directories currently installed.) +Removing linux-headers-4.13.0-37-generic (4.13.0-37.42) ... +Removing linux-headers-4.13.0-37 (4.13.0-37.42) ... +Removing linux-image-extra-4.13.0-37-generic (4.13.0-37.42) ... +run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +update-initramfs: Generating /boot/initrd.img-4.13.0-37-generic +run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +run-parts: executing /etc/kernel/postinst.d/update-notifier 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +Generating grub configuration file ... +Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. +Found linux image: /boot/vmlinuz-4.16.7-041607-generic +Found initrd image: /boot/initrd.img-4.16.7-041607-generic +Found linux image: /boot/vmlinuz-4.13.0-39-generic +Found initrd image: /boot/initrd.img-4.13.0-39-generic +Found linux image: /boot/vmlinuz-4.13.0-38-generic +Found initrd image: /boot/initrd.img-4.13.0-38-generic +Found linux image: /boot/vmlinuz-4.13.0-37-generic +Found initrd image: /boot/initrd.img-4.13.0-37-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +done +Removing linux-image-4.13.0-37-generic (4.13.0-37.42) ... +Examining /etc/kernel/postrm.d . +run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +update-initramfs: Deleting /boot/initrd.img-4.13.0-37-generic +run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +Generating grub configuration file ... +Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. +Found linux image: /boot/vmlinuz-4.16.7-041607-generic +Found initrd image: /boot/initrd.img-4.16.7-041607-generic +Found linux image: /boot/vmlinuz-4.13.0-39-generic +Found initrd image: /boot/initrd.img-4.13.0-39-generic +Found linux image: /boot/vmlinuz-4.13.0-38-generic +Found initrd image: /boot/initrd.img-4.13.0-38-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +done +(Reading database ... 290810 files and directories currently installed.) +Purging configuration files for linux-image-extra-4.13.0-37-generic (4.13.0-37.42) ... +Purging configuration files for linux-image-4.13.0-37-generic (4.13.0-37.42) ... +Examining /etc/kernel/postrm.d . +run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic +run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic + +Thanks for using this script!!! + +``` + +Re-check the list of installed kernels using the below command. This will keep only old three kernels. +``` +$ dpkg --list | grep linux-image +ii linux-image-4.13.0-38-generic 4.13.0-38.43 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-4.13.0-39-generic 4.13.0-39.44 amd64 Linux kernel image for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-38-generic 4.13.0-38.43 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-extra-4.13.0-39-generic 4.13.0-39.44 amd64 Linux kernel extra modules for version 4.13.0 on 64 bit x86 SMP +ii linux-image-generic 4.13.0.39.42 amd64 Generic Linux kernel image +ii linux-image-unsigned-4.16.7-041607-generic 4.16.7-041607.201805021131 amd64 Linux kernel image for version 4.16.7 on 64 bit x86 SMP + +``` + +For next time you can call `do-kernel-upgrade` utility for new kernel installation. If any new kernel is available then it will install. If no, it will report no kernel update is available at the moment. +``` +$ do-kernel-upgrade +Kernel up to date. Finishing + +``` + +Run the `do-kernel-purge` command once again to confirm on this. If this found more than three kernels then it will remove. If no, it will report nothing to remove message. +``` +$ do-kernel-purge + +Ubuntu Kernel Purge - by Caio Oliveira + +This script will only keep three versions: the first and the last two, others will be purge + +---Current version: +Linux Kernel 4.16.7-041607 Generic (linux-image-4.16.7-041607-generic) +Nothing to remove! + +Thanks for using this script!!! + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/uktools-easy-way-to-install-latest-stable-linux-kernel-on-ubuntu-mint-and-derivatives/ + +作者:[Prakash Subramanian][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.2daygeek.com/author/prakash/ +[1]:https://www.2daygeek.com/lku-linux-kernel-utilities-compile-install-update-latest-kernel-in-linux-mint-ubuntu/ +[2]:https://www.2daygeek.com/ukuu-install-upgrade-linux-kernel-in-linux-mint-ubuntu-debian-elementary-os/ +[3]:https://www.2daygeek.com/check-find-determine-running-installed-linux-kernel-version/ +[4]:https://github.com/usbkey9/uktools +[5]:http://kernel.ubuntu.com/~kernel-ppa/mainline/ From 02db862f15ff6ef35fb6231d83406c49f9583882 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 15:57:21 +0800 Subject: [PATCH 066/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20a=20univers?= =?UTF-8?q?ity=20network=20assistant=20used=20Linux=20in=20the=2090s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...network assistant used Linux in the 90s.md | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sources/talk/20180504 How a university network assistant used Linux in the 90s.md diff --git a/sources/talk/20180504 How a university network assistant used Linux in the 90s.md b/sources/talk/20180504 How a university network assistant used Linux in the 90s.md new file mode 100644 index 0000000000..9f3ffae3fd --- /dev/null +++ b/sources/talk/20180504 How a university network assistant used Linux in the 90s.md @@ -0,0 +1,38 @@ +How a university network assistant used Linux in the 90s +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/moneyrecycle_520x292.png?itok=SAaIziNr) +In the mid-1990s, I was enrolled in computer science classes. My university’s computer science department provided a SunOS server—a multi-user, multitasking Unix system—for its students. We logged into it and wrote source code for the programming languages we were learning, such as C, C++, and ADA. In those days, well before social networks and instant messaging, we also used the system to communicate with each other, sending emails and using utilities such as `write` and `talk`. We were each also allowed to host a personal website. I enjoyed being able to complete my assignments and contact other users. + +It was my first experience with this type of operating environment, but I soon learned about another operating system that could do the same thing: Linux. + +While I was a student, I also worked part-time at the university. My first position was as a network installer in the Department of Housing and Residence (H&R). This involved connecting student dormitories to the campus network. As this was the university's first dormitory network service, only two buildings and about 75 students had been connected. + +In my second year, the network expanded to cover an additional two buildings. H&R decided to let the university’s Office of Information Technology (OIT) manage this growing operation. I transferred to OIT and started the position of Student Assistant to the OIT Network Manager. That is how I discovered Linux. One of my new responsibilities was to manage the firewall systems that provided network and internet access to the dormitories. + +Each student was registered with their hardware MAC address. Registered students could connect to the dorm network and receive an IP address and a route to the internet. Unlike the other expensive SunOS and VMS servers used by the university, these firewalls used low-cost computers running the free and open source Linux operating system. By the end of the year, the system had registered nearly 500 students. + +![Red hat Linux install disks][1] + +The OIT network staff members were using Linux for HTTP, FTP, and other services. They also used Linux on their personal desktops. That's when I realized I had my hands on a computer system that looked and acted just like the expensive SunOS box in the CS department but without the high cost. Linux could run on commodity x86 hardware, such as a Dell Latitude with 8 MB of RAM and a 133Mhz Intel Pentium CPU. That was the selling point for me! I installed Red Hat Linux 5.2 on a box scavenged from the surplus warehouse and gave my friends login accounts. + +While I used my new Linux server to host my website and provide accounts to my friends, it also offered graphics capabilities over the CS department server. Using the X Windows system, I could browse the web with Netscape Navigator, play music with [XMMS][2], and try out different window managers. I could also download and compile other open source software and write my own code. + +I learned that Linux offered some pretty advanced features, many of which were more convenient than or superior to more mainstream operating systems. For example, many operating systems did not yet offer simple ways to apply updates. In Linux, this was easy, thanks to [autoRPM][3], an update manager written by Kirk Bauer, which sent the root user a daily email with available updates. It had an intuitive interface for reviewing and selecting software updates to install—pretty amazing for the mid-'90s. + +Linux may not have been well-known back then, and it was often received with skepticism, but I was convinced it would survive. And survive it did! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/my-linux-story-student + +作者:[Alan Formy-Duval][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/alanfdoss +[1]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/red_hat_linux_install_disks.png?itok=VSw6Cke9 (Red hat Linux install disks) +[2]:http://www.xmms.org/ +[3]:http://www.ccp14.ac.uk/solution/linux/autorpm_redhat7_3.html From 046295fac46a5ff5024d8c33fec60ac8f23d5073 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 15:59:00 +0800 Subject: [PATCH 067/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20the=20four?= =?UTF-8?q?=20components=20of=20a=20distributed=20tracing=20system=20work?= =?UTF-8?q?=20together?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...istributed tracing system work together.md | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 sources/tech/20180503 How the four components of a distributed tracing system work together.md diff --git a/sources/tech/20180503 How the four components of a distributed tracing system work together.md b/sources/tech/20180503 How the four components of a distributed tracing system work together.md new file mode 100644 index 0000000000..56239fc872 --- /dev/null +++ b/sources/tech/20180503 How the four components of a distributed tracing system work together.md @@ -0,0 +1,155 @@ +How the four components of a distributed tracing system work together +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/touch-tracing.jpg?itok=rOmsY-nU) +Ten years ago, essentially the only people thinking hard about distributed tracing were academics and a handful of large internet companies. Today, it’s turned into table stakes for any organization adopting microservices. The rationale is well-established: microservices fail in surprising and often spectacular ways, and distributed tracing is the best way to describe and diagnose those failures. + +That said, if you set out to integrate distributed tracing into your own application, you’ll quickly realize that the term “Distributed Tracing” means different things to different people. Furthermore, the tracing ecosystem is crowded with partially-overlapping projects with similar charters. This article describes the four (potentially) independent components in distributed tracing, and how they fit together. + +### Distributed tracing: A mental model + +Most mental models for tracing descend from [Google’s Dapper paper][1]. [OpenTracing][2] uses similar nouns and verbs, so we will borrow the terms from that project: + +![Tracing][3] + + * **Trace:** The description of a transaction as it moves through a distributed system. + * **Span:** A named, timed operation representing a piece of the workflow. Spans accept key:value tags as well as fine-grained, timestamped, structured logs attached to the particular span instance. + * **Span context:** Trace information that accompanies the distributed transaction, including when it passes from service to service over the network or through a message bus. The span context contains the trace identifier, span identifier, and any other data that the tracing system needs to propagate to the downstream service. + + + +If you would like to dig into a detailed description of this mental model, please check out the [OpenTracing specification][4]. + +### The four big pieces + +From the perspective of an application-layer distributed tracing system, a modern software system looks like the following diagram: + +![Tracing][5] + +The components in a modern software system can be broken down into three categories: + + * **Application and business logic:** Your code. + * **Widely shared libraries:** Other people's code. + * **Widely shared services:** Other people’s infrastructure. + + + +These three components have different requirements and drive the design of the Distributed Tracing systems which is tasked with monitoring the application. The resulting design yields four important pieces: + + * **A tracing instrumentation API:** What decorates application code. + * **Wire protocol:** What gets sent alongside application data in RPC requests. + * **Data protocol:** What gets sent asynchronously (out-of-band) to your analysis system. + * **Analysis system:** A database and interactive UI for working with the trace data. + + + +To explain this further, we’ll dig into the details which drive this design. If you just want my suggestions, please skip to the four big solutions at the bottom. + +### Requirements, details, and explanations + +Application code, shared libraries, and shared services have notable operational differences, which heavily influence the requirements for instrumenting them. + +#### Instrumenting application code and business logic + +In any particular microservice, the bulk of the code written by the microservice developer is the application or business logic. This is the code that defines domain-specific operations; typically, it contains whatever special, unique logic justified the creation of a new microservice in the first place. Almost by definition, **this code is usually not shared or otherwise present in more than one service.** + +That said, you still need to understand it, and that means it needs to be instrumented somehow. Some monitoring and tracing analysis systems auto-instrument code using black-box agents, and others expect explicit "white-box" instrumentation. For the latter, abstract tracing APIs offer many practical advantages for microservice-specific application code: + + * An abstract API allows you to swap in new monitoring tools without re-writing instrumentation code. You may want to change cloud providers, vendors, and monitoring technologies, and a huge pile of non-portable instrumentation code would add meaningful overhead and friction to that procedure. + * It turns out there are other interesting uses for instrumentation, beyond production monitoring. There are existing projects that use this same tracing instrumentation to power testing tools, distributed debuggers, “chaos engineering” fault injectors, and other meta-applications. + * But most importantly, what if you wanted to extract an application component into a shared library? That leads us to: + + + +#### Instrumenting shared libraries + +The utility code present in most applications—code that handles network requests, database calls, disk writes, threading, queueing, concurrency management, and so on—is often generic and not specific to any particular application. This code is packaged up into libraries and frameworks which are then installed in many microservices, and deployed into many different environments. + +This is the real difference: with shared code, someone else is the user. Most users have different dependencies and operational styles. If you attempt to instrument this shared code, you will note a couple of common issues: + + * You need an API to write instrumentation. However, your library does not know what analysis system is being used. There are many choices, and all the libraries running in the same application cannot make incompatible choices. + * The task of injecting and extracting span contexts from request headers often falls on RPC libraries, since those packages encapsulate all network-handling code. However, a shared library cannot not know which tracing protocol is being used by each application. + * Finally, you don’t want to force conflicting dependencies on your user. Most users have different dependencies and operational styles. Even if they use gRPC, will it be the same version of gRPC you are binding to? So any monitoring API your library brings in for tracing must be free of dependencies. + + + +**So, an abstract API which (a) has no dependencies, (b) is wire protocol agnostic, and (c) works with popular vendors and analysis systems should be a requirement for instrumenting shared library code.** + +#### Instrumenting shared services + +Finally, sometimes entire services—or sets of microservices—are general-purpose enough that they are used by many independent applications. These shared services are often hosted and managed by third parties. Examples might be cache servers, message queues, and databases. + +It’s important to understand that **shared services are essentially "black boxes" from the perspective of application developers.** It is not possible to inject your application’s monitoring solution into a shared service. Instead, the hosted service often runs its own monitoring solution. + +### **The four big solutions** + +So, an abstracted tracing API would help libraries emit data and inject/extract Span Context. A standard wire protocol would help black-box services interconnect, and a standard data format would help separate analysis systems consolidate their data. Let's have a look at some promising options for solving these problems. + +#### Tracing API: The OpenTracing project + +#### As shown above, in order to instrument application code, a tracing API is required. And in order to extend that instrumentation to shared libraries, where most of the Span Context injection and extraction occurs, the API must be abstracted in certain critical ways. + +The [OpenTracing][2] project aims to solve this problem for library developers. OpenTracing is a vendor-neutral tracing API which comes with no dependencies, and is quickly gaining support from a large number of monitoring systems. This means that, increasingly, if libraries ship with native OpenTracing instrumentation baked in, tracing will automatically be enabled when a monitoring system connects at application startup. + +Personally, as someone who has been writing, shipping, and operating open source software for over a decade, it is profoundly satisfying to work on the OpenTracing project and finally scratch this observability itch. + +In addition to the API, the OpenTracing project maintains a growing list of contributed instrumentation, some of which can be found [here][6]. If you would like to get involved, either by contributing an instrumentation plugin, natively instrumenting your own OSS libraries, or just want to ask a question, please find us on [Gitter][7] and say hi. + +#### Wire Protocol: The trace-context HTTP headers + +In order for monitoring systems to interoperate, and to mitigate migration issues when changing from one monitoring system to another, a standard wire protocol is needed for propagating Span Context. + +The [w3c Distributed Trace Context Community Group][8] is hard at work defining this standard. Currently, the focus is on defining a set of standard HTTP headers. The latest draft of the specification can be found [here][9]. If you have questions for this group, the [mailing list][10] and [Gitter chatroom][11] are great places to go for answers. + +#### Data protocol (Doesn't exist yet!!) + +For black-box services, where it is not possible to install a tracer or otherwise interact with the program, a data protocol is needed to export data from the system. + +Work on this data format and protocol is currently at an early stage, and mostly happening within the context of the w3c Distributed Trace Context Working Group. There is particular interest is in defining higher-level concepts, such as RPC calls, database statements, etc, in a standard data schema. This would allow tracing systems to make assumptions about what kind of data would be available. The OpenTracing project is also working on this issue, by starting to define a [standard set of tags][12]. The plan is for these two efforts to dovetail with each other. + +Note that there is a middle ground available at the moment. For “network appliances” that the application developer operates, but does not want to compile or otherwise perform code modifications to, dynamic linking can help. The primary examples of this are service meshes and proxies, such as Envoy or NGINX. For this situation, an OpenTracing-compliant tracer can be compiled as a shared object, and then dynamically linked into the executable at runtime. This option is currently provided by the [C++ OpenTracing API][13]. For Java, an OpenTracing [Tracer Resolver][14] is also under development. + +These solutions work well for services that support dynamic linking, and are deployed by the application developer. But in the long run, a standard data protocol may solve this problem more broadly. + +#### Analysis system: A service for extracting insights from trace data + +Last but not least, there is now a cornucopia of tracing and monitoring solutions. A list of monitoring systems known to be compatible with OpenTracing can be found [here][15], but there are many more options out there. I would encourage you to research your options, and I hope you find the framework provided in this article to be useful when comparing options. In addition to rating monitoring systems based on their operational characteristics (not to mention whether you like the UI and features), make sure you think about the three big pieces above, their relative importance to you, and how the tracing system you are interested in provides a solution to them. + +### Conclusion + +In the end, how important each piece is depends heavily on who you are and what kind of system you are building. For example, open source library authors are very interested in the OpenTracing API, while service developers tend to be more interested in the Trace-Context specification. When someone says one piece is more important than the other, they usually mean “one piece is more important to me than the other." + +However, the reality is this: Distributed Tracing has become a necessity for monitoring modern systems. In designing the building blocks for these systems, the age-old approach—"decouple where you can"—still holds true. Cleanly decoupled components are the best way to maintain flexibility and forwards-compatibility when building a system as cross-cutting as a distributed monitoring system. + +Thanks for reading! Hopefully, now when you're ready to implement tracing in your own application, you have a guide to understanding which pieces they are talking about, and how they fit together. + +Want to learn more? Sign up to attend [KubeCon EU][16] in May or [KubeCon North America][17] in December. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/distributed-tracing + +作者:[Ted Young][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/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/ From c6ad8da813d5952a0e1195b2d4621761da631a00 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 14 May 2018 16:47:47 +0800 Subject: [PATCH 068/111] submit tech/20180418 Getting started with Anaconda Python for data science.md --- ...d with Anaconda Python for data science.md | 117 ------------------ ...d with Anaconda Python for data science.md | 116 +++++++++++++++++ 2 files changed, 116 insertions(+), 117 deletions(-) delete mode 100644 sources/tech/20180418 Getting started with Anaconda Python for data science.md create mode 100644 translated/tech/20180418 Getting started with Anaconda Python for data science.md diff --git a/sources/tech/20180418 Getting started with Anaconda Python for data science.md b/sources/tech/20180418 Getting started with Anaconda Python for data science.md deleted file mode 100644 index 063324c284..0000000000 --- a/sources/tech/20180418 Getting started with Anaconda Python for data science.md +++ /dev/null @@ -1,117 +0,0 @@ -pinewall translating - -Getting started with Anaconda Python for data science -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) -Like many others, I've been trying to get involved in the rapidly expanding field of data science. When I took Udemy courses on the [R][1] and [Python][2] programming languages, I downloaded and installed the applications independently. As I was trying to work through the challenges of installing data science packages like [NumPy][3] and [Matplotlib][4] and solving the various dependencies, I learned about the [Anaconda Python distribution][5]. - -Anaconda is a complete, [open source][6] data science package with a community of over 6 million users. It is easy to [download][7] and install, and it is supported on Linux, MacOS, and Windows. - -I appreciate that Anaconda eases the frustration of getting started for new users. The distribution comes with more than 1,000 data packages as well as the [Conda][8] package and virtual environment manager, so it eliminates the need to learn to install each library independently. As Anaconda's website says, "The Python and R conda packages in the Anaconda Repository are curated and compiled in our secure environment so you get optimized binaries that 'just work' on your system." - -I recommend using [Anaconda Navigator][9], a desktop graphical user interface (GUI) system that includes links to all the applications included with the distribution including [RStudio][10], [iPython][11], [Jupyter Notebook][12], [JupyterLab][13], [Spyder][14], [Glue][15], and [Orange][16]. The default environment is Python 3.6, but you can also easily install Python 3.5, Python 2.7, or R. The [documentation][9] is incredibly detailed and there is an excellent community of users for additional support. - -### Installing Anaconda - -To install Anaconda on my Linux laptop (an I3 with 4GB of RAM), I downloaded the Anaconda 5.1 Linux installer and ran `md5sum` to verify the file: -``` -$ md5sum Anaconda3-5.1.0-Linux-x86_64.sh - -``` - -Then I followed the directions in the [documentation][17], which instructed me to issue the following Bash command whether I was in the Bash shell or not: -``` -$ bash Anaconda3-5.1.0-Linux-x86_64.sh - -``` - -I followed the installation directions exactly, and the well-scripted install took about five minutes to complete. When the installation prompted: "Do you wish the installer to prepend the Anaconda install location to PATH in your `/home//.bashrc`?" I allowed it and restarted the shell, which I found was necessary for the `.bashrc` environment to work correctly. - -After completing the install, I launched Anaconda Navigator by entering the following at the command prompt in the shell: -``` -$ anaconda-navigator - -``` - -Every time Anaconda Navigator launches, it checks to see if new software is available and prompts you to update if necessary. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-update.png?itok=wMk78pGQ) - -Anaconda updated successfully without needing to return to the command line. Anaconda's initial launch was a little slow; that plus the update meant it took a few additional minutes to get started. - -You can also update manually by entering the following: -``` -$ conda update anaconda-navigator - -``` - -### Exploring and installing applications - -Once Navigator launched, I was free to explore the range of applications included with Anaconda Distribution. According to the documentation, the 64-bit Python 3.6 version of Anaconda [supports 499 packages][18]. The first application I explored was [Jupyter QtConsole][19]. The easy-to-use GUI supports inline figures and syntax highlighting. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-jupyterqtconsole.png?itok=fQQoErIO) - -Jupyter Notebook is included with the distribution, so (unlike other Python environments I have used) there is no need for a separate install. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-jupyternotebook.png?itok=VqvbyOcI) - -I was already familiar with RStudio. It's not installed by default, but it's easy to add with the click of a mouse. Other applications, including JupyterLab, Orange, Glue, and Spyder, can be launched or installed with just a mouse click. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-otherapps.png?itok=9QmSUdel) - -One of the Anaconda distribution's strengths is the ability to create multiple environments. For example, if I wanted to create a Python 2.7 environment instead of the default Python 3.6, I would enter the following in the shell: -``` -$ conda create -n py27 python=2.7 anaconda - -``` - -Conda takes care of the entire install; to launch it, just open the shell and enter: -``` -$ anaconda-navigator - -``` - -Select the **py27** environment from the "Applications on" drop-down in the Anaconda GUI. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-navigator.png?itok=2i5qYAyG) - -### Learn more - -There's a wealth of information available about Anaconda if you'd like to know more. You can start by searching the [Anaconda Community][20] and its [mailing list][21]. - -Are you using Anaconda Distribution and Navigator? Let us know your impressions in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/getting-started-anaconda-python - -作者:[Don Watkins][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/don-watkins -[1]:https://www.r-project.org/ -[2]:https://www.python.org/ -[3]:http://www.numpy.org/ -[4]:https://matplotlib.org/ -[5]:https://www.anaconda.com/distribution/ -[6]:https://docs.anaconda.com/anaconda/eula -[7]:https://www.anaconda.com/download/#linux -[8]:https://conda.io/ -[9]:https://docs.anaconda.com/anaconda/navigator/ -[10]:https://www.rstudio.com/ -[11]:https://ipython.org/ -[12]:http://jupyter.org/ -[13]:https://blog.jupyter.org/jupyterlab-is-ready-for-users-5a6f039b8906 -[14]:https://spyder-ide.github.io/ -[15]:http://glueviz.org/ -[16]:https://orange.biolab.si/ -[17]:https://docs.anaconda.com/anaconda/install/linux -[18]:https://docs.anaconda.com/anaconda/packages/py3.6_linux-64 -[19]:http://qtconsole.readthedocs.io/en/stable/ -[20]:https://www.anaconda.com/community/ -[21]:https://groups.google.com/a/continuum.io/forum/#!forum/anaconda diff --git a/translated/tech/20180418 Getting started with Anaconda Python for data science.md b/translated/tech/20180418 Getting started with Anaconda Python for data science.md new file mode 100644 index 0000000000..14da041971 --- /dev/null +++ b/translated/tech/20180418 Getting started with Anaconda Python for data science.md @@ -0,0 +1,116 @@ +面向数据科学的 Anaconda Python 入门 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) +像很多人一样,我一直努力加入到快速发展的数据科学领域。我上过 Udemy 的 [R][1] 及 [Python][2] 语言编程课,那时我分别下载并安装了应用程序。当我试图解决各种依赖关系,安装类似 [Numpy][3] 和 [Matplotlib][4] 这样的数据科学扩展包时,我了解了 [Anaconda Python 发行版][5]。 + +Anaconda 是一个完备、[开源][6]的数据科学包,拥有超过 600 万社区用户。[下载][7]和安装 Anaconda 都很容易,支持的操作系统包括 Linux, MacOS 及 Windows。 + +我感谢 Anaconda 降低了初学者的学习门槛。发行版自带 1000 多个数据科学包以及 [Conda][8] 包和虚拟环境管理器,让你无需单独学习每个库的安装方法。就像 Anaconda 官网上提到的,“Anaconda 库中的 Python 和 R 语言的conda 包是我们在安全环境中修订并编译得到的优化二进制程序,可以在你系统上工作”。 + +我推荐使用 [Anaconda Navigator][9],它是一个桌面 GUI (graphical user interface) 系统,包含发行版自带应用的链接,包括[RStudio][10], [iPython][11], [Jupyter Notebook][12], [JupyterLab][13], [Spyder][14], [Glue][15] 和 [Orange][16]。默认环境采用 Python 3.6,但你可以轻松安装 Python 3.5, Python 2.7 或 R。[文档][16]十分详尽,而且用户社区极好,可以提供额外的支持。 + +### 安装 Anaconda + +为在我的 Linux 笔记本 (I3 CPU,4GB 内存) 上安装 Anaconda,我下载了 Anaconda 5.1 Linux 版安装器并运行 `md5sum` 进行文件校验: +``` +$ md5sum Anaconda3-5.1.0-Linux-x86_64.sh + +``` + +接着按照[安装文档][17]的说明,无论是否在 Bash shell 环境下,执行如下 shell 命令: +``` +$ bash Anaconda3-5.1.0-Linux-x86_64.sh + +``` + +我完全按照安装指南操作,运行这个精心编写的脚本,大约花费 5 分钟可以完成安装。安装过程中会提示:“是否希望安装器将 Anaconda 的安装路径加入到你的 `/home//.bashrc`?我选择允许并重启了 shell,这会让 `.bashrc` 中的环境变量生效。 + +安装完成后,我启动了 Anaconda Navigator,具体操作是在 shell 中执行如下命令: +``` +$ anaconda-navigator + +``` + +Anaconda Navigator 每次启动时会检查是否有可更新的软件包,如果有,会提醒你进行更新。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-update.png?itok=wMk78pGQ) + +按照提醒进行更新即可,无需使用命令行。Anaconda 初次启动会有些慢,如果涉及更新会额外花费几分钟。 + +当然,你也可以通过执行如下命令手动更新: + +``` +$ conda update anaconda-navigator + +``` + +### 浏览和安装应用 + +Navigator 启动后,可以很容易地浏览 Anaconda 发行版包含的应用。按照文档所述,64 位 Python 3.6 版本的 Anaconda [支持 499 个软件包][18]。我浏览的第一个应用是 [Jupyter QtConsole][19],这个简单易用的 GUI 支持内联数据 (inline figures) 和语法高亮。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-jupyterqtconsole.png?itok=fQQoErIO) + +发行版中包含 Jupyter Notebook,故(不像我用的其它 Python 环境那样)无需在发行版外安装。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-jupyternotebook.png?itok=VqvbyOcI) + +我习惯使用的 RStudio 并没有默认安装,但安装它也仅需点击一下鼠标。其它应用的启动或安装也仅需点击一下鼠标,包括 JupyterLab, Orange, Glue 和 Spyder 等。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-otherapps.png?itok=9QmSUdel) + +Anaconda 发行版的一个强大功能是创建多套环境。假如我需要创建一套与默认 Python 3.6 不同的 Python 2.7 的环境,可以在 shell 中执行如下命令: +``` +$ conda create -n py27 python=2.7 anaconda + +``` + +Conda 负责整个安装流程,如需启动它,仅需在 shell 中执行如下命令: +``` +$ anaconda-navigator + +``` + +在 Anaconda GUI 的 "Applications on" 下拉菜单中选取 **py27** 即可。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/anaconda-navigator.png?itok=2i5qYAyG) + +### 更多内容 + +如果你想了解更多关于 Anaconda 的信息,可供参考的资源十分丰富。不妨从检索 [Anaconda 社区][20]及对应的[邮件列表][21]开始。 + +你是否在使用 Anaconda 发行版及 Navigator 呢?欢迎在评论中留下你的使用感想。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/getting-started-anaconda-python + +作者:[Don Watkins][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[pinewall](https://github.com/pinewall) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/don-watkins +[1]:https://www.r-project.org/ +[2]:https://www.python.org/ +[3]:http://www.numpy.org/ +[4]:https://matplotlib.org/ +[5]:https://www.anaconda.com/distribution/ +[6]:https://docs.anaconda.com/anaconda/eula +[7]:https://www.anaconda.com/download/#linux +[8]:https://conda.io/ +[9]:https://docs.anaconda.com/anaconda/navigator/ +[10]:https://www.rstudio.com/ +[11]:https://ipython.org/ +[12]:http://jupyter.org/ +[13]:https://blog.jupyter.org/jupyterlab-is-ready-for-users-5a6f039b8906 +[14]:https://spyder-ide.github.io/ +[15]:http://glueviz.org/ +[16]:https://orange.biolab.si/ +[17]:https://docs.anaconda.com/anaconda/install/linux +[18]:https://docs.anaconda.com/anaconda/packages/py3.6_linux-64 +[19]:http://qtconsole.readthedocs.io/en/stable/ +[20]:https://www.anaconda.com/community/ +[21]:https://groups.google.com/a/continuum.io/forum/#!forum/anaconda From 9de649f0d345fabb06f4a24551c60a60880232a9 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 17:57:58 +0800 Subject: [PATCH 069/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Creating=20small?= =?UTF-8?q?=20containers=20with=20Buildah?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Creating small containers with Buildah.md | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 sources/tech/20180510 Creating small containers with Buildah.md diff --git a/sources/tech/20180510 Creating small containers with Buildah.md b/sources/tech/20180510 Creating small containers with Buildah.md new file mode 100644 index 0000000000..4fef005908 --- /dev/null +++ b/sources/tech/20180510 Creating small containers with Buildah.md @@ -0,0 +1,98 @@ +Creating small containers with Buildah +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open%20source_collaboration_0.png?itok=YEl_GXbv) +I recently joined Red Hat after many years working for another tech company. In my previous job, I developed a number of different software products that were successful but proprietary. Not only were we legally compelled to not share the software outside of the company, we often didn’t even share it within the company. At the time, that made complete sense to me: The company spent time, energy, and budget developing the software, so they should protect and claim the rewards it garnered. + +Fast-forward to a year ago, when I joined Red Hat and developed a completely different mindset. One of the first things I jumped into was the [Buildah project][1]. It facilitates building Open Container Initiative (OCI) images, and it is especially good at allowing you to tailor the size of the image that is created. At that time Buildah was in its very early stages, and there were some warts here and there that weren’t quite production-ready. + +Being new to the project, I made a few minor changes, then asked where the company’s internal git repository was so that I could push my changes. The answer: Nothing internal, just push your changes to GitHub. I was baffled—sending my changes out to GitHub would mean anyone could look at that code and use it for their own projects. Plus, the code still had a few warts, so that just seemed so counterintuitive. But being the new guy, I shook my head in wonder and pushed the changes out. + +A year later, I’m now convinced of the power and value of open source software. I’m still working on Buildah, and we recently had an issue that illustrates that power and value. The issue, titled [Buildah images not so small?][2] , was raised by Tim Dudgeon (@tdudgeon). To summarize, he noted that images created by Buildah were bigger than those created by Docker, even though the Buildah images didn’t contain the extra "fluff" he saw in the Docker images. + +For comparison he first did: +``` +$ docker pull centos:7 +$ docker images +REPOSITORY            TAG              IMAGE ID                 CREATED             SIZE +docker.io/centos          7                   2d194b392dd1        2 weeks ago         195 MB +``` + +He noted that the size of the Docker image was 195MB. Tim then created a minimal (scratch) image using Buildah, with only the `coreutils` and `bash` packages added to the image, using the following script: +``` +$ cat  ./buildah-base.sh +#!/bin/bash + +set -x + +# build a minimal image +newcontainer=$(buildah from scratch) +scratchmnt=$(buildah mount $newcontainer) + +# install the packages +yum install --installroot $scratchmnt bash coreutils --releasever 7 --setopt install_weak_deps=false -y +yum clean all -y --installroot $scratchmnt --releasever 7 + +sudo buildah config --cmd /bin/bash $newcontainer + +# set some config info +buildah config --label name=centos-base $newcontainer + +# commit the image +buildah unmount $newcontainer +buildah commit $newcontainer centos-base + +$ sudo ./buildah-base.sh + +$ sudo buildah images +IMAGE ID               IMAGE NAME                                             CREATED AT            SIZE +8379315d3e3e     docker.io/library/centos-base:latest           Mar 25, 2018 17:08   212.1 MB +``` + +Tim wondered why the image was 17MB larger, because `python` and `yum` were not installed in the Buildah image, whereas they were installed in the Docker image. This set off quite the discussion in the GitHub issue, as it was not at all an expected result. + +What was great about the discussion was that not only were Red Hat folks involved, but several others from outside as well. In particular, a lot of great discussion and investigation was led by GitHub user @pixdrift, who noted that the documentation and locale-archive were chewing up a little more than 100MB of space in the Buildah image. Pixdrift suggested forcing locale in the yum installer and provided this updated `buildah-bash.sh` script with those changes: +``` +#!/bin/bash + +set -x + +# build a minimal image +newcontainer=$(buildah from scratch) +scratchmnt=$(buildah mount $newcontainer) + +# install the packages +yum install --installroot $scratchmnt bash coreutils --releasever 7 --setopt=install_weak_deps=false --setopt=tsflags=nodocs --setopt=override_install_langs=en_US.utf8 -y +yum clean all -y --installroot $scratchmnt --releasever 7 + +sudo buildah config --cmd /bin/bash $newcontainer + +# set some config info +buildah config --label name=centos-base $newcontainer + +# commit the image +buildah unmount $newcontainer +buildah commit $newcontainer centos-base +``` + +When Tim ran this new script, the image size shrank to 92MB, shedding 120MB from the original Buildah image size and getting closer to the expected size; however, engineers being engineers, a size savings of 56% wasn’t enough. The discussion went further, involving how to remove individual locale packages to save even more space. To see more details of the discussion, click the [Buildah images not so small?][2] link. Who knows—maybe you’ll have a helpful tip, or better yet, become a contributor for Buildah. On a side note, this solution illustrates how the Buildah software can be used to quickly and easily create a minimally sized container that's loaded only with the software that you need to do your job efficiently. As a bonus, it doesn’t require a daemon to be running. + +This image-sizing issue drove home the power of open source software for me. A number of people from different companies all collaborated to solve a problem through open discussion in a little over a day. Although no code changes were created to address this particular issue, there have been many code contributions to Buildah from contributors outside of Red Hat, and this has helped to make the project even better. These contributions have served to get a wider variety of talented people to look at the code than ever would have if it were a proprietary piece of software stuck in a private git repository. It’s taken only a year to convert me to the [open source way][3], and I don’t think I could ever go back. + +This article was originally posted at [Project Atomic][4]. Reposted with permission. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/containers-buildah + +作者:[Tom Sweeney][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/tomsweeneyredhat +[1]:https://github.com/projectatomic/buildah +[2]:https://github.com/projectatomic/buildah/issues/532 +[3]:https://twitter.com/opensourceway +[4]:http://www.projectatomic.io/blog/2018/04/open-source-what-a-concept/ From b1c2992ebc1a25d960814c62951b78339148f7b7 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 14 May 2018 18:50:01 +0800 Subject: [PATCH 070/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Get=20more=20done?= =?UTF-8?q?=20at=20the=20Linux=20command=20line=20with=20GNU=20Parallel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...he Linux command line with GNU Parallel.md | 260 ++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 sources/tech/20180510 Get more done at the Linux command line with GNU Parallel.md diff --git a/sources/tech/20180510 Get more done at the Linux command line with GNU Parallel.md b/sources/tech/20180510 Get more done at the Linux command line with GNU Parallel.md new file mode 100644 index 0000000000..72aceaacb8 --- /dev/null +++ b/sources/tech/20180510 Get more done at the Linux command line with GNU Parallel.md @@ -0,0 +1,260 @@ +Get more done at the Linux command line with GNU Parallel +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR) + +Do you ever get the funny feeling that your computer isn't quite as fast as it should be? I used to feel that way, and then I found GNU Parallel. + +GNU Parallel is a shell utility for executing jobs in parallel. It can parse multiple inputs, thereby running your script or command against sets of data at the same time. You can use all your CPU at last! + +If you've ever used `xargs`, you already know how to use Parallel. If you don't, then this article teaches you, along with many other use cases. + +### Installing GNU Parallel + +GNU Parallel may not come pre-installed on your Linux or BSD computer. Install it from your repository or ports collection. For example, on Fedora: +``` +$ sudo dnf install parallel + +``` + +Or on NetBSD: +``` +# pkg_add parallel + +``` + +If all else fails, refer to the [project homepage][1]. + +### From serial to parallel + +As its name suggests, Parallel's strength is that it runs jobs in parallel rather than, as many of us still do, sequentially. + +When you run one command against many objects, you're inherently creating a queue. Some number of objects can be processed by the command, and all the other objects just stand around and wait their turn. It's inefficient. Given enough data, there's always going to be a queue, but instead of having just one queue, why not have lots of small queues? + +Imagine you have a folder full of images you want to convert from JPEG to PNG. There are many ways to do this. There's the manual way of opening each image in GIMP and exporting it to the new format. That's usually the worst possible way. It's not only time-intensive, it's labor-intensive. + +A pretty neat variation on this theme is the shell-based solution: +``` +$ convert 001.jpeg 001.png + +$ convert 002.jpeg 002.png + +$ convert 003.jpeg 003.png + +... and so on ... + +``` + +It's a great trick when you first learn it, and at first it's a vast improvement. No need for a GUI and constant clicking. But it's still labor-intensive. + +Better still: +``` +$ for i in *jpeg; do convert $i $i.png ; done + +``` + +This, at least, sets the job(s) in motion and frees you up to do more productive things. The problem is, it's still a serial process. One image gets converted, and then the next one in the queue steps up for conversion, and so on until the queue has been emptied. + +With Parallel: +``` +$ find . -name "*jpeg" | parallel -I% --max-args 1 convert % %.png + +``` + +This is a combination of two commands: the `find` command, which gathers the objects you want to operate on, and the `parallel` command, which sorts through the objects and makes sure everything gets processed as required. + + * `find . -name "*jpeg"` finds all files in the current directory that end in `jpeg`. + * `parallel` invokes GNU Parallel. + * `-I%` creates a placeholder, called `%`, to stand in for whatever `find` hands over to Parallel. You use this because otherwise you'd have to manually write a new command for each result of `find`, and that's exactly what you're trying to avoid. + * `--max-args 1` limits the rate at which Parallel requests a new object from the queue. Since the command Parallel is running requires only one file, you limit the rate to 1. Were you doing a more complex command that required two files (such as `cat 001.txt 002.txt > new.txt`), you would limit the rate to 2. + * `convert % %.png` is the command you want to run in Parallel. + + + +The result of this command is that `find` gathers all relevant files and hands them over to `parallel`, which launches a job and immediately requests the next in line. Parallel continues to do this for as long as it is safe to launch new jobs without crippling your computer. As old jobs are completed, it replaces them with new ones, until all the data provided to it has been processed. What took 10 minutes before might take only 5 or 3 with Parallel. + +### Multiple inputs + +The `find` command is an excellent gateway to Parallel as long as you're familiar with `find` and `xargs` (collectively called GNU Find Utilities, or `findutils`). It provides a flexible interface that many Linux users are already comfortable with and is pretty easy to learn if you're a newcomer. + +The `find` command is fairly straightforward: you provide `find` with a path to a directory you want to search and some portion of the file name you want to search for. Use wildcard characters to cast your net wider; in this example, the asterisk indicates anything, so `find` locates all files that end with the string `searchterm`: +``` +$ find /path/to/directory -name "*searchterm" + +``` + +By default, `find` returns the results of its search one item at a time, with one item per line: +``` +$ find ~/graphics -name "*jpg" + +/home/seth/graphics/001.jpg + +/home/seth/graphics/cat.jpg + +/home/seth/graphics/penguin.jpg + +/home/seth/graphics/IMG_0135.jpg + +``` + +When you pipe the results of `find` to `parallel`, each item on each line is treated as one argument to the command that `parallel` is arbitrating. If, on the other hand, you need to process more than one argument in one command, you can split up the way the data in the queue is handed over to `parallel`. + +Here's a simple, unrealistic example, which I'll later turn into something more useful. You can follow along with this example, as long as you have GNU Parallel installed. + +Assume you have four files. List them, one per line, to see exactly what you have: +``` +$ echo ada > ada ; echo lovelace > lovelace + +$ echo richard > richard ; echo stallman > stallman + +$ ls -1 + +ada + +lovelace + +richard + +stallman + +``` + +You want to combine two files into a third that contains the contents of both files. This requires that Parallel has access to two files, so the `-I%` variable won't work in this case. + +Parallel's default behavior is basically invisible: +``` +$ ls -1 | parallel echo + +ada + +lovelace + +richard + +stallman + +``` + +Now tell Parallel you want to get two objects per job: +``` +$ ls -1 | parallel --max-args=2 echo + +ada lovelace + +richard stallman + +``` + +Now the lines have been combined. Specifically, two results from `ls -1` are passed to Parallel all at once. That's the right number of arguments for this task, but they're effectively one argument right now: "ada lovelace" and "richard stallman." What you actually want is two distinct arguments per job. + +Luckily, that technicality is parsed by Parallel itself. If you set `--max-args` to `2`, you get two variables, `{1}` and `{2}`, representing the first and second parts of the argument: +``` +$ ls -1 | parallel --max-args=2 cat {1} {2} ">" {1}_{2}.person + +``` + +In this command, the variable `{1}` is ada or richard (depending on which job you look at) and `{2}` is either `lovelace` or `stallman`. The contents of the files are redirected with a redirect symbol in quotes (the quotes grab the redirect symbol from Bash so Parallel can use it) and placed into new files called `ada_lovelace.person` and `richard_stallman.person`. +``` +$ ls -1 + +ada + +ada_lovelace.person + +lovelace + +richard + +richard_stallman.person + +stallman + + + +$ cat ada_*person + +ada lovelace + +$ cat ri*person + +richard stallman + +``` + +If you spend all day parsing log files that are hundreds of megabytes in size, you might see how parallelized text parsing could be useful to you; otherwise, this is mostly a demonstrative exercise. + +However, this kind of processing is invaluable for more than just text parsing. Here's a real-life example from the film world. Consider a directory of video files and audio files that need to be joined together. +``` +$ ls -1 + +12_LS_establishing-manor.avi + +12_wildsound.flac + +14_butler-dialogue-mixed.flac + +14_MS_butler.avi + +...and so on... + +``` + +Using the same principles, a simple command can be created so that the files are combined in parallel: +``` +$ ls -1 | parallel --max-args=2 ffmpeg -i {1} -i {2} -vcodec copy -acodec copy {1}.mkv + +``` + +### Brute. Force. + +All this fancy input and output parsing isn't to everyone's taste. If you prefer a more direct approach, you can throw commands at Parallel and walk away. + +First, create a text file with one command on each line: +``` +$ cat jobs2run + +bzip2 oldstuff.tar + +oggenc music.flac + +opusenc ambiance.wav + +convert bigfile.tiff small.jpeg + +ffmepg -i foo.avi -v:b 12000k foo.mp4 + +xsltproc --output build/tmp.fo style/dm.xsl src/tmp.xml + +bzip2 archive.tar + +``` + +Then hand the file over to Parallel: +``` +$ parallel --jobs 6 < jobs2run + +``` + +And now all jobs in your file are run in Parallel. If more jobs exist than jobs allowed, a queue is formed and maintained by Parallel until all jobs have run. + +### Much, much more + +GNU Parallel is a powerful and flexible tool, with far more use cases than can fit into this article. Its man page provides examples of really cool things you can do with it, from remote execution over SSH to incorporating Bash functions into your Parallel commands. There's even an extensive demonstration series on [YouTube][2], so you can learn from the GNU Parallel team directly. The GNU Parallel lead maintainer has also just released the command's official guide, available from [Lulu.com][3]. + +GNU Parallel has the power to change the way you compute, and if doesn't do that, it will at the very least change the time your computer spends computing. Try it today! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/gnu-parallel + +作者:[Seth Kenlon][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/seth +[1]:https://www.gnu.org/software/parallel +[2]:https://www.youtube.com/watch?v=OpaiGYxkSuQ&list=PL284C9FF2488BC6D1 +[3]:http://www.lulu.com/shop/ole-tange/gnu-parallel-2018/paperback/product-23558902.html From a785fe2830bce04f762e2e874e571f3a41da7ef0 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 19:05:14 +0800 Subject: [PATCH 071/111] PRF:20180417 How to do math on the Linux command line.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @pinewall 翻译的不错。 --- ...ow to do math on the Linux command line.md | 100 +++++++++--------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/translated/tech/20180417 How to do math on the Linux command line.md b/translated/tech/20180417 How to do math on the Linux command line.md index eb4567454c..2aefe080be 100644 --- a/translated/tech/20180417 How to do math on the Linux command line.md +++ b/translated/tech/20180417 How to do math on the Linux command line.md @@ -1,23 +1,27 @@ Linux 命令行下的数学运算 ====== +> 有几个有趣的命令可以在 Linux 系统下做数学运算: `expr`、`factor`、`jot` 和 `bc` 命令。 + ![](https://images.techhive.com/images/article/2014/12/math_blackboard-100534564-large.jpg) + 可以在 Linux 命令行下做数学运算吗?当然可以!事实上,有不少命令可以轻松完成这些操作,其中一些甚至让你大吃一惊。让我们来学习这些有用的数学运算命令或命令语法吧。 ### expr -首先,对于在命令行使用命令进行数学运算,可能最容易想到、最常用的命令就是 **expr** (expression)。它可以完成四则运算,也可以用于比较大小。下面是几个例子: +首先,对于在命令行使用命令进行数学运算,可能最容易想到、最常用的命令就是 `expr` (表达式expression。它可以完成四则运算,也可以用于比较大小。下面是几个例子: #### 变量递增 + ``` $ count=0 $ count=`expr $count + 1` $ echo $count 1 - ``` #### 完成简单运算 + ``` $ expr 11 + 123 134 @@ -31,11 +35,12 @@ $ expr 11 \* 123 1353 $ expr 20 % 3 2 - ``` -注意,你需要在 * 运算符之前增加 \ 符号,避免语法错误。% 运算符用于取余运算。 + +注意,你需要在 `*` 运算符之前增加 `\` 符号,避免语法错误。`%` 运算符用于取余运算。 下面是一个稍微复杂的例子: + ``` participants=11 total=156 @@ -45,47 +50,49 @@ echo $share 14 echo $remaining 2 - ``` 假设某个活动中有 11 位参与者,需要颁发的奖项总数为 156,那么平均每个参与者获得 14 项奖项,额外剩余 2 个奖项。 -#### 比较大小 +#### 比较 + +下面让我们看一下比较的操作。从第一印象来看,语句看似有些怪异;这里并不是**设置**数值,而是进行数字比较。在本例中 `expr` 判断表达式是否为真:如果结果是 1,那么表达式为真;反之,表达式为假。 -下面让我们看一下比较大小的操作。从第一印象来看,语句看似有些怪异;这里并不是设置数值,而是进行数字大小比较。在本例中 **expr** 判断表达式是否为真:如果结果是 1,那么表达式为真;反之,表达式为假。 ``` $ expr 11 = 11 1 $ expr 11 = 12 0 - ``` -请读作"11 是否等于 11?"及"11 是否等于 12?",你很快就会习惯这种写法。当然,我们不会在命令行上执行上述比较,可能的比较是 $age 是否等于 11。 + +请读作“11 是否等于 11?”及“11 是否等于 12?”,你很快就会习惯这种写法。当然,我们不会在命令行上执行上述比较,可能的比较是 `$age` 是否等于 `11`。 + ``` $ age=11 $ expr $age = 11 1 - ``` + 如果将数字放到引号中间,那么你将进行字符串比较,而不是数值比较。 + ``` $ expr "11" = "11" 1 $ expr "eleven" = "11" 0 - ``` -在本例中,我们判断 10 是否大于 5,以及是否 大于 99。 +在本例中,我们判断 10 是否大于 5,以及是否大于 99。 + ``` $ expr 10 \> 5 1 $ expr 10 \> 99 0 - ``` -的确,返回 1 和 0 分别代表比较的结果为真和假,我们一般预期在 Linux 上得到这个结果。在下面的例子中,按照上述逻辑使用 **expr** 并不正确,因为 **if** 的工作原理刚好相反,即 0 代表真。 +的确,返回 1 和 0 分别代表比较的结果为真和假,我们一般预期在 Linux 上得到这个结果。在下面的例子中,按照上述逻辑使用 `expr` 并不正确,因为 `if` 的工作原理刚好相反,即 0 代表真。 + ``` #!/bin/bash @@ -99,19 +106,19 @@ if [ `expr $price \> $cost` ]; then else echo "Don't sell it" fi - ``` 下面,我们运行这个脚本: + ``` $ ./checkPrice Cost to us> 11.50 Price we're asking> 6 We make money - ``` 这显然与我们预期不符!我们稍微修改一下,以便使其按我们预期工作: + ``` #!/bin/bash @@ -125,12 +132,12 @@ if [ `expr $price \> $cost` == 1 ]; then else echo "Don't sell it" fi - ``` ### factor -**factor** 命令的功能基本与你预期相符。你给出一个数字,该命令会给出对应数字的因子。 +`factor` 命令的功能基本与你预期相符。你给出一个数字,该命令会给出对应数字的因子。 + ``` $ factor 111 111: 3 37 @@ -143,11 +150,12 @@ $ factor 1987 ``` -注:factor 命令对于最后一个数字没有返回很多,这是因为 1987 是一个 **质数**。 +注:`factor` 命令对于最后一个数字没有返回更多因子,这是因为 1987 是一个**质数**。 ### jot -**jot** 命令可以创建一系列数字。给定数字总数及起始数字即可。 +`jot` 命令可以创建一系列数字。给定数字总数及起始数字即可。 + ``` $ jot 8 10 10 @@ -158,10 +166,10 @@ $ jot 8 10 15 16 17 - ``` -你也可以用如下方式使用 **jot**,这里我们要求递减至数字 2。 +你也可以用如下方式使用 `jot`,这里我们要求递减至数字 2。 + ``` $ jot 8 10 2 10 @@ -172,10 +180,10 @@ $ jot 8 10 2 4 3 2 - ``` -**jot** 可以帮你构造一系列数字组成的列表,该列表可以用于其它任务。 +`jot` 可以帮你构造一系列数字组成的列表,该列表可以用于其它任务。 + ``` $ for i in `jot 7 17`; do echo April $i; done April 17 @@ -185,28 +193,28 @@ April 20 April 21 April 22 April 23 - ``` ### bc -**bc** 基本上是命令行数学运算最佳工具之一。输入你想执行的运算,使用管道发送至该命令即可: +`bc` 基本上是命令行数学运算最佳工具之一。输入你想执行的运算,使用管道发送至该命令即可: + ``` $ echo "123.4+5/6-(7.89*1.234)" | bc 113.664 - ``` -可见 **bc** 并没有忽略精度,而且输入的字符串也相当直截了当。它还可以进行大小比较、处理布尔值、计算平方根、正弦、余弦和正切等。 +可见 `bc` 并没有忽略精度,而且输入的字符串也相当直截了当。它还可以进行大小比较、处理布尔值、计算平方根、正弦、余弦和正切等。 + ``` $ echo "sqrt(256)" | bc 16 $ echo "s(90)" | bc -l .89399666360055789051 - ``` -事实上,**bc** 甚至可以计算 pi。你需要指定需要的精度。 +事实上,`bc` 甚至可以计算 pi。你需要指定需要的精度。 + ``` $ echo "scale=5; 4*a(1)" | bc -l 3.14156 @@ -216,10 +224,10 @@ $ echo "scale=20; 4*a(1)" | bc -l 3.14159265358979323844 $ echo "scale=40; 4*a(1)" | bc -l 3.1415926535897932384626433832795028841968 - ``` -除了通过管道接收数据并返回结果,**bc**还可以交互式运行,输入你想执行的运算即可。本例中提到的 scale 设置可以指定有效数字的个数。 +除了通过管道接收数据并返回结果,`bc`还可以交互式运行,输入你想执行的运算即可。本例中提到的 `scale` 设置可以指定有效数字的个数。 + ``` $ bc bc 1.06.95 @@ -232,10 +240,10 @@ scale=2 2/3 .66 quit - ``` -你还可以使用 **bc** 完成数字进制转换。**obase** 用于设置输出的数字进制。 +你还可以使用 `bc` 完成数字进制转换。`obase` 用于设置输出的数字进制。 + ``` $ bc bc 1.06.95 @@ -248,23 +256,23 @@ obase=16 256 <=== entered 100 <=== response quit - ``` -按如下方式使用 **bc** 也是完成十六进制与十进制转换的最简单方式之一: +按如下方式使用 `bc` 也是完成十六进制与十进制转换的最简单方式之一: + ``` $ echo "ibase=16; F2" | bc 242 $ echo "obase=16; 242" | bc F2 - ``` -在上面第一个例子中,我们将输入进制 (ibase) 设置为十六进制 (hex),完成十六进制到为十进制的转换。在第二个例子中,我们执行相反的操作,即将输出进制 (obase) 设置为十六进制。 +在上面第一个例子中,我们将输入进制(`ibase`)设置为十六进制(`hex`),完成十六进制到为十进制的转换。在第二个例子中,我们执行相反的操作,即将输出进制(`obase`)设置为十六进制。 ### 简单的 bash 数学运算 通过使用双括号,我们可以在 bash 中完成简单的数学运算。在下面的例子中,我们创建一个变量,为变量赋值,然后依次执行加法、自减和平方。 + ``` $ ((e=11)) $ (( e = e + 7 )) @@ -278,19 +286,19 @@ $ echo $e $ ((e=e**2)) $ echo $e 289 - ``` 允许使用的运算符包括: + ``` + - 加法及减法 ++ -- 自增与自减 -* / % 乘法,除法及求余数 +* / % 乘法、除法及求余数 ^ 指数运算 - ``` 你还可以使用逻辑运算符和布尔运算符: + ``` $ ((x=11)); ((y=7)) $ if (( x > y )); then @@ -303,14 +311,13 @@ $ if (( x > y )) >> (( y > z )); then > echo "letters roll downhill" > fi letters roll downhill - ``` 或者如下方式: + ``` $ if [ x > y ] << [ y > z ]; then echo "letters roll downhill"; fi letters roll downhill - ``` 下面计算 2 的 3 次幂: @@ -319,23 +326,20 @@ $ echo "2 ^ 3" 2 ^ 3 $ echo "2 ^ 3" | bc 8 - ``` ### 总结 在 Linux 系统中,有很多不同的命令行工具可以完成数字运算。希望你在读完本文之后,能掌握一两个新工具。 -使用 [Facebook][1] 或 [LinkedIn][2] 加入 Network World 社区,点评你最喜爱的主题。 - -------------------------------------------------------------------------------- via: https://www.networkworld.com/article/3268964/linux/how-to-do-math-on-the-linux-command-line.html 作者:[Sandra Henry-Stocker][a] -译者:[pinewall](https://github.com/pinewall) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[pinewall](https://github.com/pinewall) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 6202023deaa567448eb0f8f2adba4b61274cfc0c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 14 May 2018 19:06:18 +0800 Subject: [PATCH 072/111] PUB:20180417 How to do math on the Linux command line.md @pinewall https://linux.cn/article-9642-1.html --- .../20180417 How to do math on the Linux command line.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180417 How to do math on the Linux command line.md (100%) diff --git a/translated/tech/20180417 How to do math on the Linux command line.md b/published/20180417 How to do math on the Linux command line.md similarity index 100% rename from translated/tech/20180417 How to do math on the Linux command line.md rename to published/20180417 How to do math on the Linux command line.md From 31dbe7af1d77008c92b0317666fe93b6c23a35de Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Mon, 14 May 2018 22:24:57 +0800 Subject: [PATCH 073/111] Delete 20180201 IT automation- How to make the case.md --- ...201 IT automation- How to make the case.md | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 sources/talk/20180201 IT automation- How to make the case.md diff --git a/sources/talk/20180201 IT automation- How to make the case.md b/sources/talk/20180201 IT automation- How to make the case.md deleted file mode 100644 index 19f096051e..0000000000 --- a/sources/talk/20180201 IT automation- How to make the case.md +++ /dev/null @@ -1,95 +0,0 @@ -Translating by FelxiYFZ IT automation: How to make the case -====== -At the start of any significant project or change initiative, IT leaders face a proverbial fork in the road. - -Path #1 might seem to offer the shortest route from A to B: Simply force-feed the project to everyone by executive mandate, essentially saying, “You’re going to do this – or else.” - -Path #2 might appear less direct, because on this journey you take the time to explain the strategy and the reasons behind it. In fact, you’re going to be making pit stops along this route, rather than marathoning from start to finish: “Here’s what we’re doing – and why we’re doing it.” - -Guess which path bears better results? - -If you said #2, you’ve traveled both paths before – and experienced the results first-hand. Getting people on board with major changes beforehand is almost always the smarter choice. - -IT leaders know as well as anyone that with significant change often comes [significant fear][1], skepticism, and other challenges. It may be especially true with IT automation. The term alone sounds scary to some people, and it is often tied to misconceptions. Helping people understand the what, why, and how of your company’s automation strategy is a necessary step to achieving your goals associated with that strategy. - -[ **Read our related article,** [**IT automation best practices: 7 keys to long-term success**][2]. ] - -With that in mind, we asked a variety of IT leaders for their advice on making the case for automation in your organization: - -## 1. Show people what’s in it for them - -Let’s face it: Self-interest and self-preservation are natural instincts. Tapping into that human tendency is a good way to get people on board: Show people how your automation strategy will benefit them and their jobs. Will automating a particular process in the software pipeline mean fewer middle-of-the-night calls for team members? Will it enable some people to dump low-skill, manual tasks in favor of more strategic, higher-order work – the sort that helps them take the next step in their career? - -“Convey what’s in it for them, and how it will benefit clients and the whole company,” advises Vipul Nagrath, global CIO at [ADP][3]. “Compare the current state to a brighter future state, where the company enjoys greater stability, agility, efficiency, and security.” - -The same approach holds true when making the case outside of IT; just lighten up on the jargon when explaining the benefits to non-technical stakeholders, Nagrath says. - -Setting up a before-and-after picture is a good storytelling device for helping people see the upside. - -“You want to paint a picture of the current state that people can relate to,” Nagrath says. “Present what’s working, but also highlight what’s causing teams to be less than agile.” Then explain how automating certain processes will improve that current state. - -## 2. Connect automation to specific business goals - -Part of making a strong case entails making sure people understand that you’re not just trend-chasing. If you’re automating simply for the sake of automating, people will sniff that out and become more resistant – perhaps especially within IT. - -“The case for automation needs to be driven by a business demand signal, such as revenue or operating expense,” says David Emerson, VP and deputy CISO at [Cyxtera][4]. “No automation endeavor is self-justifying, and no technical feat, generally, should be a means unto itself, unless it’s a core competency of the company.” - -Like Nagrath, Emerson recommends promoting the incentives associated with achieving the business goals of automation, and working toward these goals (and corresponding incentives) in an iterative, step-by-step fashion. - -## 3. Break the automation plan into manageable pieces - -Even if your automation strategy is literally “automate everything,” that’s a tough sell (and probably unrealistic) for most organizations. You’ll make a stronger case with a plan that approaches automation manageable piece by manageable piece, and that enables greater flexibility to adapt along the way. - -“When making a case for automation, I recommend clearly illustrating the incentive to move to an automated process, and allowing iteration toward that goal to introduce and prove the benefits at lower risk,” Emerson says. - -Sergey Zuev, founder at [GA Connector][5], shares an in-the-trenches account of why automating incrementally is crucial – and how it will help you build a stronger, longer-lasting argument for your strategy. Zuev should know: His company’s tool automates the import of data from CRM applications into Google Analytics. But it was actually the company’s internal experience automating its own customer onboarding process that led to a lightbulb moment. - -“At first, we tried to build the whole onboarding funnel at once, and as a result, the project dragged [on] for months,” Zuev says. “After realizing that it [was] going nowhere, we decided to select small chunks that would have the biggest immediate effect, and start with that. As a result, we managed to implement one of the email sequences in just a week, and are already reaping the benefits of the desecrated manual effort.” - -## 4. Sell the big-picture benefits too - -A step-by-step approach does not preclude painting a bigger picture. Just as it’s a good idea to make the case at the individual or team level, it’s also a good idea for help people understand the company-wide benefits. - -“If we can accelerate the time it takes for the business to get what it needs, it will silence the skeptics.” - -Eric Kaplan, CTO at [AHEAD][6], agrees that using small wins to show automation’s value is a smart strategy for winning people over. But the value those so-called “small” wins reveal can actually help you sharpen the big picture for people. Kaplan points to the value of individual and organizational time as an area everyone can connect with easily. - -“The best place to do this is where you can show savings in terms of time,” Kaplan says. “If we can accelerate the time it takes for the business to get what it needs, it will silence the skeptics.” - -Time and scalability are powerful benefits business and IT colleagues, both charged with growing the business, can grasp. - -“The result of automation is scalability – less effort per person to maintain and grow your IT environment, as [Red Hat][7] VP, Global Services John Allessio recently [noted][8]. “If adding manpower is the only way to grow your business, then scalability is a pipe dream. Automation reduces your manpower requirements and provides the flexibility required for continued IT evolution.” (See his full article, [What DevOps teams really need from a CIO][8].) - -## 5. Promote the heck out of your results - -At the outset of your automation strategy, you’ll likely be making the case based on goals and the anticipated benefits of achieving those goals. But as your automation strategy evolves, there’s no case quite as convincing as one grounded in real-world results. - -“Seeing is believing,” says Nagrath, ADP’s CIO. “Nothing quiets skeptics like a track record of delivery.” - -That means, of course, not only achieving your goals, but also doing so on time – another good reason for the iterative, step-by-step approach. - -While quantitative results such as percentage improvements or cost savings can speak loudly, Nagrath advises his fellow IT leaders not to stop there when telling your automation story. - -“Making a case for automation is also a qualitative discussion, where we can promote the issues prevented, overall business continuity, reductions in failures/errors, and associates taking on [greater] responsibility as they tackle more value-added tasks.” - - --------------------------------------------------------------------------------- - -via: https://enterprisersproject.com/article/2018/1/how-make-case-it-automation - -作者:[Kevin Casey][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://enterprisersproject.com/user/kevin-casey -[1]:https://enterprisersproject.com/article/2017/10/how-beat-fear-and-loathing-it-change -[2]:https://enterprisersproject.com/article/2018/1/it-automation-best-practices-7-keys-long-term-success?sc_cid=70160000000h0aXAAQ -[3]:https://www.adp.com/ -[4]:https://www.cyxtera.com/ -[5]:http://gaconnector.com/ -[6]:https://www.thinkahead.com/ -[7]:https://www.redhat.com/en?intcmp=701f2000000tjyaAAA -[8]:https://enterprisersproject.com/article/2017/12/what-devops-teams-really-need-cio -[9]:https://enterprisersproject.com/email-newsletter?intcmp=701f2000000tsjPAAQ From d294bccfaac0c9389323e60abb0478164c36cf9b Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Mon, 14 May 2018 22:26:10 +0800 Subject: [PATCH 074/111] Create IT automation: How to make the case --- .../talk/IT automation: How to make the case | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 translated/talk/IT automation: How to make the case diff --git a/translated/talk/IT automation: How to make the case b/translated/talk/IT automation: How to make the case new file mode 100644 index 0000000000..5910b6c2f1 --- /dev/null +++ b/translated/talk/IT automation: How to make the case @@ -0,0 +1,96 @@ +IT自动化:如何去实现 +====== + +在任何重要的项目或变更刚开始的时候,TI的管理者在前进的道路上面临着普遍的抉择。 + +第一条路径看上去是提供了一个从A到B的最短路径:简单的把项目强制分配给每个人去执行,本质来说就是你要么按照要求去做要么就不要做了。 + +第二条路径可能看上去会不是很直接,因为要通过这条路径你要花时间去解释项目背后的策略以及原因。你会沿着这条路线设置停靠站点而不是从起点到终点的马拉松: +“这就是我们正在做的-和为什么我们这么做。” + +猜想一下哪条路径会赢得更好的结果? + +如果你选的是路径2,你肯定是以前都经历过这两条路径-而且经历了第一次的结局。让人们参与到重大变革中总会是最明智的选择。 + +IT领导者也知道重大的变革总会带来严重的恐慌、怀疑,和其他的挑战。IT自动化确实是很正确的改变。这个术语对某些人来说是很可怕的,而且容易被曲解。帮助人们理解你的公司需要IT自动化的必要性的原因以及如何去实现是达到你的目标和策略的重要步骤。 + +[**阅读我们的相关文章,**[**IT自动化最佳实践:持久成功的7个关键点**][2]. ] + +考虑到这一点,我们咨询了许多IT管理者关于如何在你的组织中实现IT自动化。 + +## 1. 向人们展示它的优点 + +我们要面对的一点事实是:自我利益和自我保护是本能。利用人们的这种本能是一个吸引他们的好方法:向他们展示自动化策略将如何让他们和他们的工作获益。自动化将会是软件管道中的一个特定过程意味着将会减少在半夜呼叫团队同事来解决故障?他将能让一些人丢弃技术含量低的技能,用更有策略,高效的有序工作代替手工作业,这将会帮助他们的职业生涯更进一步? + +”向他们传达他们能得到什么好处,自动化将会如何让他们的客户和公司受益,“来自vipual的建议,ADP全球首席技术官。”将现在的状态和未来光明的未来进行对比,展现公司将会变得如何稳定,敏捷,高效和安全。“ + +这样的方法同样适用于IT领域之外的其他领域;只要在向非技术领域的股东们解读利益的时候解释清楚一些术语即可,Nagrath 说道。 + +设置好前后的情景是一个不错的帮助人们理解的更透彻的故事机。 + +“你要描述一幅人们能够联想到的当前状态的画面,”Nagrath 说。“描述现在是什么工作,但也要重点强调是什么导致团队的工作效率不够敏捷。”然后再阐释自动化过程将如何提高现在的状态。 + +## 2.将自动化和特定的商业目标绑定在一起 + +一个强有力的案列的一部分要确保人们理解你不只是在追逐潮流趋势。如果i只是为了自动化而自动化,人们会很快察觉到进而会更加抵制的-也许在IT界更是如此。 + +“自动化需要商业需求的驱动,列如收入和运营开销,” David说道,Cyxtera的副总裁和首席信息安全官。“没有自动化的努力是自我辩护的,而且任何技术专长都不应该被当做一种手段,除非它是公司的一项核心能力” + +像Nagrath一样,Emerson建议将达到自动化的商业目标和奖励措施挂钩,用迭代式的循序渐进的方式推进这些目标和相关的激励措施。 + +## 3. 将自动化计划分解为可管理的条目 + +即使你的自动化策略字面上是“一切都自动化,”对大多数组织来说那也是很艰难的而且可能是没有灵活性的。你需要一个能够将自动化目标分解为可管理的目标的计划来制定一个强有力的方案。而且这将能够创造很大的灵活性来适应之后漫长的道路。 + +“当制定一个自动化方案的时候,我建议详细的阐明推进自动化进程的奖励措施,而且允许迭代朝着目标前进来介绍和证明利益处于一个低风险水平,”Emerson说道。 + +Sergey Zuev, GA Connector的创始人,分享了一个为什么自动化如此重要的快节奏体验的报告-它将如何帮助你的策略建立一个强壮持久的论点。Zuevz应该知道:他的公司的自动化工具将公司的客户关系应用数据导入谷歌分析。但实际上是公司的内部经验使顾客培训进程自动化从而出现了一个闪耀的时刻。 + +“起初, 我们曾尝试去建立整个培训机制,结果这个项目搁浅了好几个月,”Zuev说道。“认识到这将无法继续下去之后,我们决定挑选其中的一个能够有巨大的时效的领域,而且立即启动。结果我们只用了一周就实现了其中的电子邮件序列的目标,而且我们已经从被亵渎的体力劳动中获益。” + +## 4. 出售主要部分也有好处 + +循序渐进的方法并不会阻碍构建一个宏伟的蓝图。就像以个人或者团队的水平来制定方案是一个好主意,帮助人们理解全公司的利益也是一个不错的主意。 + +“如果我们能够加速达到商业需求所需的时间,那么一切质疑将会平息。” + +Eric Kaplan, AHEAD的首席技术官,赞同通过小范围的胜利来展示自动化的价值是一个赢得人心的聪明策略。但是那些所谓的“小的”的价值揭示能够帮助你提高人们的整体形象。Kaplan指出个人和组织间的价值是每个人都可以容易联系到的领域。 + +“最能展现的地方就是你能够在节约多少时间,”Kaaplan说。“如果我们能够加速达到商业需求所需的时间,那么一切质疑将会消失。” + +时间和可伸缩性是业务和IT同事的强大优势,都被业务的增长控制,能够被控制。 + +“自动化的结果是伸缩灵活的-每个人只需较少的努力就能保持和改善你的IT环境”,红帽的全球服务副总裁John最近提到。“如果增加人力是提升你的商业的唯一途径,那么伸缩灵活就是白日梦。自动化减少了你的人力需求而且提供了IT演进所需的灵活性和韧性。”(详细内容请参考他的文章,[DevOps团队对CIO的真正需求是什么。]) + +## 5. 推广你的成果。 + +在你自动化策略的开始时,你可能是在目标和要达到目标的预期利益上制定方案。但随着你的自动化策略的不断演进,没有什么能够比现实中的实际结果令人信服。 + +“眼见为实,”ADP的首席技术官Nagrath说。“没有什么比追踪记录能够平息质疑。” + +那意味着,不仅仅要达到你的目标,还要准时的完成-这是迭代的循序渐进的方法论的另一个不错的解释。 + +而量化的结果如比列的提高或者成本的节省可以大声宣扬出来,Nagrath建议他的IT领导者的同事们在讲述你们的自动化故事的时候不要仅仅止步于此。 + +为自动化提供案列也是一个定性的讨论,通过它我们能够促进问题的预防,归总商业的连续性,减伤失败或错误,而且能够在他们处理更有价值的任务时承担更多的责任。 + +-------------------------------------------------------------------------------- + +via: https://enterprisersproject.com/article/2018/1/how-make-case-it-automation + +作者:[Kevin Casey][a] +译者:[FelixYFZ](https://github.com/FelixYFZ) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://enterprisersproject.com/user/kevin-casey +[1]:https://enterprisersproject.com/article/2017/10/how-beat-fear-and-loathing-it-change +[2]:https://enterprisersproject.com/article/2018/1/it-automation-best-practices-7-keys-long-term-success?sc_cid=70160000000h0aXAAQ +[3]:https://www.adp.com/ +[4]:https://www.cyxtera.com/ +[5]:http://gaconnector.com/ +[6]:https://www.thinkahead.com/ +[7]:https://www.redhat.com/en?intcmp=701f2000000tjyaAAA +[8]:https://enterprisersproject.com/article/2017/12/what-devops-teams-really-need-cio +[9]:https://enterprisersproject.com/email-newsletter?intcmp=701f2000000tsjPAAQ From a9f326b2b00329216cb3e77642b510dd69df25a0 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Mon, 14 May 2018 22:29:12 +0800 Subject: [PATCH 075/111] Delete 20171116 10 easy steps from proprietary to open source.md --- ...y steps from proprietary to open source.md | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 sources/tech/20171116 10 easy steps from proprietary to open source.md diff --git a/sources/tech/20171116 10 easy steps from proprietary to open source.md b/sources/tech/20171116 10 easy steps from proprietary to open source.md deleted file mode 100644 index a8bd86314d..0000000000 --- a/sources/tech/20171116 10 easy steps from proprietary to open source.md +++ /dev/null @@ -1,79 +0,0 @@ -Translating by FelixYFZ 10 easy steps from proprietary to open source -====== -"But surely open source software is less secure, because everybody can see it, and they can just recompile it and replace it with bad stuff they've written." Hands up: who's heard this?1 - -When I talk to customers--yes, they let me talk to customers sometimes--and to folks in the field2 this comes up quite frequently. In a previous article, "[Review by many eyes does not always prevent buggy code][1]", I talked about how open source software--particularly security software--isn't magically more secure than proprietary software, but I'd still go with open source over proprietary every time. But the way I've heard the particular question--about open source software being less secure--suggests that sometimes it's not enough to just explain that open source needs work, but we must also actively engage in [apologetics][2]3. - -So here goes. I don't expect it to be up to Newton's or Wittgenstein's levels of logic, but I'll do what I can, and I'll summarise at the bottom so you have a quick list of the points if you want it. - -### The arguments - -First, we should accept that no software is perfect6. Not proprietary software, not open source software. Second, we should accept that good proprietary software exists, and third, there is also some bad open source software out there. Fourth, there are extremely intelligent, gifted, and dedicated architects, designers, and software engineers who create proprietary software. - -But here's the rub: fifth, there is a limited pool of people who will work on or otherwise look at proprietary software. And you can never hire all the best people. Even in government and public sector organisations--who often have a larger talent pool available to them, particularly for cough security-related cough applications--the pool is limited. - -Sixth, the pool of people available to look at, test, improve, break, re-improve, and roll out open source software is almost unlimited and does include the best people. Seventh (and I love this one), the pool also includes many of the people writing the proprietary software. Eighth, many of the applications being written by public sector and government organisations are open sourced anyway. - -Ninth, if you're worried about running open source software that is unsupported or comes from dodgy, un-provenanced sources, then good news: There are a bunch of organisations7 who will check the provenance of that code, support, maintain, and patch it. They'll do it along the same type of business lines that you'd expect from a proprietary software provider. You can also ensure that the software you get from them is the right software: Their standard technique is to sign bundles of software so you can verify that what you're installing isn't from some random bad person who's taken that code and done Bad Things™ with it. - -Tenth (and here's the point of this article), when you run open source software, when you test it, when you provide feedback on issues, when you discover errors and report them, you are tapping into--and adding to--the commonwealth of knowledge and expertise and experience that is open source, which is made only greater by your doing so. If you do this yourself, or through one of the businesses that support open source software8, you are part of this commonwealth. Things get better with open source software, and you can see them getting better. Nothing is hidden--it's, well, open. Can things get worse? Yes, they can, but we can see when that happens and fix it. - -This commonwealth does not apply to proprietary software: what stays hidden does not enlighten or enrich the world. - -I know that I need to be careful about the use of the "commonwealth" as a Briton; it has connotations of (faded…) empires, which I don't intend in this case. It's probably not what Cromwell9 had in mind when he talked about the "Commonwealth," either, and anyway, he's a somewhat controversial historical figure. What I'm talking about is a concept in which I think the words deserve concatenation--"common" and "wealth"--to show that we're talking about something more than just money, but shared wealth available to all of humanity. - -I really believe in this. If you want to take away a religious message from this article, it should be this10: the commonwealth is our heritage, our experience, our knowledge, our responsibility. The commonwealth is available to all of humanity. We have it in common, and it is an almost inestimable wealth. - -### A handy crib sheet - - 1. (Almost) no software is perfect. - 2. There is good proprietary software. - 3. There is bad open source software. - 4. There are clever, talented, and devoted people who create proprietary software. - 5. The pool of people available to write and improve proprietary software is limited, even within the public sector and government realm. - 6. The corresponding pool of people for open source is virtually unlimited… - 7. …and includes a goodly number of the talent pool of people writing proprietary software. - 8. Public sector and government organisations often open source their software anyway. - 9. There are businesses that will support open source software for you. - 10. Contribution--even usage--adds to the commonwealth. - - - -1 OK--you can put your hands down now. - -2 Should this be capitalized? Is there a particular field, or how does it work? I'm not sure. - -3 I have a degree in English literature and theology--this probably won't surprise regular readers of my articles.4 - -4 Not, I hope, because I spout too much theology,5 but because it's often full of long-winded, irrelevant humanities (U.S. English: "liberal arts") references. - -5 Emacs. Every time. - -6 Not even Emacs. And yes, I know that there are techniques to prove the correctness of some software. (I suspect that Emacs doesn't pass many of them…) - -7 Hand up here: I'm employed by one of them, [Red Hat][3]. Go have a look--it's a fun place to work, and [we're usually hiring][4]. - -8 Assuming that they fully abide by the rules of the open source licence(s) they're using, that is. - -9 Erstwhile "Lord Protector of England, Scotland, and Ireland"--that Cromwell. - -10 Oh, and choose Emacs over Vi variants, obviously. - -This article originally appeared on [Alice, Eve, and Bob - a security blog][5] and is republished with permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/commonwealth-open-source - -作者:[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://opensource.com/article/17/10/many-eyes -[2]:https://en.wikipedia.org/wiki/Apologetics -[3]:https://www.redhat.com/ -[4]:https://www.redhat.com/en/jobs -[5]:https://aliceevebob.com/2017/10/24/the-commonwealth-of-open-source/ From 20f61653ec4b5ee1b61e6fb08398bc37d1b5d527 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Mon, 14 May 2018 22:30:24 +0800 Subject: [PATCH 076/111] Create 10 easy steps from proprietary to open source --- ...easy steps from proprietary to open source | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 translated/tech/10 easy steps from proprietary to open source diff --git a/translated/tech/10 easy steps from proprietary to open source b/translated/tech/10 easy steps from proprietary to open source new file mode 100644 index 0000000000..9d46f03246 --- /dev/null +++ b/translated/tech/10 easy steps from proprietary to open source @@ -0,0 +1,81 @@ +从专有到开源的十个简单步骤 +====== + +"开源软件的确不是很安全,因为每个人都能使用它,而且他们能够随意的进行编译并且用他们自己写的不好的东西进行替换。"举手示意:谁之前听说过这个?1 + +当我和顾客讨论的时候,是的,他们有时候会让我和顾客交谈,对于场景2的人来说这是很常见的。在前一篇文章中,"[许多人的评论并不一定能防止错误代码]",我会 +谈论尤其是安全的软件这块--并没有如外界所说的那样比专有软件安全,但是和专有软件比起来,我每次还是比较青睐开源软件。但我听到--关于开源软件不是很安全--表明了有时候仅仅解释开源需要工作投入是不够的,但是我们也需要积极的参与进去。 + +我并不期望能够达到牛顿或者维特根斯坦的逻辑水平,但是我会尽我所能,而且我会在结尾做个总结,如果你感兴趣的话可以去快速的浏览一下。 + +### 关键因素 + +首先,我们必须明白没有任何一款软件是绝对安全的。无论是专有软件还是开源软件。第二,我们应该接受确实还是存在一些很不错的专利软件的。第三,也存在一些不好的开源软件。第四,有很多优秀的,很有天赋的,专业的架构师,设计师和软件工程师设计开发专利软件。 + +但也有些摩擦:第五点,从事专有软件的人员是有限的,而且你不可能总是能够雇佣到最好的员工。即使在政府部门或者公共组织--他们拥有丰富的人才资源池,但在安全应用这块,他们的人才也是有限的。 + +第六点,开发,测试,提升改善开源软件的人总是无限的,而且还包含最好的人才。第七(也是我最欢的一),这群人找那个包含很多编写专有软件的人才。第八,许多政府或者公共组织开发的软件也都逐渐开源了。 + +第九,如果你在担心你在运行的软件的不被支持或者来源不明,好消息是:有一批组织会来检查软件代码的来源,提供支持和补丁更新。他们会按照专利软件模式那样去运行开源软件:他们的技术标准就是去签署认证以便你可以验证你正在运行的开源软件不是来源不明或者是恶意的软件。 + +第十点(也是这篇文章的重点),当你运行,测试,在问题上进行反馈,发现问题并且报告的时候,你正在为共福利贡献知识,专业技能以及经验,这就是开源,正因为你的所做的这些而变得更好。如果你是通过个人或者提供支持的商业组织,,你已经成为了这个组织的一部分了。开源让软件变得越来越好,你可以看到它们的变化。没有什么是隐藏封闭的,它是完全开放的。事情会变坏吗?是的,但是我们能够及时发现问题并且修复。 + +这个共享福利并不适用于专有软件:保持隐藏的东西是不能照亮个丰富世界的。 + +我知道作为一个英国人在使用联邦这个词的时候要小心谨慎的;它和帝国连接着的,但我所表达的不是这个意思。它不是克伦威尔在对这个词所表述的意思,无论如何,他是一个有争议的历史人物。我所表达的意思是这个词有共同和福利连接,福利不是指钱而是全人类都能拥有的福利。 + +我真的很相信这点的。如果i想从这篇文章中国得到一些虔诚的信息的话,那应该是第十条:共享福利是我们的遗产,我们的经验,我们的知识,我们的责任。共享福利是全人类都能拥有的。我们共同拥有它而且它是一笔无法估量的财富。 + +### 便利贴 + + 1. (几乎)没有一款软件是完美无缺的。 + 2. 有很好的专有软件。 + 3. 有不好的专有软件。 + 4. 有聪明,有才能,专注的人开开发专有软件。 + 5. 从事开发完善专有软件的人是有限的,即使在政府或者公共组织也是如此。 + 6. 相对来说从事开源软件的人是无限的。 + 7. …而且包括很多从事专有软件的人才。 + 8. 政府和公共组织的人经常开源它们的软件. + 9. 有商业组织会为你的开源软件提供支持. + 10. 贡献--即使使用--为开源软件贡献. + + + +1 OK--you can put your hands down now. + +2 Should this be capitalized? Is there a particular field, or how does it work? I'm not sure. + +3 I have a degree in English literature and theology--this probably won't surprise regular readers of my articles.4 + +4 Not, I hope, because I spout too much theology,5 but because it's often full of long-winded, irrelevant humanities (U.S. English: "liberal arts") references. + +5 Emacs. Every time. + +6 Not even Emacs. And yes, I know that there are techniques to prove the correctness of some software. (I suspect that Emacs doesn't pass many of them…) + +7 Hand up here: I'm employed by one of them, [Red Hat][3]. Go have a look--it's a fun place to work, and [we're usually hiring][4]. + +8 Assuming that they fully abide by the rules of the open source licence(s) they're using, that is. + +9 Erstwhile "Lord Protector of England, Scotland, and Ireland"--that Cromwell. + +10 Oh, and choose Emacs over Vi variants, obviously. + +This article originally appeared on [Alice, Eve, and Bob - a security blog][5] and is republished with permission. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/commonwealth-open-source + +作者:[Mike Bursell][a] +译者:[FelixYFZ](https://github.com/FelixYFZ) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/mikecamel +[1]:https://opensource.com/article/17/10/many-eyes +[2]:https://en.wikipedia.org/wiki/Apologetics +[3]:https://www.redhat.com/ +[4]:https://www.redhat.com/en/jobs +[5]:https://aliceevebob.com/2017/10/24/the-commonwealth-of-open-source/ From c8547607f3ec05df51dedad8eaa08d04de9c22b0 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 14 May 2018 22:34:57 +0800 Subject: [PATCH 077/111] Translated by qhwdw --- ...IoT using Android Things and TensorFlow.md | 312 ------------------ ...IoT using Android Things and TensorFlow.md | 311 +++++++++++++++++ 2 files changed, 311 insertions(+), 312 deletions(-) delete mode 100644 sources/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md create mode 100644 translated/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md diff --git a/sources/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md b/sources/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md deleted file mode 100644 index 68ed3bf05f..0000000000 --- a/sources/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md +++ /dev/null @@ -1,312 +0,0 @@ -Translating by qhwdw -How to apply Machine Learning to IoT using Android Things and TensorFlow -============================================================  - -This project explores how to apply Machine Learning to IoT. In more details, as IoT platform, we will use **Android Things** and as Machine Learning engine we will use **Google TensorFlow**. - -![Machine Learning with Android Things](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/machine_learning_android_things.png) - -Nowadays, Machine Learning is with Internet of Things one of the most interesting technological topics.  To give a simple definition of the Machine Learning, it is possible to the [Wikipedia definition][13]:Machine learning is a field of computer science that gives computer systems the ability to “learn” (i.e. progressively improve performance on a specific task) with data, without being explicitly programmed. - -In other words, after a training step, a system can predict outcomes even if it is not specifically programmed for them. On the other hands, we all know IoT and the concept of connected devices. One of the most promising topics is how to apply Machine Learning to IoT, building expert systems so that it is possible to develop a system that is able to “learn”. Moreover, it uses this knowledge to control and manage physical objects. - -There are several fields where applying Machine Learning and IoT produce  an important value, just to mention a few interesting fields, there are: - -* Industrial IoT (IIoT) in the predictive maintenance - -* Consumer IoT where the Machine earning can make the device intelligent so that it can adapt to our habits - -In this tutorial, we want to explore how to apply Machine Learning to IoT using Android Things and TensorFlow. The basic idea that stands behind this Android Things IoT project is exploring how to build a  _robot car that is able to recognize some basic shapes (like arrows) and control in this way the robot car directions_ . We have already covered [how to build robot car using Android Things][5], so I suggest you read the tutorial before starting this project. - -This Machine Learning and IoT project cover these main topics: - -* How to set up the TensorFlow environment using Docker - -* How to train the TensorFlow system - -* How to integrate TensorFlow with Android Things - -* How to control the robot car using TensorFlow result - -This project is derived from [Android Things TensorFlow image classifier][6]. - -Let us start! - -### How to use Tensorflow image recognition - -Before starting it is necessary to install and configure the TensorFlow environment. I’m not a Machine Learning expert, so I need to find something fast and ready to use so that we can build the TensorFlow image classifier. For this reason, we can use Docker to run an image of TensorFlow. Follow these steps: - -1. Clone the TensorFlow repository: - ``` - git clone https://github.com/tensorflow/tensorflow.git - cd /tensorflow - git checkout v1.5.0 - ``` - -2. Create a directory (`/tf-data`) that will hold all the files that we will use during the project. - -3. Run Docker: - ``` - docker run -it \ - --volume /tf-data:/tf-data \ - --volume /tensorflow:/tensorflow \ - --workdir /tensorflow tensorflow/tensorflow:1.5.0 bash - ``` - - Using this command, we run an interactive TensorFlow environment and we mount some directories that we will use during the project - -### How to Train TensorFlow to recognize images - -Before the Android Things system is able to recognize images, it is necessary to train the TensorFlow engine so that it can build its model. For this purpose, it is necessary to gather several images. As said before, we want to use arrows to control the Android Things robot car so that we have to collect at least four arrow types: - -* up arrow - -* down arrow - -* left arrow - -* right arrow - -To train the system is necessary to create a “knowledge base” with these four different image categories. Create in `/tf-data` a directory called `images` and under it four sub-directories named: - -* up-arrow - -* down-arrow - -* left-arrow - -* right-arrow - -Now it is time to look for the images. I have used Google Image search but you can use other approaches too. To simplify the image download process, you should install a Chrome plugin that downloads all the images with only one click. Do not forget more images you download better is the training process, even if the time to create the model could increase. - -**You may like also** -[How to integrate Android Things using API][2] -[How to use Android Things with Firebase][3] - -Open your browser and start looking for the four image categories: - -![TensorFlow image classifier](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/TensorFlow-image-classifier.png) -[Save][7] - -I have downloaded 80 images for each category.  Do not care about image extension. - -Once all the categories have their images follow these steps (in the Docker interface): - -``` -python /tensorflow/examples/image_retraining/retrain.py \ ---bottleneck_dir=tf_files/bottlenecks \ ---how_many_training_steps=4000 \ ---output_graph=/tf-data/retrained_graph.pb \ ---output_labels=/tf-data/retrained_labels.txt \ ---image_dir=/tf-data/images -``` - -It could take some time so be patient. At the end, you should have two files in `/tf-data` folder: - -1. retrained_graph.pb - -2. retrained_labels.txt - -The first file contains our model as the result of the TensorFlow training process while the second file contains the labels related to our four image categories. - -### How to test the Tensorflow model - -If you want to test the model to check if everything is working you can use this command: - -``` -python scripts.label_image \ ---graph=/tf-data/retrained-graph.pb \ ---image=/tf-data/images/[category]/[image_name.jpg] -``` - -### Optimizing the model - -Before we can use this TensorFlow model in the Android Things project it is necessary to optimize it: - -``` -python /tensorflow/python/tools/optimize_for_inference.py \ ---input=/tf-data/retrained_graph.pb \ ---output=/tf-data/opt_graph.pb \ ---input_names="Mul" \ ---output_names="final_result" -``` - -That’s all we have our model. We will use this model to apply Machine Learning to IoT or in more details to integrate Android Things with TensorFlow. The goal is applying to the Android Things app the intelligence to recognize arrow images and react consequently controlling the robot car directions. - -If you want to have more details about TensorFlow and how to generate the model look at the official documentation and to this [tutorial][8]. - -### How to apply Machine Learning to IoT using Android Things and TensorFlow - -Once the TensorFlow data model is ready, we can move to the next step: how to integrate Android Things with TensorFlow.  To this purpose, we can split this task into two steps: - -1. The hardware part, where we connect motors and other peripherals to the Android Things board - -2. Implementing the app - -### Android Things Schematics - -Before digging into the details about how to connect peripherals, this is the list of components used in this Android Things project: - -1. Android Things board (Raspberry Pi 3) - -2. Raspberry Pi Camera - -3. One LED - -4. LN298N Dual H Bridge (to control the motors) - -5. A robot car chassis with two wheels - -I do not cover again [how to control motors using Android Things][9] because we have already covered in the previous post. - -Below the schematics: - -![Integrating Android Things with IoT](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/tensor_bb.png) -[Save][10] - -In the picture above, the camera is not shown. The final result is: - -![Integrating Android Things with TensorFlow](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/android_things_with_tensorflow-min.jpg) -[Save][11] - -### Implementing the Android Things app with TensorFlow - -The last step is implementing the Android Things app. To this purpose, we can re-use the example available in Github named [sample TensorFlow image classifier][12]. Before starting, clone the Github repository so that you can modify the source code. - -This Android Things app is different from the original app because: - -1. it does not use the button to start the camera to capture the image - -2. It uses a different model - -3. It uses a blinking led to notify that the camera will take the picture after the LED stops blinking - -4. It controls the motors when TensorFlow detects an image (arrows). Moreover, it turns on the motors for 5 seconds before starting the loop from step 3 - -To handle a blinking LED, use the following code: - -``` -private Handler blinkingHandler = new Handler(); -private Runnable blinkingLED = new Runnable() { - @Override - public void run() { - try { - // If the motor is running the app does not start the cam - if (mc.getStatus()) - return ; - - Log.d(TAG, "Blinking.."); - mReadyLED.setValue(!mReadyLED.getValue()); - if (currentValue <= NUM_OF_TIMES) { - currentValue++; - blinkingHandler.postDelayed(blinkingLED, - BLINKING_INTERVAL_MS); - } - else { - mReadyLED.setValue(false); - currentValue = 0; - mBackgroundHandler.post(mBackgroundClickHandler); - } - } catch (IOException e) { - e.printStackTrace(); - } - } -}; -``` - -When the LED stops blinking, the app captures the image. - -Now it is necessary to focus on how to control the motors according to the image detected. Modify the method: - -``` -@Override -public void onImageAvailable(ImageReader reader) { - final Bitmap bitmap; - try (Image image = reader.acquireNextImage()) { - bitmap = mImagePreprocessor.preprocessImage(image); - } - - final List results = - mTensorFlowClassifier.doRecognize(bitmap); - - Log.d(TAG, - "Got the following results from Tensorflow: " + results); - - // Check the result - if (results == null || results.size() == 0) { - Log.d(TAG, "No command.."); - blinkingHandler.post(blinkingLED); - return ; - } - - Classifier.Recognition rec = results.get(0); - Float confidence = rec.getConfidence(); - Log.d(TAG, "Confidence " + confidence.floatValue()); - - if (confidence.floatValue() < 0.55) { - Log.d(TAG, "Confidence too low.."); - blinkingHandler.post(blinkingLED); - return ; - } - - String command = rec.getTitle(); - Log.d(TAG, "Command: " + rec.getTitle()); - - if (command.indexOf("down") != -1) - mc.backward(); - else if (command.indexOf("up") != -1) - mc.forward(); - else if (command.indexOf("left") != -1) - mc.turnLeft(); - else if (command.indexOf("right") != -1) - mc.turnRight(); -} -``` - -In this method, after the TensorFlow returns the possible labels matching the image captured, the app compares the result with the possible directions and controls the motors consequently. - -Finally, it is time to use the model created at the beginning. Copy the `opt_graph.pb` and the `reatrained_labels.txt` under the  _assets_  folder replacing the existing files. - -Open the `Helper.java` and modify the following lines: - -``` -public static final int IMAGE_SIZE = 299; -private static final int IMAGE_MEAN = 128; -private static final float IMAGE_STD = 128; -private static final String LABELS_FILE = "retrained_labels.txt"; -public static final String MODEL_FILE = "file:///android_asset/opt_graph.pb"; -public static final String INPUT_NAME = "Mul"; -public static final String OUTPUT_OPERATION = "output"; -public static final String OUTPUT_NAME = "final_result"; -``` - -Run the app and have fun showing arrows to the camera and check the result. The robot car has to move according to the arrow shown. - -### Summary - -At the end of this tutorial, we have discovered how to apply Machine Learning to IoT using Android Things and TensorFlow. We can control the robot car using images and make it moving according to the image shown. - --------------------------------------------------------------------------------- - -via: https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html - -作者:[Francesco Azzola ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.survivingwithandroid.com/author/francesco-azzolagmail-com -[1]:https://www.survivingwithandroid.com/author/francesco-azzolagmail-com -[2]:https://www.survivingwithandroid.com/2017/11/building-a-restful-api-interface-using-android-things.html -[3]:https://www.survivingwithandroid.com/2017/10/synchronize-android-things-with-firebase-real-time-control-firebase-iot.html -[4]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=Machine%20Learning%20with%20Android%20Things -[5]:https://www.survivingwithandroid.com/2017/12/building-a-remote-controlled-car-using-android-things-gpio.html -[6]:https://github.com/androidthings/sample-tensorflow-imageclassifier -[7]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=TensorFlow%20image%20classifier -[8]:https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0 -[9]:https://www.survivingwithandroid.com/2017/12/building-a-remote-controlled-car-using-android-things-gpio.html -[10]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=Integrating%20Android%20Things%20with%20IoT -[11]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=Integrating%20Android%20Things%20with%20TensorFlow -[12]:https://github.com/androidthings/sample-tensorflow-imageclassifier -[13]:https://en.wikipedia.org/wiki/Machine_learning diff --git a/translated/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md b/translated/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md new file mode 100644 index 0000000000..6905e64f39 --- /dev/null +++ b/translated/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md @@ -0,0 +1,311 @@ +如何使用 Android Things 和 TensorFlow 在物联网上应用机器学习 +============================================================  + +这个项目探索了如何将机器学习应用到物联网上。具体来说,物联网平台我们将使用 **Android Things**,而机器学习引擎我们将使用 **Google TensorFlow**。 + +![Machine Learning with Android Things](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/machine_learning_android_things.png) + +现如今,机器学习是物联网上使用的最热门的主题之一。给机器学习的最简单的定义,可能就是 [维基百科上的定义][13]:机器学习是计算机科学中,让计算机不需要显式编程就能去“学习”(即,逐步提升在特定任务上的性能)使用数据的一个领域。 + +换句话说就是,经过训练之后,那怕是它没有针对它们进行特定的编程,这个系统也能够预测结果。另一方面,我们都知道物联网和联网设备的概念。其中一个前景看好的领域就是如何在物联网上应用机器学习,构建专业的系统,这样就能够去开发一个能够“学习”的系统。此外,还可以使用这些知识去控制和管理物理对象。 + +这里有几个应用机器学习和物联网产生重要价值的领域,以下仅提到了几个感兴趣的领域,它们是: + +* 在工业物联网(IIoT)中的预见性维护 + +* 消费物联网中,机器学习可以让设备更智能,它通过调整使设备更适应我们的习惯 + +在本教程中,我们希望去探索如何使用 Android Things 和 TensorFlow 在物联网上应用机器学习。这个 Adnroid Things 物联网项目的基本想法是,探索如何去*构建一个能够识别前方道路上基本形状(比如箭头)的无人驾驶汽车*。我们已经介绍了 [如何使用 Android Things 去构建一个无人驾驶汽车][5],因此,在开始这个项目之前,我们建议你去阅读那个教程。 + +这个机器学习和物联网项目包含如下的主题: + +* 如何使用 Docker 配置 TensorFlow 环境 + +* 如何训练 TensorFlow 系统 + +* 如何使用 Android Things 去集成 TensorFlow + +* 如何使用 TensorFlow 的成果去控制无人驾驶汽车 + +这个项目起源于 [Android Things TensorFlow 图像分类器][6]。 + +我们开始吧! + +### 如何使用 Tensorflow 图像识别 + +在开始之前,需要安装和配置 TensorFlow 环境。我不是机器学习方面的专家,因此,我需要快速找到并且准备去使用一些东西,因此,我们可以构建 TensorFlow 图像识别器。为此,我们使用 Docker 去运行一个 TensorFlow 镜像。以下是操作步骤: + +1. 克隆 TensorFlow 仓库: + ``` + git clone https://github.com/tensorflow/tensorflow.git + cd /tensorflow + git checkout v1.5.0 + ``` + +2. 创建一个目录(`/tf-data`),它将用于保存这个项目中使用的所有文件。 + +3. 运行 Docker: + ``` + docker run -it \ + --volume /tf-data:/tf-data \ + --volume /tensorflow:/tensorflow \ + --workdir /tensorflow tensorflow/tensorflow:1.5.0 bash + ``` + + 使用这个命令,我们运行一个交互式 TensorFlow 环境,可以在使用项目期间挂载一些目录。 + +### 如何训练 TensorFlow 去识别图像 + +在 Android Things 系统能够识别图像之前,我们需要去训练 TensorFlow 引擎,以使它能够构建它的模型。为此,我们需要去收集一些图像。正如前面所言,我们需要使用箭头来控制 Android Things 无人驾驶汽车,因此,我们至少要收集四种类型的箭头: + +* 向上的箭头 + +* 向下的箭头 + +* 向左的箭头 + +* 向右的箭头 + +为训练这个系统,需要使用这四类不同的图像去创建一个“知识库”。在 `/tf-data` 目录下创建一个名为 `images` 的目录,然后在它下面创建如下名字的四个子目录: + +* up-arrow + +* down-arrow + +* left-arrow + +* right-arrow + +现在,我们去找图片。我使用的是 Google 图片搜索,你也可以使用其它的方法。为了简化图片下载过程,你可以安装一个 Chrome 下载插件,这样你只需要点击就可以下载选定的图片。别忘了多下载一些图片,这样训练效果更好,当然,这样创建模型的时间也会相应增加。 + +**扩展阅读** +[如何使用 API 去集成 Android Things][2] +[如何与 Firebase 一起使用 Android Things][3] + +打开浏览器,开始去查找四种箭头的图片: + +![TensorFlow image classifier](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/TensorFlow-image-classifier.png) +[Save][7] + +每个类别我下载了 80 张图片。不用管图片文件的扩展名。 + +为所有类别的图片做一次如下的操作(在 Docker 界面下): + +``` +python /tensorflow/examples/image_retraining/retrain.py \ +--bottleneck_dir=tf_files/bottlenecks \ +--how_many_training_steps=4000 \ +--output_graph=/tf-data/retrained_graph.pb \ +--output_labels=/tf-data/retrained_labels.txt \ +--image_dir=/tf-data/images +``` + +这个过程你需要耐心等待,它需要花费很长时间。结束之后,你将在 `/tf-data` 目录下发现如下的两个文件: + +1. retrained_graph.pb + +2. retrained_labels.txt + +第一个文件包含了 TensorFlow 训练过程产生的结果模型,而第二个文件包含了我们的四个图片类相关的标签。 + +### 如何测试 Tensorflow 模型 + +如果你想去测试这个模型,去验证它是否能按预期工作,你可以使用如下的命令: + +``` +python scripts.label_image \ +--graph=/tf-data/retrained-graph.pb \ +--image=/tf-data/images/[category]/[image_name.jpg] +``` + +### 优化模型 + +在 Android Things 项目中使用我们的 TensorFlow 模型之前,需要去优化它: + +``` +python /tensorflow/python/tools/optimize_for_inference.py \ +--input=/tf-data/retrained_graph.pb \ +--output=/tf-data/opt_graph.pb \ +--input_names="Mul" \ +--output_names="final_result" +``` + +那个就是我们全部的模型。我们将使用这个模型,把 TensorFlow 与 Android Things 集成到一起,在物联网或者更多任务上应用机器学习。目标是使用 Android Things 应用程序智能识别箭头图片,并反应到接下来的无人驾驶汽车的方向控制上。 + +如果你想去了解关于 TensorFlow 以及如何生成模型的更多细节,请查看官方文档以及这篇 [教程][8]。 + +### 如何使用 Android Things 和 TensorFlow 在物联网上应用机器学习 + +TensorFlow 的数据模型准备就绪之后,我们继续下一步:如何将 Android Things 与 TensorFlow 集成到一起。为此,我们将这个任务分为两步来完成: + +1. 硬件部分,我们将把电机和其它部件连接到 Android Things 开发板上 + +2. 实现这个应用程序 + +### Android Things 示意图 + +在深入到如何连接外围部件之前,先列出在这个 Android Things 项目中使用到的组件清单: + +1. Android Things 开发板(树莓派 3) + +2. 树莓派摄像头 + +3. 一个 LED 灯 + +4. LN298N 双 H 桥电机驱动模块(连接控制电机) + +5. 一个带两个轮子的无人驾驶汽车底盘 + +我不再重复 [如何使用 Android Things 去控制电机][9] 了,因为在以前的文章中已经讲过了。 + +下面是示意图: + +![Integrating Android Things with IoT](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/tensor_bb.png) +[Save][10] + +上图中没有展示摄像头。最终成果如下图: + +![Integrating Android Things with TensorFlow](https://www.survivingwithandroid.com/wp-content/uploads/2018/03/android_things_with_tensorflow-min.jpg) +[Save][11] + +### 使用 TensorFlow 实现 Android Things 应用程序 + +最后一步是实现 Android Things 应用程序。为此,我们可以复用 Github 上名为 [TensorFlow 图片分类器示例][12] 的示例代码。开始之前,先克隆 Github 仓库,这样你就可以修改源代码。 + +这个 Android Things 应用程序与原始的应用程序是不一样的,因为: + +1. 它不使用按钮去开启摄像头图像捕获 + +2. 它使用了不同的模型 + +3. 它使用一个闪烁的 LED 灯来提示,摄像头将在 LED 停止闪烁后拍照 + +4. 当 TensorFlow 检测到图像时(箭头)它将控制电机。此外,在第 3 步的循环开始之前,它将打开电机 5 秒钟。 + +为了让 LED 闪烁,使用如下的代码: + +``` +private Handler blinkingHandler = new Handler(); +private Runnable blinkingLED = new Runnable() { + @Override + public void run() { + try { + // If the motor is running the app does not start the cam + if (mc.getStatus()) + return ; + + Log.d(TAG, "Blinking.."); + mReadyLED.setValue(!mReadyLED.getValue()); + if (currentValue <= NUM_OF_TIMES) { + currentValue++; + blinkingHandler.postDelayed(blinkingLED, + BLINKING_INTERVAL_MS); + } + else { + mReadyLED.setValue(false); + currentValue = 0; + mBackgroundHandler.post(mBackgroundClickHandler); + } + } catch (IOException e) { + e.printStackTrace(); + } + } +}; +``` + +当 LED 停止闪烁后,应用程序将捕获图片。 + +现在需要去关心如何根据检测到的图片去控制电机。修改这个方法: + +``` +@Override +public void onImageAvailable(ImageReader reader) { + final Bitmap bitmap; + try (Image image = reader.acquireNextImage()) { + bitmap = mImagePreprocessor.preprocessImage(image); + } + + final List results = + mTensorFlowClassifier.doRecognize(bitmap); + + Log.d(TAG, + "Got the following results from Tensorflow: " + results); + + // Check the result + if (results == null || results.size() == 0) { + Log.d(TAG, "No command.."); + blinkingHandler.post(blinkingLED); + return ; + } + + Classifier.Recognition rec = results.get(0); + Float confidence = rec.getConfidence(); + Log.d(TAG, "Confidence " + confidence.floatValue()); + + if (confidence.floatValue() < 0.55) { + Log.d(TAG, "Confidence too low.."); + blinkingHandler.post(blinkingLED); + return ; + } + + String command = rec.getTitle(); + Log.d(TAG, "Command: " + rec.getTitle()); + + if (command.indexOf("down") != -1) + mc.backward(); + else if (command.indexOf("up") != -1) + mc.forward(); + else if (command.indexOf("left") != -1) + mc.turnLeft(); + else if (command.indexOf("right") != -1) + mc.turnRight(); +} +``` + +在这个方法中,当 TensorFlow 返回捕获的图片匹配到的可能的标签之后,应用程序将比较这个结果与可能的方向,并因此来控制电机。 + +最后,将去使用前面创建的模型了。拷贝 _assets_ 文件夹下的 `opt_graph.pb` 和 `reatrained_labels.txt` 去替换现在的文件。 + +打开 `Helper.java` 并修改如下的行: + +``` +public static final int IMAGE_SIZE = 299; +private static final int IMAGE_MEAN = 128; +private static final float IMAGE_STD = 128; +private static final String LABELS_FILE = "retrained_labels.txt"; +public static final String MODEL_FILE = "file:///android_asset/opt_graph.pb"; +public static final String INPUT_NAME = "Mul"; +public static final String OUTPUT_OPERATION = "output"; +public static final String OUTPUT_NAME = "final_result"; +``` + +运行这个应用程序,并给摄像头展示几种箭头,以检查它的反应。无人驾驶汽车将根据展示的箭头进行移动。 + +### 总结 + +教程到此结束,我们讲解了如何使用 Android Things 和 TensorFlow 在物联网上应用机器学习。我们使用图片去控制无人驾驶汽车的移动。 + +-------------------------------------------------------------------------------- + +via: https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html + +作者:[Francesco Azzola ][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.survivingwithandroid.com/author/francesco-azzolagmail-com +[1]:https://www.survivingwithandroid.com/author/francesco-azzolagmail-com +[2]:https://www.survivingwithandroid.com/2017/11/building-a-restful-api-interface-using-android-things.html +[3]:https://www.survivingwithandroid.com/2017/10/synchronize-android-things-with-firebase-real-time-control-firebase-iot.html +[4]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=Machine%20Learning%20with%20Android%20Things +[5]:https://www.survivingwithandroid.com/2017/12/building-a-remote-controlled-car-using-android-things-gpio.html +[6]:https://github.com/androidthings/sample-tensorflow-imageclassifier +[7]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=TensorFlow%20image%20classifier +[8]:https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0 +[9]:https://www.survivingwithandroid.com/2017/12/building-a-remote-controlled-car-using-android-things-gpio.html +[10]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=Integrating%20Android%20Things%20with%20IoT +[11]:http://pinterest.com/pin/create/bookmarklet/?media=data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=&url=https://www.survivingwithandroid.com/2018/03/apply-machine-learning-iot-using-android-things-tensorflow.html&is_video=false&description=Integrating%20Android%20Things%20with%20TensorFlow +[12]:https://github.com/androidthings/sample-tensorflow-imageclassifier +[13]:https://en.wikipedia.org/wiki/Machine_learning From 45bd7072f202daa64f3fa062eee53695e370ab5e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 08:51:34 +0800 Subject: [PATCH 078/111] Rename IT automation: How to make the case to 20180201 IT automation- How to make the case.md --- ...e the case => 20180201 IT automation- How to make the case.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/talk/{IT automation: How to make the case => 20180201 IT automation- How to make the case.md} (100%) diff --git a/translated/talk/IT automation: How to make the case b/translated/talk/20180201 IT automation- How to make the case.md similarity index 100% rename from translated/talk/IT automation: How to make the case rename to translated/talk/20180201 IT automation- How to make the case.md From 32277e646a38bf3c3de49b28033bbb7556590234 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 08:52:29 +0800 Subject: [PATCH 079/111] Rename 10 easy steps from proprietary to open source to 20171116 10 easy steps from proprietary to open source.md --- ... => 20171116 10 easy steps from proprietary to open source.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{10 easy steps from proprietary to open source => 20171116 10 easy steps from proprietary to open source.md} (100%) diff --git a/translated/tech/10 easy steps from proprietary to open source b/translated/tech/20171116 10 easy steps from proprietary to open source.md similarity index 100% rename from translated/tech/10 easy steps from proprietary to open source rename to translated/tech/20171116 10 easy steps from proprietary to open source.md From 6f3803322fe65e4536711c3d304c55bf52f1e45e Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 15 May 2018 08:59:55 +0800 Subject: [PATCH 080/111] translated --- ...1221 A Commandline Food Recipes Manager.md | 143 ------------------ ...1221 A Commandline Food Recipes Manager.md | 141 +++++++++++++++++ 2 files changed, 141 insertions(+), 143 deletions(-) delete mode 100644 sources/tech/20171221 A Commandline Food Recipes Manager.md create mode 100644 translated/tech/20171221 A Commandline Food Recipes Manager.md diff --git a/sources/tech/20171221 A Commandline Food Recipes Manager.md b/sources/tech/20171221 A Commandline Food Recipes Manager.md deleted file mode 100644 index 7a70cb172f..0000000000 --- a/sources/tech/20171221 A Commandline Food Recipes Manager.md +++ /dev/null @@ -1,143 +0,0 @@ -translating---geekpi - -HeRM’s - A Commandline Food Recipes Manager -====== -![配图](https://www.ostechnix.com/wp-content/uploads/2017/12/herms-720x340.jpg) - -Cooking is love made visible, isn't? Indeed! Either cooking is your passion or hobby or profession, I am sure you will maintain a cooking journal. Keeping a cooking journal is one way to improve your cooking practice. There are many ways to take notes about the recipes. You could maintain a small diary/notebook or store the recipe's notes in the smartphone or save them in a word document in your computer. There are multitude of options. Today, I introduce **HeRM 's**, a Haskell-based commandline food recipes manager to make notes about your delicious food recipes. Using Herm's, you can add, view, edit, and delete food recipes and even can make your shopping lists. All from your Terminal! It is free, and open source utility written using Haskell programming language. The source code is freely available in GitHub, so you can fork it, add more features or improve it. - -### HeRM's - A Commandline Food Recipes Manager - -#### **Installing HeRM 's** - -Since it is written using Haskell, we need to install Cabal first. Cabal is a command-line program for downloading and building software written in Haskell programming language. Cabal is available in the core repositories of most Linux distributions, so you can install it using your distribution's default package manager. - -For instance, you can install cabal in Arch Linux and its variants such as Antergos, Manjaro Linux using command: -``` -sudo pacman -S cabal-install -``` - -On Debian, Ubuntu: -``` -sudo apt-get install cabal-install -``` - -After installing Cabal, make sure you have added it your PATH. To do so, edit your **~/.bashrc** file: -``` -vi ~/.bashrc -``` - -Add the following line: -``` -PATH=$PATH:~/.cabal/bin -``` - -Press **:wq** to save and quit the file. Then, run the following command to update the changes made. -``` -source ~/.bashrc -``` - -Once cabal installed, run the following command to install herms: -``` -cabal install herms -``` - -Have a cup of coffee! This will take a while. After couple minutes, you will see an output, something like below. -``` -[...] -Linking dist/build/herms/herms ... -Installing executable(s) in /home/sk/.cabal/bin -Installed herms-1.8.1.2 -``` - -Congratulations! Herms is installed. - -#### **Adding recipes** - -Let us add a food recipe, for example **Dosa**. For those wondering, Dosa is a popular south Indian food served hot with **sambar** and **chutney**. It is a healthy, and arguably most delicious food. It contains no added sugars or saturated fats. It is also easy to make one. There are couple types of different Dosas, the most common served in our home is Plain Dosa. - -To add a recipe, type: -``` -herms add -``` - -You will see a screen something like below. Start entering the recipe's details. - -[![][1]][2] - -To navigate through fields,use the following keyboard shortcuts: - - * **Tab / Shift+Tab** - Next / Previous field - * **Ctrl + ** - Navigate fields - * **[Meta or Alt] + ** - Navigate fields - * **Esc** - Save or Cancel. - - - -Once you added the recipe's details, press ESC key and hit Y to save it. Similarly, you can add as many recipes as you want. - -To list the added recipes, type: -``` -herms list -``` - -[![][1]][3] - -To view the details of any recipes listed above, just use the respective number like below. -``` -herms view 1 -``` - -[![][1]][4] - -To edit any recipes, use: -``` -herms edit 1 -``` - -Once you made the changes, press ESC key. You'll be asked whether you want to save or not. Just choose the appropriate option. - -[![][1]][5] - -To delete a recipe, the command would be: -``` -herms remove 1 -``` - -To generate a shopping list for a given recipe(s), run: -``` -herms shopping 1 -``` - -[![][1]][6] - -For help, run: -``` -herms -h -``` - -The next time you overhear a conversation about a good recipe from your colleague or friend or somewhere else, just open Herms and quickly take a note and share them to your spouse. She would be delighted! - -And, that's all. More good stuffs to come. Stay tuned! - -Cheers!! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/herms-commandline-food-recipes-manager/ - -作者:[][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com -[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]:http://www.ostechnix.com/wp-content/uploads/2017/12/Make-Dosa-1.png () -[3]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-1-1.png () -[4]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-2.png () -[5]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-3.png () -[6]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-4.png () diff --git a/translated/tech/20171221 A Commandline Food Recipes Manager.md b/translated/tech/20171221 A Commandline Food Recipes Manager.md new file mode 100644 index 0000000000..95771a3b2c --- /dev/null +++ b/translated/tech/20171221 A Commandline Food Recipes Manager.md @@ -0,0 +1,141 @@ +HeRM’s - 一个命令行食谱管理器 +====== +![配图](https://www.ostechnix.com/wp-content/uploads/2017/12/herms-720x340.jpg) + +烹饪让爱变得可见,不是吗?确实!烹饪也许是你的热情或爱好或职业,我相信你会维护一份烹饪日记。保持写烹饪日记是改善烹饪习惯的一种方法。有很多方法可以记录食谱。你可以维护一份小日记/笔记或将配方的笔记存储在智能手机中,或将它们保存在计算机中文档中。这有很多选择。今天,我介绍 **HeRM 's**,一个基于 Haskell 的命令行食谱管理器,能为你的美食食谱做笔记。使用 Herm's,你可以添加、查看、编辑和删除食物配方,甚至可以制作购物清单。这些全部来自你的终端!它是免费的,并使用 Haskell 语言编写的开源程序。源代码在 GitHub 中免费提供,因此你可以 fork 它,添加更多功能或改进它。 + +### HeRM's - 一个命令食谱管理器 + +#### **安装 HeRM 's** + +由于它是使用 Haskell 编写的,因此我们需要首先安装 Cabal。 Cabal 是一个用于下载和编译用 Haskell 语言编写的软件的命令行程序。Cabal 存在于大多数 Linux 发行版的核心软件库中,因此你可以使用发行版的默认软件包管理器来安装它。 + +例如,你可以使用以下命令在 Arch Linux 及其变体(如 Antergos、Manjaro Linux)中安装 cabal: +``` +sudo pacman -S cabal-install +``` + +在 Debian、Ubuntu 上: +``` +sudo apt-get install cabal-install +``` + +安装 Cabal 后,确保你已经添加了 PATH。为此,请编辑你的 **~/.bashrc** : +``` +vi ~/.bashrc +``` + +添加下面这行: +``` +PATH=$PATH:~/.cabal/bin +``` + +按 **:wq** 保存并退出文件。然后,运行以下命令更新所做的更改。 +``` +source ~/.bashrc +``` + +安装 cabal 后,运行以下命令安装 herms: +``` +cabal install herms +``` + +喝一杯咖啡!这将需要一段时间。几分钟后,你会看到一个输出,如下所示。 +``` +[...] +Linking dist/build/herms/herms ... +Installing executable(s) in /home/sk/.cabal/bin +Installed herms-1.8.1.2 +``` + +恭喜! Herms 已经安装完成。 + +#### **添加食谱** + +让我们添加一个食谱,例如 **Dosa**。对于那些想知道的,Dosa 是一种受欢迎的南印度食物,配以 **sambar** 和**酸辣酱**。这是一种健康的,可以说是最美味的食物。它不含添加的糖或饱和脂肪。制作一个也很容易。有几种不同的 Dosas,在我们家中最常见的是 Plain Dosa。 + +要添加食谱,请输入: +``` +herms add +``` + +你会看到一个如下所示的屏幕。开始输入食谱的详细信息。 + +[![][1]][2] + +要变换字段,请使用以下键盘快捷键: + + * **Tab / Shift+Tab** - 下一个/前一个字段 + * **Ctrl + <箭头键>** - 导航字段 + * **[Meta 或者 Alt] + ** - 导航字段 + * **Esc** - 保存或取消。 + + + +添加完配方的详细信息后,按下 ESC 键并点击 Y 保存。同样,你可以根据需要添加尽可能多的食谱。 + +要列出添加的食谱,输入: +``` +herms list +``` + +[![][1]][3] + +要查看上面列出的任何食谱的详细信息,请使用下面的相应编号。 +``` +herms view 1 +``` + +[![][1]][4] + +要编辑任何食谱,使用: +``` +herms edit 1 +``` + +完成更改后,按下 ESC 键。系统会询问你是否要保存。你只需选择适当的选项。 + +[![][1]][5] + +要删除食谱,命令是: +``` +herms remove 1 +``` + +要为指定食谱生成购物清单,运行: +``` +herms shopping 1 +``` + +[![][1]][6] + +要获得帮助,运行: +``` +herms -h +``` + +当你下次听到你的同事、朋友或其他地方谈到好的食谱时,只需打开 Herms,并快速记下,并将它们分享给你的配偶。她会很高兴! + +今天就是这些。还有更好的东西。敬请关注! + +干杯!! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/herms-commandline-food-recipes-manager/ + +作者:[][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com +[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]:http://www.ostechnix.com/wp-content/uploads/2017/12/Make-Dosa-1.png () +[3]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-1-1.png () +[4]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-2.png () +[5]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-3.png () +[6]:http://www.ostechnix.com/wp-content/uploads/2017/12/herms-4.png () From 3d8d9c47df8daaeea86681356871ef5b727fdeb3 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 15 May 2018 09:03:58 +0800 Subject: [PATCH 081/111] translating --- ...508 Orbital Apps - A New Generation Of Linux applications.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md b/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md index ada15d4ddd..3f7f51ba94 100644 --- a/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md +++ b/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md @@ -1,3 +1,5 @@ +translating---geekpi + Orbital Apps – A New Generation Of Linux applications ====== From 339d8b59492942f08a4a643b13c8ef1dd9951ee5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 09:25:07 +0800 Subject: [PATCH 082/111] =?UTF-8?q?=E6=8F=90=E5=8D=87=20MjSeven=20?= =?UTF-8?q?=E4=B8=BA=E6=A0=B8=E5=BF=83=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @MjSeven --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fba9abe8ae..2769014a6a 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ LCTT 的组成 * 2017/11/19 wxy 在上海交大举办的 2017 中国开源年会上做了演讲:《[如何以翻译贡献参与开源社区](https://linux.cn/article-9084-1.html)》。 * 2018/01/11 提升 lujun9972 成为核心成员,并加入选题组。 * 2018/02/20 遭遇 DMCA 仓库被封。 +* 2018/05/15 提升 MjSeven 为核心成员。 核心成员 ------------------------------- @@ -92,6 +93,7 @@ LCTT 的组成 - 核心成员 @rusking, - 核心成员 @qhwdw, - 核心成员 @lujun9972 +- 核心成员 @MjSeven - 前任选题 @DeadFire, - 前任校对 @reinoir222, - 前任校对 @PurlingNayuki, From 1421a4c807b26bc98c3a10d6220a10870180b0c6 Mon Sep 17 00:00:00 2001 From: ShenYu Zheng Date: Tue, 15 May 2018 09:41:55 +0800 Subject: [PATCH 083/111] Update 20171121 How To Kill The Largest Process In An Unresponsive Linux System.md --- ... Kill The Largest Process In An Unresponsive Linux System.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171121 How To Kill The Largest Process In An Unresponsive Linux System.md b/sources/tech/20171121 How To Kill The Largest Process In An Unresponsive Linux System.md index 8711f170af..e87a206d61 100644 --- a/sources/tech/20171121 How To Kill The Largest Process In An Unresponsive Linux System.md +++ b/sources/tech/20171121 How To Kill The Largest Process In An Unresponsive Linux System.md @@ -1,3 +1,5 @@ +translating by cizezsy + How To Kill The Largest Process In An Unresponsive Linux System ====== ![](https://www.ostechnix.com/wp-content/uploads/2017/11/Kill-The-Largest-Process-720x340.png) From fa6058be5baafaa4614a76358c88f6e188250976 Mon Sep 17 00:00:00 2001 From: Kevin Sicong Jiang Date: Mon, 14 May 2018 20:42:12 -0500 Subject: [PATCH 084/111] Translating KevinSJ -- 05142018 --- sources/tech/20180510 How To Display Images In The Terminal.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180510 How To Display Images In The Terminal.md b/sources/tech/20180510 How To Display Images In The Terminal.md index e4ea138a27..8ecf430ad0 100644 --- a/sources/tech/20180510 How To Display Images In The Terminal.md +++ b/sources/tech/20180510 How To Display Images In The Terminal.md @@ -1,3 +1,4 @@ +Translating KevinSJ -- 05142018 How To Display Images In The Terminal ====== From 42609652a473da5b291fdf7ca1eea4ff62d2cc4a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 10:28:31 +0800 Subject: [PATCH 085/111] PRF:20180115 2 scientific calculators for the Linux desktop.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @zyk2290 翻译的挺好 --- ...tific calculators for the Linux desktop.md | 82 ++++++++++--------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/translated/tech/20180115 2 scientific calculators for the Linux desktop.md b/translated/tech/20180115 2 scientific calculators for the Linux desktop.md index fc94edf4ad..805bff0bce 100644 --- a/translated/tech/20180115 2 scientific calculators for the Linux desktop.md +++ b/translated/tech/20180115 2 scientific calculators for the Linux desktop.md @@ -1,93 +1,97 @@ 两款 Linux 桌面端可用的科学计算器 ====== - - -Translating by zyk2290 +> 如果你想找个高级的桌面计算器的话,你可以看看开源软件,以及一些其它有趣的工具。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_OpenData_CityNumbers.png?itok=lC03ce76) -Image by : opensource.com - -每个Linux 桌面环境都至少带有一个功能简单的桌面计算器,但大多数计算器只能进行一些简单的计算。 +每个 Linux 桌面环境都至少带有一个功能简单的桌面计算器,但大多数计算器只能进行一些简单的计算。 幸运的是,还是有例外的:不仅可以做得比开平方根和一些三角函数还多,而且还很简单。这里将介绍两款强大的计算器,外加一大堆额外的功能。 ### SpeedCrunch -[SpeedCrunch][1]是一款高精度科学计算器有着 Qt5 图像界面前端,并且强烈依赖键盘。 +[SpeedCrunch][1] 是一款高精度科学计算器,有着简明的 Qt5 图像界面,并且强烈依赖键盘。 ![SpeedCrunch graphical interface][3] -SpeedCrunch 在工作时 +*SpeedCrunch 在工作时* -It supports working with units and comes loaded with all kinds of functions. - -所有函数都支持与单位一起工作。 +它支持单位,并且可用在所有函数中。 例如, -`2 * 10^6 newton / (meter^2)` +``` +2 * 10^6 newton / (meter^2) +``` -你可以得到 +你可以得到: -`= 2000000 pascal` +``` += 2000000 pascal +``` -SpeedCrunch 会默认地将结果转化为国际标准单位,但还是可以用"in"命令转换 +SpeedCrunch 会默认地将结果转化为国际标准单位,但还是可以用 `in` 命令转换: 例如: -`3*10^8 meter / second in kilo meter / hour` +``` +3*10^8 meter / second in kilo meter / hour +``` 结果是: -`= 1080000000 kilo meter / hour` -`F5` 键可以将所有结果转为科学计数法 (`1.08e9 kilo meter / hour`),`F2`键可以只将那些很大的数或很小的数转为科学计数法。更多选项可以在配置(Configuration)页面找到。 +``` += 1080000000 kilo meter / hour +``` -可用的函数的列表看上去非常惊艳。它可以在 Linux 、 Windows、macOS.。许可证是GPLv2,你可以在[Bitbucket][4]上得到它的源码。 +`F5` 键可以将所有结果转为科学计数法(`1.08e9 kilo meter / hour`),`F2` 键可以只将那些很大的数或很小的数转为科学计数法。更多选项可以在配置页面找到。 + +可用的函数的列表看上去非常壮观。它可以用在 Linux 、 Windows、macOS。许可证是 GPLv2,你可以在 [Bitbucket][4] 上得到它的源码。 ### Qalculate! [Qalculate!][5](有感叹号)有一段长而复杂的历史。 -这个项目给了我们一个强大的库,而这个库可以被其它程序使用(在 Plasma 桌面中,krunner 可以用它来计算),以及一个用 GTK3 搭建的图形界面前端。它允许你转换单位,处理物理常量,创建图像,使用复数,矩阵以及向量,选择任意准确度,等等 - +这个项目给了我们一个强大的库,而这个库可以被其它程序使用(在 Plasma 桌面中,krunner 可以用它来计算),以及一个用 GTK3 搭建的图形界面。它允许你转换单位,处理物理常量,创建图像,使用复数,矩阵以及向量,选择任意精度,等等。 ![Qalculate! Interface][7] -正在在 Qalculate! 寻找物理常量 +*在 Qalculate! 中寻找物理常量* -在使用单位上,Qalculate! 会比SppedCrunch 更加直观,而且可以识别一些常用前缀。你有听说过 exapascal 吗?反正我没有(太阳的中心大概在 `~26 PPa`),但 Qalculate! ,可以准确识别出 `1 EPa`。同时,Qalculate! 可以更加灵活地处理语法错误,所以你不需要担心打括号:如果没有歧义,Qalculate! 会直接给出正确答案。 +在单位的使用方面,Qalculate! 会比 SppedCrunch 更加直观,而且可以识别一些常用前缀。你有听说过 exapascal 压力吗?反正我没有(太阳的中心大概在 `~26 PPa`),但 Qalculate! ,可以准确 `1 EPa` 的意思。同时,Qalculate! 可以更加灵活地处理语法错误,所以你不需要担心打括号:如果没有歧义,Qalculate! 会直接给出正确答案。 -一段时间之后这个计划看上去被遗弃了。但在2016年,它又变得强大了,在一年里更新了10个版本。它的许可证是 GPLv2 (源码在 [GitHub][8] 上),提供Linux 、Windows 、macOS的版本。 +一段时间之后这个项目看上去被遗弃了。但在 2016 年,它又变得强大了,在一年里更新了 10 个版本。它的许可证是 GPLv2 (源码在 [GitHub][8] 上),提供Linux 、Windows 、macOS的版本。 -### Bonus calculators +### 更多计算器 -#### 转换一切 +#### ConvertAll -好吧,这不是“计算器”,但这个程序非常好用 +好吧,这不是“计算器”,但这个程序非常好用。 -大部分单位转换器只是一大个基本单位列表以及一大堆基本组合,但[ConvertAll][9]与它们不一样。有试过把光年转换为英尺每秒吗?不管它们说不说得通,只要你想转换任何种类的单位,ConvertAll 就是你要的工具。 +大部分单位转换器只是一个大的基本单位列表以及一大堆基本组合,但 [ConvertAll][9] 与它们不一样。有试过把光年转换为英尺每秒吗?不管它们说不说得通,只要你想转换任何种类的单位,ConvertAll 就是你要的工具。 只需要在相应的输入框内输入转换前和转换后的单位:如果单位相容,你会直接得到答案。 -主程序是在 PyQt5 上搭建的,但也有[JavaScript 的在线版本][10]。 +主程序是在 PyQt5 上搭建的,但也有 [JavaScript 的在线版本][10]。 -#### (wx)Maxima with the units package +#### 带有单位包的 (wx)Maxima -有时候(好吧,很多时候)一款桌面计算器时候不够你用的,然后你需要更多的原力(raw power?) +有时候(好吧,很多时候)一款桌面计算器时候不够你用的,然后你需要更多的原力。 -[Maxima][11]是一款计算机代数系统(LCTT 译者注:进行符号运算的软件。这种系统的要件是数学表示式的符号运算),你可以用它计算导数、积分、方程、特征值和特征向量、泰勒级数、拉普拉斯变换与傅立叶变换,以及任意精度的数字计算、二维或三维图像··· ···列出这些都够我们写几页纸的了。 +[Maxima][11] 是一款计算机代数系统(LCTT 译注:进行符号运算的软件。这种系统的要件是数学表示式的符号运算),你可以用它计算导数、积分、方程、特征值和特征向量、泰勒级数、拉普拉斯变换与傅立叶变换,以及任意精度的数字计算、二维或三维图像··· ···列出这些都够我们写几页纸的了。 -[wxMaxima][12]是一个设计精湛的 Maxima 的图形前端,它简化了许多 Maxima 的选项,但并不会影响其它。在 Maxima 的基础上,wxMaxima 还允许你创建 “笔记本”(notebooks),你可以在上面写一些笔记,保存你的图像等。其中一项 (wx)Maxima 最惊艳的功能是它可以处理标注单位(dimension units)。 +[wxMaxima][12] 是一个设计精湛的 Maxima 的图形前端,它简化了许多 Maxima 的选项,但并不会影响其它。在 Maxima 的基础上,wxMaxima 还允许你创建 “笔记本”,你可以在上面写一些笔记,保存你的图像等。其中一项 (wx)Maxima 最惊艳的功能是它可以处理尺寸单位。 -`load("unit")` +在提示符只需要输入: -只需要输入`load("unit")` +``` +load("unit") +``` -按 Shift+Enter,等几秒钟的时间,然后你就可以开始了 +按 `Shift+Enter`,等几秒钟的时间,然后你就可以开始了。 -默认地,单位包与基本 MKS 单位工作,但如果你喜欢,例如,要拿到 `N`为单位而不是 `kg*m/s2`,你只需要输入:`setunits(N)` +默认地,单位包可以用基本的 MKS 单位,但如果你喜欢,例如,你可以用 `N` 为单位而不是 `kg*m/s2`,你只需要输入:`setunits(N)`。 Maxima 的帮助(也可以在 wxMaxima 的帮助菜单中找到)会给你更多信息。 @@ -98,8 +102,8 @@ Maxima 的帮助(也可以在 wxMaxima 的帮助菜单中找到)会给你更 via: https://opensource.com/article/18/1/scientific-calculators-linux 作者:[Ricardo Berlasso][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[zyk2290](https://github.com/zyk2290) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0228f015ff4f1623290d6a86bd51d2da891278f3 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 15 May 2018 10:29:03 +0800 Subject: [PATCH 086/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20useful=20thin?= =?UTF-8?q?gs=20you=20can=20do=20with=20the=20IP=20tool=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...gs you can do with the IP tool in Linux.md | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 sources/tech/20180511 3 useful things you can do with the IP tool in Linux.md diff --git a/sources/tech/20180511 3 useful things you can do with the IP tool in Linux.md b/sources/tech/20180511 3 useful things you can do with the IP tool in Linux.md new file mode 100644 index 0000000000..433595132f --- /dev/null +++ b/sources/tech/20180511 3 useful things you can do with the IP tool in Linux.md @@ -0,0 +1,84 @@ +3 useful things you can do with the IP tool in Linux +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0) + +It has been more than a decade since the `ifconfig` command has been deprecated on Linux in favor of the `iproute2` project, which contains the magical tool `ip`. Many online tutorial resources still refer to old command-line tools like `ifconfig`, `route`, and `netstat`. The goal of this tutorial is to share some of the simple networking-related things you can do easily using the `ip` tool instead. + +### Find your IP address +``` +[dneary@host]$ ip addr show + +[snip] + +44: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 + +        link/ether 5c:e0:c5:c7:f0:f1 brd ff:ff:ff:ff:ff:ff + +        inet 10.16.196.113/23 brd 10.16.197.255 scope global dynamic wlp4s0 + +        valid_lft 74830sec preferred_lft 74830sec + +        inet6 fe80::5ee0:c5ff:fec7:f0f1/64 scope link + +        valid_lft forever preferred_lft forever + +``` + +`ip addr show` will show you a lot of information about all of your network link devices. In this case, my wireless Ethernet card (wlp4s0) is the IPv4 address (the `inet` field) `10.16.196.113/23`. The `/23` means that there are 23 bits of the 32 bits in the IP address, which will be shared by all of the IP addresses in this subnet. IP addresses in the subnet will range from `10.16.196.0 to 10.16.197.254`. The broadcast address for the subnet (the `brd` field after the IP address) `10.16.197.255` is reserved for broadcast traffic to all hosts on the subnet. + +We can show only the information about a single device using `ip addr show dev wlp4s0`, for example. + +### Display your routing table +``` +[dneary@host]$ ip route list + +default via 10.16.197.254 dev wlp4s0 proto static metric 600 + +10.16.196.0/23 dev wlp4s0 proto kernel scope link src 10.16.196.113 metric 601 + +192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown + +``` + +The routing table is the local host's way of helping network traffic figure out where to go. It contains a set of signposts, sending traffic to a specific interface, and a specific next waypoint on its journey. + +If you run any virtual machines or containers, these will get their own IP addresses and subnets, which can make these routing tables quite complicated, but in a single host, there are typically two instructions. For local traffic, send it out onto the local Ethernet, and the network switches will figure out (using a protocol called ARP) which host owns the destination IP address, and thus where the traffic should be sent. For traffic to the internet, send it to the local gateway node, which will have a better idea how to get to the destination. + +In the situation above, the first line represents the external gateway for external traffic, the second line is for local traffic, and the third is reserved for a virtual bridge for VMs running on the host, but this link is not currently active. + +### Monitor your network configuration +``` +[dneary@host]$ ip monitor all + +[dneary@host]$ ip -s link list wlp4s0 + +``` + +The `ip monitor` command can be used to monitor changes in routing tables, network addressing on network interfaces, or changes in ARP tables on the local host. This command can be particularly useful in debugging network issues related to containers and networking, when two VMs should be able to communicate with each other but cannot. + +`all`, `ip monitor` will report all changes, prefixed with one of `[LINK]` (network interface changes), `[ROUTE]` (changes to a routing table), `[ADDR]` (IP address changes), or `[NEIGH]` (nothing to do with horses—changes related to ARP addresses of neighbors). + +When used withwill report all changes, prefixed with one of(network interface changes),(changes to a routing table),(IP address changes), or(nothing to do with horses—changes related to ARP addresses of neighbors). + +You can also monitor changes on specific objects (for example, a specific routing table or an IP address). + +Another useful option that works with many commands is `ip -s`, which gives some statistics. Adding a second `-s` option adds even more statistics. `ip -s link list wlp4s0` above will give lots of information about packets received and transmitted, with the number of packets dropped, errors detected, and so on. + +### Handy tip: Shorten your commands + +In general, for the `ip` tool, you need to include only enough letters to uniquely identify what you want to do. Instead of `ip monitor`, you can use `ip mon`. Instead of `ip addr list`, you can use `ip a l`, and you can use `ip r` in place of `ip route`. `Ip link list` can be shorted to `ip l ls`. To read about the many options you can use to change the behavior of a command, visit the [ip manpage][1]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/useful-things-you-can-do-with-IP-tool-Linux + +作者:[Dave Neary][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/dneary +[1]:https://www.systutorials.com/docs/linux/man/8-ip-route/ From 0c14d8d36a3f226e6b29bd875475ca27514fecd5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 10:29:10 +0800 Subject: [PATCH 087/111] PUB: 20180115 2 scientific calculators for the Linux desktop.md @zyk2290 https://linux.cn/article-9643-1.html --- .../20180115 2 scientific calculators for the Linux desktop.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180115 2 scientific calculators for the Linux desktop.md (100%) diff --git a/translated/tech/20180115 2 scientific calculators for the Linux desktop.md b/published/20180115 2 scientific calculators for the Linux desktop.md similarity index 100% rename from translated/tech/20180115 2 scientific calculators for the Linux desktop.md rename to published/20180115 2 scientific calculators for the Linux desktop.md From 425efed5a7a611ef43bec61bf9e9d53b067180a8 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 15 May 2018 10:30:51 +0800 Subject: [PATCH 088/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20LikeCoin,=20a=20c?= =?UTF-8?q?ryptocurrency=20for=20creators=20of=20openly=20licensed=20conte?= =?UTF-8?q?nt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...for creators of openly licensed content.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md diff --git a/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md b/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md new file mode 100644 index 0000000000..451dc27344 --- /dev/null +++ b/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md @@ -0,0 +1,47 @@ +LikeCoin, a cryptocurrency for creators of openly licensed content +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_whitehurst_money.png?itok=ls-SOzM0) + +Conventional wisdom indicates that writers, photographers, artists, and other creators who share their content for free, under Creative Commons and other open licenses, won't get paid. That means most independent creators don't make any money by publishing their work on the internet. Enter [LikeCoin][1]: a new, open source project that intends to make this convention, where artists often have to compromise or sacrifice in order to contribute, a thing of the past. + +The LikeCoin protocol is designed to monetize creative content so creators can focus on creating great material rather than selling it. + +The protocol is also based on decentralized technologies that track when content is used and reward its creators with LikeCoin, an [Ethereum ERC-20][2] cryptocurrency token. It operates through a "Proof of Creativity" algorithm which assigns LikeCoins based partially on how many "likes" a piece of content receives and how many derivative works are produced from it. Because openly licensed content has more opportunity to be reused and earn LikeCoin tokens, the system encourages content creators to publish under Creative Commons licenses. + +### How it works + +When a creative piece is uploaded via the LikeCoin protocol, the content creator includes the work's metadata, including author information and its InterPlanetary Linked Data ([IPLD][3]). This data forms a family graph of derivative works; we call the relationships between a work and its derivatives the "content footprint." This structure allows a content's inheritance tree to be easily traced all the way back to the original work. + +LikeCoin tokens will be distributed to creators using information about a work's derivation history. Since all creative works contain the metadata of the author's wallet, the corresponding LikeCoin shares can be calculated through the algorithm and distributed accordingly. + +LikeCoins are awarded in two ways: either directly by individuals who want to show their appreciation by paying a content creator, or through the Creators Pool, which collects viewers' "Likes" and distributes LikeCoin according to a content's LikeRank. Based on content-footprint tracing in the LikeCoin protocol, the LikeRank measures the importance (or creativity as we define it in this context) of a creative content. In general, the more derivative works a creative content generates, the more creative the creative content is, and thus the higher LikeRank of the content. LikeRank is the quantifier of the creativity of contents. + +### Want to get involved? + +LikeCoin is still very new, and we expect to launch our first decentralized application later in 2018 to reward Creative Commons content and connect seamlessly with a much larger and established community. + +Most of LikeCoin's code can be accessed in the [LikeCoin GitHub][4] repository under a [GPL 3.0 license][5]. Since it's still under active development, some of the experimental code is not yet open to the public, but we will make it so as soon as possible. + +We welcome feature requests, pull requests, forks, and stars. Please join our development on GitHub and our general discussions on [Telegram][6]. We also release updates about our progress on [Medium][7], [Facebook][8], [Twitter][9], and our website, [like.co][1]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/likecoin + +作者:[Kin Ko][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/ckxpress +[1]:https://like.co/ +[2]:https://en.wikipedia.org/wiki/ERC20 +[3]:https://ipld.io/ +[4]:https://github.com/likecoin +[5]:https://www.gnu.org/licenses/gpl-3.0.en.html +[6]:https://t.me/likecoin +[7]:http://medium.com/likecoin +[8]:http://fb.com/likecoin.foundation +[9]:https://twitter.com/likecoin_fdn From bb5ad54995f751cfc5a0a2c79bb5516bb2842028 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 15 May 2018 10:33:42 +0800 Subject: [PATCH 089/111] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Check?= =?UTF-8?q?=20Laptop=20Battery=20Status=20In=20Terminal=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...top Battery Status In Terminal In Linux.md | 309 ++++++++++++++++++ 1 file changed, 309 insertions(+) create mode 100644 sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md diff --git a/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md b/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md new file mode 100644 index 0000000000..7fdc6c055e --- /dev/null +++ b/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md @@ -0,0 +1,309 @@ +How To Check Laptop Battery Status In Terminal In Linux +====== +![](https://www.ostechnix.com/wp-content/uploads/2016/12/Check-Laptop-Battery-Status-In-Terminal-In-Linux-720x340.png) +Finding your Laptop battery status in GUI mode is easy. You could easily tell the battery level by hovering the mouse pointer over the battery indicator icon in the task bar. But, how about from the command line? Not everyone know this. The other day a friend of mine asked how to check his Laptop battery level from Terminal in his Ubuntu desktop – hence this post. Here I have included three simple methods which will help you to check Laptop battery status in Terminal in any Linux distribution. + +### Check Laptop Battery Status In Terminal In Linux + +We can find the Laptop battery status from command line in three methods. + +##### Method 1 – Using “Upower” command + +The **Upower** command comes preinstalled with most Linux distributions. To display the battery status using Upower, open up the Terminal and run: +``` +$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 + +``` + +**Sample output:** +``` +native-path: BAT0 + vendor: Samsung SDI + model: DELL 7XFJJA2 + serial: 4448 + power supply: yes + updated: Sat 12 May 2018 06:48:48 PM IST (41 seconds ago) + has history: yes + has statistics: yes + battery + present: yes + rechargeable: yes + state: charging + warning-level: none + energy: 43.3011 Wh + energy-empty: 0 Wh + energy-full: 44.5443 Wh + energy-full-design: 48.84 Wh + energy-rate: 9.8679 W + voltage: 12.548 V + time to full: 7.6 minutes + percentage: 97% + capacity: 91.2045% + technology: lithium-ion + icon-name: 'battery-full-charging-symbolic' + History (charge): + 1526131128 97.000 charging + History (rate): + 1526131128 9.868 charging + +``` + +As you see above, my battery is in charging mode now and the battery level is 97%. + +If the above command doesn’t work for any reason, try the following command instead: +``` +$ upower -i `upower -e | grep 'BAT'` + +``` + +**Sample output:** +``` +native-path: BAT0 + vendor: Samsung SDI + model: DELL 7XFJJA2 + serial: 4448 + power supply: yes + updated: Sat 12 May 2018 06:50:49 PM IST (22 seconds ago) + has history: yes + has statistics: yes + battery + present: yes + rechargeable: yes + state: charging + warning-level: none + energy: 43.6119 Wh + energy-empty: 0 Wh + energy-full: 44.5443 Wh + energy-full-design: 48.84 Wh + energy-rate: 8.88 W + voltage: 12.552 V + time to full: 6.3 minutes + percentage: 97% + capacity: 91.2045% + technology: lithium-ion + icon-name: 'battery-full-charging-symbolic' + History (rate): + 1526131249 8.880 charging + +``` + +Upower not just display the battery status, but also the complete details of the installed battery such as model, vendor name, serial no, state, voltage etc. + +However, you can only display the status of the battery by with combination of upower and [**grep**][1] commands as shown below. +``` +$ upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" + +``` + +**Sample output:** +``` +state: fully-charged +percentage: 100% + +``` + +![][3] + +As you see in the above output, my Laptop battery has been fully charged. + +For more details, refer man pages. +``` +$ man upower + +``` + +##### Method 2 – Using “acpi” command + +The **acpi** command shows battery status and other ACPI information in your Linux distribution. + +You might need to install **acpi** command in some Linux distributions. + +To install acpi on Debian, Ubuntu and its derivatives: +``` +$ sudo apt-get install acpi + +``` + +On RHEL, CentOS, Fedora: +``` +$ sudo yum install acpi + +``` + +Or, +``` +$ sudo dnf install acpi + +``` + +On Arch Linux and its derivatives: +``` +$ sudo pacman -S acpi + +``` + +Once acpi installed, run the following command: +``` +$ acpi -V + +``` + +**Note:** Here, “V” is capital letter. + +**Sample output:** +``` +Battery 0: Charging, 99%, 00:02:09 until charged +Battery 0: design capacity 4400 mAh, last full capacity 4013 mAh = 91% +Battery 1: Discharging, 0%, rate information unavailable +Adapter 0: on-line +Thermal 0: ok, 77.5 degrees C +Thermal 0: trip point 0 switches to mode critical at temperature 84.0 degrees C +Cooling 0: Processor 0 of 3 +Cooling 1: Processor 0 of 3 +Cooling 2: LCD 0 of 15 +Cooling 3: Processor 0 of 3 +Cooling 4: Processor 0 of 3 +Cooling 5: intel_powerclamp no state information available +Cooling 6: x86_pkg_temp no state information available + +``` + +Let us only check the state of the charge of battery. To do so, run: +``` +$ acpi + +``` + +**Sample output:** +``` +Battery 0: Charging, 99%, 00:01:41 until charged +Battery 1: Discharging, 0%, rate information unavailable + +``` + +Let us check the battery temperature: +``` +$ acpi -t + +``` + +**Sample output:** +``` +Thermal 0: ok, 63.5 degrees C + +``` + +Let us view the above output in Fahrenheit: +``` +$ acpi -t -f + +``` + +**Sample output:** +``` +Thermal 0: ok, 144.5 degrees F + +``` + +Want to know whether the AC power is connected or not? Run: +``` +$ acpi -a + +``` + +**Sample output:** +``` +Adapter 0: on-line + +``` + +If the AC power is not available, you would the see the following instead: +``` +Adapter 0: off-line + +``` + +For more details, check the man pages. +``` +$ man acpi + +``` + +##### Method 3: Using “Batstat” Program + +The **batstat** is a small ncurses-based CLI utility to display your Laptop battery status in Unix-like systems. It will display the following details: + + * Current battery level + * Current Energy + * Full charge energy + * Time elapsed from the start of the program, without tracking the sleep time of the machine. + * Battery level history + + + +Installing batstat is a piece of cake. Git clone the latest version using command: +``` +$ git clone https://github.com/Juve45/batstat.git + +``` + +The above command will pull the latest batstat version and save it’s contents in a folder named “batstat”. + +CD to batstat/bin/ directory: +``` +$ cd batstat/bin/ + +``` + +Copy “batstat” binary file to your PATH, for example /usr/local/bin/. +``` +$ sudo cp batstat /usr/local/bin/ + +``` + +Make it executable using command: +``` +$ sudo chmod +x /usr/local/bin/batstat + +``` + +Finally, run the following command to view your battery status. +``` +$ batstat + +``` + +Sample output: + +![][4] + +As you see in the above screenshot, my battery is in charging mode. + +This utility has some limitations though. As of writing this guide, batstat will support only one battery. And, it gathers information only from this folder – **“/sys/class/power_supply/”**. If your machine contains the battery information on a different folder, this program will not work. + +For more details, check batstat github page. + +And, that’s all for today folks. There might be many commands and programs out there to check the laptop battery status in Terminal in Linux. As far as I know, the above given methods have worked just fine as expected. If you know some other commands to find out the battery status, let me know in the comment section below. I will update commands in the article if they works. + +And, that’s all for now. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-check-laptop-battery-status-in-terminal-in-linux/ + +作者:[SK][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.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/ +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:http://www.ostechnix.com/wp-content/uploads/2016/12/sk@sk_006-1.png +[4]:http://www.ostechnix.com/wp-content/uploads/2016/12/batstat-1.png From dc047d6bc5406f5898634fc6f1c0790f5c14cfd2 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Tue, 15 May 2018 11:53:39 +0800 Subject: [PATCH 090/111] Translating by qhwdw --- sources/tech/20171103 3 ways robotics affects the CIO role.md | 1 + sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md | 1 + ...2 5 open source software tools for supply chain management.md | 1 + sources/tech/20180308 Dynamic Linux Routing with Quagga.md | 1 + ...acle Linux System With The Unbreakable Linux Network (ULN).md | 1 + ...Top 9 open source ERP systems to consider - Opensource.com.md | 1 + .../tech/20180415 Some Common Concurrent Programming Mistakes.md | 1 + sources/tech/20180418 Passwordless Auth Server.md | 1 + sources/tech/20180423 An introduction to Python bytecode.md | 1 + .../20180507 How To Improve Application Startup Time In Linux.md | 1 + 10 files changed, 10 insertions(+) diff --git a/sources/tech/20171103 3 ways robotics affects the CIO role.md b/sources/tech/20171103 3 ways robotics affects the CIO role.md index a14027aebc..e89b72ee1a 100644 --- a/sources/tech/20171103 3 ways robotics affects the CIO role.md +++ b/sources/tech/20171103 3 ways robotics affects the CIO role.md @@ -1,3 +1,4 @@ +Translating by qhwdw 3 ways robotics affects the CIO role ====== ![配图](https://enterprisersproject.com/sites/default/files/styles/620x350/public/cio_ai.png?itok=toMIgELj) diff --git a/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md b/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md index b9787effe0..48c95295fc 100644 --- a/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md +++ b/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md @@ -1,3 +1,4 @@ +Translating by qhwdw Testing IPv6 Networking in KVM: Part 2 ====== diff --git a/sources/tech/20180302 5 open source software tools for supply chain management.md b/sources/tech/20180302 5 open source software tools for supply chain management.md index 20f0c8d554..80d8dec545 100644 --- a/sources/tech/20180302 5 open source software tools for supply chain management.md +++ b/sources/tech/20180302 5 open source software tools for supply chain management.md @@ -1,3 +1,4 @@ +Translating by qhwdw 5 open source software tools for supply chain management ====== diff --git a/sources/tech/20180308 Dynamic Linux Routing with Quagga.md b/sources/tech/20180308 Dynamic Linux Routing with Quagga.md index 89e632cda6..967295ac89 100644 --- a/sources/tech/20180308 Dynamic Linux Routing with Quagga.md +++ b/sources/tech/20180308 Dynamic Linux Routing with Quagga.md @@ -1,3 +1,4 @@ +Translating by qhwdw Dynamic Linux Routing with Quagga ============================================================ diff --git a/sources/tech/20180406 How To Register The Oracle Linux System With The Unbreakable Linux Network (ULN).md b/sources/tech/20180406 How To Register The Oracle Linux System With The Unbreakable Linux Network (ULN).md index a6cb4b4154..34e6c36401 100644 --- a/sources/tech/20180406 How To Register The Oracle Linux System With The Unbreakable Linux Network (ULN).md +++ b/sources/tech/20180406 How To Register The Oracle Linux System With The Unbreakable Linux Network (ULN).md @@ -1,3 +1,4 @@ +Translating by qhwdw How To Register The Oracle Linux System With The Unbreakable Linux Network (ULN) ====== Most of us knows about RHEL subscription but only few of them knows about Oracle subscription and its details. diff --git a/sources/tech/20180410 Top 9 open source ERP systems to consider - Opensource.com.md b/sources/tech/20180410 Top 9 open source ERP systems to consider - Opensource.com.md index 492c532339..ec5592056a 100644 --- a/sources/tech/20180410 Top 9 open source ERP systems to consider - Opensource.com.md +++ b/sources/tech/20180410 Top 9 open source ERP systems to consider - Opensource.com.md @@ -1,3 +1,4 @@ +Translating by qhwdw Top 9 open source ERP systems to consider | Opensource.com ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_orgchart1.png?itok=tukiFj89) diff --git a/sources/tech/20180415 Some Common Concurrent Programming Mistakes.md b/sources/tech/20180415 Some Common Concurrent Programming Mistakes.md index 3bec5ee229..6553b96f54 100644 --- a/sources/tech/20180415 Some Common Concurrent Programming Mistakes.md +++ b/sources/tech/20180415 Some Common Concurrent Programming Mistakes.md @@ -1,3 +1,4 @@ +Translating by qhwdw Some Common Concurrent Programming Mistakes ============================================================ diff --git a/sources/tech/20180418 Passwordless Auth Server.md b/sources/tech/20180418 Passwordless Auth Server.md index 001b55c27c..541d732212 100644 --- a/sources/tech/20180418 Passwordless Auth Server.md +++ b/sources/tech/20180418 Passwordless Auth Server.md @@ -1,3 +1,4 @@ +Translating by qhwdw Passwordless Auth: Server ============================================================ diff --git a/sources/tech/20180423 An introduction to Python bytecode.md b/sources/tech/20180423 An introduction to Python bytecode.md index f170cfac7f..fc6661e6d0 100644 --- a/sources/tech/20180423 An introduction to Python bytecode.md +++ b/sources/tech/20180423 An introduction to Python bytecode.md @@ -1,3 +1,4 @@ +Translating by qhwdw An introduction to Python bytecode ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82) diff --git a/sources/tech/20180507 How To Improve Application Startup Time In Linux.md b/sources/tech/20180507 How To Improve Application Startup Time In Linux.md index 708835c82f..520eadb1dd 100644 --- a/sources/tech/20180507 How To Improve Application Startup Time In Linux.md +++ b/sources/tech/20180507 How To Improve Application Startup Time In Linux.md @@ -1,3 +1,4 @@ +Translating by qhwdw How To Improve Application Startup Time In Linux ====== From de5700d4b6f7a918c1a7a0ac916bdd3a18e20b07 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 15 May 2018 12:13:41 +0800 Subject: [PATCH 091/111] Update 20171221 How to create mobile-friendly documentation.md --- .../20171221 How to create mobile-friendly documentation.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171221 How to create mobile-friendly documentation.md b/sources/tech/20171221 How to create mobile-friendly documentation.md index 96d01f515a..eb1b7444d2 100644 --- a/sources/tech/20171221 How to create mobile-friendly documentation.md +++ b/sources/tech/20171221 How to create mobile-friendly documentation.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + How to create mobile-friendly documentation ====== ![配图](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd) From 7684700e5db3d03e0bf21333401109c22bab61c7 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 15 May 2018 12:14:03 +0800 Subject: [PATCH 092/111] Update 20171221 How to create mobile-friendly documentation.md --- .../20171221 How to create mobile-friendly documentation.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/sources/tech/20171221 How to create mobile-friendly documentation.md b/sources/tech/20171221 How to create mobile-friendly documentation.md index eb1b7444d2..96d01f515a 100644 --- a/sources/tech/20171221 How to create mobile-friendly documentation.md +++ b/sources/tech/20171221 How to create mobile-friendly documentation.md @@ -1,6 +1,3 @@ -Translating by MjSeven - - How to create mobile-friendly documentation ====== ![配图](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd) From 5d3ee0a70602c0e6047e5daddb65d7262ab4fc55 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 15 May 2018 12:16:14 +0800 Subject: [PATCH 093/111] Update 20171221 How to create mobile-friendly documentation.md --- .../20171221 How to create mobile-friendly documentation.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171221 How to create mobile-friendly documentation.md b/sources/tech/20171221 How to create mobile-friendly documentation.md index 96d01f515a..eb1b7444d2 100644 --- a/sources/tech/20171221 How to create mobile-friendly documentation.md +++ b/sources/tech/20171221 How to create mobile-friendly documentation.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + How to create mobile-friendly documentation ====== ![配图](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd) From 988a1b639b55243c7e845bad00aa366865f67380 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 13:22:00 +0800 Subject: [PATCH 094/111] PRF:20170213 Getting Started with Taskwarrior.md @MjSeven --- ...170213 Getting Started with Taskwarrior.md | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/translated/tech/20170213 Getting Started with Taskwarrior.md b/translated/tech/20170213 Getting Started with Taskwarrior.md index 2edf0562d5..b2e276859e 100644 --- a/translated/tech/20170213 Getting Started with Taskwarrior.md +++ b/translated/tech/20170213 Getting Started with Taskwarrior.md @@ -1,65 +1,67 @@ -Taskwarrior 入门 +基于命令行的任务管理器 Taskwarrior ===== Taskwarrior 是一个灵活的[命令行任务管理程序][1],用他们[自己的话说][2]: -Taskwarrior 是从你的命令行管理你的 TODO 列表。它灵活,快速,高效,不显眼,它默默做自己的事情让你避免自己管理。 +> Taskwarrior 在命令行里管理你的 TODO 列表。它灵活,快速,高效,不显眼,它默默做自己的事情让你避免自己管理。 Taskwarrior 是高度可定制的,但也可以“立即使用”。在本文中,我们将向你展示添加和完成任务的基本命令,然后我们将介绍几个更高级的命令。最后,我们将向你展示一些基本的配置设置,以开始自定义你的设置。 ### 安装 Taskwarrior Taskwarrior 在 Fedora 仓库中是可用的,所有安装它很容易: + ``` sudo dnf install task - ``` -一旦完成安装,运行 `task`。第一次运行将会创建一个 `~/.taskrc` 文件。 +一旦完成安装,运行 `task` 命令。第一次运行将会创建一个 `~/.taskrc` 文件。 + ``` -$ **task** +$ task A configuration file could not be found in ~ Would you like a sample /home/link/.taskrc created, so Taskwarrior can proceed? (yes/no) yes [task next] No matches. - ``` ### 添加任务 添加任务快速而不显眼。 + ``` -$ **task add Plant the wheat** +$ task add Plant the wheat Created task 1. ``` 运行 `task` 或者 `task list` 来显示即将来临的任务。 + ``` -$ **task list** +$ task list ID Age Description Urg 1 8s Plant the wheat 0 1 task - ``` 让我们添加一些任务来完成这个示例。 -``` -$ **task add Tend the wheat** -Created task 2. -$ **task add Cut the wheat** -Created task 3. -$ **task add Take the wheat to the mill to be ground into flour** -Created task 4. -$ **task add Bake a cake** -Created task 5. +``` +$ task add Tend the wheat +Created task 2. +$ task add Cut the wheat +Created task 3. +$ task add Take the wheat to the mill to be ground into flour +Created task 4. +$ task add Bake a cake +Created task 5. ``` 再次运行 `task` 来查看列表。 + ``` [task next] @@ -71,84 +73,83 @@ ID Age Description Urg 5 2s Bake a cake 0 5 tasks - ``` ### 完成任务 将一个任务标记为完成, 查找其 ID 并运行: + ``` -$ **task 1 done** +$ task 1 done Completed task 1 'Plant the wheat'. Completed 1 task. - ``` 你也可以用它的描述来标记一个任务已完成。 + ``` -$ **task 'Tend the wheat' done** +$ task 'Tend the wheat' done Completed task 1 'Tend the wheat'. Completed 1 task. - ``` -通过使用 `add`, `list` 和 `done`,你可以说已经入门了。 +通过使用 `add`、`list` 和 `done`,你可以说已经入门了。 ### 设定截止日期 很多任务不需要一个截止日期: + ``` task add Finish the article on Taskwarrior - ``` 但是有时候,设定一个截止日期正是你需要提高效率的动力。在添加任务时使用 `due` 修饰符来设置特定的截止日期。 ``` task add Finish the article on Taskwarrior due:tomorrow - ``` -`due` 非常灵活。它接受特定日期 ("2017-02-02") 或 ISO-8601 ("2017-02-02T20:53:00Z"),甚至相对时间 ("8hrs")。可以查看所有示例的 [Date & Time][3] 文档。 +`due` 非常灵活。它接受特定日期 (`2017-02-02`) 或 ISO-8601 (`2017-02-02T20:53:00Z`),甚至相对时间 (`8hrs`)。可以查看所有示例的 [Date & Time][3] 文档。 + +日期也不只有截止日期,Taskwarrior 有 `scheduled`, `wait` 和 `until` 选项。 -日期也会超出截止日期,Taskwarrior 有 `scheduled`, `wait` 和 `until` 选项。 ``` task add Proof the article on Taskwarrior scheduled:thurs - ``` 一旦日期(本例中的星期四)通过,该任务就会被标记为 `READY` 虚拟标记。它会显示在 `ready` 报告中。 + ``` -$ **task ready** +$ task ready ID Age S Description Urg 1 2s 1d Proof the article on Taskwarrior 5 - ``` 要移除一个日期,使用空白值来 `modify` 任务: + ``` $ task 1 modify scheduled: - ``` ### 查找任务 如果没有使用正则表达式搜索的能力,任务列表是不完整的,对吧? + ``` -$ **task '/.* the wheat/' list** +$ task '/.* the wheat/' list ID Age Project Description Urg 2 42min Take the wheat to the mill to be ground into flour 0 1 42min Home Cut the wheat 1 2 tasks - ``` ### 自定义 Taskwarrior 记得我们在开头创建的文件 (`~/.taskrc`)吗?让我们来看看默认设置: + ``` # [Created by task 2.5.1 2/9/2017 16:39:14] # Taskwarrior program configuration file. @@ -180,41 +181,40 @@ data.location=~/.task #include /usr//usr/share/task/solarized-dark-256.theme #include /usr//usr/share/task/solarized-light-256.theme #include /usr//usr/share/task/no-color.theme - - ``` -现在唯一有效的选项是 `data.location=~/.task`。要查看活动配置设置(包括内置的默认设置),运行 `show`。 +现在唯一生效的选项是 `data.location=~/.task`。要查看活动配置设置(包括内置的默认设置),运行 `show`。 + ``` task show - ``` -改变设置,使用 `config`。 +要改变设置,使用 `config`。 + ``` -$ **task config displayweeknumber no** +$ task config displayweeknumber no Are you sure you want to add 'displayweeknumber' with a value of 'no'? (yes/no) yes Config file /home/link/.taskrc modified. - ``` ### 示例 这些只是你可以用 Taskwarrior 做的一部分事情。 -为你的任务分配一个项目: +将你的任务分配到一个项目: + ``` task 'Fix leak in the roof' modify project:Home - ``` 使用 `start` 来标记你正在做的事情,这可以帮助你回忆起你周末后在做什么: + ``` task 'Fix bug #141291' start - ``` 使用相关的标签: + ``` task add 'Clean gutters' +weekend +house @@ -229,7 +229,7 @@ via: https://fedoramagazine.org/getting-started-taskwarrior/ 作者:[Link Dupont][a] 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f0420728f768286eeeac6226715bab7c5f224f30 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 13:22:31 +0800 Subject: [PATCH 095/111] PUB:20170213 Getting Started with Taskwarrior.md @MjSeven https://linux.cn/article-9644-1.html --- .../20170213 Getting Started with Taskwarrior.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170213 Getting Started with Taskwarrior.md (100%) diff --git a/translated/tech/20170213 Getting Started with Taskwarrior.md b/published/20170213 Getting Started with Taskwarrior.md similarity index 100% rename from translated/tech/20170213 Getting Started with Taskwarrior.md rename to published/20170213 Getting Started with Taskwarrior.md From 5117b15aa875dd8ef1c9d453da2de07e463381e9 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Tue, 15 May 2018 14:34:48 +0800 Subject: [PATCH 096/111] Translated by qhwdw --- ...prove Application Startup Time In Linux.md | 91 ------------------- ...prove Application Startup Time In Linux.md | 90 ++++++++++++++++++ 2 files changed, 90 insertions(+), 91 deletions(-) delete mode 100644 sources/tech/20180507 How To Improve Application Startup Time In Linux.md create mode 100644 translated/tech/20180507 How To Improve Application Startup Time In Linux.md diff --git a/sources/tech/20180507 How To Improve Application Startup Time In Linux.md b/sources/tech/20180507 How To Improve Application Startup Time In Linux.md deleted file mode 100644 index 520eadb1dd..0000000000 --- a/sources/tech/20180507 How To Improve Application Startup Time In Linux.md +++ /dev/null @@ -1,91 +0,0 @@ -Translating by qhwdw -How To Improve Application Startup Time In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/05/Preload-720x340.png) -Most Linux distributions are fast enough by default. However, we can still make them a little bit faster using some additional applications and methods. One such application we are about to see is **Preload**. It monitors the most frequently-used applications by the user and adds them to the memory, so that the applications will load little bit faster than before. Because, as you might already know, reading from the RAM is always faster than from the hard drive. Preload runs as a daemon on the background all the time and records the statistics about usage of files by more frequently-used programs. It then fetches those binaries and their dependencies into memory to improve the application loading time. In a nutshell, once preload is installed, you should be able to load the often-used applications much faster. - -In this brief tutorial, we are going to see how to install and use Preload to improve an application startup time in Linux. - -### Improve Application Startup Time In Linux Using Preload - -Preload is available in [**AUR**][1]. So you can install it using AUR helper programs in any Arch-based systems such as Antergos, Manjaro Linux. - -Using [**Pacaur**][2]: -``` -$ pacaur -S preload - -``` - -Using [**Packer**][3]: -``` -$ packer -S preload - -``` - -Using [**Trizen**][4]: -``` -$ trizen -S preload - -``` - -Using [**Yay**][5]: -``` -$ yay -S preload - -``` - -Using [**Yaourt**][6]: -``` -$ yaourt -S preload - -``` - -On Debian, Ubuntu, Linux Mint, Preload is available in the default repositories. So you can install it using APT package manager like below. -``` -$ sudo apt-get install preload - -``` - -Once Preload installed, reboot your system. From now on, Preload monitors the frequently-used applications and adds their binaries and libraries into the Memory for faster startup time. For example, if you often use Firefox, Chrome or LibreOffice, Preload will then add those binaries and libraries into RAM, so those applications will start faster. Good thing is it doesn’t need any configuration. It will just work out of the box. If you, however, wants to tweak the configuration, you can do it by editing the default configuration file **/etc/preload.conf**. - -### Preload isn’t for everyone! - -Here are some drawbacks of Preload and why it is not that effective for everyone, discussed in this [**thread**][7]. - - 1. I do have a decent specification system with 8GB RAM. So my system is generally fast. Also, I will open heavy memory-consuming applications, such as Firefox, Chrome, VirtualBox, Gimp etc., one or two times per day. They remain open all the time, hence their binaries and libraries are preloaded into memory and occupying the RAM all day. I rarely close and open those applications, so the RAM usage is simply waste. - 2. If you’re using modern systems with SSD, Preload is obviously useless. Because SSDs access time is much faster than normal hard drives, so using Preload is pointless. - 3. Preload significantly affects the boot time. Because the more applications are preloaded into RAM, the longer it takes to get your system up and running. - - - -You will only the see the real difference only if you’re reloading applications a LOT of time per day. So Preload will be ideal for the developers and testers who open and close the applications several times everyday. - -For more details about what exactly preload is and how it works, read the complete [**Preload thesis**][8] paper submitted by the author. - -And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-improve-application-startup-time-in-linux/ - -作者:[SK][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.ostechnix.com/author/sk/ -[1]:https://aur.archlinux.org/packages/preload/ -[2]:https://www.ostechnix.com/install-pacaur-arch-linux/ -[3]:https://www.ostechnix.com/install-packer-arch-linux-2/ -[4]:https://www.ostechnix.com/trizen-lightweight-aur-package-manager-arch-based-systems/ -[5]:https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ -[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ -[7]:https://askubuntu.com/questions/110335/drawbacks-of-using-preload-why-isnt-it-included-by-default -[8]:https://cs.uwaterloo.ca/~brecht/courses/702/Possible-Readings/prefetching-to-memory/preload-thesis.pdf diff --git a/translated/tech/20180507 How To Improve Application Startup Time In Linux.md b/translated/tech/20180507 How To Improve Application Startup Time In Linux.md new file mode 100644 index 0000000000..93fb4c484c --- /dev/null +++ b/translated/tech/20180507 How To Improve Application Startup Time In Linux.md @@ -0,0 +1,90 @@ +如何改善应用程序在 Linux 中的启动时间 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/05/Preload-720x340.png) +大多数 Linux 发行版在默认配置下已经足够快了。但是,我们仍然可以借助一些额外的应用程序和方法让它们启动更快一点。其中一个可用的这种应用程序就是 **Preload**。它监视用户使用频率比较高的应用程序,并将它们添加到内存中,这样就比一般的方式加载更快一点。因为,正如你所知道的,内存的读取速度远远快于硬盘。Preload 以守护进程的方式在后台中运行,并记录用户使用较为频繁的程序的文件使用相关的统计数据。然后,它将这些二进制文件及它们的依赖项加载进内存,以改善应用程序的加载时间。简而言之,一旦安装了 preload,你使用较为频繁的应用程序将可能加载的更快。 + +在这篇详细的教程中,我们将去了解如何安装和使用 Preload,以改善应用程序在 Linux 中的启动时间。 + +### 在 Linux 中使用 Preload 改善应用程序启动时间 + +Preload 可以在 [**AUR**][1] 上找到。因此,你可以使用 AUR 助理程序在任何基于 Arch 的系统上去安装它,比如,Antergos、Manjaro Linux。 + +使用 [**Pacaur**][2]: +``` +$ pacaur -S preload + +``` + +使用 [**Packer**][3]: +``` +$ packer -S preload + +``` + +使用 [**Trizen**][4]: +``` +$ trizen -S preload + +``` + +使用 [**Yay**][5]: +``` +$ yay -S preload + +``` + +使用 [**Yaourt**][6]: +``` +$ yaourt -S preload + +``` + +在 Debian、Ubuntu、Linux Mint 上,Preload 可以在默认仓库中找到。因此,你可以像下面一样,使用 APT 包管理器去安装它。 +``` +$ sudo apt-get install preload + +``` + +Preload 安装完成后,重新启动你的系统。从现在开始,Preload 将监视频繁使用的应用程序,并将它们的二进制文件和库添加到内存中,以使它的启动速度更快。比如,如果你经常使用 Firefox、Chrome 以及 LibreOffice,Preload 将添加这些二进制文件和库到内存中,因此,这些应用程序将启动的更快。而且更好的是,它不需要做任何配置。它是开箱即用的。但是,如果你想去对它进行微调,你可以通过编辑缺省的配置文件 **/etc/preload.conf** 来实现。 + +### Preload 并不一定适合每个人! + +以下是 Preload 的一些缺点,它并不是对每个人都有帮助,在这个 [**跟贴**][7] 中有讨论到。 + + 1. 我使用的是一个有 8GB 内存的现代系统。因此,我的系统总体上来说很快。我每天只打开狂吃内存的应用程序(比如,Firefox、Chrome、VirtualBox、Gimp、等等)一到两次,并且它们始终处于打开状态,因此,它们的二进制文件和库被预读到内存中,并始终整天在内存中。我一般很少去关闭和打开这些应用程序,因此,内存使用纯属浪费。 + 2. 如果你使用的是带有 SSD 的现代系统,Preload 是绝对没用的。因为 SSD 的访问时间比起一般的硬盘来要快的多,因此,使用 Preload 是没有意义的。 + 3. Preload 显著影响启动时间。因为大多数的应用程序都预读到内存中,长此以往,将让你的系统启动和运行的更快。 + + + +你只有在每天都在大量的重新加载应用程序时,才能看到真正的差别。因此,Preload 最适合开发人员和测试人员,他们每天都打开和关闭应用程序好多次。 + +关于 Preload 更多的信息和它是如何工作的,请阅读它的作者写的完整版的 [**Preload 论文**][8]。 + +教程到此为止,希望能帮到你。后面还有更精彩的内容,请继续关注! + +再见! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-improve-application-startup-time-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://aur.archlinux.org/packages/preload/ +[2]:https://www.ostechnix.com/install-pacaur-arch-linux/ +[3]:https://www.ostechnix.com/install-packer-arch-linux-2/ +[4]:https://www.ostechnix.com/trizen-lightweight-aur-package-manager-arch-based-systems/ +[5]:https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[6]:https://www.ostechnix.com/install-yaourt-arch-linux/ +[7]:https://askubuntu.com/questions/110335/drawbacks-of-using-preload-why-isnt-it-included-by-default +[8]:https://cs.uwaterloo.ca/~brecht/courses/702/Possible-Readings/prefetching-to-memory/preload-thesis.pdf From a710e048146305526e8fdd3175bfc093822c7c2f Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 15 May 2018 15:36:45 +0800 Subject: [PATCH 097/111] Update 20180512 How To Check Laptop Battery Status In Terminal In Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 准备进行翻译。 --- ...2 How To Check Laptop Battery Status In Terminal In Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md b/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md index 7fdc6c055e..61f702eecc 100644 --- a/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md +++ b/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md @@ -1,3 +1,5 @@ +FSSlc translating + How To Check Laptop Battery Status In Terminal In Linux ====== ![](https://www.ostechnix.com/wp-content/uploads/2016/12/Check-Laptop-Battery-Status-In-Terminal-In-Linux-720x340.png) From 51e6ead3d77436a315a2bd6813b4e2d4deadec23 Mon Sep 17 00:00:00 2001 From: Tao Wu Date: Tue, 15 May 2018 10:43:07 +0200 Subject: [PATCH 098/111] Update 20180115 2 scientific calculators for the Linux desktop.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原文是 astronomical units per year into inches per second,“天文单位每年转换为英寸每秒”。 --- ...180115 2 scientific calculators for the Linux desktop.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/published/20180115 2 scientific calculators for the Linux desktop.md b/published/20180115 2 scientific calculators for the Linux desktop.md index 805bff0bce..9e10e16355 100644 --- a/published/20180115 2 scientific calculators for the Linux desktop.md +++ b/published/20180115 2 scientific calculators for the Linux desktop.md @@ -15,7 +15,7 @@ ![SpeedCrunch graphical interface][3] -*SpeedCrunch 在工作时* +*SpeedCrunch 运行中* 它支持单位,并且可用在所有函数中。 @@ -57,7 +57,7 @@ SpeedCrunch 会默认地将结果转化为国际标准单位,但还是可以 ![Qalculate! Interface][7] -*在 Qalculate! 中寻找物理常量* +*在 Qalculate! 中查看物理常量* 在单位的使用方面,Qalculate! 会比 SppedCrunch 更加直观,而且可以识别一些常用前缀。你有听说过 exapascal 压力吗?反正我没有(太阳的中心大概在 `~26 PPa`),但 Qalculate! ,可以准确 `1 EPa` 的意思。同时,Qalculate! 可以更加灵活地处理语法错误,所以你不需要担心打括号:如果没有歧义,Qalculate! 会直接给出正确答案。 @@ -69,7 +69,7 @@ SpeedCrunch 会默认地将结果转化为国际标准单位,但还是可以 好吧,这不是“计算器”,但这个程序非常好用。 -大部分单位转换器只是一个大的基本单位列表以及一大堆基本组合,但 [ConvertAll][9] 与它们不一样。有试过把光年转换为英尺每秒吗?不管它们说不说得通,只要你想转换任何种类的单位,ConvertAll 就是你要的工具。 +大部分单位转换器只是一个大的基本单位列表以及一大堆基本组合,但 [ConvertAll][9] 与它们不一样。有试过把天文单位每年转换为英寸每秒吗?不管它们说不说得通,只要你想转换任何种类的单位,ConvertAll 就是你要的工具。 只需要在相应的输入框内输入转换前和转换后的单位:如果单位相容,你会直接得到答案。 From ebbe9c29818f3609c6f96ad1d088fdc20f67a6fc Mon Sep 17 00:00:00 2001 From: FSSlc Date: Tue, 15 May 2018 17:14:31 +0800 Subject: [PATCH 099/111] [Translated] 20180512 How To Check Laptop Battery Status In Terminal In Linux.md --- ...top Battery Status In Terminal In Linux.md | 311 ------------------ ...top Battery Status In Terminal In Linux.md | 310 +++++++++++++++++ 2 files changed, 310 insertions(+), 311 deletions(-) delete mode 100644 sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md create mode 100644 translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md diff --git a/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md b/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md deleted file mode 100644 index 61f702eecc..0000000000 --- a/sources/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md +++ /dev/null @@ -1,311 +0,0 @@ -FSSlc translating - -How To Check Laptop Battery Status In Terminal In Linux -====== -![](https://www.ostechnix.com/wp-content/uploads/2016/12/Check-Laptop-Battery-Status-In-Terminal-In-Linux-720x340.png) -Finding your Laptop battery status in GUI mode is easy. You could easily tell the battery level by hovering the mouse pointer over the battery indicator icon in the task bar. But, how about from the command line? Not everyone know this. The other day a friend of mine asked how to check his Laptop battery level from Terminal in his Ubuntu desktop – hence this post. Here I have included three simple methods which will help you to check Laptop battery status in Terminal in any Linux distribution. - -### Check Laptop Battery Status In Terminal In Linux - -We can find the Laptop battery status from command line in three methods. - -##### Method 1 – Using “Upower” command - -The **Upower** command comes preinstalled with most Linux distributions. To display the battery status using Upower, open up the Terminal and run: -``` -$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 - -``` - -**Sample output:** -``` -native-path: BAT0 - vendor: Samsung SDI - model: DELL 7XFJJA2 - serial: 4448 - power supply: yes - updated: Sat 12 May 2018 06:48:48 PM IST (41 seconds ago) - has history: yes - has statistics: yes - battery - present: yes - rechargeable: yes - state: charging - warning-level: none - energy: 43.3011 Wh - energy-empty: 0 Wh - energy-full: 44.5443 Wh - energy-full-design: 48.84 Wh - energy-rate: 9.8679 W - voltage: 12.548 V - time to full: 7.6 minutes - percentage: 97% - capacity: 91.2045% - technology: lithium-ion - icon-name: 'battery-full-charging-symbolic' - History (charge): - 1526131128 97.000 charging - History (rate): - 1526131128 9.868 charging - -``` - -As you see above, my battery is in charging mode now and the battery level is 97%. - -If the above command doesn’t work for any reason, try the following command instead: -``` -$ upower -i `upower -e | grep 'BAT'` - -``` - -**Sample output:** -``` -native-path: BAT0 - vendor: Samsung SDI - model: DELL 7XFJJA2 - serial: 4448 - power supply: yes - updated: Sat 12 May 2018 06:50:49 PM IST (22 seconds ago) - has history: yes - has statistics: yes - battery - present: yes - rechargeable: yes - state: charging - warning-level: none - energy: 43.6119 Wh - energy-empty: 0 Wh - energy-full: 44.5443 Wh - energy-full-design: 48.84 Wh - energy-rate: 8.88 W - voltage: 12.552 V - time to full: 6.3 minutes - percentage: 97% - capacity: 91.2045% - technology: lithium-ion - icon-name: 'battery-full-charging-symbolic' - History (rate): - 1526131249 8.880 charging - -``` - -Upower not just display the battery status, but also the complete details of the installed battery such as model, vendor name, serial no, state, voltage etc. - -However, you can only display the status of the battery by with combination of upower and [**grep**][1] commands as shown below. -``` -$ upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" - -``` - -**Sample output:** -``` -state: fully-charged -percentage: 100% - -``` - -![][3] - -As you see in the above output, my Laptop battery has been fully charged. - -For more details, refer man pages. -``` -$ man upower - -``` - -##### Method 2 – Using “acpi” command - -The **acpi** command shows battery status and other ACPI information in your Linux distribution. - -You might need to install **acpi** command in some Linux distributions. - -To install acpi on Debian, Ubuntu and its derivatives: -``` -$ sudo apt-get install acpi - -``` - -On RHEL, CentOS, Fedora: -``` -$ sudo yum install acpi - -``` - -Or, -``` -$ sudo dnf install acpi - -``` - -On Arch Linux and its derivatives: -``` -$ sudo pacman -S acpi - -``` - -Once acpi installed, run the following command: -``` -$ acpi -V - -``` - -**Note:** Here, “V” is capital letter. - -**Sample output:** -``` -Battery 0: Charging, 99%, 00:02:09 until charged -Battery 0: design capacity 4400 mAh, last full capacity 4013 mAh = 91% -Battery 1: Discharging, 0%, rate information unavailable -Adapter 0: on-line -Thermal 0: ok, 77.5 degrees C -Thermal 0: trip point 0 switches to mode critical at temperature 84.0 degrees C -Cooling 0: Processor 0 of 3 -Cooling 1: Processor 0 of 3 -Cooling 2: LCD 0 of 15 -Cooling 3: Processor 0 of 3 -Cooling 4: Processor 0 of 3 -Cooling 5: intel_powerclamp no state information available -Cooling 6: x86_pkg_temp no state information available - -``` - -Let us only check the state of the charge of battery. To do so, run: -``` -$ acpi - -``` - -**Sample output:** -``` -Battery 0: Charging, 99%, 00:01:41 until charged -Battery 1: Discharging, 0%, rate information unavailable - -``` - -Let us check the battery temperature: -``` -$ acpi -t - -``` - -**Sample output:** -``` -Thermal 0: ok, 63.5 degrees C - -``` - -Let us view the above output in Fahrenheit: -``` -$ acpi -t -f - -``` - -**Sample output:** -``` -Thermal 0: ok, 144.5 degrees F - -``` - -Want to know whether the AC power is connected or not? Run: -``` -$ acpi -a - -``` - -**Sample output:** -``` -Adapter 0: on-line - -``` - -If the AC power is not available, you would the see the following instead: -``` -Adapter 0: off-line - -``` - -For more details, check the man pages. -``` -$ man acpi - -``` - -##### Method 3: Using “Batstat” Program - -The **batstat** is a small ncurses-based CLI utility to display your Laptop battery status in Unix-like systems. It will display the following details: - - * Current battery level - * Current Energy - * Full charge energy - * Time elapsed from the start of the program, without tracking the sleep time of the machine. - * Battery level history - - - -Installing batstat is a piece of cake. Git clone the latest version using command: -``` -$ git clone https://github.com/Juve45/batstat.git - -``` - -The above command will pull the latest batstat version and save it’s contents in a folder named “batstat”. - -CD to batstat/bin/ directory: -``` -$ cd batstat/bin/ - -``` - -Copy “batstat” binary file to your PATH, for example /usr/local/bin/. -``` -$ sudo cp batstat /usr/local/bin/ - -``` - -Make it executable using command: -``` -$ sudo chmod +x /usr/local/bin/batstat - -``` - -Finally, run the following command to view your battery status. -``` -$ batstat - -``` - -Sample output: - -![][4] - -As you see in the above screenshot, my battery is in charging mode. - -This utility has some limitations though. As of writing this guide, batstat will support only one battery. And, it gathers information only from this folder – **“/sys/class/power_supply/”**. If your machine contains the battery information on a different folder, this program will not work. - -For more details, check batstat github page. - -And, that’s all for today folks. There might be many commands and programs out there to check the laptop battery status in Terminal in Linux. As far as I know, the above given methods have worked just fine as expected. If you know some other commands to find out the battery status, let me know in the comment section below. I will update commands in the article if they works. - -And, that’s all for now. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-check-laptop-battery-status-in-terminal-in-linux/ - -作者:[SK][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.ostechnix.com/author/sk/ -[1]:https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/ -[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[3]:http://www.ostechnix.com/wp-content/uploads/2016/12/sk@sk_006-1.png -[4]:http://www.ostechnix.com/wp-content/uploads/2016/12/batstat-1.png diff --git a/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md b/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md new file mode 100644 index 0000000000..a82dc8ed52 --- /dev/null +++ b/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md @@ -0,0 +1,310 @@ +如何在 Linux 终端下检查笔记本电池状态 +====== +![](https://www.ostechnix.com/wp-content/uploads/2016/12/Check-Laptop-Battery-Status-In-Terminal-In-Linux-720x340.png) + +在图形界面下查看你的笔记本电池状态是很容易的,只需将鼠标指向任务栏中的电池图标上,你便可以很容易地知道电池的电量。但如果我们想要从命令行中获得这些信息呢?并不是所有人都知道如何做到这点。前几天我的一个朋友询问我如何从他的 Ubuntu 系统里,在终端中查看他的笔记本电池的电量。这便是我写这篇文章的起因。在本文中我概括了三种简单的方法来让你在任何 Linux 发行版本中从终端查看笔记本电池的状态。 + +### 在终端下检查笔记本电池状态 + +我们可以使用下面的三种方法来从命令行中查找到笔记本电池状态。 + +##### 方法一 – 使用 “Upower” 命令 + +**Upower** 命令预装在大多数的 Linux 发行版本中。为了使用 `upower` 命令来展示电池的状态,打开终端并运行如下命令: +``` +$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 + +``` + +**示例输出:** +``` +native-path: BAT0 + vendor: Samsung SDI + model: DELL 7XFJJA2 + serial: 4448 + power supply: yes + updated: Sat 12 May 2018 06:48:48 PM IST (41 seconds ago) + has history: yes + has statistics: yes + battery + present: yes + rechargeable: yes + state: charging + warning-level: none + energy: 43.3011 Wh + energy-empty: 0 Wh + energy-full: 44.5443 Wh + energy-full-design: 48.84 Wh + energy-rate: 9.8679 W + voltage: 12.548 V + time to full: 7.6 minutes + percentage: 97% + capacity: 91.2045% + technology: lithium-ion + icon-name: 'battery-full-charging-symbolic' + History (charge): + 1526131128 97.000 charging + History (rate): + 1526131128 9.868 charging + +``` + +正如你所看到的那样,我的电池正处于充电状态,并且它的电量百分比是 97%。 + +假如上面的命令因为某些未知原因不起作用,可以尝试使用下面的命令: +``` +$ upower -i `upower -e | grep 'BAT'` + +``` + +**示例输出:** +``` +native-path: BAT0 + vendor: Samsung SDI + model: DELL 7XFJJA2 + serial: 4448 + power supply: yes + updated: Sat 12 May 2018 06:50:49 PM IST (22 seconds ago) + has history: yes + has statistics: yes + battery + present: yes + rechargeable: yes + state: charging + warning-level: none + energy: 43.6119 Wh + energy-empty: 0 Wh + energy-full: 44.5443 Wh + energy-full-design: 48.84 Wh + energy-rate: 8.88 W + voltage: 12.552 V + time to full: 6.3 minutes + percentage: 97% + capacity: 91.2045% + technology: lithium-ion + icon-name: 'battery-full-charging-symbolic' + History (rate): + 1526131249 8.880 charging + +``` + +Upower 不仅可以显示出电池的状态,它还可以显示出已安装电池的其他完整信息,例如 +电池型号,供应商名称,电池的序列号,电池的状态,电池的电压等信息。 + +当然,如果你只想显示电池的状态,你可以可以结合使用 `upower` 命令和[**grep**][1] 命令,具体命令如下: +``` +$ upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" + +``` + +**示例输出:** +``` +state: fully-charged +percentage: 100% + +``` + +![][3] + +从上面的输出中可以看到我的笔记本电池已经完全充满了。 + +想知晓更多的细节,可以参看 man 页: +``` +$ man upower + +``` + +##### 方法二 – 使用 “acpi” 命令 + +**acpi** 命令可以用来显示你的 Linux 发行版本中电池的状态以及其他 ACPI 信息。 + +在某些 Linux 发行版本中,你可能需要安装 **acpi** 命令。 + +要在 Debian, Ubuntu 及其衍生版本中安装它,可以使用如下命令: +``` +$ sudo apt-get install acpi + +``` + +在 RHEL, CentOS, Fedora 等系统中使用: +``` +$ sudo yum install acpi + +``` + +或者使用如下命令: +``` +$ sudo dnf install acpi + +``` + +在 Arch Linux 及其衍生版本中使用: +``` +$ sudo pacman -S acpi + +``` + +一旦 `acpi` 安装好后,运行下面的命令: +``` +$ acpi -V + +``` + +**注意:** 在上面的命令中, “V” 是大写字母。 + +**示例输出:** +``` +Battery 0: Charging, 99%, 00:02:09 until charged +Battery 0: design capacity 4400 mAh, last full capacity 4013 mAh = 91% +Battery 1: Discharging, 0%, rate information unavailable +Adapter 0: on-line +Thermal 0: ok, 77.5 degrees C +Thermal 0: trip point 0 switches to mode critical at temperature 84.0 degrees C +Cooling 0: Processor 0 of 3 +Cooling 1: Processor 0 of 3 +Cooling 2: LCD 0 of 15 +Cooling 3: Processor 0 of 3 +Cooling 4: Processor 0 of 3 +Cooling 5: intel_powerclamp no state information available +Cooling 6: x86_pkg_temp no state information available + +``` + +首先让我们来检查电池的电量,可以运行: +``` +$ acpi + +``` + +**示例输出:** +``` +Battery 0: Charging, 99%, 00:01:41 until charged +Battery 1: Discharging, 0%, rate information unavailable + +``` + +下面,让我们来查看电池的温度: +``` +$ acpi -t + +``` + +**示例输出:** +``` +Thermal 0: ok, 63.5 degrees C + +``` + +如果需要将温度以华氏温标显示,可以使用: +``` +$ acpi -t -f + +``` + +**示例输出:** +``` +Thermal 0: ok, 144.5 degrees F + +``` + +如果想看看交流电适配器是否连接上了没有,可以运行: +``` +$ acpi -a + +``` + +**示例输出:** +``` +Adapter 0: on-line + +``` + +假如交流电适配器没有连接上,则你将看到如下的输出: +``` +Adapter 0: off-line + +``` + +想获取更多的信息,可以查看 man 页: +``` +$ man acpi + +``` + +##### 方法三 - 使用 “Batstat” 程序 + +**batstat** 是一个基于 ncurses 的命令行小工具,使用它可以在类 Unix 系统中展示笔记本电池状态。它可以展示如下具体信息: + + * 当前电池电量 + * 当前电池所存能量 + * 充满时所存能量 + * 从程序启动开始经历的时间,它不会追踪记录机器休眠的时间 + * 电池电量消耗历史数据 + +安装 `batstat` 轻而易举。使用下面的命令来复刻(clone)该程序的最新版本: +``` +$ git clone https://github.com/Juve45/batstat.git + +``` + +上面的命令将拉取 batstat 的最新版本并将它的内容保存在一个名为 ”batstat“ 的文件夹中。 + +首先将目录切换到 `batstat/bin/` 中: +``` +$ cd batstat/bin/ + +``` + +接着将 “batstat” 二进制文件复制到 PATH 环境变量中的某个目录中,例如 `/usr/local/bin/` 目录: +``` +$ sudo cp batstat /usr/local/bin/ + +``` + +使用下面的命令来让它可被执行: +``` +$ sudo chmod +x /usr/local/bin/batstat + +``` + +最后,使用下面的命令来查看你的电池状态。 +``` +$ batstat + +``` + +示例输出: + +![][4] + +从上面的截图中可以看到我的笔记本电池正处于充电状态。 + +这个小工具还有某些小的限制。在书写本文之时,batstat 仅支持显示一个电池的相关信息。而且它只从 **“/sys/class/power_supply/”** 目录搜集相关的信息。假如你的电池信息被存放在另外的目录中,则这个小工具就不会起作用了。 + +想知晓更多信息,可以查看 batstat 的 [github 主页][5]。 + +上面就是今天我要分享的所有内容。当然,可能还有很多其他的命令或者程序来从 Linux 终端检查笔记本的电池状态。据我所知,上面给出的命令都运行良好。假如你知道其他命令来查看电池的状态,请在下面的评论框中让我们知晓。假如你所给出的方法能够起作用,我将对我的这篇文章进行更新。 + +最后,上面便是今天的全部内容了。更多的优质内容敬请期待,敬请关注! + +欢呼吧! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-check-laptop-battery-status-in-terminal-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[FSSlc](https://github.com/FSSlc) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/ +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:http://www.ostechnix.com/wp-content/uploads/2016/12/sk@sk_006-1.png +[4]:http://www.ostechnix.com/wp-content/uploads/2016/12/batstat-1.png +[5]:https://github.com/Juve45/batstat \ No newline at end of file From 5c9aa0aacaa27f2bbe34751ca28cd42a8387efad Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 18:32:13 +0800 Subject: [PATCH 100/111] PRF:20140510 Journey to the Stack Part I.md @qhwdw --- .../20140510 Journey to the Stack Part I.md | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/translated/tech/20140510 Journey to the Stack Part I.md b/translated/tech/20140510 Journey to the Stack Part I.md index b18c7d32f5..86a01363cc 100644 --- a/translated/tech/20140510 Journey to the Stack Part I.md +++ b/translated/tech/20140510 Journey to the Stack Part I.md @@ -1,40 +1,41 @@ -#[探秘“栈”之旅(I)][1] +探秘“栈”之旅 +============== -早些时候,我们讲解了 [“剖析内存中的程序之秘”][2],我们欣赏了在一台电脑中是如何运行我们的程序的。今天,我们去探索栈的调用,它在大多数编程语言和虚拟机中都默默地存在。在此过程中,我们将接触到一些平时很难见到的东西,像闭包(closures)、递归、以及缓冲溢出等等。但是,我们首先要作的事情是,描绘出栈是如何运作的。 +早些时候,我们探索了 [“内存中的程序之秘”][2],我们欣赏了在一台电脑中是如何运行我们的程序的。今天,我们去探索*栈的调用*,它在大多数编程语言和虚拟机中都默默地存在。在此过程中,我们将接触到一些平时很难见到的东西,像闭包closure、递归、以及缓冲溢出等等。但是,我们首先要作的事情是,描绘出栈是如何运作的。 -栈非常重要,因为它持有着在一个程序中运行的函数,而函数又是一个软件的重要组成部分。事实上,程序的内部操作都是非常简单的。它大部分是由函数向栈中推入数据或者从栈中弹出数据的相互调用组成的,虽然为数据分配内存是在堆上,但是,在跨函数的调用中数据必须要保存下来,不论是低级(low-leverl)的 C 软件还是像 JavaScript 和 C# 这样的基于虚拟机的语言,它们都是这样的。而对这些行为的深刻理解,对排错、性能调优以及大概了解究竟发生了什么是非常重要的。 +栈非常重要,因为它追踪着一个程序中运行的*函数*,而函数又是一个软件的重要组成部分。事实上,程序的内部操作都是非常简单的。它大部分是由函数向栈中推入数据或者从栈中弹出数据的相互调用组成的,而在堆上为数据分配内存才能在跨函数的调用中保持数据。不论是低级的 C 软件还是像 JavaScript 和 C# 这样的基于虚拟机的语言,它们都是这样的。而对这些行为的深刻理解,对排错、性能调优以及大概了解究竟发生了什么是非常重要的。 -当一个函数被调用时,将会创建一个栈帧(stack frame)去支持函数的运行。这个栈帧包含函数的本地变量和调用者传递给它的参数。这个栈帧也包含了允许被调用的函数安全返回给调用者的内部事务信息。栈帧的精确内容和结构因处理器架构和函数调用规则而不同。在本文中我们以 Intel x86 架构和使用 C 风格的函数调用(cdecl)的栈为例。下图是一个处于栈顶部的一个单个栈帧: +当一个函数被调用时,将会创建一个栈帧stack frame去支持函数的运行。这个栈帧包含函数的*局部变量*和调用者传递给它的*参数*。这个栈帧也包含了允许被调用的函数(*callee*)安全返回给其调用者的内部事务信息。栈帧的精确内容和结构因处理器架构和函数调用规则而不同。在本文中我们以 Intel x86 架构和使用 C 风格的函数调用(`cdecl`)的栈为例。下图是一个处于栈顶部的一个单个栈帧: ![](https://manybutfinite.com/img/stack/stackIntro.png) -在图上的场景中,有三个 CPU 寄存器进入栈。栈指针 `esp`(译者注:扩展栈指针寄存器) 指向到栈的顶部。栈的顶部总是被最后一个推入到栈且还没有弹出的东西所占据,就像现实世界中堆在一起的一叠板子或者面值 $100 的钞票。 +在图上的场景中,有三个 CPU 寄存器进入栈。栈指针stack pointer `esp`(LCTT 译注:扩展栈指针寄存器) 指向到栈的顶部。栈的顶部总是被最*后一个推入到栈且还没有弹出*的东西所占据,就像现实世界中堆在一起的一叠盘子或者 100 美元大钞一样。 保存在 `esp` 中的地址始终在变化着,因为栈中的东西不停被推入和弹出,而它总是指向栈中的最后一个推入的东西。许多 CPU 指令的一个副作用就是自动更新 `esp`,离开寄存器而使用栈是行不通的。 -在 Intel 的架构中,绝大多数情况下,栈的增长是向着低位内存地址的方向。因此,这个“顶部” 在包含数据(在这种情况下,包含的数据是 `local_buffer`)的栈中是处于低位的内存地址。注意,关于从 `esp` 到 `local_buffer` 的箭头,这里并没有模糊的地方。这个箭头代表着事务:它专门指向到由 `local_buffer` 所拥有的第一个字节,因为,那是一个保存在 `esp` 中的精确地址。 +在 Intel 的架构中,绝大多数情况下,栈的增长是向着*低位内存地址*的方向。因此,这个“顶部” 在包含数据的栈中是处于低位的内存地址(在这种情况下,包含的数据是 `local_buffer`)。注意,关于从 `esp` 到 `local_buffer` 的箭头不是随意连接的。这个箭头代表着事务:它*专门*指向到由 `local_buffer` 所拥有的*第一个字节*,因为,那是一个保存在 `esp` 中的精确地址。 -第二个寄存器跟踪的栈是 `ebp`(译者注:扩展基址指针寄存器),它包含一个基指针或者称为帧指针。它指向到一个当前运行的函数的栈帧内的固定的位置,并且它为参数和本地变量的访问提供一个稳定的参考点(基址)。仅当开始或者结束调用一个函数时,`ebp` 的内容才会发生变化。因此,我们可以很容易地处理每个在栈中的从 `ebp` 开始偏移后的一个东西。如下图所示。 +第二个寄存器跟踪的栈是 `ebp`(LCTT 译注:扩展基址指针寄存器),它包含一个基指针base pointer或者称为帧指针frame pointer。它指向到一个*当前运行*的函数的栈帧内的固定位置,并且它为参数和局部变量的访问提供一个稳定的参考点(基址)。仅当开始或者结束调用一个函数时,`ebp` 的内容才会发生变化。因此,我们可以很容易地处理在栈中的从 `ebp` 开始偏移后的每个东西。如图所示。 -不像 `esp`, `ebp` 大多数情况下是在程序代码中通过花费很少的 CPU 来进行维护的。有时候,完成抛弃 `ebp` 有一些性能优势,可以通过 [编译标志][3] 来做到这一点。Linux 内核中有一个实现的示例。 +不像 `esp`, `ebp` 大多数情况下是在程序代码中通过花费很少的 CPU 来进行维护的。有时候,完成抛弃 `ebp` 有一些性能优势,可以通过 [编译标志][3] 来做到这一点。Linux 内核就是一个这样做的示例。 -最后,`eax`(译者注:扩展的 32 位通用数据寄存器)寄存器是被调用规则所使用的寄存器,对于大多数 C 数据类型来说,它的作用是转换一个返回值给调用者。 +最后,`eax`(LCTT 译注:扩展的 32 位通用数据寄存器)寄存器惯例被用来转换大多数 C 数据类型返回值给调用者。 -现在,我们来看一下在我们的栈帧中的数据。下图清晰地按字节展示了字节的内容,就像你在一个调试器中所看到的内容一样,内存是从左到右、从底部到顶部增长的,如下图所示: +现在,我们来看一下在我们的栈帧中的数据。下图清晰地按字节展示了字节的内容,就像你在一个调试器中所看到的内容一样,内存是从左到右、从顶部至底部增长的,如下图所示: ![](https://manybutfinite.com/img/stack/frameContents.png) -本地变量 `local_buffer` 是一个字节数组,它包含一个空终止(null-terminated)的 ascii 字符串,这是一个 C 程序中的基本元素。这个字符串可以从任意位置读取,例如,从键盘输入或者来自一个文件,它只有 7 个字节的长度。因为,`local_buffer` 只能保存 8 字节,在它的左侧保留了 1 个未使用的字节。这个字节的内容是未知的,因为栈的推入和弹出是极其活跃的,除了你写入的之外,你从不知道内存中保存了什么。因为 C 编译器并不为栈帧初始化内存,所以它的内容是未知的并且是随机的 - 除非是你自己写入。这使得一些人对此很困惑。 +局部变量 `local_buffer` 是一个字节数组,包含一个由 null 终止的 ASCII 字符串,这是 C 程序中的一个基本元素。这个字符串可以读取自任意地方,例如,从键盘输入或者来自一个文件,它只有 7 个字节的长度。因为,`local_buffer` 只能保存 8 字节,所以还剩下 1 个未使用的字节。*这个字节的内容是未知的*,因为栈不断地推入和弹出,*除了你写入的之外*,你根本不会知道内存中保存了什么。这是因为 C 编译器并不为栈帧初始化内存,所以它的内容是未知的并且是随机的 —— 除非是你自己写入。这使得一些人对此很困惑。 -再往上走,`local1` 是一个 4 字节的整数,并且你可以看到每个字节的内容。它似乎是一个很大的数字,所有的零都在 8 后面,在这里可能会让你误入歧途。 +再往上走,`local1` 是一个 4 字节的整数,并且你可以看到每个字节的内容。它似乎是一个很大的数字,在8 后面跟着的都是零,在这里可能会误导你。 -Intel 处理器是按从小到大的机制来处理的,这表示在内存中的数字也是首先从小的位置开始的。因此,在一个多字节数字中,最小的标志字节在内存中处于低端地址。因为一般情况下是从左边开始显示的,这背离了我们一般意义上对数字的认识。我们讨论的这种从小到大的机制,使我想起《Gulliver 游记》:就像 Lilliput 吃鸡蛋是从小头开始的一样,Intel 处理器处理它们的数字也是从字节的小端开始的。 +Intel 处理器是小端little endian机器,这表示在内存中的数字也是首先从小的一端开始的。因此,在一个多字节数字中,较小的部分在内存中处于最低端的地址。因为一般情况下是从左边开始显示的,这背离了我们通常的数字表示方式。我们讨论的这种从小到大的机制,使我想起《格里佛游记》:就像小人国的人们吃鸡蛋是从小头开始的一样,Intel 处理器处理它们的数字也是从字节的小端开始的。 -因此,`local1` 事实上只保存了一个数字 8,就像一个章鱼的腿。然而,`param1` 在第二个字节的位置有一个值 2,因此,它的数学上的值是 2 * 256 = 512(我们与 256 相乘是因为,每个位置值的范围都是从 0 到 255)。同时,`param2` 承载的数量是 1 * 256 * 256 = 65536。 +因此,`local1` 事实上只保存了一个数字 8,和章鱼的腿数量一样。然而,`param1` 在第二个字节的位置有一个值 2,因此,它的数学上的值是 `2 * 256 = 512`(我们与 256 相乘是因为,每个位置值的范围都是从 0 到 255)。同时,`param2` 承载的数量是 `1 * 256 * 256 = 65536`。 -这个栈帧的内部数据是由两个重要的部分组成:前一个栈帧的地址和函数的出口(返回地址)上运行的指令的地址。它们一起确保了函数能够正常返回,从而使程序可以继续正常运行。 +这个栈帧的内部数据是由两个重要的部分组成:*前一个*栈帧的地址(保存的 `ebp` 值)和函数退出才会运行的指令的地址(返回地址)。它们一起确保了函数能够正常返回,从而使程序可以继续正常运行。 -现在,我们来看一下栈帧是如何产生的,以及去建立一个它们如何共同工作的内部蓝图。在刚开始的时候,栈的增长是非常令人困惑的,因为它发生的一切都不是你所期望的东西。例如,在栈上从 `esp` 减去 8,去分配一个 8 字节,而减法是以一种奇怪的方式去开始的。 +现在,我们来看一下栈帧是如何产生的,以及去建立一个它们如何共同工作的内部蓝图。首先,栈的增长是非常令人困惑的,因为它与你你预期的方式相反。例如,在栈上分配一个 8 字节,就要从 `esp` 减去 8,去,而减法是与增长不同的奇怪方式。 我们来看一个简单的 C 程序: @@ -54,23 +55,25 @@ int main(int argc) } ``` -假设我们在 Linux 中不使用命令行参数去运行它。当你运行一个 C 程序时,去真实运行的第一个代码是 C 运行时库,由它来调用我们的 `main` 函数。下图展示了程序运行时每一步都发生了什么。每个图链接的 GDB 输出展示了内存的状态和寄存器。你也可以看到所使用的 [GDB 命令][4],以及整个 [GDB 输出][5]。如下: +*简单的加法程序 - add.c* + +假设我们在 Linux 中不使用命令行参数去运行它。当你运行一个 C 程序时,实际运行的第一行代码是在 C 运行时库里,由它来调用我们的 `main` 函数。下图展示了程序运行时每一步都发生了什么。每个图链接的 GDB 输出展示了内存和寄存器的状态。你也可以看到所使用的 [GDB 命令][4],以及整个 [GDB 输出][5]。如下: ![](https://manybutfinite.com/img/stack/mainProlog.png) -第 2 步和第 3 步,以及下面的第 4 步,都只是函数的开端,几乎所有的函数都是这样的:`ebp` 的当前值保存着栈的顶部,然后,将 `esp` 的内容拷贝到 `ebp`,维护一个新帧。`main` 的开端和任何一个其它函数都是一样,但是,不同之处在于,当程序启动时 `ebp` 被清零。 +第 2 步和第 3 步,以及下面的第 4 步,都只是函数的序言prologue,几乎所有的函数都是这样的:`ebp` 的当前值被保存到了栈的顶部,然后,将 `esp` 的内容拷贝到 `ebp`,以建立一个新的栈帧。`main` 的序言和其它函数一样,但是,不同之处在于,当程序启动时 `ebp` 被清零。 -如果你去检查栈下面的整形变量(argc),你将找到更多的数据,包括指向到程序名和命令行参数(传统的 C 参数数组)、Unix 环境变量以及它们真实的内容的指针。但是,在这里这些并不是重点,因此,继续向前调用 add(): +如果你去检查栈下方(右边)的整形变量(`argc`),你将找到更多的数据,包括指向到程序名和命令行参数(传统的 C 的 `argv`)、以及指向 Unix 环境变量以及它们真实的内容的指针。但是,在这里这些并不是重点,因此,继续向前调用 `add()`: ![](https://manybutfinite.com/img/stack/callAdd.png) -在 `main` 从 `esp` 减去 12 之后得到它所需的栈空间,它为 a 和 b 设置值。在内存中值展示为十六进制,并且是从小到大的格式。与你从调试器中看到的一样。一旦设置了参数值,`main` 将调用 `add` ,并且它开始运行: +在 `main` 从 `esp` 减去 12 之后得到它所需的栈空间,它为 `a` 和 `b` 设置值。在内存中的值展示为十六进制,并且是小端格式,与你从调试器中看到的一样。一旦设置了参数值,`main` 将调用 `add`,并且开始运行: ![](https://manybutfinite.com/img/stack/addProlog.png) -现在,有一点小激动!我们进入了另一个开端,在这时你可以明确看到栈帧是如何从 `ebp` 的一个链表开始进入到栈的。这就是在高级语言中调试器和异常对象如何对它们的栈进行跟踪的。当一个新帧产生时,你也可以看到更多这种从 `ebp` 到 `esp` 的典型的捕获。我们再次从 `esp` 中做减法得到更多的栈空间。 +现在,有一点小激动!我们进入了另一个函数序言,但这次你可以明确看到栈帧是如何从 `ebp` 到栈建立一个链表。这就是调试器和高级语言中的 `Exception` 对象如何对它们的栈进行跟踪的。当一个新帧产生时,你也可以看到更多这种典型的从 `ebp` 到 `esp` 的捕获。我们再次从 `esp` 中做减法得到更多的栈空间。 -当 `ebp` 寄存器的值拷贝到内存时,这里也有一个稍微有些怪异的地方。在这里发生的奇怪事情是,寄存器并没有真的按字节顺序拷贝:因为对于内存,没有像寄存器那样的“增长的地址”。因此,通过调试器的规则以最自然的格式给人展示了寄存器的值:从最重要的到最不重要的数字。因此,这个在从小到大的机制中拷贝的结果,与内存中常用的从左到右的标记法正好相反。我想用图去展示你将会看到的东西,因此有了下面的图。 +当 `ebp` 寄存器的值拷贝到内存时,这里也有一个稍微有些怪异的字节逆转。在这里发生的奇怪事情是,寄存器其实并没有字节顺序:因为对于内存,没有像寄存器那样的“增长的地址”。因此,惯例上调试器以对人类来说最自然的格式展示了寄存器的值:数位从最重要的到最不重要。因此,这个在小端机器中的副本的结果,与内存中常用的从左到右的标记法正好相反。我想用图去展示你将会看到的东西,因此有了下面的图。 在比较难懂的部分,我们增加了注释: @@ -78,7 +81,7 @@ int main(int argc) 这是一个临时寄存器,用于帮你做加法,因此没有什么警报或者惊喜。对于加法这样的作业,栈的动作正好相反,我们留到下次再讲。 -对于任何读到这篇文章的人都应该有一个小礼物,因此,我做了一个大的图表展示了 [组合到一起的所有步骤][6]。 +对于任何读到这里的人都应该有一个小礼物,因此,我做了一个大的图表展示了 [组合到一起的所有步骤][6]。 一旦把它们全部布置好了,看上起似乎很乏味。这些小方框给我们提供了很多帮助。事实上,在计算机科学中,这些小方框是主要的展示工具。我希望这些图片和寄存器的移动能够提供一种更直观的构想图,将栈的增长和内存的内容整合到一起。从软件的底层运作来看,我们的软件与一个简单的图灵机器差不多。 @@ -90,13 +93,13 @@ via:https://manybutfinite.com/post/journey-to-the-stack/ 作者:[Gustavo Duarte][a] 译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:http://duartes.org/gustavo/blog/about/ [1]:https://manybutfinite.com/post/journey-to-the-stack/ -[2]:https://manybutfinite.com/post/anatomy-of-a-program-in-memory +[2]:https://linux.cn/article-9255-1.html [3]:http://stackoverflow.com/questions/14666665/trying-to-understand-gcc-option-fomit-frame-pointer [4]:https://github.com/gduarte/blog/blob/master/code/x86-stack/add-gdb-commands.txt [5]:https://github.com/gduarte/blog/blob/master/code/x86-stack/add-gdb-output.txt From 2d4d7dc04fd816cd5e3bf5ff05a178c203933e52 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 15 May 2018 18:33:20 +0800 Subject: [PATCH 101/111] PUB:20140510 Journey to the Stack Part I.md @qhwdw https://linux.cn/article-9645-1.html --- .../tech => published}/20140510 Journey to the Stack Part I.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20140510 Journey to the Stack Part I.md (100%) diff --git a/translated/tech/20140510 Journey to the Stack Part I.md b/published/20140510 Journey to the Stack Part I.md similarity index 100% rename from translated/tech/20140510 Journey to the Stack Part I.md rename to published/20140510 Journey to the Stack Part I.md From 8654e9c7507a11303817654f16f15e8c1fc69f0a Mon Sep 17 00:00:00 2001 From: qhwdw Date: Tue, 15 May 2018 18:55:58 +0800 Subject: [PATCH 102/111] Translated by qhwdw --- ... Testing IPv6 Networking in KVM- Part 2.md | 120 ------------------ ... Testing IPv6 Networking in KVM- Part 2.md | 119 +++++++++++++++++ 2 files changed, 119 insertions(+), 120 deletions(-) delete mode 100644 sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md create mode 100644 translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md diff --git a/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md b/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md deleted file mode 100644 index 48c95295fc..0000000000 --- a/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md +++ /dev/null @@ -1,120 +0,0 @@ -Translating by qhwdw -Testing IPv6 Networking in KVM: Part 2 -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner_4.png?itok=yZBHylwd) -When last we met, in [Testing IPv6 Networking in KVM: Part 1][1], we learned about IPv6 private addressing. Today, we're going to use KVM to create networks for testing IPv6 to our heart's content. - -Should you desire a refresh in using KVM, see [Creating Virtual Machines in KVM: Part 1][2] and [Creating Virtual Machines in KVM: Part 2 - Networking][3]. - -### Creating Networks in KVM - -You need at least two virtual machines in KVM. Of course, you may create as many as you like. My little setup has Fedora, Ubuntu, and openSUSE. To create a new IPv6 network, open Edit > Connection Details > Virtual Networks in the main Virtual Machine Manager window. Click on the button with the green cross on the bottom left to create a new network (Figure 1). - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kvm-fig-1_0.png?itok=ruqjPXxd) -Figure 1: Create a network. - -Give your new network a name, then click the Forward button. You may opt to not create an IPv4 network if you wish. When you create a new IPv4 network the Virtual Machine Manager will not let you create a duplicate network, or one with an invalid address. On my host Ubuntu system a valid address is highlighted in green, and an invalid address is highlighted in a tasteful rosy hue. On my openSUSE machine there are no colored highlights. Enable DHCP or not, and create a static route or not, then move on to the next window. - -Check "Enable IPv6 network address space definition" and enter your private address range. You may use any IPv6 address class you wish, being careful, of course, to not allow your experiments to leak out of your network. We shall use the nice IPv6 unique local addresses (ULA), and use the online address generator at [Simple DNS Plus][4] to create our network address. Copy the "Combined/CID" address into the Network field (Figure 2). - - -![network address][6] - -Figure 2: Copy the "Combined/CID" address into the Network field. - -[Used with permission][7] - -Virtual Machine Manager thinks my address is not valid, as evidenced by the rose highlight. Can it be right? Let us use ipv6calc to check: -``` -$ ipv6calc -qi fd7d:844d:3e17:f3ae::/64 -Address type: unicast, unique-local-unicast, iid, iid-local -Registry for address: reserved(RFC4193#3.1) -Address type has SLA: f3ae -Interface identifier: 0000:0000:0000:0000 -Interface identifier is probably manual set - -``` - -ipv6calc thinks it's fine. Just for fun, change one of the numbers to something invalid, like the letter g, and try it again. (Asking "What if...?" and trial and error is the awesomest way to learn.) - -Let us carry on and enable DHCPv6 (Figure 3). You can accept the default values, or set your own. - -![](https://www.linux.com/sites/lcom/files/styles/floated_images/public/kvm-fig-3.png?itok=F-oAAtN9) - -We shall skip creating a default route definition and move on to the next screen, where we shall enable "Isolated Virtual Network" and "Enable IPv6 internal routing/networking". - -### VM Network Selection - -Now you can configure your virtual machines to use your new network. Open your VMs, and then click the "i" button at the top left to open its "Show virtual hardware details" screen. In the "Add Hardware" column click on the NIC button to open the network selector, and select your nice new IPv6 network. Click Apply, and then reboot. (Or use your favorite method for restarting networking, or renewing your DHCP lease.) - -### Testing - -What does ifconfig tell us? -``` -$ ifconfig -ens3: flags=4163 UP,BROADCAST,RUNNING,MULTICAST mtu 1500 - inet 192.168.30.207 netmask 255.255.255.0 - broadcast 192.168.30.255 - inet6 fd7d:844d:3e17:f3ae::6314 - prefixlen 128 scopeid 0x0 - inet6 fe80::4821:5ecb:e4b4:d5fc - prefixlen 64 scopeid 0x20 - -``` - -And there is our nice new ULA, fd7d:844d:3e17:f3ae::6314, and the auto-generated link-local address that is always present. Let's have some ping fun, pinging another VM on the network: -``` -vm1 ~$ ping6 -c2 fd7d:844d:3e17:f3ae::2c9f -PING fd7d:844d:3e17:f3ae::2c9f(fd7d:844d:3e17:f3ae::2c9f) 56 data bytes -64 bytes from fd7d:844d:3e17:f3ae::2c9f: icmp_seq=1 ttl=64 time=0.635 ms -64 bytes from fd7d:844d:3e17:f3ae::2c9f: icmp_seq=2 ttl=64 time=0.365 ms - -vm2 ~$ ping6 -c2 fd7d:844d:3e17:f3ae:a:b:c:6314 -PING fd7d:844d:3e17:f3ae:a:b:c:6314(fd7d:844d:3e17:f3ae:a:b:c:6314) 56 data bytes -64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=1 ttl=64 time=0.744 ms -64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=2 ttl=64 time=0.364 ms - -``` - -When you're struggling to understand subnetting, this gives you a fast, easy way to try different addresses and see whether they work. You can assign multiple IP addresses to a single interface and then ping them to see what happens. In a ULA, the interface, or host, portion of the IP address is the last four quads, so you can do anything to those and still be in the same subnet, which in this example is f3ae. This example changes only the interface ID on one of my VMs, to show how you really can do whatever you want with those four quads: -``` -vm1 ~$ sudo /sbin/ip -6 addr add fd7d:844d:3e17:f3ae:a:b:c:6314 dev ens3 - -vm2 ~$ ping6 -c2 fd7d:844d:3e17:f3ae:a:b:c:6314 -PING fd7d:844d:3e17:f3ae:a:b:c:6314(fd7d:844d:3e17:f3ae:a:b:c:6314) 56 data bytes -64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=1 ttl=64 time=0.744 ms -64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=2 ttl=64 time=0.364 ms - -``` - -Now try it with a different subnet, which in this example is f4ae instead of f3ae: -``` -$ ping6 -c2 fd7d:844d:3e17:f4ae:a:b:c:6314 -PING fd7d:844d:3e17:f4ae:a:b:c:6314(fd7d:844d:3e17:f4ae:a:b:c:6314) 56 data bytes -From fd7d:844d:3e17:f3ae::1 icmp_seq=1 Destination unreachable: No route -From fd7d:844d:3e17:f3ae::1 icmp_seq=2 Destination unreachable: No route - -``` - -This is also a great time to practice routing, which we will do in a future installment along with setting up auto-addressing without DHCP. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-2 - -作者:[CARLA SCHRODER][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/cschroder -[1]:https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-1 -[2]:https://www.linux.com/learn/intro-to-linux/2017/5/creating-virtual-machines-kvm-part-1 -[3]:https://www.linux.com/learn/intro-to-linux/2017/5/creating-virtual-machines-kvm-part-2-networking -[4]:http://simpledns.com/private-ipv6.aspx -[5]:/files/images/kvm-fig-2png -[6]:https://www.linux.com/sites/lcom/files/styles/floated_images/public/kvm-fig-2.png?itok=gncdPGj- (network address) -[7]:https://www.linux.com/licenses/category/used-permission diff --git a/translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md b/translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md new file mode 100644 index 0000000000..78ec513d5f --- /dev/null +++ b/translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md @@ -0,0 +1,119 @@ +在 KVM 中测试 IPv6 网络:第 2 部分 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/banner_4.png?itok=yZBHylwd) +我们又见面了,在上一篇 [在 KVM 中测试 IPv6 网络:第 1 部分][1] 中,我们学习了有关 IPv6 私有地址的内容。今天,我们将使用 KVM 创建一个网络,去测试上一星期学习的 IPv6 的内容。 + +如果你想重新温习如何使用 KVM,可以查看 [在 KVM 中创建虚拟机:第 1 部分][2] 和 [在 KVM 中创建虚拟机:第 2 部分— 网络][3]。 + +### 在 KVM 中创建网络 + +在 KVM 中你至少需要两个虚拟机。当然了,如果你愿意,也可以创建更多的虚拟机。在我的系统中有 Fedora、Ubuntu、以及 openSUSE。去创建一个新的 IPv6 网络,在主虚拟机管理窗口中打开 Edit > Connection Details > Virtual Networks。点击左下角的绿色十字按钮去创建一个新的网络(图 1)。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kvm-fig-1_0.png?itok=ruqjPXxd) +图 1:创建一个网络 + +给新网络输入一个名字,然后,点击 Forward 按钮。如果你愿意,也可以不创建 IPv4 网络。当你创建一个新的 IPv4 网络时,虚拟机管理器将不让你创建重复网络,或者是使用了一个无效地址。在我的宿主机 Ubuntu 系统上,有效的地址是以绿色高亮显示的,而无效地址是使用高亮的玫瑰红色调。在我的 openSUSE 机器上没有高亮颜色。启用或不启用 DHCP,以及创建或不创建一个静态路由,然后进入下一个窗口。 + +选中 "Enable IPv6 network address space definition",然后输入你的私有地址范围。你可以使用任何你希望的 IPv6 地址类,但是要注意,不能将你的实验网络泄漏到公网上去。我们将使用非常好用的 IPv6 唯一本地地址(ULA),并且使用在 [Simple DNS Plus][4] 上的在线地址生成器,去创建我们的网络地址。拷贝 "Combined/CID" 地址到网络框中(图 2)。 + + +![network address][6] + +图 2:拷贝 "Combined/CID" 地址到网络框中 + +[使用已获授权][7] + +虚拟机认为我的地址是无效的,因为,它显示了高亮的玫瑰红色。它做的对吗?我们使用 ipv6calc 去验证一下: +``` +$ ipv6calc -qi fd7d:844d:3e17:f3ae::/64 +Address type: unicast, unique-local-unicast, iid, iid-local +Registry for address: reserved(RFC4193#3.1) +Address type has SLA: f3ae +Interface identifier: 0000:0000:0000:0000 +Interface identifier is probably manual set + +``` + +ipv6calc 认为没有问题。如果感兴趣,你可以改变其中一个数字为无效的东西,比如字母 g,然后再试一次。(问 “如果…?”,试验和错误是最好的学习方法)。 + +我们继续进行,启用 DHCPv6(图 3)。你可以接受缺省值,或者输入一个你自己的设置值。 + +![](https://www.linux.com/sites/lcom/files/styles/floated_images/public/kvm-fig-3.png?itok=F-oAAtN9) + +我们将跳过缺省路由定义这一步,继续进入下一屏,在那里我们将启用 “Isolated Virtual Network" 和 "Enable IPv6 internal routing/networking"。 + +### 虚拟机网络选择 + +现在,你可以配置你的虚拟机去使用新的网络。打开你的虚拟机,然后点击顶部左侧的 "i" 按钮去打开 "Show virtual hardware details" 屏幕。在 "Add Hardware" 列点击 NIC 按钮去打开网络选择器,然后选择你喜欢的新的 IPv6 网络。点击 Apply,然后重新启动。(或者使用你喜欢的方法去重新启动网络,或者更新你的 DHCP 租期。) + +### 测试 + +ifconfig 告诉我们它做了什么? +``` +$ ifconfig +ens3: flags=4163 UP,BROADCAST,RUNNING,MULTICAST mtu 1500 + inet 192.168.30.207 netmask 255.255.255.0 + broadcast 192.168.30.255 + inet6 fd7d:844d:3e17:f3ae::6314 + prefixlen 128 scopeid 0x0 + inet6 fe80::4821:5ecb:e4b4:d5fc + prefixlen 64 scopeid 0x20 + +``` + +这是我们新的 ULA,fd7d:844d:3e17:f3ae::6314,它是自动生成的本地链路地址。如果你有兴趣,可以 ping 一下,ping 网络上的其它虚拟机: +``` +vm1 ~$ ping6 -c2 fd7d:844d:3e17:f3ae::2c9f +PING fd7d:844d:3e17:f3ae::2c9f(fd7d:844d:3e17:f3ae::2c9f) 56 data bytes +64 bytes from fd7d:844d:3e17:f3ae::2c9f: icmp_seq=1 ttl=64 time=0.635 ms +64 bytes from fd7d:844d:3e17:f3ae::2c9f: icmp_seq=2 ttl=64 time=0.365 ms + +vm2 ~$ ping6 -c2 fd7d:844d:3e17:f3ae:a:b:c:6314 +PING fd7d:844d:3e17:f3ae:a:b:c:6314(fd7d:844d:3e17:f3ae:a:b:c:6314) 56 data bytes +64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=1 ttl=64 time=0.744 ms +64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=2 ttl=64 time=0.364 ms + +``` + +当你努力去理解子网时,这是一个提供给你的快速、易用的尝试不同地址是否可以正常工作的方法。你可以给单个接口分配多个 IP 地址,然后 ping 它们去看一下会发生什么。在一个 ULA 中,接口,或者主机是 IP 地址的最后四部分,因此,你可以在那里做任何事情,只要它们在同一个子网中即可,在那个例子中是 f3ae。在我的其中一个虚拟机上,我只改变了这个示例的接口 ID,以展示使用这四个部分,你可以做任何你想做的事情: +``` +vm1 ~$ sudo /sbin/ip -6 addr add fd7d:844d:3e17:f3ae:a:b:c:6314 dev ens3 + +vm2 ~$ ping6 -c2 fd7d:844d:3e17:f3ae:a:b:c:6314 +PING fd7d:844d:3e17:f3ae:a:b:c:6314(fd7d:844d:3e17:f3ae:a:b:c:6314) 56 data bytes +64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=1 ttl=64 time=0.744 ms +64 bytes from fd7d:844d:3e17:f3ae:a:b:c:6314: icmp_seq=2 ttl=64 time=0.364 ms + +``` + +现在,尝试使用不同的子网,在下面的示例中使用了 f4ae 代替 f3ae: +``` +$ ping6 -c2 fd7d:844d:3e17:f4ae:a:b:c:6314 +PING fd7d:844d:3e17:f4ae:a:b:c:6314(fd7d:844d:3e17:f4ae:a:b:c:6314) 56 data bytes +From fd7d:844d:3e17:f3ae::1 icmp_seq=1 Destination unreachable: No route +From fd7d:844d:3e17:f3ae::1 icmp_seq=2 Destination unreachable: No route + +``` + +这也是练习路由的好机会,以后,我们将专门做一期,如何在不使用 DHCP 情况下实现自动寻址。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-2 + +作者:[CARLA SCHRODER][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/cschroder +[1]:https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-1 +[2]:https://www.linux.com/learn/intro-to-linux/2017/5/creating-virtual-machines-kvm-part-1 +[3]:https://www.linux.com/learn/intro-to-linux/2017/5/creating-virtual-machines-kvm-part-2-networking +[4]:http://simpledns.com/private-ipv6.aspx +[5]:/files/images/kvm-fig-2png +[6]:https://www.linux.com/sites/lcom/files/styles/floated_images/public/kvm-fig-2.png?itok=gncdPGj- "network address" +[7]:https://www.linux.com/licenses/category/used-permission From d30fbdfac9bac90298ec3b07a3d3a7e6e0e809cc Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Tue, 15 May 2018 22:11:18 +0800 Subject: [PATCH 103/111] Update 20171116 10 easy steps from proprietary to open source.md --- ...y steps from proprietary to open source.md | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/translated/tech/20171116 10 easy steps from proprietary to open source.md b/translated/tech/20171116 10 easy steps from proprietary to open source.md index 9d46f03246..e3ec44840d 100644 --- a/translated/tech/20171116 10 easy steps from proprietary to open source.md +++ b/translated/tech/20171116 10 easy steps from proprietary to open source.md @@ -41,28 +41,17 @@ -1 OK--you can put your hands down now. - -2 Should this be capitalized? Is there a particular field, or how does it work? I'm not sure. - -3 I have a degree in English literature and theology--this probably won't surprise regular readers of my articles.4 - -4 Not, I hope, because I spout too much theology,5 but because it's often full of long-winded, irrelevant humanities (U.S. English: "liberal arts") references. - -5 Emacs. Every time. - -6 Not even Emacs. And yes, I know that there are techniques to prove the correctness of some software. (I suspect that Emacs doesn't pass many of them…) - -7 Hand up here: I'm employed by one of them, [Red Hat][3]. Go have a look--it's a fun place to work, and [we're usually hiring][4]. - -8 Assuming that they fully abide by the rules of the open source licence(s) they're using, that is. - -9 Erstwhile "Lord Protector of England, Scotland, and Ireland"--that Cromwell. - -10 Oh, and choose Emacs over Vi variants, obviously. - -This article originally appeared on [Alice, Eve, and Bob - a security blog][5] and is republished with permission. - +1 好的--你现在可以放下手了 +2 这应该大写吗?有特定的领域吗?后者他是如何工作的?我不确定。 +3 我有一个英国文学和神学的学位--这可能不会使我的文章的普通读者感到惊讶 +4 我希望不是,因为我说的太多了,但是它经常是冗余的,无关紧要的人文。 +5 每次编辑 +6 即使是编辑器。而且是的,我知道有技术能够去证明一些软件的正确性。(我怀疑编辑器不能使它们全部通过...) +7 注意这里:我被他们其中之一雇佣,去查看一下--它是一个有趣的工作地方,E而且[我们通常招聘][4] +8 假设他们完全遵守他们正在使用的开源软件的认证。 +9 昔日的“英格兰、苏格兰、爱尔兰的上帝守护者”--比克伦威尔 +10 很明显,选择Vi 编辑器 +这篇文章原载于[Alice, Eve, and Bob - a security blog] 而且已经 被授权重新出版。 -------------------------------------------------------------------------------- via: https://opensource.com/article/17/11/commonwealth-open-source From 89509b6902be87ecb6b9bd351bf710b76af9fc76 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 16 May 2018 08:12:43 +0800 Subject: [PATCH 104/111] PRF:20171116 10 easy steps from proprietary to open source.md @FelixYFZ --- ...y steps from proprietary to open source.md | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/translated/tech/20171116 10 easy steps from proprietary to open source.md b/translated/tech/20171116 10 easy steps from proprietary to open source.md index e3ec44840d..b7b9b6d028 100644 --- a/translated/tech/20171116 10 easy steps from proprietary to open source.md +++ b/translated/tech/20171116 10 easy steps from proprietary to open source.md @@ -1,64 +1,68 @@ 从专有到开源的十个简单步骤 ====== -"开源软件的确不是很安全,因为每个人都能使用它,而且他们能够随意的进行编译并且用他们自己写的不好的东西进行替换。"举手示意:谁之前听说过这个?1 +> 这个共同福利并不适用于专有软件:保持隐藏的东西是不能照亮或丰富这个世界的。 -当我和顾客讨论的时候,是的,他们有时候会让我和顾客交谈,对于场景2的人来说这是很常见的。在前一篇文章中,"[许多人的评论并不一定能防止错误代码]",我会 -谈论尤其是安全的软件这块--并没有如外界所说的那样比专有软件安全,但是和专有软件比起来,我每次还是比较青睐开源软件。但我听到--关于开源软件不是很安全--表明了有时候仅仅解释开源需要工作投入是不够的,但是我们也需要积极的参与进去。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_abstract_pieces.jpg?itok=tGR1d2MU) + +“开源软件肯定不太安全,因为每个人都能看到它的源代码,而且他们能重新编译它,用他们自己写的不好的东西进行替换。”举手示意:谁之前听说过这个说法?^注1 + +当我和客户讨论的时候(是的,他们有时候会让我和客户交谈),对于这个领域^注2 的人来说种问题是很常见的。在前一篇文章中,“[许多只眼睛的审查并不一定能防止错误代码]”,我谈论的是开源软件(尤其是安全软件)并不能神奇地比专有软件更安全,但是和专有软件比起来,我每次还是比较青睐开源软件。但我听到“关于开源软件不是很安全”这种问题表明了有时候只是说“开源需要参与”是不够的,我们也需要积极的参与辩护^注3 。 我并不期望能够达到牛顿或者维特根斯坦的逻辑水平,但是我会尽我所能,而且我会在结尾做个总结,如果你感兴趣的话可以去快速的浏览一下。 ### 关键因素 -首先,我们必须明白没有任何一款软件是绝对安全的。无论是专有软件还是开源软件。第二,我们应该接受确实还是存在一些很不错的专利软件的。第三,也存在一些不好的开源软件。第四,有很多优秀的,很有天赋的,专业的架构师,设计师和软件工程师设计开发专利软件。 +首先,我们必须明白没有任何软件是完美的^注6 。无论是专有软件还是开源软件。第二,我们应该承认确实还是存在一些很不错的专有软件的,以及第三,也存在一些糟糕的开源软件。第四,有很多非常聪明的,很有天赋的,专业的架构师、设计师和软件工程师设计开发了专有软件。 -但也有些摩擦:第五点,从事专有软件的人员是有限的,而且你不可能总是能够雇佣到最好的员工。即使在政府部门或者公共组织--他们拥有丰富的人才资源池,但在安全应用这块,他们的人才也是有限的。 +但也有些问题:第五,从事专有软件的人员是有限的,而且你不可能总是能够雇佣到最好的员工。即使在政府部门或者公共组织 —— 他们拥有丰富的人才资源池,但在安全应用这块,他们的人才也是有限的。第六,可以查看、测试、改进、拆解、再次改进和发布开源软件的人总是无限的,而且还包含最好的人才。第七(也是我最喜欢的一条),这群人也包含很多编写专有软件的人才。第八,许多政府或者公共组织开发的软件也都逐渐开源了。 -第六点,开发,测试,提升改善开源软件的人总是无限的,而且还包含最好的人才。第七(也是我最欢的一),这群人找那个包含很多编写专有软件的人才。第八,许多政府或者公共组织开发的软件也都逐渐开源了。 +第九,如果你在担心你在运行的软件的不被支持或者来源不明,好消息是:有一批组织^注7 会来检查软件代码的来源,提供支持、维护和补丁更新。他们会按照专利软件模式那样去运行开源软件,你也可以确保你从他们那里得到的软件是正确的软件:他们的技术标准就是对软件包进行签名,以便你可以验证你正在运行的开源软件不是来源不明或者是恶意的软件。 -第九,如果你在担心你在运行的软件的不被支持或者来源不明,好消息是:有一批组织会来检查软件代码的来源,提供支持和补丁更新。他们会按照专利软件模式那样去运行开源软件:他们的技术标准就是去签署认证以便你可以验证你正在运行的开源软件不是来源不明或者是恶意的软件。 +第十(也是这篇文章的重点),当你运行开源软件,测试它,对问题进行反馈,发现问题并且报告的时候,你就是在为共同福利commonwealth贡献知识、专业技能以及经验,这就是开源,其因为你的所做的这些而变得更好。如果你是通过个人或者提供支持开源软件的商业组织之一^注8 参与的,你已经成为了这个共同福利的一部分了。开源让软件变得越来越好,你可以看到它们的变化。没有什么是隐藏封闭的,它是完全开放的。事情会变坏吗?是的,但是我们能够及时发现问题并且修复。 -第十点(也是这篇文章的重点),当你运行,测试,在问题上进行反馈,发现问题并且报告的时候,你正在为共福利贡献知识,专业技能以及经验,这就是开源,正因为你的所做的这些而变得更好。如果你是通过个人或者提供支持的商业组织,,你已经成为了这个组织的一部分了。开源让软件变得越来越好,你可以看到它们的变化。没有什么是隐藏封闭的,它是完全开放的。事情会变坏吗?是的,但是我们能够及时发现问题并且修复。 +这个共同福利并不适用于专有软件:保持隐藏的东西是不能照亮或丰富这个世界的。 -这个共享福利并不适用于专有软件:保持隐藏的东西是不能照亮个丰富世界的。 +我知道作为一个英国人在使用共同福利commonwealth这个词的时候要小心谨慎的;它和帝国连接着的,但我所表达的不是这个意思。它不是克伦威尔^注9 在对这个词所表述的意思,无论如何,他是一个有争议的历史人物。我所表达的意思是这个词有“共同”和“福利”连接,福利不是指钱而是全人类都能拥有的福利。 -我知道作为一个英国人在使用联邦这个词的时候要小心谨慎的;它和帝国连接着的,但我所表达的不是这个意思。它不是克伦威尔在对这个词所表述的意思,无论如何,他是一个有争议的历史人物。我所表达的意思是这个词有共同和福利连接,福利不是指钱而是全人类都能拥有的福利。 - -我真的很相信这点的。如果i想从这篇文章中国得到一些虔诚的信息的话,那应该是第十条:共享福利是我们的遗产,我们的经验,我们的知识,我们的责任。共享福利是全人类都能拥有的。我们共同拥有它而且它是一笔无法估量的财富。 +我真的很相信这点的。如果i想从这篇文章中得到一些虔诚信息的话,那应该是第十条^注10 :共同福利是我们的遗产,我们的经验,我们的知识,我们的责任。共同福利是全人类都能拥有的。我们共同拥有它而且它是一笔无法估量的财富。 ### 便利贴 1. (几乎)没有一款软件是完美无缺的。 2. 有很好的专有软件。 3. 有不好的专有软件。 - 4. 有聪明,有才能,专注的人开开发专有软件。 + 4. 有聪明,有才能,专注的人开发专有软件。 5. 从事开发完善专有软件的人是有限的,即使在政府或者公共组织也是如此。 6. 相对来说从事开源软件的人是无限的。 7. …而且包括很多从事专有软件的人才。 - 8. 政府和公共组织的人经常开源它们的软件. - 9. 有商业组织会为你的开源软件提供支持. - 10. 贡献--即使使用--为开源软件贡献. + 8. 政府和公共组织的人经常开源它们的软件。 + 9. 有商业组织会为你的开源软件提供支持。 + 10. 贡献--即使是使用--为开源软件贡献。 +### 脚注 + +- 注1: 好的--你现在可以放下手了 +- 注2:这应该大写吗?有特定的领域吗?或者它是如何工作的?我不确定。 +- 注3:我有一个英国文学和神学的学位--这可能不会惊讶到我的文章的普通读者^注4 。 +- 注4: 我希望不是,因为我说的太多神学了^注5 。但是它经常充满了冗余的,无关紧要的人文科学引用。 +- 注5: Emacs,每一次。 +- 注6: 甚至是 Emacs。而且我知道有技术能够去证明一些软件的正确性。(我怀疑 Emacs 不能全部通过它们...) +- 注7: 注意这里:我被他们其中之一 [Red Hat][3] 所雇佣,去查看一下--它是一个有趣的工作地方,而且[我们经常在招聘][4]。 +- 注8: 假设他们完全遵守他们正在使用的开源软件许可证。 +- 注9: 昔日的“英格兰、苏格兰、爱尔兰的上帝守护者”--比克伦威尔。 +- 注10: 很明显,我选择 Emacs 而不是 Vi 变体。 + +这篇文章原载于 [Alice, Eve, and Bob - a security blog] 而且已经被授权重新发布。 -1 好的--你现在可以放下手了 -2 这应该大写吗?有特定的领域吗?后者他是如何工作的?我不确定。 -3 我有一个英国文学和神学的学位--这可能不会使我的文章的普通读者感到惊讶 -4 我希望不是,因为我说的太多了,但是它经常是冗余的,无关紧要的人文。 -5 每次编辑 -6 即使是编辑器。而且是的,我知道有技术能够去证明一些软件的正确性。(我怀疑编辑器不能使它们全部通过...) -7 注意这里:我被他们其中之一雇佣,去查看一下--它是一个有趣的工作地方,E而且[我们通常招聘][4] -8 假设他们完全遵守他们正在使用的开源软件的认证。 -9 昔日的“英格兰、苏格兰、爱尔兰的上帝守护者”--比克伦威尔 -10 很明显,选择Vi 编辑器 -这篇文章原载于[Alice, Eve, and Bob - a security blog] 而且已经 被授权重新出版。 -------------------------------------------------------------------------------- via: https://opensource.com/article/17/11/commonwealth-open-source 作者:[Mike Bursell][a] 译者:[FelixYFZ](https://github.com/FelixYFZ) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a79d589761caa0aa3b8042ec04b96fe5cfcb644a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 16 May 2018 08:13:16 +0800 Subject: [PATCH 105/111] PUB: 20171116 10 easy steps from proprietary to open source.md @FelixYFZ --- .../20171116 10 easy steps from proprietary to open source.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171116 10 easy steps from proprietary to open source.md (100%) diff --git a/translated/tech/20171116 10 easy steps from proprietary to open source.md b/published/20171116 10 easy steps from proprietary to open source.md similarity index 100% rename from translated/tech/20171116 10 easy steps from proprietary to open source.md rename to published/20171116 10 easy steps from proprietary to open source.md From 6ed979d7a2aaa3760d3e61940917ec09f5add766 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 16 May 2018 08:24:13 +0800 Subject: [PATCH 106/111] PRF:20180512 How To Check Laptop Battery Status In Terminal In Linux.md @FSSlc --- ...top Battery Status In Terminal In Linux.md | 216 +++++++++--------- 1 file changed, 107 insertions(+), 109 deletions(-) diff --git a/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md b/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md index a82dc8ed52..5d5a06d503 100644 --- a/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md +++ b/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md @@ -1,5 +1,6 @@ 如何在 Linux 终端下检查笔记本电池状态 ====== + ![](https://www.ostechnix.com/wp-content/uploads/2016/12/Check-Laptop-Battery-Status-In-Terminal-In-Linux-720x340.png) 在图形界面下查看你的笔记本电池状态是很容易的,只需将鼠标指向任务栏中的电池图标上,你便可以很容易地知道电池的电量。但如果我们想要从命令行中获得这些信息呢?并不是所有人都知道如何做到这点。前几天我的一个朋友询问我如何从他的 Ubuntu 系统里,在终端中查看他的笔记本电池的电量。这便是我写这篇文章的起因。在本文中我概括了三种简单的方法来让你在任何 Linux 发行版本中从终端查看笔记本电池的状态。 @@ -8,100 +9,99 @@ 我们可以使用下面的三种方法来从命令行中查找到笔记本电池状态。 -##### 方法一 – 使用 “Upower” 命令 +#### 方法一 – 使用 upower 命令 + +`upower` 命令预装在大多数的 Linux 发行版本中。为了使用 `upower` 命令来展示电池的状态,打开终端并运行如下命令: -**Upower** 命令预装在大多数的 Linux 发行版本中。为了使用 `upower` 命令来展示电池的状态,打开终端并运行如下命令: ``` $ upower -i /org/freedesktop/UPower/devices/battery_BAT0 - ``` -**示例输出:** +示例输出: + ``` native-path: BAT0 - vendor: Samsung SDI - model: DELL 7XFJJA2 - serial: 4448 - power supply: yes - updated: Sat 12 May 2018 06:48:48 PM IST (41 seconds ago) - has history: yes - has statistics: yes - battery - present: yes - rechargeable: yes - state: charging - warning-level: none - energy: 43.3011 Wh - energy-empty: 0 Wh - energy-full: 44.5443 Wh - energy-full-design: 48.84 Wh - energy-rate: 9.8679 W - voltage: 12.548 V - time to full: 7.6 minutes - percentage: 97% - capacity: 91.2045% - technology: lithium-ion - icon-name: 'battery-full-charging-symbolic' - History (charge): - 1526131128 97.000 charging - History (rate): - 1526131128 9.868 charging - +vendor: Samsung SDI +model: DELL 7XFJJA2 +serial: 4448 +power supply: yes +updated: Sat 12 May 2018 06:48:48 PM IST (41 seconds ago) +has history: yes +has statistics: yes +battery +present: yes +rechargeable: yes +state: charging +warning-level: none +energy: 43.3011 Wh +energy-empty: 0 Wh +energy-full: 44.5443 Wh +energy-full-design: 48.84 Wh +energy-rate: 9.8679 W +voltage: 12.548 V +time to full: 7.6 minutes +percentage: 97% +capacity: 91.2045% +technology: lithium-ion +icon-name: 'battery-full-charging-symbolic' +History (charge): +1526131128 97.000 charging +History (rate): +1526131128 9.868 charging ``` 正如你所看到的那样,我的电池正处于充电状态,并且它的电量百分比是 97%。 假如上面的命令因为某些未知原因不起作用,可以尝试使用下面的命令: + ``` $ upower -i `upower -e | grep 'BAT'` - ``` -**示例输出:** +示例输出: + ``` native-path: BAT0 - vendor: Samsung SDI - model: DELL 7XFJJA2 - serial: 4448 - power supply: yes - updated: Sat 12 May 2018 06:50:49 PM IST (22 seconds ago) - has history: yes - has statistics: yes - battery - present: yes - rechargeable: yes - state: charging - warning-level: none - energy: 43.6119 Wh - energy-empty: 0 Wh - energy-full: 44.5443 Wh - energy-full-design: 48.84 Wh - energy-rate: 8.88 W - voltage: 12.552 V - time to full: 6.3 minutes - percentage: 97% - capacity: 91.2045% - technology: lithium-ion - icon-name: 'battery-full-charging-symbolic' - History (rate): - 1526131249 8.880 charging - +vendor: Samsung SDI +model: DELL 7XFJJA2 +serial: 4448 +power supply: yes +updated: Sat 12 May 2018 06:50:49 PM IST (22 seconds ago) +has history: yes +has statistics: yes +battery +present: yes +rechargeable: yes +state: charging +warning-level: none +energy: 43.6119 Wh +energy-empty: 0 Wh +energy-full: 44.5443 Wh +energy-full-design: 48.84 Wh +energy-rate: 8.88 W +voltage: 12.552 V +time to full: 6.3 minutes +percentage: 97% +capacity: 91.2045% +technology: lithium-ion +icon-name: 'battery-full-charging-symbolic' +History (rate): +1526131249 8.880 charging ``` -Upower 不仅可以显示出电池的状态,它还可以显示出已安装电池的其他完整信息,例如 -电池型号,供应商名称,电池的序列号,电池的状态,电池的电压等信息。 +`upower` 不仅可以显示出电池的状态,它还可以显示出已安装电池的其他完整信息,例如电池型号,供应商名称,电池的序列号,电池的状态,电池的电压等信息。 + +当然,如果你只想显示电池的状态,你可以可以结合使用 `upower` 命令和[grep][1] 命令,具体命令如下: -当然,如果你只想显示电池的状态,你可以可以结合使用 `upower` 命令和[**grep**][1] 命令,具体命令如下: ``` $ upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage" - ``` -**示例输出:** +示例输出: + ``` state: fully-charged percentage: 100% - ``` ![][3] @@ -109,50 +109,51 @@ percentage: 100% 从上面的输出中可以看到我的笔记本电池已经完全充满了。 想知晓更多的细节,可以参看 man 页: + ``` $ man upower - ``` -##### 方法二 – 使用 “acpi” 命令 +#### 方法二 – 使用 acpi 命令 -**acpi** 命令可以用来显示你的 Linux 发行版本中电池的状态以及其他 ACPI 信息。 +`acpi` 命令可以用来显示你的 Linux 发行版本中电池的状态以及其他 ACPI 信息。 -在某些 Linux 发行版本中,你可能需要安装 **acpi** 命令。 +在某些 Linux 发行版本中,你可能需要安装 `acpi` 命令。 + +要在 Debian、 Ubuntu 及其衍生版本中安装它,可以使用如下命令: -要在 Debian, Ubuntu 及其衍生版本中安装它,可以使用如下命令: ``` $ sudo apt-get install acpi - ``` -在 RHEL, CentOS, Fedora 等系统中使用: +在 RHEL、 CentOS、 Fedora 等系统中使用: + ``` $ sudo yum install acpi - ``` 或者使用如下命令: + ``` $ sudo dnf install acpi - ``` 在 Arch Linux 及其衍生版本中使用: + ``` $ sudo pacman -S acpi - ``` 一旦 `acpi` 安装好后,运行下面的命令: + ``` $ acpi -V - ``` -**注意:** 在上面的命令中, “V” 是大写字母。 +注意: 在上面的命令中, `V` 是大写字母。 + +示例输出: -**示例输出:** ``` Battery 0: Charging, 99%, 00:02:09 until charged Battery 0: design capacity 4400 mAh, last full capacity 4013 mAh = 91% @@ -167,73 +168,72 @@ Cooling 3: Processor 0 of 3 Cooling 4: Processor 0 of 3 Cooling 5: intel_powerclamp no state information available Cooling 6: x86_pkg_temp no state information available - ``` 首先让我们来检查电池的电量,可以运行: + ``` $ acpi - ``` -**示例输出:** +示例输出: + ``` Battery 0: Charging, 99%, 00:01:41 until charged Battery 1: Discharging, 0%, rate information unavailable - ``` 下面,让我们来查看电池的温度: + ``` $ acpi -t - ``` -**示例输出:** +示例输出: + ``` Thermal 0: ok, 63.5 degrees C - ``` 如果需要将温度以华氏温标显示,可以使用: + ``` $ acpi -t -f - ``` -**示例输出:** +示例输出: + ``` Thermal 0: ok, 144.5 degrees F - ``` 如果想看看交流电适配器是否连接上了没有,可以运行: + ``` $ acpi -a - ``` -**示例输出:** +示例输出: + ``` Adapter 0: on-line - ``` 假如交流电适配器没有连接上,则你将看到如下的输出: + ``` Adapter 0: off-line - ``` 想获取更多的信息,可以查看 man 页: + ``` $ man acpi - ``` -##### 方法三 - 使用 “Batstat” 程序 +#### 方法三 - 使用 batstat 程序 -**batstat** 是一个基于 ncurses 的命令行小工具,使用它可以在类 Unix 系统中展示笔记本电池状态。它可以展示如下具体信息: +`batstat` 是一个基于 ncurses 的命令行小工具,使用它可以在类 Unix 系统中展示笔记本电池状态。它可以展示如下具体信息: * 当前电池电量 * 当前电池所存能量 @@ -241,36 +241,36 @@ $ man acpi * 从程序启动开始经历的时间,它不会追踪记录机器休眠的时间 * 电池电量消耗历史数据 -安装 `batstat` 轻而易举。使用下面的命令来复刻(clone)该程序的最新版本: +安装 `batstat` 轻而易举。使用下面的命令来克隆该程序的最新版本: + ``` $ git clone https://github.com/Juve45/batstat.git - ``` -上面的命令将拉取 batstat 的最新版本并将它的内容保存在一个名为 ”batstat“ 的文件夹中。 +上面的命令将拉取 `batstat` 的最新版本并将它的内容保存在一个名为 `batstat` 的文件夹中。 首先将目录切换到 `batstat/bin/` 中: + ``` $ cd batstat/bin/ - ``` -接着将 “batstat” 二进制文件复制到 PATH 环境变量中的某个目录中,例如 `/usr/local/bin/` 目录: +接着将 `batstat` 二进制文件复制到 `PATH` 环境变量中的某个目录中,例如 `/usr/local/bin/` 目录: + ``` $ sudo cp batstat /usr/local/bin/ - ``` 使用下面的命令来让它可被执行: + ``` $ sudo chmod +x /usr/local/bin/batstat - ``` 最后,使用下面的命令来查看你的电池状态。 + ``` $ batstat - ``` 示例输出: @@ -279,9 +279,9 @@ $ batstat 从上面的截图中可以看到我的笔记本电池正处于充电状态。 -这个小工具还有某些小的限制。在书写本文之时,batstat 仅支持显示一个电池的相关信息。而且它只从 **“/sys/class/power_supply/”** 目录搜集相关的信息。假如你的电池信息被存放在另外的目录中,则这个小工具就不会起作用了。 +这个小工具还有某些小的限制。在书写本文之时,`batstat` 仅支持显示一个电池的相关信息。而且它只从 `/sys/class/power_supply/` 目录搜集相关的信息。假如你的电池信息被存放在另外的目录中,则这个小工具就不会起作用了。 -想知晓更多信息,可以查看 batstat 的 [github 主页][5]。 +想知晓更多信息,可以查看 `batstat` 的 [GitHub 主页][5]。 上面就是今天我要分享的所有内容。当然,可能还有很多其他的命令或者程序来从 Linux 终端检查笔记本的电池状态。据我所知,上面给出的命令都运行良好。假如你知道其他命令来查看电池的状态,请在下面的评论框中让我们知晓。假如你所给出的方法能够起作用,我将对我的这篇文章进行更新。 @@ -289,8 +289,6 @@ $ batstat 欢呼吧! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-check-laptop-battery-status-in-terminal-in-linux/ @@ -298,7 +296,7 @@ via: https://www.ostechnix.com/how-to-check-laptop-battery-status-in-terminal-in 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[FSSlc](https://github.com/FSSlc) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From eceb4d0e99c73cf887066bf46a2bc75afa2363c8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 16 May 2018 08:24:37 +0800 Subject: [PATCH 107/111] PUB:20180512 How To Check Laptop Battery Status In Terminal In Linux.md @FSSlc https://linux.cn/article-9647-1.html --- ...512 How To Check Laptop Battery Status In Terminal In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180512 How To Check Laptop Battery Status In Terminal In Linux.md (100%) diff --git a/translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md b/published/20180512 How To Check Laptop Battery Status In Terminal In Linux.md similarity index 100% rename from translated/tech/20180512 How To Check Laptop Battery Status In Terminal In Linux.md rename to published/20180512 How To Check Laptop Battery Status In Terminal In Linux.md From a456019ff8c30d9d7e2d2af577210b6be8198b8d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 16 May 2018 08:37:29 +0800 Subject: [PATCH 108/111] PRF:20180427 How to use FIND in Linux.md @geekpi --- .../tech/20180427 How to use FIND in Linux.md | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/translated/tech/20180427 How to use FIND in Linux.md b/translated/tech/20180427 How to use FIND in Linux.md index 1fcbd9b766..ff8b4b86cf 100644 --- a/translated/tech/20180427 How to use FIND in Linux.md +++ b/translated/tech/20180427 How to use FIND in Linux.md @@ -1,77 +1,79 @@ -如何在 Linux 中使用 FIND +如何在 Linux 中使用 find ====== +> 使用正确的参数,`find` 命令是在你的系统上找到数据的强大而灵活的方式。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux31x_cc.png?itok=Pvim4U-B) -在[最近的一篇 Opensource.com 文章][1]中,Lewis Cowles 介绍了 `find` 命令。 +在[最近的一篇文章][1]中,Lewis Cowles 介绍了 `find` 命令。 `find` 是日常工具箱中功能更强大、更灵活的命令行工具之一,因此值得花费更多的时间。 最简单的,`find` 跟上路径寻找一些东西。例如: + ``` find / - ``` -它将找到(并打印)系统中的每个文件。而且由于一切都是文件,你会得到很多输出需要排序。这可能不会帮助你找到你要找的东西。你可以改变路径参数来缩小范围,但它不会比使用 `ls` 命令更有帮助。所以你需要考虑你想要找的东西。 +它将找到(并打印出)系统中的每个文件。而且由于一切都是文件,你会得到很多需要整理的输出。这可能不能帮助你找到你要找的东西。你可以改变路径参数来缩小范围,但它不会比使用 `ls` 命令更有帮助。所以你需要考虑你想要找的东西。 也许你想在主目录中找到所有的 JPEG 文件。 `-name` 参数允许你将结果限制为与给定模式匹配的文件。 + ``` find ~ -name '*jpg' - ``` 可是等等!如果它们中的一些是大写的扩展名会怎么样?`-iname` 就像 `-name`,但是不区分大小写。 + ``` find ~ -iname '*jpg' - ``` -很好!但是 8.3 名称方案是如此的老。一些图片可能是 .jpeg 扩展名。幸运的是,我们可以将模式用 “or” 表示为 `-o`,来组合。 +很好!但是 8.3 名称方案是如此的老。一些图片可能是 .jpeg 扩展名。幸运的是,我们可以将模式用“或”(表示为 `-o`)来组合。 + ``` find ~ ( -iname 'jpeg' -o -iname 'jpg' ) - ``` -我们正在接近。但是如果你有一些以 jpg 结尾的目录呢? (为什么你命名一个 `bucketofjpg` 而不是 `pictures` 的目录超出了我的范围。)我们使用 `-type` 参数修改我们的命令来查找文件。 +我们正在接近目标。但是如果你有一些以 jpg 结尾的目录呢? (为什么你要命名一个 `bucketofjpg` 而不是 `pictures` 的目录就超出了本文的范围。)我们使用 `-type` 参数修改我们的命令来查找文件。 + ``` find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f - ``` 或者,也许你想找到那些命名奇怪的目录,以便稍后重命名它们: + ``` find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type d - ``` 你最近拍了很多照片,所以让我们把它缩小到上周更改的文件。 + ``` find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f -mtime -7 - ``` -你可以根据文件状态更改时间 (ctime),修改时间 (mtime) 或访问时间 (atime) 来执行时间过滤。 这些是在几天内,所以如果你想要更细粒度的控制,你可以表示为在几分钟内(分别是 `cmin`、`mmin` 和 `amin`)。 除非你确切地知道你想要的时间,否则你可能会在 + (大于)或 - (小于)的后面加上数字。 +你可以根据文件状态更改时间 (`ctime`)、修改时间 (`mtime`) 或访问时间 (`atime`) 来执行时间过滤。 这些是在几天内,所以如果你想要更细粒度的控制,你可以表示为在几分钟内(分别是 `cmin`、`mmin` 和 `amin`)。 除非你确切地知道你想要的时间,否则你可能会在 `+` (大于)或 `-` (小于)的后面加上数字。 但也许你不关心你的照片。也许你的磁盘空间不够用,所以你想在 `log` 目录下找到所有巨大的(让我们定义为“大于 1GB”)文件: + ``` find /var/log -size +1G - ``` -或者,也许你想在 `/ data` 中找到 bcotton 拥有的所有文件: +或者,也许你想在 `/data` 中找到 bcotton 拥有的所有文件: + ``` find /data -owner bcotton - ``` 你还可以根据权限查找文件。也许你想在你的主目录中找到对所有人可读的文件,以确保你不会过度分享。 + ``` find ~ -perm -o=r - ``` -这篇文章只说了 `find` 能做什么的表面。将测试与布尔逻辑相结合可以为你提供难以置信的灵活性,以便准确找到要查找的文件。并且像 `-exec` 或 `-delete` 这样的参数,你可以让 `find` 对它发现的内容采取行动。你有任何最喜欢的 `find` 表达式么?在评论中分享它们! +这篇文章只说了 `find` 能做什么的表面。将测试条件与布尔逻辑相结合可以为你提供难以置信的灵活性,以便准确找到要查找的文件。并且像 `-exec` 或 `-delete` 这样的参数,你可以让 `find` 对它发现的内容采取行动。你有任何最喜欢的 `find` 表达式么?在评论中分享它们! -------------------------------------------------------------------------------- @@ -80,9 +82,9 @@ via: https://opensource.com/article/18/4/how-use-find-linux 作者:[Ben Cotton][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[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/) 荣誉推出 [a]:https://opensource.com/users/bcotton -[1]:https://opensource.com/article/18/4/how-find-files-linux +[1]:https://linux.cn/article-9585-1.html From bd21efaeaa2192c948974ca7fafd8c63db1efc39 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 16 May 2018 08:37:56 +0800 Subject: [PATCH 109/111] PUB:20180427 How to use FIND in Linux.md @geekpi https://linux.cn/article-9648-1.html --- .../tech => published}/20180427 How to use FIND in Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180427 How to use FIND in Linux.md (100%) diff --git a/translated/tech/20180427 How to use FIND in Linux.md b/published/20180427 How to use FIND in Linux.md similarity index 100% rename from translated/tech/20180427 How to use FIND in Linux.md rename to published/20180427 How to use FIND in Linux.md From 48e1a68b4d5adbc0b0ec4eca8777887a23c6eda9 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 16 May 2018 08:39:22 +0800 Subject: [PATCH 110/111] translated --- ...426 Continuous Profiling of Go programs.md | 108 ------------------ ...426 Continuous Profiling of Go programs.md | 106 +++++++++++++++++ 2 files changed, 106 insertions(+), 108 deletions(-) delete mode 100644 sources/tech/20180426 Continuous Profiling of Go programs.md create mode 100644 translated/tech/20180426 Continuous Profiling of Go programs.md diff --git a/sources/tech/20180426 Continuous Profiling of Go programs.md b/sources/tech/20180426 Continuous Profiling of Go programs.md deleted file mode 100644 index 8d474b7124..0000000000 --- a/sources/tech/20180426 Continuous Profiling of Go programs.md +++ /dev/null @@ -1,108 +0,0 @@ -translating----geekpi - -Continuous Profiling of Go programs -============================================================ - -One of the most interesting parts of Google is our fleet-wide continuous profiling service. We can see who is accountable for CPU and memory usage, we can continuously monitor our production services for contention and blocking profiles, and we can generate analysis and reports and easily can tell what are some of the highly impactful optimization projects we can work on. - -I briefly worked on [Stackdriver Profiler][2], our new product that is filling the gap of cloud-wide profiling service for Cloud users. Note that you DON’T need to run your code on Google Cloud Platform in order to use it. Actually, I use it at development time on a daily basis now. It also supports Java and Node.js. - -#### Profiling in production - -pprof is safe to use in production. We target an additional 5% overhead for CPU and heap allocation profiling. The collection is happening for 10 seconds for every minute from a single instance. If you have multiple replicas of a Kubernetes pod, we make sure we do amortized collection. For example, if you have 10 replicas of a pod, the overhead will be 0.5%. This makes it possible for users to keep the profiling always on. - -We currently support CPU, heap, mutex and thread profiles for Go programs. - -#### Why? - -Before explaining how you can use the profiler in production, it would be helpful to explain why you would ever want to profile in production. Some very common cases are: - -* Debug performance problems only visible in production. - -* Understand the CPU usage to reduce billing. - -* Understand where the contention cumulates and optimize. - -* Understand the impact of new releases, e.g. seeing the difference between canary and production. - -* Enrich your distributed traces by [correlating][1] them with profiling samples to understand the root cause of latency. - -#### Enabling - -Stackdriver Profiler doesn’t work with the  _net/http/pprof_  handlers and require you to install and configure a one-line agent in your program. - -``` -go get cloud.google.com/go/profiler -``` - -And in your main function, start the profiler: - -``` -if err := profiler.Start(profiler.Config{ - Service: "indexing-service", - ServiceVersion: "1.0", - ProjectID: "bamboo-project-606", // optional on GCP -}); err != nil { - log.Fatalf("Cannot start the profiler: %v", err) -} -``` - -Once you start running your program, the profiler package will report the profilers for 10 seconds for every minute. - -#### Visualization - -As soon as profiles are reported to the backend, you will start seeing a flamegraph at [https://console.cloud.google.com/profiler][4]. You can filter by tags and change the time span, as well as break down by service name and version. The data will be around up to 30 days. - - -![](https://cdn-images-1.medium.com/max/900/1*JdCm1WwmTgExzee5-ZWfNw.gif) - -You can choose one of the available profiles; break down by service, zone and version. You can move in the flame and filter by tags. - -#### Reading the flame - -Flame graph visualization is explained by [Brendan Gregg][5] very comprehensively. Stackdriver Profiler adds a little bit of its own flavor. - - -![](https://cdn-images-1.medium.com/max/900/1*QqzFJlV9v7U1s1reYsaXog.png) - -We will examine a CPU profile but all also applies to the other profiles. - -1. The top-most x-axis represents the entire program. Each box on the flame represents a frame on the call path. The width of the box is proportional to the CPU time spent to execute that function. - -2. Boxes are sorted from left to right, left being the most expensive call path. - -3. Frames from the same package have the same color. All runtime functions are represented with green in this case. - -4. You can click on any box to expand the execution tree further. - - -![](https://cdn-images-1.medium.com/max/900/1*1jCm6f-Fl2mpkRe3-57mTg.png) - -You can hover on any box to see detailed information for any frame. - -#### Filtering - -You can show, hide and and highlight by symbol name. These are extremely useful if you specifically want to understand the cost of a particular call or package. - -![](https://cdn-images-1.medium.com/max/900/1*ka9fA-AAuKggAuIBq_uhGQ.png) - -1. Choose your filter. You can combine multiple filters. In this case, we are highlighting runtime.memmove. - -2. The flame is going to filter the frames with the filter and visualize the filtered boxes. In this case, it is highlighting all runtime.memmove boxes. - --------------------------------------------------------------------------------- - -via: https://medium.com/google-cloud/continuous-profiling-of-go-programs-96d4416af77b - -作者:[JBD ][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/@rakyll?source=post_header_lockup -[1]:https://rakyll.org/profiler-labels/ -[2]:https://cloud.google.com/profiler/ -[3]:http://cloud.google.com/go/profiler -[4]:https://console.cloud.google.com/profiler -[5]:http://www.brendangregg.com/flamegraphs.html diff --git a/translated/tech/20180426 Continuous Profiling of Go programs.md b/translated/tech/20180426 Continuous Profiling of Go programs.md new file mode 100644 index 0000000000..fb5c9ac9fc --- /dev/null +++ b/translated/tech/20180426 Continuous Profiling of Go programs.md @@ -0,0 +1,106 @@ +Go 程序的持续分析 +============================================================ + +Google 最有趣的部分之一就是我们的持续分析服务。我们可以看到谁在使用 CPU 和内存,我们可以持续地监控我们的生产服务以争用和阻止配置文件,并且我们可以生成分析和报告,并轻松地告诉我们可以进行哪些有重要影响的优化。 + +我简单研究了 [Stackdriver Profiler][2],这是我们的新产品,它填补了针对云端用户云端分析服务的空白。请注意,你无需在 Google 云平台上运行你的代码即可使用它。实际上,我现在每天都在开发时使用它。它也支持 Java 和 Node.js。 + +#### 在生产中分析 + +pprof 可安全地用于生产。我们针对 CPU 和堆分配分析的额外开销会增加 5%。一个实例中每分钟收集 10 秒。如果你有一个 Kubernetes Pod 的多个副本,我们确保进行分摊收集。例如,如果你拥有一个 pod 的 10 个副本,模式,那么开销将变为 0.5%。这使用户可以始终进行分析。 + +我们目前支持 Go 程序的 CPU、堆、互斥和线程分析。 + +#### 为什么? + +在解释如何在生产中使用分析器之前,先解释为什么你想要在生产中进行分析将有所帮助。一些非常常见的情况是: + +* 调试仅在生产中可见的性能问题。 + +* 了解 CPU 使用率以减少费用。 + +* 了解争用的累积和优化的地方。 + +* 了解新版本的影响,例如看到 canary 和生产之间的区别。 + +* 通过[关联][1]分析样本以了解延迟的根本原因来丰富你的分布式经验。 + +#### 启用 + +Stackdriver Profiler 不能与 _net/http/pprof_ 处理程序一起使用,并要求你在程序中安装和配置一个一行的代理。 + +``` +go get cloud.google.com/go/profiler +``` + +在你的主函数中,启动分析器: + +``` +if err := profiler.Start(profiler.Config{ + Service: "indexing-service", + ServiceVersion: "1.0", + ProjectID: "bamboo-project-606", // optional on GCP +}); err != nil { + log.Fatalf("Cannot start the profiler: %v", err) +} +``` + +当你运行你的程序后,profiler 包将每分钟报告给 profiler 10 秒钟。 + +#### 可视化 + +当分析报告给后端后,你将在 [https://console.cloud.google.com/profiler][4] 上看到火焰图。你可以按标签过滤并更改时间范围,也可以按服务名称和版本进行细分。数据将会长达 30 天。 + + +![](https://cdn-images-1.medium.com/max/900/1*JdCm1WwmTgExzee5-ZWfNw.gif) + +你可以选择其中一个分析,按服务,区域和版本分解。你可以在火焰中移动并通过标签进行过滤。 + +#### 阅读火焰图 + +火焰图可视化由 [Brendan Gregg][5] 非常全面地解释了。Stackdriver Profiler 增加了一点它自己的特点。 + + +![](https://cdn-images-1.medium.com/max/900/1*QqzFJlV9v7U1s1reYsaXog.png) + +我们将查看一个 CPU 分析,但这也适用于其他分析。 + +1. 最上面的 x 轴表示整个程序。火焰上的每个框表示调用路径上的一帧。框的宽度与执行该函数花费的 CPU 时间成正比。 + +2. 框从左到右排序,左边是花费最多的调用路径。 + +3. 来自同一包的帧具有相同的颜色。这里所有运行时功能均以绿色表示。 + +4. 你可以单击任何框进一步展开执行树。 + + +![](https://cdn-images-1.medium.com/max/900/1*1jCm6f-Fl2mpkRe3-57mTg.png) + +你可以将鼠标悬停在任何框上查看任何帧的详细信息。 + +#### 过滤 + +你可以显示,隐藏和高亮符号名称。如果你特别想了解某个特定调用或包的消耗,这些信息非常有用。 + +![](https://cdn-images-1.medium.com/max/900/1*ka9fA-AAuKggAuIBq_uhGQ.png) + +1. 选择你的过滤器。你可以组合多个过滤器。在这里,我们将高亮显示 runtime.memmove。 + +2. 火焰将使用过滤器过滤帧并可视化过滤后的框。在这种情况下,它高亮显示所有 runtime.memmove 框。 + +-------------------------------------------------------------------------------- + +via: https://medium.com/google-cloud/continuous-profiling-of-go-programs-96d4416af77b + +作者:[JBD ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.com/@rakyll?source=post_header_lockup +[1]:https://rakyll.org/profiler-labels/ +[2]:https://cloud.google.com/profiler/ +[3]:http://cloud.google.com/go/profiler +[4]:https://console.cloud.google.com/profiler +[5]:http://www.brendangregg.com/flamegraphs.html From 92ccaf3087e50234a3673b8f1380bb5126c4f6f9 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 16 May 2018 08:45:22 +0800 Subject: [PATCH 111/111] translating --- ... a cryptocurrency for creators of openly licensed content.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md b/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md index 451dc27344..f08c81b10e 100644 --- a/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md +++ b/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md @@ -1,3 +1,5 @@ +translating----geekpi + LikeCoin, a cryptocurrency for creators of openly licensed content ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_whitehurst_money.png?itok=ls-SOzM0)