From f8a86ee1199f249c1252eade872fd8baede76724 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Fri, 23 Feb 2018 11:43:36 +0800 Subject: [PATCH 0001/1057] alter translated --- ...180201 How I coined the term open source.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index fa77d13c6b..1c35caf1c2 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -7,11 +7,11 @@ ![How I coined the term 'open source'](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb "How I coined the term 'open source'") 图片来自: opensource.com -In a few days, on February 3, the 20th anniversary of the introduction of the term "[开源软件][6]" is upon us. As open source software grows in popularity and powers some of the most robust and important innovations of our time, we reflect on its rise to prominence. +几天后, 2 月 3 日, 术语 "[开源软件][6]" 首次使用的20周年纪念日即将到来。 As open source software grows in popularity and powers some of the most robust and important innovations of our time, we reflect on its rise to prominence. -I am the originator of the term "open source software" and came up with it while executive director at Foresight Institute. Not a software developer like the rest, I thank Linux programmer Todd Anderson for supporting the term and proposing it to the group. +我是 “开源软件” 这个词的始作俑者而且他在前瞻技术协会(Foresight Institute)担任执行董事时想出了它。Not a software developer like the rest, I thank Linux programmer Todd Anderson for supporting the term and proposing it to the group. -This is my account of how I came up with it, how it was proposed, and the subsequent reactions. Of course, there are a number of accounts of the coining of the term, for example by Eric Raymond and Richard Stallman, yet this is mine, written on January 2, 2006. +这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些关于该术语的记叙,例如 Eric Raymond 和 Richard Stallman 创造的,但这是我的,写于2006年1月2日。 直到今天,它才公诸于世。 @@ -23,13 +23,13 @@ This term had long been used in an "intelligence" (i.e., spying) context, but to ### 计算机安全会议 -In late 1997, weekly meetings were being held at Foresight Institute to discuss computer security. Foresight is a nonprofit think tank focused on nanotechnology and artificial intelligence, and software security is regarded as central to the reliability and security of both. We had identified free software as a promising approach to improving software security and reliability and were looking for ways to promote it. Interest in free software was starting to grow outside the programming community, and it was increasingly clear that an opportunity was coming to change the world. However, just how to do this was unclear, and we were groping for strategies. +在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索策略中。 At these meetings, we discussed the need for a new term due to the confusion factor. The argument was as follows: those new to the term "free software" assume it is referring to the price. Oldtimers must then launch into an explanation, usually given as follows: "We mean free as in freedom, not free as in beer." At this point, a discussion on software has turned into one about the price of an alcoholic beverage. The problem was not that explaining the meaning is impossible—the problem was that the name for an important idea should not be so confusing to newcomers. A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. ### 网景发布 -On February 2, 1998, Eric Raymond arrived on a visit to work with Netscape on the plan to release the browser code under a free-software-style license. We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message. In addition to Eric and me, active participants included Brian Behlendorf, Michael Tiemann, Todd Anderson, Mark S. Miller, and Ka-Ping Yee. But at that meeting, the field was still described as free software or, by Brian, "source code available" software. +1998 年 2 月 2 日,Eric Raymond arrived on a visit to work with Netscape on the plan to 发布了浏览器代码 under a free-software-style license. We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 included Brian Behlendorf, Michael Tiemann, Todd Anderson, Mark S. Miller, and Ka-Ping Yee. But at that meeting, the field was still described as free software or, by Brian, "source code available" software. While in town, Eric used Foresight as a base of operations. At one point during his visit, he was called to the phone to talk with a couple of Netscape legal and/or marketing staff. When he was finished, I asked to be put on the phone with them—one man and one woman, perhaps Mitchell Baker—so I could bring up the need for a new term. They agreed in principle immediately, but no specific term was agreed upon. @@ -57,11 +57,11 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti After this, there was a period during which the term was promoted by Eric Raymond to the media, by Tim O'Reilly to business, and by both to the programming community. It seemed to spread very quickly. -On April 7, 1998, Tim O'Reilly held a meeting of key leaders in the field. Announced in advance as the first "[Freeware Summit][10]," by April 14 it was referred to as the first "[Open Source Summit][11]." +On April 7, 1998, Tim O'Reilly held a meeting of key leaders in the field. 提前宣布 as the first "[Freeware Summit][10]," by April 14 it was referred to as the first "[Open Source Summit][11]." -These months were extremely exciting for open source. Every week, it seemed, a new company announced plans to participate. Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. +These months were extremely exciting for open source.这是对于开源来说激动人心的几个月。 Every week, it seemed, a new company announced plans to participate. Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. -A quick Google search indicates that "open source" appears more often than "free software," but there still is substantial use of the free software term, which remains useful and should be included when communicating with audiences who prefer it. +快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,和偏爱它的人们沟通的时候就特别有用。 ### A happy twinge @@ -69,7 +69,7 @@ When an [early account][12] of the terminology change written by Eric Raymond Coming up with a phrase is a small contribution, but I admit to being grateful to those who remember to credit me with it. Every time I hear it, which is very often now, it gives me a little happy twinge. -The big credit for persuading the community goes to Eric Raymond and Tim O'Reilly, who made it happen. Thanks to them for crediting me, and to Todd Anderson for his role throughout. The above is not a complete account of open source history; apologies to the many key players whose names do not appear. Those seeking a more complete account should refer to the links in this article and elsewhere on the net. +说服团队的大功劳归功于Eric Raymond和 Tim O'Reilly,是他们搞定的它。感谢他们对我的评价,并感谢Todd Anderson 在整个过程中的角色。以上内容并非完整的开源历史记录,对很多没有无名人士表示歉意。那些寻求更完整讲述的人应该参考本文和网上其他地方的链接。 ### 关于作者 From 38bbd73a733c18b12c9946c2ba3d55e7fd12da89 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Fri, 23 Feb 2018 16:41:55 +0800 Subject: [PATCH 0002/1057] add a part --- ...20180201 How I coined the term open source.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 1c35caf1c2..7f38d33617 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -7,11 +7,11 @@ ![How I coined the term 'open source'](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb "How I coined the term 'open source'") 图片来自: opensource.com -几天后, 2 月 3 日, 术语 "[开源软件][6]" 首次使用的20周年纪念日即将到来。 As open source software grows in popularity and powers some of the most robust and important innovations of our time, we reflect on its rise to prominence. +几天后, 2 月 3 日, 术语 "[开源软件][6]" 创立20周年的纪念日即将到来。由于开源软件渐受欢迎并且为这个时代强有力的重要变革提供动力,我们仔细思考了它的初生到崛起。 -我是 “开源软件” 这个词的始作俑者而且他在前瞻技术协会(Foresight Institute)担任执行董事时想出了它。Not a software developer like the rest, I thank Linux programmer Todd Anderson for supporting the term and proposing it to the group. +我是 “开源软件” 这个词的始作俑者,它是我在前瞻技术协会(Foresight Institute)担任执行董事时想出的。Not a software developer like the rest, I thank Linux programmer Todd Anderson for supporting the term and proposing it to the group. -这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些关于该术语的记叙,例如 Eric Raymond 和 Richard Stallman 创造的,但这是我的,写于2006年1月2日。 +这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些关于该术语的记叙,例如 Eric Raymond 和 Richard Stallman 的,而我的,写于 2006 年 1 月 2 日。 直到今天,它才公诸于世。 @@ -23,13 +23,13 @@ This term had long been used in an "intelligence" (i.e., spying) context, but to ### 计算机安全会议 -在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索策略中。 +在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 At these meetings, we discussed the need for a new term due to the confusion factor. The argument was as follows: those new to the term "free software" assume it is referring to the price. Oldtimers must then launch into an explanation, usually given as follows: "We mean free as in freedom, not free as in beer." At this point, a discussion on software has turned into one about the price of an alcoholic beverage. The problem was not that explaining the meaning is impossible—the problem was that the name for an important idea should not be so confusing to newcomers. A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. ### 网景发布 -1998 年 2 月 2 日,Eric Raymond arrived on a visit to work with Netscape on the plan to 发布了浏览器代码 under a free-software-style license. We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 included Brian Behlendorf, Michael Tiemann, Todd Anderson, Mark S. Miller, and Ka-Ping Yee. But at that meeting, the field was still described as free software or, by Brian, "source code available" software. +1998 年 2 月 2 日,Eric Raymond arrived on a visit to work with Netscape on the plan to 发布了浏览器代码 under a free-software-style license. We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。But at that meeting, the field was still described as free software or, by Brian, “可获得源代码的” 软件。 While in town, Eric used Foresight as a base of operations. At one point during his visit, he was called to the phone to talk with a couple of Netscape legal and/or marketing staff. When he was finished, I asked to be put on the phone with them—one man and one woman, perhaps Mitchell Baker—so I could bring up the need for a new term. They agreed in principle immediately, but no specific term was agreed upon. @@ -55,13 +55,13 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti ### 名字的诞生 -After this, there was a period during which the term was promoted by Eric Raymond to the media, by Tim O'Reilly to business, and by both to the programming community. It seemed to spread very quickly. +在那之后,有一段时间,这条术语由 Eric Raymond 推向媒体,由 Tim O'Reilly 推向商业,并由二人推向编程社区,那似乎传播的相当快。 On April 7, 1998, Tim O'Reilly held a meeting of key leaders in the field. 提前宣布 as the first "[Freeware Summit][10]," by April 14 it was referred to as the first "[Open Source Summit][11]." -These months were extremely exciting for open source.这是对于开源来说激动人心的几个月。 Every week, it seemed, a new company announced plans to participate. Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. +这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. -快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,和偏爱它的人们沟通的时候就特别有用。 +尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,和偏爱它的人们沟通的时候就特别有用。 ### A happy twinge From 7327a3eee642d3d7fa420a693c0353447f09176a Mon Sep 17 00:00:00 2001 From: Means Lee Date: Fri, 23 Feb 2018 20:07:04 +0800 Subject: [PATCH 0003/1057] fetch remote --- ... What Is Kali Linux, and Do You Need It.md | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 published/20180206 What Is Kali Linux, and Do You Need It.md diff --git a/published/20180206 What Is Kali Linux, and Do You Need It.md b/published/20180206 What Is Kali Linux, and Do You Need It.md deleted file mode 100644 index 5506807a6b..0000000000 --- a/published/20180206 What Is Kali Linux, and Do You Need It.md +++ /dev/null @@ -1,74 +0,0 @@ -Kali Linux 是什么,你需要它吗? -====== - -![](https://www.maketecheasier.com/assets/uploads/2018/01/kl-feat.jpg) - -如果你听到一个 13 岁的黑客吹嘘他是多么的牛逼,是有可能的,因为有 Kali Linux 的存在。尽管有可能会被称为“脚本小子”,但是事实上,Kali 仍旧是安全专家手头的重要工具(或工具集)。 - -Kali 是一个基于 Debian 的 Linux 发行版。它的目标就是为了简单:在一个实用的工具包里尽可能多的包含渗透和审计工具。Kali 实现了这个目标。大多数做安全测试的开源工具都被囊括在内。 - -**相关** : [4 个极好的为隐私和安全设计的 Linux 发行版][1] - -### 为什么是 Kali? - -![Kali Linux Desktop][2] - -[Kali][3] 是由 [Offensive Security](https://www.offensive-security.com/) 公司开发和维护的。它在安全领域是一家知名的、值得信赖的公司,它甚至还有一些受人尊敬的认证,来对安全从业人员做资格认证。 - -Kali 也是一个简便的安全解决方案。Kali 并不要求你自己去维护一个 Linux 系统,或者你自己去收集软件和依赖项。它是一个“交钥匙工程”。所有这些繁杂的工作都不需要你去考虑,因此,你只需要专注于要审计的真实工作上,而不需要去考虑准备测试系统。 - -### 如何使用它? - -Kali 是一个 Linux 发行版。与任何一个其它的 Linux 发行版一样,你可以将它永久安装到一个硬盘上。那样它会工作的更好,但是你不能将它作为一个日常使用的操作系统。因为它是为渗透测试构建的,这就是你使用它的全部理由。 - -最好是将 Kali 制作为自启动发行版。你可以将 Kali 刻录到一张 DVD 或者是制作到一个自启动 U 盘上来运行它。你没有必要在一个 Kali 上安装任何软件或者保存任何文件。你可以在需要测试一个系统时随时来启动它。它也有非常好的灵活性,可以让运行 Kali 的机器随时运行在想要测试的网络上。 - -### Kali 可以做什么? - -Kali 里面有很多的安全工具而不是别的。这就是它能做的事。不管怎么说,Kali 就是一个安全工具。 - -![Kali Zenmap][4] - -它有像 NMap 和 Wireskark 这样的经典信息采集工具。 - -![Kali Linux Wireshark][5] - -Kali 也有面向 WiFi 的工具,像 Aircrack-ng、Kismet、以及 Pixie。 - -对于破解密码,它也有像 Hydra、Crunch、Hashcat、以及 John the Ripper 这样的工具。 - -![Kali Metasploit][6] - -还有更多的成套工具,包括 Metasploit 和 Burp Suite。 - -这些只是 Kali 缺省内置的一小部分安全工具。完整的了解这些工具需要很多的时间,但是,你可以清楚地看到许多非常流行的工具它都有。 - -### Kali 是为你准备的吗? - -Kali 并不是为普通用户准备的。它并不是一个运行在你的笔记本电脑上的普通 Linux 发行版,而是一个很酷的“黑客操作系统“。如果你使用这个操作系统,那么你将会运行着一个缺乏安全保障的系统,因为 Kali 被设计为以 root 权限运行。它自身并不安全,并且它的配置也与普通的 Linux 发行版不一样。它是一个攻击型工具,而不是一个防御型工具。 - -Kali 并不是个玩具。你可以使用它内置的工具去做一些会产生真实伤害的危险的事(你懂的),那将给你带来很多真实的麻烦。对于一个未受到严格教育的用户来说,做一些严重违法的事情是很容易的,并且之后你就会发现自己被陷入很无助的境地。 - -说了这么多,但是,Kali 对于一个专业用户来说,它是一个极好的工具。如果你是一个网络管理员,想对你的网络做一个真实的测试,Kali 可以做到你所希望的一切事情。Kali 也有一些优秀的开发工具,用于去实时审计它们的应用程序。 - -当然,如果你正好有兴趣学习关于安全的知识,你可以在某些受控环境中去使用 Kali,它可以教你学习很多的非常优秀的知识。 - -Kali Linux 是许多优秀的安全工具的集合。对于专业用户来说,它有难以置信的好处,但是对于一些不怀好意的人来说,也可以产生很多大麻烦。小心地使用 Kali,充分利用它的巨大优势。如果不这样的话,你将在某个地方(你懂的)度过你的余生。 - --------------------------------------------------------------------------------- - -via: https://www.maketecheasier.com/what-is-kali-linux-and-do-you-need-it/ - -作者:[Nick Congleton][a] -译者:[qhwdw](https://github.com/qhwdw) -校对:[wxy](https://github.com/wxy) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.maketecheasier.com/author/nickcongleton/ -[1]:https://www.maketecheasier.com/linux-distros-designed-for-privacy-security/ "4 Great Linux Distros Designed for Privacy and Security" -[2]:https://www.maketecheasier.com/assets/uploads/2018/01/kl-desktop.jpg "Kali Linux Desktop" -[3]:https://www.offensive-security.com/kali-linux-vmware-virtualbox-image-download/ -[4]:https://www.maketecheasier.com/assets/uploads/2018/01/kl-zenmap.jpg "Kali Zenmap" -[5]:https://www.maketecheasier.com/assets/uploads/2018/01/kl-wireshark.jpg "Kali Linux Wireshark" -[6]:https://www.maketecheasier.com/assets/uploads/2018/01/kl-metasploit.jpg "Kali Metasploit" From beda71d42e03eb959df40a040a600ad2229bd92c Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sat, 24 Feb 2018 14:53:39 +0800 Subject: [PATCH 0004/1057] 2018-02-24 --- sources/talk/20180201 How I coined the term open source.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 7f38d33617..a93795bea4 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -29,7 +29,7 @@ At these meetings, we discussed the need for a new term due to the confusion fac ### 网景发布 -1998 年 2 月 2 日,Eric Raymond arrived on a visit to work with Netscape on the plan to 发布了浏览器代码 under a free-software-style license. We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。But at that meeting, the field was still described as free software or, by Brian, “可获得源代码的” 软件。 +1998 年 2 月 2 日,Eric Raymond arrived on a visit to work with Netscape on the plan to 采用免费软件样式的许可证发布浏览器代码 under a free-software-style license. We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。但在那次会议上,这个领域仍然被描述成自由软件,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 While in town, Eric used Foresight as a base of operations. At one point during his visit, he was called to the phone to talk with a couple of Netscape legal and/or marketing staff. When he was finished, I asked to be put on the phone with them—one man and one woman, perhaps Mitchell Baker—so I could bring up the need for a new term. They agreed in principle immediately, but no specific term was agreed upon. @@ -57,7 +57,7 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti 在那之后,有一段时间,这条术语由 Eric Raymond 推向媒体,由 Tim O'Reilly 推向商业,并由二人推向编程社区,那似乎传播的相当快。 -On April 7, 1998, Tim O'Reilly held a meeting of key leaders in the field. 提前宣布 as the first "[Freeware Summit][10]," by April 14 it was referred to as the first "[Open Source Summit][11]." +On April 7, 1998, Tim O'Reilly 提前宣布 as the first "[Freeware Summit][10]," by April 14 it was referred to as the first "[Open Source Summit][11]." 这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. From 5e687caa454bbcd29895c026389d824b1b95af4d Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sun, 25 Feb 2018 11:52:20 +0800 Subject: [PATCH 0005/1057] 2018-2-25 --- .../talk/20180201 How I coined the term open source.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index a93795bea4..435ee4a9ed 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -2,7 +2,7 @@ 我是如何创造“开源”这个词的 ============================================================ -### Christine Peterson 最终发布了对于二十年前那决定命运一天的陈述。 +### Christine Peterson 最终公开讲述了二十年前那决定命运一天。 ![How I coined the term 'open source'](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb "How I coined the term 'open source'") 图片来自: opensource.com @@ -63,13 +63,13 @@ On April 7, 1998, Tim O'Reilly 提前宣布 as the first "[Freeware Summit][10], 尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,和偏爱它的人们沟通的时候就特别有用。 -### A happy twinge +### A happy twinge喜出望外 When an [early account][12] of the terminology change written by Eric Raymond was posted on the Open Source Initiative website, I was listed as being at the VA brainstorming meeting, but not as the originator of the term. This was my own fault; I had neglected to tell Eric the details. My impulse was to let it pass and stay in the background, but Todd felt otherwise. He suggested to me that one day I would be glad to be known as the person who coined the name "open source software." He explained the situation to Eric, who promptly updated his site. -Coming up with a phrase is a small contribution, but I admit to being grateful to those who remember to credit me with it. Every time I hear it, which is very often now, it gives me a little happy twinge. +想出这个短语只是一个小贡献,但是我得承认我十分感激那些把它归功于我的人。每次我听到它,它都给我些许激动的喜悦,到现在也时常感受到。 -说服团队的大功劳归功于Eric Raymond和 Tim O'Reilly,是他们搞定的它。感谢他们对我的评价,并感谢Todd Anderson 在整个过程中的角色。以上内容并非完整的开源历史记录,对很多没有无名人士表示歉意。那些寻求更完整讲述的人应该参考本文和网上其他地方的链接。 +说服团队的大功劳归功于Eric Raymond和 Tim O'Reilly,这是他们搞定的。感谢他们对我的评价,并感谢Todd Anderson 在整个过程中的角色。以上内容并非完整的开源历史记录,对很多没有无名人士表示歉意。那些寻求更完整讲述的人应该参考本文和网上其他地方的链接。 ### 关于作者 From 3176f18297f3963d583d2dd5c2c00c9a63b586ff Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Thu, 1 Mar 2018 22:09:19 +0800 Subject: [PATCH 0006/1057] a part finished before start school --- ...80201 How I coined the term open source.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 435ee4a9ed..db6d289432 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -9,9 +9,9 @@ 几天后, 2 月 3 日, 术语 "[开源软件][6]" 创立20周年的纪念日即将到来。由于开源软件渐受欢迎并且为这个时代强有力的重要变革提供动力,我们仔细思考了它的初生到崛起。 -我是 “开源软件” 这个词的始作俑者,它是我在前瞻技术协会(Foresight Institute)担任执行董事时想出的。Not a software developer like the rest, I thank Linux programmer Todd Anderson for supporting the term and proposing it to the group. +我是 “开源软件” 这个词的始作俑者,它是我在前瞻技术协会(Foresight Institute)担任执行董事时想出的。并非向上面的一个程序开发者一样,我感谢 Linux 程序员 Todd Anderson 对这个术语的支持并将它提交小组讨论。 -这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些关于该术语的记叙,例如 Eric Raymond 和 Richard Stallman 的,而我的,写于 2006 年 1 月 2 日。 +这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些关于该术语的记叙,例如 Eric Raymond 和 Richard Stallman 写的,而我的,则写于 2006 年 1 月 2 日。 直到今天,它才公诸于世。 @@ -19,29 +19,29 @@ The introduction of the term "open source software" was a deliberate effort to make this field of endeavor more understandable to newcomers and to business, which was viewed as necessary to its spread to a broader community of users. The problem with the main earlier label, "free software," was not its political connotations, but that—to newcomers—its seeming focus on price is distracting. A term was needed that focuses on the key issue of source code and that does not immediately confuse those new to the concept. The first term that came along at the right time and fulfilled these requirements was rapidly adopted: open source. -This term had long been used in an "intelligence" (i.e., spying) context, but to my knowledge, use of the term with respect to software prior to 1998 has not been confirmed. The account below describes how the term [open source software][7] caught on and became the name of both an industry and a movement. +This term had long been used in an "intelligence" (i.e., spying) context, 但据我所知but to my knowledge, use of the term with respect to software prior to 1998 has not been confirmed. 下面这个就是讲述了术语“开源软件”如何流行起来并且变成了一项产业和一场运动的名字。 ### 计算机安全会议 在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 -At these meetings, we discussed the need for a new term due to the confusion factor. The argument was as follows: those new to the term "free software" assume it is referring to the price. Oldtimers must then launch into an explanation, usually given as follows: "We mean free as in freedom, not free as in beer." At this point, a discussion on software has turned into one about the price of an alcoholic beverage. The problem was not that explaining the meaning is impossible—the problem was that the name for an important idea should not be so confusing to newcomers. A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. +At these meetings, we discussed the need for a new term due to the confusion factor. 观点主要有以下:对于那些新接触“自由软件”的人把它(free)当成了价格。 Oldtimers must then launch into an explanation, usually given as follows: "We mean free as in freedom, not free as in beer." At this point, a discussion on software has turned into one about the price of an alcoholic beverage. The problem was not that explaining the meaning is impossible—the problem was that the name for an important idea should not be so confusing to newcomers. A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. ### 网景发布 -1998 年 2 月 2 日,Eric Raymond arrived on a visit to work with Netscape on the plan to 采用免费软件样式的许可证发布浏览器代码 under a free-software-style license. We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。但在那次会议上,这个领域仍然被描述成自由软件,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 +1998 年 2 月 2 日,Eric Raymond 抵达访问网景并与它一起计划采用免费软件样式的许可证发布浏览器代码。We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。但在那次会议上,这个领域仍然被描述成“自由软件”,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 While in town, Eric used Foresight as a base of operations. At one point during his visit, he was called to the phone to talk with a couple of Netscape legal and/or marketing staff. When he was finished, I asked to be put on the phone with them—one man and one woman, perhaps Mitchell Baker—so I could bring up the need for a new term. They agreed in principle immediately, but no specific term was agreed upon. -Between meetings that week, I was still focused on the need for a better name and came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, while a friend in marketing and public relations felt the term "open" had been overused and abused and believed we could do better. He was right in theory; however, I didn't have a better idea, so I thought I would try to go ahead and introduce it. In hindsight, I should have simply proposed it to Eric Raymond, but I didn't know him well at the time, so I took an indirect strategy instead. +在那周的会议中,我仍然关注Between meetings that week, I was still focused on the need for a better name and came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, while a friend in marketing and public relations felt the term "open" had been overused and abused and believed we could do better. 理论上它是对的,我想不出更好的了,所以我想尝试并推广它。 事后一想我应该简单地向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 -Todd had agreed strongly about the need for a new term and offered to assist in getting the term introduced. This was helpful because, as a non-programmer, my influence within the free software community was weak. My work in nanotechnology education at Foresight was a plus, but not enough for me to be taken very seriously on free software questions. As a Linux programmer, Todd would be listened to more closely. +Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我在纳米技术的工作是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 ### 关键的会议 Later that week, on February 5, 1998, a group was assembled at VA Research to brainstorm on strategy. Attending—in addition to Eric Raymond, Todd, and me—were Larry Augustin, Sam Ockman, and attending by phone, Jon "maddog" Hall. -The primary topic was promotion strategy, especially which companies to approach. I said little, but was looking for an opportunity to introduce the proposed term. I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. +会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. Fortunately, Todd was on the ball. Instead of making an assertion that the community should use this specific new term, he did something less directive—a smart thing to do with this community of strong-willed individuals. He simply used the term in a sentence on another topic—just dropped it into the conversation to see what happened. I went on alert, hoping for a response, but there was none at first. The discussion continued on the original topic. It seemed only he and I had noticed the usage. @@ -61,11 +61,11 @@ On April 7, 1998, Tim O'Reilly 提前宣布 as the first "[Freeware Summit][10], 这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. -尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,和偏爱它的人们沟通的时候就特别有用。 +尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,特别是和偏爱它的人们沟通的时候。 -### A happy twinge喜出望外 +### 一丝快感 -When an [early account][12] of the terminology change written by Eric Raymond was posted on the Open Source Initiative website, I was listed as being at the VA brainstorming meeting, but not as the originator of the term. This was my own fault; I had neglected to tell Eric the details. My impulse was to let it pass and stay in the background, but Todd felt otherwise. He suggested to me that one day I would be glad to be known as the person who coined the name "open source software." He explained the situation to Eric, who promptly updated his site. +When an [early account][12] of the terminology change written by Eric Raymond was posted on the Open Source Initiative website, I was listed as being at the VA brainstorming meeting, but not as the originator of the term. 这是我自己的错,我没告诉 Eric 细节。我一时冲动只想让它表决通过然后我呆在后台,但是 Todd 不这样认为。他认为我总有一天将作为“开源软件”这个名词的创造者而感到高兴。他向 Eric 解释了这个情况,Eric 及时更新了它的网站。 想出这个短语只是一个小贡献,但是我得承认我十分感激那些把它归功于我的人。每次我听到它,它都给我些许激动的喜悦,到现在也时常感受到。 @@ -80,7 +80,7 @@ When an [early account][12] of the terminology change written by Eric Raymond via: https://opensource.com/article/18/2/coining-term-open-source-software 作者:[ Christine Peterson][a] -译者:[译者ID](https://github.com/译者ID) +译者:[fuzheng1998](https://github.com/fuzheng1998) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From dc01a0c20299b1ed48a6734107d8303c2790be85 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sun, 4 Mar 2018 14:21:09 +0800 Subject: [PATCH 0007/1057] update word [translating] --- .../talk/20180201 How I coined the term open source.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index db6d289432..76a0f13932 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -33,9 +33,9 @@ At these meetings, we discussed the need for a new term due to the confusion fac While in town, Eric used Foresight as a base of operations. At one point during his visit, he was called to the phone to talk with a couple of Netscape legal and/or marketing staff. When he was finished, I asked to be put on the phone with them—one man and one woman, perhaps Mitchell Baker—so I could bring up the need for a new term. They agreed in principle immediately, but no specific term was agreed upon. -在那周的会议中,我仍然关注Between meetings that week, I was still focused on the need for a better name and came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, while a friend in marketing and public relations felt the term "open" had been overused and abused and believed we could do better. 理论上它是对的,我想不出更好的了,所以我想尝试并推广它。 事后一想我应该简单地向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 +在那周的会议中,我仍然关注一个更好的名字Between meetings that week, I was still focused on the need for a better name and 提出术语 “开源软件”came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, while a friend in marketing and public relations felt the term "open" had been overused and abused and 相信我们能做的更好。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 -Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我在纳米技术的工作是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 +Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 ### 关键的会议 @@ -55,9 +55,9 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti ### 名字的诞生 -在那之后,有一段时间,这条术语由 Eric Raymond 推向媒体,由 Tim O'Reilly 推向商业,并由二人推向编程社区,那似乎传播的相当快。 +在那之后,有一段时间,这条术语由 Eric Raymond 向媒体推广,由 Tim O'Reilly 向商业推广,并由二人向编程社区推广,那似乎传播的相当快。 -On April 7, 1998, Tim O'Reilly 提前宣布 as the first "[Freeware Summit][10]," by April 14 it was referred to as the first "[Open Source Summit][11]." +1998 年 4 月 17 日, Tim O'Reilly 提前宣布 首届 “[自由软件峰会][10]” 在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. From ca81d711de6d88119eb2e86afc5e2cf973bfb261 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Mon, 5 Mar 2018 08:07:09 +0800 Subject: [PATCH 0008/1057] 2018-3-5 --- sources/talk/20180201 How I coined the term open source.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 76a0f13932..84ccb7a1df 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -1,8 +1,8 @@ -[fuzheng1998 tranlating] +[fuzheng1998 translating] 我是如何创造“开源”这个词的 ============================================================ -### Christine Peterson 最终公开讲述了二十年前那决定命运一天。 +### Christine Peterson 最终公开讲述了二十年前那决定命运的一天。 ![How I coined the term 'open source'](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb "How I coined the term 'open source'") 图片来自: opensource.com @@ -17,7 +17,7 @@ * * * -The introduction of the term "open source software" was a deliberate effort to make this field of endeavor more understandable to newcomers and to business, which was viewed as necessary to its spread to a broader community of users. The problem with the main earlier label, "free software," was not its political connotations, but that—to newcomers—its seeming focus on price is distracting. A term was needed that focuses on the key issue of source code and that does not immediately confuse those new to the concept. The first term that came along at the right time and fulfilled these requirements was rapidly adopted: open source. +The introduction of the term "open source software" was 是特地为了这个领域让新手和商业人士更加易懂a deliberate effort to make this field of endeavor more understandable to newcomers and to business, which was viewed as necessary to its spread to a broader community of users. 早期称号的问题是,“自由软件”,并非有政治含义,但是那对于新手来说貌似对于价格的关注令人心烦意乱。一个术语需要聚焦于源代码的关键问题而且不会被立即把概念跟那些新东西混淆。一个恰好想出并且满足这些要求的第一个术语被快速接受:开源。 This term had long been used in an "intelligence" (i.e., spying) context, 但据我所知but to my knowledge, use of the term with respect to software prior to 1998 has not been confirmed. 下面这个就是讲述了术语“开源软件”如何流行起来并且变成了一项产业和一场运动的名字。 From c63d1ce8cb0271e7404017f707741c46db794af0 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Tue, 6 Mar 2018 11:44:51 +0800 Subject: [PATCH 0009/1057] amend [translation] with text translated --- .../talk/20180201 How I coined the term open source.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 84ccb7a1df..f830e4beb6 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -19,13 +19,13 @@ The introduction of the term "open source software" was 是特地为了这个领域让新手和商业人士更加易懂a deliberate effort to make this field of endeavor more understandable to newcomers and to business, which was viewed as necessary to its spread to a broader community of users. 早期称号的问题是,“自由软件”,并非有政治含义,但是那对于新手来说貌似对于价格的关注令人心烦意乱。一个术语需要聚焦于源代码的关键问题而且不会被立即把概念跟那些新东西混淆。一个恰好想出并且满足这些要求的第一个术语被快速接受:开源。 -This term had long been used in an "intelligence" (i.e., spying) context, 但据我所知but to my knowledge, use of the term with respect to software prior to 1998 has not been confirmed. 下面这个就是讲述了术语“开源软件”如何流行起来并且变成了一项产业和一场运动的名字。 +这个术语很长一段时间被用在“情报”(即间谍活动)的情境下,但据我所知but to my knowledge, use of the term with respect to software prior to 1998 has not been confirmed. 下面这个就是讲述了术语“开源软件”如何流行起来并且变成了一项产业和一场运动的名字。 ### 计算机安全会议 在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 -At these meetings, we discussed the need for a new term due to the confusion factor. 观点主要有以下:对于那些新接触“自由软件”的人把它(free)当成了价格。 Oldtimers must then launch into an explanation, usually given as follows: "We mean free as in freedom, not free as in beer." At this point, a discussion on software has turned into one about the price of an alcoholic beverage. The problem was not that explaining the meaning is impossible—the problem was that the name for an important idea should not be so confusing to newcomers. A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. +At these meetings, we discussed the need for a new term due to the confusion factor. 观点主要有以下:对于那些新接触“自由软件”的人把它(free)当成了价格。 Oldtimers must then launch into an explanation, usually given as follows: “我们的意思是自由上的,而不是啤酒免费上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。At this point, a discussion on software has turned into one about the price of an alcoholic beverage. The problem was not that explaining the meaning is impossible—the problem was that the name for an important idea should not be so confusing to newcomers. A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. ### 网景发布 @@ -55,7 +55,7 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti ### 名字的诞生 -在那之后,有一段时间,这条术语由 Eric Raymond 向媒体推广,由 Tim O'Reilly 向商业推广,并由二人向编程社区推广,那似乎传播的相当快。 +在那之后的一段时间,这条术语由 Eric Raymond 向媒体推广,由 Tim O'Reilly 向商业推广,并由二人向编程社区推广,那似乎传播的相当快。 1998 年 4 月 17 日, Tim O'Reilly 提前宣布 首届 “[自由软件峰会][10]” 在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 @@ -65,7 +65,7 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti ### 一丝快感 -When an [early account][12] of the terminology change written by Eric Raymond was posted on the Open Source Initiative website, I was listed as being at the VA brainstorming meeting, but not as the originator of the term. 这是我自己的错,我没告诉 Eric 细节。我一时冲动只想让它表决通过然后我呆在后台,但是 Todd 不这样认为。他认为我总有一天将作为“开源软件”这个名词的创造者而感到高兴。他向 Eric 解释了这个情况,Eric 及时更新了它的网站。 +当一个被 Eric Raymond写的有关修改术语的早期的陈述被发布在了开放源代码促进会的网站上时,我上了 VA 头脑风暴会议的名单,但并不是作为一个术语的创始人。这是我自己的错,我没告诉 Eric 细节。我一时冲动只想让它表决通过然后我呆在后台,但是 Todd 不这样认为。他认为我总有一天将作为“开源软件”这个名词的创造者而感到高兴。他向 Eric 解释了这个情况,Eric 及时更新了它的网站。 想出这个短语只是一个小贡献,但是我得承认我十分感激那些把它归功于我的人。每次我听到它,它都给我些许激动的喜悦,到现在也时常感受到。 From bfc6e8c90a58bb9533011d0d037861734c0feda5 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Wed, 7 Mar 2018 08:30:59 +0800 Subject: [PATCH 0010/1057] 2018-03-07 --- sources/talk/20180201 How I coined the term open source.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index f830e4beb6..12e8421121 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -25,7 +25,7 @@ The introduction of the term "open source software" was 是特地为了这个领 在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 -At these meetings, we discussed the need for a new term due to the confusion factor. 观点主要有以下:对于那些新接触“自由软件”的人把它(free)当成了价格。 Oldtimers must then launch into an explanation, usually given as follows: “我们的意思是自由上的,而不是啤酒免费上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。At this point, a discussion on software has turned into one about the price of an alcoholic beverage. The problem was not that explaining the meaning is impossible—the problem was that the name for an important idea should not be so confusing to newcomers. A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. +在这些会议中,我们讨论了由于一些使人迷惑不解的原因而产生一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把它(free)当成了价格。老资格的成员们肯定开始一个解释,通常像下面所说的那样:“我们的意思是自由上的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. ### 网景发布 From a3f7b1dc529f0879fc092a7a4071aceaeebfc2e6 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Thu, 8 Mar 2018 12:14:18 +0800 Subject: [PATCH 0011/1057] 2018-03-08 --- sources/talk/20180201 How I coined the term open source.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 12e8421121..774e0b397a 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -29,7 +29,7 @@ The introduction of the term "open source software" was 是特地为了这个领 ### 网景发布 -1998 年 2 月 2 日,Eric Raymond 抵达访问网景并与它一起计划采用免费软件样式的许可证发布浏览器代码。We held a meeting that night at Foresight's office in Los Altos to strategize and refine our message.除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。但在那次会议上,这个领域仍然被描述成“自由软件”,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 +1998 年 2 月 2 日,Eric Raymond 抵达访问网景并与它一起计划采用免费软件样式的许可证发布浏览器代码。我们那晚在前瞻位于罗斯阿尔托斯(Los Altos)的办公室制定了策略并改进了我们的要旨。除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。但在那次会议上,这个领域仍然被描述成“自由软件”,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 While in town, Eric used Foresight as a base of operations. At one point during his visit, he was called to the phone to talk with a couple of Netscape legal and/or marketing staff. When he was finished, I asked to be put on the phone with them—one man and one woman, perhaps Mitchell Baker—so I could bring up the need for a new term. They agreed in principle immediately, but no specific term was agreed upon. @@ -57,7 +57,7 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti 在那之后的一段时间,这条术语由 Eric Raymond 向媒体推广,由 Tim O'Reilly 向商业推广,并由二人向编程社区推广,那似乎传播的相当快。 -1998 年 4 月 17 日, Tim O'Reilly 提前宣布 首届 “[自由软件峰会][10]” 在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 +1998 年 4 月 17 日, Tim O'Reilly 提前宣布首届 “[自由软件峰会][10]” ,在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. From da282c11b1c3acab13bce9ddb96001be2596b1bb Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Fri, 9 Mar 2018 08:26:38 +0800 Subject: [PATCH 0012/1057] 2018-03-09 --- sources/talk/20180201 How I coined the term open source.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 774e0b397a..8a06af7910 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -25,13 +25,13 @@ The introduction of the term "open source software" was 是特地为了这个领 在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 -在这些会议中,我们讨论了由于一些使人迷惑不解的原因而产生一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把它(free)当成了价格。老资格的成员们肯定开始一个解释,通常像下面所说的那样:“我们的意思是自由上的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。A clearer term was needed. No political issues were raised regarding the free software term; the issue was its lack of clarity to those new to the concept. +在这些会议中,我们讨论了由于一些使人迷惑不解的因素而产生一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把 "free" 当成了价格上的 “免费” 。老资格的成员们开始解释,通常像下面所说的那样:“我们的意思是自由的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。所以需要一个更清晰的术语了。关于自由软件术语并没有政治上的问题;问题是缺乏对新概念的认识。 ### 网景发布 1998 年 2 月 2 日,Eric Raymond 抵达访问网景并与它一起计划采用免费软件样式的许可证发布浏览器代码。我们那晚在前瞻位于罗斯阿尔托斯(Los Altos)的办公室制定了策略并改进了我们的要旨。除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。但在那次会议上,这个领域仍然被描述成“自由软件”,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 -While in town, Eric used Foresight as a base of operations. At one point during his visit, he was called to the phone to talk with a couple of Netscape legal and/or marketing staff. When he was finished, I asked to be put on the phone with them—one man and one woman, perhaps Mitchell Baker—so I could bring up the need for a new term. They agreed in principle immediately, but no specific term was agreed upon. +在这个镇上,Eric 把前瞻协会(Foresight) 作为行动的大本营。他一开始访问行程,他就被几个网景法律和市场部门的员工通电话。当他挂电话后,我被要求带着电话跟他们——一男一女,可能是 Mitchell Baker——这样我才能谈论对于新术语的需求。他们原则上是立即同意了,但详细条款并未达成协议。 在那周的会议中,我仍然关注一个更好的名字Between meetings that week, I was still focused on the need for a better name and 提出术语 “开源软件”came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, while a friend in marketing and public relations felt the term "open" had been overused and abused and 相信我们能做的更好。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 From 6d36a1b749df9246a4078d0fdb0c2f3479007821 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sat, 10 Mar 2018 08:17:34 +0800 Subject: [PATCH 0013/1057] 2018-03-09 --- sources/talk/20180201 How I coined the term open source.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 8a06af7910..977346af0c 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -51,7 +51,7 @@ Toward the end of the meeting, the [question of terminology][8] was brought up But I was elated. These were some key leaders in the community, and they liked the new name, or at least didn't object. This was a very good sign. There was probably not much more I could do to help; Eric Raymond was far better positioned to spread the new meme, and he did. Bruce Perens signed on to the effort immediately, helping set up [Opensource.org][9] and playing a key role in spreading the new term. -For the name to succeed, it was necessary, or at least highly desirable, that Tim O'Reilly agree and actively use it in his many projects on behalf of the community. Also helpful would be use of the term in the upcoming official release of the Netscape Navigator code. By late February, both O'Reilly & Associates and Netscape had started to use the term. +对于成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。 Also helpful would be use of the term in the upcoming official release of the Netscape Navigator code. 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 ### 名字的诞生 @@ -59,7 +59,7 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti 1998 年 4 月 17 日, Tim O'Reilly 提前宣布首届 “[自由软件峰会][10]” ,在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 -这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. I strongly believe that the new term was helpful in enabling this rapid spread into business, which then enabled wider use by the public. +这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. 我十分相信新术语能对快速传播到商业很有帮助,能被公众广泛使用。 尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,特别是和偏爱它的人们沟通的时候。 @@ -69,7 +69,7 @@ For the name to succeed, it was necessary, or at least highly desirable, that Ti 想出这个短语只是一个小贡献,但是我得承认我十分感激那些把它归功于我的人。每次我听到它,它都给我些许激动的喜悦,到现在也时常感受到。 -说服团队的大功劳归功于Eric Raymond和 Tim O'Reilly,这是他们搞定的。感谢他们对我的评价,并感谢Todd Anderson 在整个过程中的角色。以上内容并非完整的开源历史记录,对很多没有无名人士表示歉意。那些寻求更完整讲述的人应该参考本文和网上其他地方的链接。 +说服团队的大功劳归功于 Eric Raymond 和 Tim O'Reilly,这是他们搞定的。感谢他们对我的评价,并感谢 Todd Anderson 在整个过程中的角色。以上内容并非完整的开源历史记录,对很多没有无名人士表示歉意。那些寻求更完整讲述的人应该参考本文和网上其他地方的链接。 ### 关于作者 From 5bae87fc1679843c944557d0f9bfaf59957040d4 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sun, 11 Mar 2018 09:29:05 +0800 Subject: [PATCH 0014/1057] 2018-03-10 --- .../talk/20180201 How I coined the term open source.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 977346af0c..29d7364904 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -39,9 +39,9 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, ### 关键的会议 -Later that week, on February 5, 1998, a group was assembled at VA Research to brainstorm on strategy. Attending—in addition to Eric Raymond, Todd, and me—were Larry Augustin, Sam Ockman, and attending by phone, Jon "maddog" Hall. +那周之后,1998 年的 2 月 5 日,一伙人在 VA research 进行头脑风暴商量对策。与会者——除了 Eric Raymond,Todd和我之外,还有 Larry Augustin,Sam Ockman,还有Jon“maddog”Hall 的电话。 -会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. +会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. Fortunately, Todd was on the ball. Instead of making an assertion that the community should use this specific new term, he did something less directive—a smart thing to do with this community of strong-willed individuals. He simply used the term in a sentence on another topic—just dropped it into the conversation to see what happened. I went on alert, hoping for a response, but there was none at first. The discussion continued on the original topic. It seemed only he and I had noticed the usage. @@ -51,7 +51,7 @@ Toward the end of the meeting, the [question of terminology][8] was brought up But I was elated. These were some key leaders in the community, and they liked the new name, or at least didn't object. This was a very good sign. There was probably not much more I could do to help; Eric Raymond was far better positioned to spread the new meme, and he did. Bruce Perens signed on to the effort immediately, helping set up [Opensource.org][9] and playing a key role in spreading the new term. -对于成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。 Also helpful would be use of the term in the upcoming official release of the Netscape Navigator code. 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 +对于这个成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。 Also helpful would be use of the term in the upcoming official release of the Netscape Navigator code. 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 ### 名字的诞生 @@ -65,7 +65,7 @@ But I was elated. These were some key leaders in the community, and they liked t ### 一丝快感 -当一个被 Eric Raymond写的有关修改术语的早期的陈述被发布在了开放源代码促进会的网站上时,我上了 VA 头脑风暴会议的名单,但并不是作为一个术语的创始人。这是我自己的错,我没告诉 Eric 细节。我一时冲动只想让它表决通过然后我呆在后台,但是 Todd 不这样认为。他认为我总有一天将作为“开源软件”这个名词的创造者而感到高兴。他向 Eric 解释了这个情况,Eric 及时更新了它的网站。 +当一个被 Eric Raymond 写的有关修改术语的早期的陈述被发布在了开放源代码促进会的网站上时,我上了 VA 头脑风暴会议的名单,但并不是作为一个术语的创始人。这是我自己的错,我没告诉 Eric 细节。我当时一时冲动只想让它表决通过然后我只是呆在后台,但是 Todd 不这样认为。他认为我总有一天将作为“开源软件”这个名词的创造者而感到高兴。他向 Eric 解释了这个情况,Eric 及时更新了它的网站。 想出这个短语只是一个小贡献,但是我得承认我十分感激那些把它归功于我的人。每次我听到它,它都给我些许激动的喜悦,到现在也时常感受到。 From 9cac8f5bcb1bbfbe58f2d9503e25b305a81e4506 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Mon, 12 Mar 2018 07:27:02 +0800 Subject: [PATCH 0015/1057] 2018-03-11 --- sources/talk/20180201 How I coined the term open source.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 29d7364904..964c0ccc70 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -43,7 +43,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. -Fortunately, Todd was on the ball. Instead of making an assertion that the community should use this specific new term, he did something less directive—a smart thing to do with this community of strong-willed individuals. He simply used the term in a sentence on another topic—just dropped it into the conversation to see what happened. I went on alert, hoping for a response, but there was none at first. The discussion continued on the original topic. It seemed only he and I had noticed the usage. +Fortunately, Todd was on the ball. 他没有主张社区应该用哪个特定的术语,而是间接地做了一些事——一件和社区里有强烈意愿的人做的明智之举。他简单地在其他话题中使用那个术语——把他放进对话里看看会发生什么。我警觉起来,希望得到一个答复,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了术语的使用。 Not so—memetic evolution was in action. A few minutes later, one of the others used the term, evidently without noticing, still discussing a topic other than terminology. Todd and I looked at each other out of the corners of our eyes to check: yes, we had both noticed what happened. I was excited—it might work! But I kept quiet: I still had low status in this group. Probably some were wondering why Eric had invited me at all. From 4fd3b9b1e2c92c900e2d2f686c34ab74d0dbb091 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Mon, 12 Mar 2018 07:27:02 +0800 Subject: [PATCH 0016/1057] 2018-03-11 --- sources/talk/20180201 How I coined the term open source.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 29d7364904..964c0ccc70 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -43,7 +43,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. -Fortunately, Todd was on the ball. Instead of making an assertion that the community should use this specific new term, he did something less directive—a smart thing to do with this community of strong-willed individuals. He simply used the term in a sentence on another topic—just dropped it into the conversation to see what happened. I went on alert, hoping for a response, but there was none at first. The discussion continued on the original topic. It seemed only he and I had noticed the usage. +Fortunately, Todd was on the ball. 他没有主张社区应该用哪个特定的术语,而是间接地做了一些事——一件和社区里有强烈意愿的人做的明智之举。他简单地在其他话题中使用那个术语——把他放进对话里看看会发生什么。我警觉起来,希望得到一个答复,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了术语的使用。 Not so—memetic evolution was in action. A few minutes later, one of the others used the term, evidently without noticing, still discussing a topic other than terminology. Todd and I looked at each other out of the corners of our eyes to check: yes, we had both noticed what happened. I was excited—it might work! But I kept quiet: I still had low status in this group. Probably some were wondering why Eric had invited me at all. From 5207ae3b74cf197c1f40342539997a76695bb489 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Tue, 13 Mar 2018 11:06:51 +0800 Subject: [PATCH 0017/1057] 2018-03-13 --- .../talk/20180201 How I coined the term open source.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 964c0ccc70..d4e23174ed 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -17,9 +17,9 @@ * * * -The introduction of the term "open source software" was 是特地为了这个领域让新手和商业人士更加易懂a deliberate effort to make this field of endeavor more understandable to newcomers and to business, which was viewed as necessary to its spread to a broader community of users. 早期称号的问题是,“自由软件”,并非有政治含义,但是那对于新手来说貌似对于价格的关注令人心烦意乱。一个术语需要聚焦于源代码的关键问题而且不会被立即把概念跟那些新东西混淆。一个恰好想出并且满足这些要求的第一个术语被快速接受:开源。 +推行术语“开源软件” 是特地为了这个领域让新手和商业人士更加易懂a deliberate effort to make this field of endeavor more understandable to newcomers and to business, which was viewed as necessary to its spread to a broader community of users. 早期称号的问题是,“自由软件”,并非有政治含义,但是那对于新手来说貌似对于价格的关注令人心烦意乱。一个术语需要聚焦于源代码的关键问题而且不会被立即把概念跟那些新东西混淆。一个恰好想出并且满足这些要求的第一个术语被快速接受:开源。 -这个术语很长一段时间被用在“情报”(即间谍活动)的情境下,但据我所知but to my knowledge, use of the term with respect to software prior to 1998 has not been confirmed. 下面这个就是讲述了术语“开源软件”如何流行起来并且变成了一项产业和一场运动的名字。 +这个术语很长一段时间被用在“情报”(即间谍活动)的情境下,但据我所知,在1998年以前对软件使用该术语尚未得到证实。下面这个就是讲述了术语“开源软件”如何流行并且变成了一项产业和一场运动的名字的故事。 ### 计算机安全会议 @@ -33,13 +33,13 @@ The introduction of the term "open source software" was 是特地为了这个领 在这个镇上,Eric 把前瞻协会(Foresight) 作为行动的大本营。他一开始访问行程,他就被几个网景法律和市场部门的员工通电话。当他挂电话后,我被要求带着电话跟他们——一男一女,可能是 Mitchell Baker——这样我才能谈论对于新术语的需求。他们原则上是立即同意了,但详细条款并未达成协议。 -在那周的会议中,我仍然关注一个更好的名字Between meetings that week, I was still focused on the need for a better name and 提出术语 “开源软件”came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, while a friend in marketing and public relations felt the term "open" had been overused and abused and 相信我们能做的更好。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 +在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关朋友觉得术语“open”被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 ### 关键的会议 -那周之后,1998 年的 2 月 5 日,一伙人在 VA research 进行头脑风暴商量对策。与会者——除了 Eric Raymond,Todd和我之外,还有 Larry Augustin,Sam Ockman,还有Jon“maddog”Hall 的电话。 +那周之后,1998 年的 2 月 5 日,一伙人在 VA research 进行头脑风暴商量对策。与会者——除了 Eric Raymond,Todd和我之外,还有 Larry Augustin,Sam Ockman,还有 Jon“maddog”Hall 的电话。 会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. @@ -47,7 +47,7 @@ Fortunately, Todd was on the ball. 他没有主张社区应该用哪个特定的 Not so—memetic evolution was in action. A few minutes later, one of the others used the term, evidently without noticing, still discussing a topic other than terminology. Todd and I looked at each other out of the corners of our eyes to check: yes, we had both noticed what happened. I was excited—it might work! But I kept quiet: I still had low status in this group. Probably some were wondering why Eric had invited me at all. -Toward the end of the meeting, the [question of terminology][8] was brought up explicitly, probably by Todd or Eric. Maddog mentioned "freely distributable" as an earlier term, and "cooperatively developed" as a newer term. Eric listed "free software," "open source," and "sourceware" as the main options. Todd advocated the "open source" model, and Eric endorsed this. I didn't say much, letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. Only about 10% of my notes from this meeting are on the terminology question. +临近会议尾声,Toward the end of the meeting, the [question of terminology][8] was brought up explicitly, probably by Todd or Eric. Maddog mentioned "freely distributable" as an earlier term, and "cooperatively developed" as a newer term. Eric listed "free software," "open source," and "sourceware" as the main options. Todd advocated the "open source" model, and Eric endorsed this. I didn't say much, letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有大约10%我在会议中的说明都放在了术语问答中。 But I was elated. These were some key leaders in the community, and they liked the new name, or at least didn't object. This was a very good sign. There was probably not much more I could do to help; Eric Raymond was far better positioned to spread the new meme, and he did. Bruce Perens signed on to the effort immediately, helping set up [Opensource.org][9] and playing a key role in spreading the new term. From 3049a5b6335f717ad892c0ee669ac29720c4adfe Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Wed, 14 Mar 2018 07:22:21 +0800 Subject: [PATCH 0018/1057] 2018-3-14 --- sources/talk/20180201 How I coined the term open source.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index d4e23174ed..5d2e3f2e6e 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -33,7 +33,7 @@ 在这个镇上,Eric 把前瞻协会(Foresight) 作为行动的大本营。他一开始访问行程,他就被几个网景法律和市场部门的员工通电话。当他挂电话后,我被要求带着电话跟他们——一男一女,可能是 Mitchell Baker——这样我才能谈论对于新术语的需求。他们原则上是立即同意了,但详细条款并未达成协议。 -在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关朋友觉得术语“open”被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 +在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关的朋友觉得术语“open”被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 @@ -43,11 +43,11 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. -Fortunately, Todd was on the ball. 他没有主张社区应该用哪个特定的术语,而是间接地做了一些事——一件和社区里有强烈意愿的人做的明智之举。他简单地在其他话题中使用那个术语——把他放进对话里看看会发生什么。我警觉起来,希望得到一个答复,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了术语的使用。 +幸运的是,Todd 是明智的。他没有主张社区应该用哪个特定的术语,而是间接地做了一些事——一件和社区里有强烈意愿的人做的明智之举。他简单地在其他话题中使用那个术语——把他放进对话里看看会发生什么。我警觉起来,希望得到一个答复,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了术语的使用。 Not so—memetic evolution was in action. A few minutes later, one of the others used the term, evidently without noticing, still discussing a topic other than terminology. Todd and I looked at each other out of the corners of our eyes to check: yes, we had both noticed what happened. I was excited—it might work! But I kept quiet: I still had low status in this group. Probably some were wondering why Eric had invited me at all. -临近会议尾声,Toward the end of the meeting, the [question of terminology][8] was brought up explicitly, probably by Todd or Eric. Maddog mentioned "freely distributable" as an earlier term, and "cooperatively developed" as a newer term. Eric listed "free software," "open source," and "sourceware" as the main options. Todd advocated the "open source" model, and Eric endorsed this. I didn't say much, letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有大约10%我在会议中的说明都放在了术语问答中。 +临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有我在会议中大约10%的说明放在了术语问答中。 But I was elated. These were some key leaders in the community, and they liked the new name, or at least didn't object. This was a very good sign. There was probably not much more I could do to help; Eric Raymond was far better positioned to spread the new meme, and he did. Bruce Perens signed on to the effort immediately, helping set up [Opensource.org][9] and playing a key role in spreading the new term. From 3304c40240e735311f2d6e658575abd26c21949f Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Thu, 15 Mar 2018 11:08:33 +0800 Subject: [PATCH 0019/1057] a bit confusion --- .../talk/20180201 How I coined the term open source.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 5d2e3f2e6e..21f5b8e86b 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -25,7 +25,7 @@ 在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 -在这些会议中,我们讨论了由于一些使人迷惑不解的因素而产生一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把 "free" 当成了价格上的 “免费” 。老资格的成员们开始解释,通常像下面所说的那样:“我们的意思是自由的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。所以需要一个更清晰的术语了。关于自由软件术语并没有政治上的问题;问题是缺乏对新概念的认识。 +在这些会议中,我们讨论了一些由于使人迷惑不解的因素而产生一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把 "free" 当成了价格上的 “免费” 。老资格的成员们开始解释,通常像下面所说的那样:“我们的意思是自由的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。所以需要一个更清晰的术语了。关于自由软件术语并没有政治上的问题;问题是缺乏对新概念的认识。 ### 网景发布 @@ -49,9 +49,9 @@ Not so—memetic evolution was in action. A few minutes later, one of the others 临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有我在会议中大约10%的说明放在了术语问答中。 -But I was elated. These were some key leaders in the community, and they liked the new name, or at least didn't object. This was a very good sign. There was probably not much more I could do to help; Eric Raymond was far better positioned to spread the new meme, and he did. Bruce Perens signed on to the effort immediately, helping set up [Opensource.org][9] and playing a key role in spreading the new term. +但是我很高兴。那有许多社区的关键领导人,并且他们喜欢新名字,或者至少没反对。这是一个好的信号信号。可能我帮不上什么忙; Eric Raymond was far better positioned to spread the new meme, and he did. Bruce Perens signed on to the effort immediately, 帮助建立 [Opensource.org][9] 并在新术语的宣传中扮演一个重要角色。 -对于这个成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。 Also helpful would be use of the term in the upcoming official release of the Netscape Navigator code. 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 +对于这个成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。 Also helpful would be use of the term in the upcoming official release of the Netscape Navigator(网景浏览器)代码。 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 ### 名字的诞生 @@ -59,7 +59,7 @@ But I was elated. These were some key leaders in the community, and they liked t 1998 年 4 月 17 日, Tim O'Reilly 提前宣布首届 “[自由软件峰会][10]” ,在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 -这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。Reading Slashdot became a necessity, even for those like me who were only peripherally involved. 我十分相信新术语能对快速传播到商业很有帮助,能被公众广泛使用。 +这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。读 Slashdot(科技资讯网站)已经成了一个必需操作, even for those like me who were only peripherally involved. 我十分相信新术语能对快速传播到商业很有帮助,能被公众广泛使用。 尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,特别是和偏爱它的人们沟通的时候。 From af2f8d95b81bababd4ce65cdcecd010457db3caa Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Fri, 16 Mar 2018 07:31:58 +0800 Subject: [PATCH 0020/1057] 2018-3-16 --- sources/talk/20180201 How I coined the term open source.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 21f5b8e86b..c19154ea4d 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -45,7 +45,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 幸运的是,Todd 是明智的。他没有主张社区应该用哪个特定的术语,而是间接地做了一些事——一件和社区里有强烈意愿的人做的明智之举。他简单地在其他话题中使用那个术语——把他放进对话里看看会发生什么。我警觉起来,希望得到一个答复,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了术语的使用。 -Not so—memetic evolution was in action. A few minutes later, one of the others used the term, evidently without noticing, still discussing a topic other than terminology. Todd and I looked at each other out of the corners of our eyes to check: yes, we had both noticed what happened. I was excited—it might work! But I kept quiet: I still had low status in this group. Probably some were wondering why Eric had invited me at all. +不仅如此——模因演化(人类学术语)在起作用。几分钟后,另一个人明显地,没有提醒地,在仍然进行话题讨论而没说术语的情况下,用了这个术语。Todd 和我面面相觑对视:是的我们都注意到了发生的事。我很激动——它起作用了!但我保持了安静:我在小组中仍然地位不高。可能有些人都奇怪为什么 Eric 会最终邀请我。 临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有我在会议中大约10%的说明放在了术语问答中。 From c91b73998d65597cf8f72b35c674771a06112f13 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sat, 17 Mar 2018 07:37:02 +0800 Subject: [PATCH 0021/1057] 2018-03-17 --- .../talk/20180201 How I coined the term open source.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index c19154ea4d..ef99769b3b 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -41,17 +41,17 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 那周之后,1998 年的 2 月 5 日,一伙人在 VA research 进行头脑风暴商量对策。与会者——除了 Eric Raymond,Todd和我之外,还有 Larry Augustin,Sam Ockman,还有 Jon“maddog”Hall 的电话。 -会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。I felt that it wouldn't work for me to just blurt out, "All you technical people should start using my new term." Most of those attending didn't know me, and for all I knew, they might not even agree that a new term was greatly needed, or even somewhat desirable. +会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。 幸运的是,Todd 是明智的。他没有主张社区应该用哪个特定的术语,而是间接地做了一些事——一件和社区里有强烈意愿的人做的明智之举。他简单地在其他话题中使用那个术语——把他放进对话里看看会发生什么。我警觉起来,希望得到一个答复,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了术语的使用。 不仅如此——模因演化(人类学术语)在起作用。几分钟后,另一个人明显地,没有提醒地,在仍然进行话题讨论而没说术语的情况下,用了这个术语。Todd 和我面面相觑对视:是的我们都注意到了发生的事。我很激动——它起作用了!但我保持了安静:我在小组中仍然地位不高。可能有些人都奇怪为什么 Eric 会最终邀请我。 -临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有我在会议中大约10%的说明放在了术语问答中。 +临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric 列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有我在会议中大约10%的说明放在了术语问答中。 -但是我很高兴。那有许多社区的关键领导人,并且他们喜欢新名字,或者至少没反对。这是一个好的信号信号。可能我帮不上什么忙; Eric Raymond was far better positioned to spread the new meme, and he did. Bruce Perens signed on to the effort immediately, 帮助建立 [Opensource.org][9] 并在新术语的宣传中扮演一个重要角色。 +但是我很高兴。在那有许多社区的关键领导人,并且他们喜欢这新名字,或者至少没反对。这是一个好的信号信号。可能我帮不上什么忙; Eric Raymond 被相当好地放在了一个宣传模因的好位子上,而且他的确做到了。立即签约参加行动,帮助建立 [Opensource.org][9] 并在新术语的宣传中发挥重要作用。 -对于这个成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。 Also helpful would be use of the term in the upcoming official release of the Netscape Navigator(网景浏览器)代码。 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 +对于这个成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。在官方即将发布的 the Netscape Navigator(网景浏览器)代码中的术语使用也为此帮了忙。 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 ### 名字的诞生 From 2f2306a13f1936049b0433634c96845ef07df3d5 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sun, 18 Mar 2018 07:51:29 +0800 Subject: [PATCH 0022/1057] 2017-03-18 --- sources/talk/20180201 How I coined the term open source.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index ef99769b3b..ec6925bd77 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -33,7 +33,7 @@ 在这个镇上,Eric 把前瞻协会(Foresight) 作为行动的大本营。他一开始访问行程,他就被几个网景法律和市场部门的员工通电话。当他挂电话后,我被要求带着电话跟他们——一男一女,可能是 Mitchell Baker——这样我才能谈论对于新术语的需求。他们原则上是立即同意了,但详细条款并未达成协议。 -在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”came up with the term "open source software." While not ideal, it struck me as good enough. I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关的朋友觉得术语“open”被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 +在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”came up with the term "open source software." 虽然那不是完美的,但我觉得足够好了。I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关的朋友觉得术语 “open” 被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 @@ -47,7 +47,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 不仅如此——模因演化(人类学术语)在起作用。几分钟后,另一个人明显地,没有提醒地,在仍然进行话题讨论而没说术语的情况下,用了这个术语。Todd 和我面面相觑对视:是的我们都注意到了发生的事。我很激动——它起作用了!但我保持了安静:我在小组中仍然地位不高。可能有些人都奇怪为什么 Eric 会最终邀请我。 -临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric 列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. It was clear that to most of those at the meeting, the name change was not the most important thing discussed there; a relatively minor issue. 只有我在会议中大约10%的说明放在了术语问答中。 +临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric 列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. 对于大多数与会者,他们很清楚改名不是在这讨论的最重要议题;那只是一个次要的相关议题。 我在会议中只有大约10%的说明放在了术语问答中。 但是我很高兴。在那有许多社区的关键领导人,并且他们喜欢这新名字,或者至少没反对。这是一个好的信号信号。可能我帮不上什么忙; Eric Raymond 被相当好地放在了一个宣传模因的好位子上,而且他的确做到了。立即签约参加行动,帮助建立 [Opensource.org][9] 并在新术语的宣传中发挥重要作用。 @@ -59,7 +59,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 1998 年 4 月 17 日, Tim O'Reilly 提前宣布首届 “[自由软件峰会][10]” ,在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 -这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。读 Slashdot(科技资讯网站)已经成了一个必需操作, even for those like me who were only peripherally involved. 我十分相信新术语能对快速传播到商业很有帮助,能被公众广泛使用。 +这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。读 Slashdot(科技资讯网站)已经成了一个必需操作, 甚至对于那些像我一样只能外围地参与者亦是如此。我坚信新术语能对快速传播到商业很有帮助,能被公众广泛使用。 尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,特别是和偏爱它的人们沟通的时候。 From e0b2d7bb487cd3f51bb8057925bb8772ab69db2e Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Mon, 19 Mar 2018 08:20:54 +0800 Subject: [PATCH 0023/1057] almost done --- ...80201 How I coined the term open source.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index ec6925bd77..0f2c6a7852 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -7,25 +7,25 @@ ![How I coined the term 'open source'](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb "How I coined the term 'open source'") 图片来自: opensource.com -几天后, 2 月 3 日, 术语 "[开源软件][6]" 创立20周年的纪念日即将到来。由于开源软件渐受欢迎并且为这个时代强有力的重要变革提供动力,我们仔细思考了它的初生到崛起。 +几天后, 2 月 3 日, 术语“[开源软件][6]”创立 20 周年的纪念日即将到来。由于开源软件渐受欢迎并且为这个时代强有力的重要变革提供动力,我们仔细反思了它的初生到崛起。 我是 “开源软件” 这个词的始作俑者,它是我在前瞻技术协会(Foresight Institute)担任执行董事时想出的。并非向上面的一个程序开发者一样,我感谢 Linux 程序员 Todd Anderson 对这个术语的支持并将它提交小组讨论。 -这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些关于该术语的记叙,例如 Eric Raymond 和 Richard Stallman 写的,而我的,则写于 2006 年 1 月 2 日。 +这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些有关该术语的记叙,例如 Eric Raymond 和 Richard Stallman 写的,而我的,则写于 2006 年 1 月 2 日。 -直到今天,它才公诸于世。 +直到今天,它终于公诸于世。 * * * -推行术语“开源软件” 是特地为了这个领域让新手和商业人士更加易懂a deliberate effort to make this field of endeavor more understandable to newcomers and to business, which was viewed as necessary to its spread to a broader community of users. 早期称号的问题是,“自由软件”,并非有政治含义,但是那对于新手来说貌似对于价格的关注令人心烦意乱。一个术语需要聚焦于源代码的关键问题而且不会被立即把概念跟那些新东西混淆。一个恰好想出并且满足这些要求的第一个术语被快速接受:开源。 +推行术语“开源软件”是特地为了这个领域让新手和商业人士更加易懂,它的推广被认为对于更大的用户社区很有必要。早期称号的问题是,“自由软件” 并非有政治含义,但是那对于新手来说貌似对于价格的关注令人感到心烦意乱。一个术语需要聚焦于关键的源代码而且不会被立即把概念跟那些新东西混淆。一个恰好想出并且满足这些要求的第一个术语被快速接受:开源(open source)。 -这个术语很长一段时间被用在“情报”(即间谍活动)的情境下,但据我所知,在1998年以前对软件使用该术语尚未得到证实。下面这个就是讲述了术语“开源软件”如何流行并且变成了一项产业和一场运动的名字的故事。 +这个术语很长一段时间被用在“情报”(即间谍活动)的背景下,但据我所知,1998 年以前软件领域使用该术语尚未得到证实。下面这个就是讲述了术语“开源软件”如何流行起来并且变成了一项产业和一场运动名称的故事。 ### 计算机安全会议 -在1997年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 +在 1997 年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 -在这些会议中,我们讨论了一些由于使人迷惑不解的因素而产生一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把 "free" 当成了价格上的 “免费” 。老资格的成员们开始解释,通常像下面所说的那样:“我们的意思是自由的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。所以需要一个更清晰的术语了。关于自由软件术语并没有政治上的问题;问题是缺乏对新概念的认识。 +在这些会议中,我们讨论了一些由于使人迷惑不解的因素而采用一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把 "free" 当成了价格上的 “免费” 。老资格的成员们开始解释,通常像下面所说的:“我们的意思是自由的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。所以需要一个更清晰的术语了。关于自由软件术语并没有政治上的问题;问题是缺乏对新概念的认识。 ### 网景发布 @@ -33,7 +33,7 @@ 在这个镇上,Eric 把前瞻协会(Foresight) 作为行动的大本营。他一开始访问行程,他就被几个网景法律和市场部门的员工通电话。当他挂电话后,我被要求带着电话跟他们——一男一女,可能是 Mitchell Baker——这样我才能谈论对于新术语的需求。他们原则上是立即同意了,但详细条款并未达成协议。 -在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”came up with the term "open source software." 虽然那不是完美的,但我觉得足够好了。I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关的朋友觉得术语 “open” 被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 +在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”。 虽然那不是完美的,但我觉得足够好了。I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关的朋友觉得术语 “open” 被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 @@ -47,7 +47,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, 不仅如此——模因演化(人类学术语)在起作用。几分钟后,另一个人明显地,没有提醒地,在仍然进行话题讨论而没说术语的情况下,用了这个术语。Todd 和我面面相觑对视:是的我们都注意到了发生的事。我很激动——它起作用了!但我保持了安静:我在小组中仍然地位不高。可能有些人都奇怪为什么 Eric 会最终邀请我。 -临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric 列出了“自由软件”、“开源软件”,并把[unknown]作为主要选项。Todd宣传“开源”模型,然后Eric 支持了他。我什么也没说,letting Todd and Eric pull the (loose, informal) consensus together around the open source name. 对于大多数与会者,他们很清楚改名不是在这讨论的最重要议题;那只是一个次要的相关议题。 我在会议中只有大约10%的说明放在了术语问答中。 +临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric 列出了“自由软件”、“开源软件”,并把 "自由软件源" 作为一个主要选项。Todd宣传 “开源” 模型,然后Eric 支持了他。我什么也没说,让 Todd 和 Eric 共同促进开源名字达成共识。对于大多数与会者,他们很清楚改名不是在这讨论的最重要议题;那只是一个次要的相关议题。 我在会议中只有大约10%的说明放在了术语问答中。 但是我很高兴。在那有许多社区的关键领导人,并且他们喜欢这新名字,或者至少没反对。这是一个好的信号信号。可能我帮不上什么忙; Eric Raymond 被相当好地放在了一个宣传模因的好位子上,而且他的确做到了。立即签约参加行动,帮助建立 [Opensource.org][9] 并在新术语的宣传中发挥重要作用。 @@ -73,7 +73,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, ### 关于作者 - [![photo of Christine Peterson](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/cp2016_crop2_185.jpg?itok=vUkSjFig)][13] Christine Peterson - Christine Peterson writes, lectures, and briefs the media on coming powerful technologies, especially nanotechnology, artificial intelligence, and longevity. She is Cofounder and Past President of Foresight Institute, the leading nanotech public interest group. Foresight educates the public, technical community, and policymakers on coming powerful technologies and how to guide their long-term impact. She serves on the Advisory Board of the [Machine Intelligence... ][2][more about Christine Peterson][3][More about me][4] + [![photo of Christine Peterson](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/cp2016_crop2_185.jpg?itok=vUkSjFig)][13] Christine Peterson - Christine Peterson 撰写,举办讲座 lectures, and briefs the media on coming powerful technologies, especially nanotechnology, artificial intelligence, and longevity. She is Cofounder and Past President of Foresight Institute, the leading nanotech public interest group. Foresight educates the public, technical community, and policymakers on coming powerful technologies and how to guide their long-term impact. She serves on the Advisory Board of the [Machine Intelligence... ][2][more about Christine Peterson][3][More about me][4] -------------------------------------------------------------------------------- From edc4198a3b21c37bb24bebe617782883c16a1ed9 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Tue, 20 Mar 2018 10:47:55 +0800 Subject: [PATCH 0024/1057] 2018-03-20 --- sources/talk/20180201 How I coined the term open source.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 0f2c6a7852..7d41259cc3 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -73,7 +73,7 @@ Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助, ### 关于作者 - [![photo of Christine Peterson](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/cp2016_crop2_185.jpg?itok=vUkSjFig)][13] Christine Peterson - Christine Peterson 撰写,举办讲座 lectures, and briefs the media on coming powerful technologies, especially nanotechnology, artificial intelligence, and longevity. She is Cofounder and Past President of Foresight Institute, the leading nanotech public interest group. Foresight educates the public, technical community, and policymakers on coming powerful technologies and how to guide their long-term impact. She serves on the Advisory Board of the [Machine Intelligence... ][2][more about Christine Peterson][3][More about me][4] + [![photo of Christine Peterson](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/cp2016_crop2_185.jpg?itok=vUkSjFig)][13] Christine Peterson - Christine Peterson 撰写,举办讲座,并向媒体介绍未来强大的技术,特别是纳米技术,人工智能和长寿。她是著名的纳米科技公共利益集团的创始人和过去的前瞻技术协会主席。前瞻向公众、技术团体和政策制定者提供未来强大的技术的教育以及告诉它是如何引导他们的长期影响。她服务于 [机器智能 ][2]咨询委员会……[更多关于 Christine Peterson][3][关于我][4] -------------------------------------------------------------------------------- From cba55e2228808548948afcfb77a31b723a180976 Mon Sep 17 00:00:00 2001 From: leemeans <1808577072@qq.com> Date: Tue, 20 Mar 2018 10:56:05 +0800 Subject: [PATCH 0025/1057] Update 20180227 How to block local spoofed addresses using the Linux firewall.md nearly half --- ...ock local spoofed addresses using the Linux firewall.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md b/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md index 2ea760e636..cd3dddd934 100644 --- a/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md +++ b/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md @@ -1,20 +1,27 @@ leemeans translating How to block local spoofed addresses using the Linux firewall +如何使用Linux防火墙隔离局域网受欺骗地址 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_UnspokenBlockers_1110_A.png?itok=x8A9mqVA) Attackers are finding sophisticated ways to penetrate even remote networks that are protected by intrusion detection and prevention systems. No IDS/IPS can halt or minimize attacks by hackers who are determined to take over your network. Improper configuration allows attackers to bypass all implemented network security measures. +即便是被入侵检测和隔离系统保护的远程网络,黑客们也在寻找精致的方法入侵。IDS/IPS是不能停止或者减少那些想要接管你的网络的黑客的攻击的。不恰当的配置允许攻击者绕过所有部署的安全措施。 In this article, I will explain how security engineers or system administrators can prevent these attacks. +在这篇文章中,我将会解释安全工程师或者系统管理员怎样可以避免这些攻击。 Almost all Linux distributions come with a built-in firewall to secure processes and applications running on the Linux host. Most firewalls are designed as IDS/IPS solutions, whose primary purpose is to detect and prevent malicious packets from gaining access to a network. +几乎所有的Linux发行版都带着一个内建的防火墙来保护运行在Linux宿主机上的进程和应用程序。大多数都按照IDS/IPS解决方案设计,这样的设计的主要目的是检测和避免恶意包获取网络的进入权。 A Linux firewall usually comes with two interfaces: iptables and ipchains. Most people refer to these interfaces as the "iptables firewall" or the "ipchains firewall." Both interfaces are designed as packet filters. Iptables acts as a stateful firewall, making decisions based on previous packets. Ipchains does not make decisions based on previous packets; hence, it is designed as a stateless firewall. +Linux防火墙通常带有两个接口:iptable和ipchain程序。大多数人将这些接口称作iptables防火墙或者ipchains防火墙。这两个接口都被设计成包过滤器。iptables是有状态防火墙,基于先前的包做出决定。 In this article, we will focus on the iptables firewall, which comes with kernel version 2.4 and beyond. +在这篇文章中,我们将会专注于内核2.4之后出现的iptables防火墙。 With the iptables firewall, you can create policies, or ordered sets of rules, which communicate to the kernel how it should treat specific classes of packets. Inside the kernel is the Netfilter framework. Netfilter is both a framework and the project name for the iptables firewall. As a framework, Netfilter allows iptables to hook functions designed to perform operations on packets. In a nutshell, iptables relies on the Netfilter framework to build firewall functionality such as filtering packet data. +有了iptables防火墙,你可以创建策略或者有序的规则集,规则集可以告诉内核如何对待特定的数据包。在内核中的是Netfilter框架。Netfilter既是框架也是iptables防火墙的工程名。作为一个框架,Netfilter允许iptables勾取被设计来操作数据包的函数。概括地说,iptables依靠Netfilter框架构筑诸如过滤数据包数据的功能。 Each iptables rule is applied to a chain within a table. An iptables chain is a collection of rules that are compared against packets with similar characteristics, while a table (such as nat or mangle) describes diverse categories of functionality. For instance, a mangle table alters packet data. Thus, specialized rules that alter packet data are applied to it, and filtering rules are applied to the filter table because the filter table filters packet data. From 1986cbab5fbb837e3e0920b9b1da707d583c2429 Mon Sep 17 00:00:00 2001 From: HankChow Date: Tue, 20 Mar 2018 22:33:05 +0800 Subject: [PATCH 0026/1057] hankchow translating --- sources/tech/20180313 Running DOS on the Raspberry Pi.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180313 Running DOS on the Raspberry Pi.md b/sources/tech/20180313 Running DOS on the Raspberry Pi.md index 8209e6b80f..86600463bd 100644 --- a/sources/tech/20180313 Running DOS on the Raspberry Pi.md +++ b/sources/tech/20180313 Running DOS on the Raspberry Pi.md @@ -1,3 +1,5 @@ +hankchow translating + Running DOS on the Raspberry Pi ====== From 66b0b49037eaa7979c8f6e76d4a999a8e088e773 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 20 Mar 2018 22:49:35 +0800 Subject: [PATCH 0027/1057] Delete 20180308 Test Your BASH Skills By Playing Command Line Games.md --- ...SH Skills By Playing Command Line Games.md | 126 ------------------ 1 file changed, 126 deletions(-) delete mode 100644 sources/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md diff --git a/sources/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md b/sources/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md deleted file mode 100644 index 17e58e33ca..0000000000 --- a/sources/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md +++ /dev/null @@ -1,126 +0,0 @@ -Translating by MjSeven - -Test Your BASH Skills By Playing Command Line Games -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/03/Test-your-bash-skills-1-720x340.png) -We tend to learn and remember Linux commands more effectively if we use them regularly in a live scenario. You may forget the Linux commands over a period of time, unless you use them often. Whether you’re newbie, intermediate user, there are always some exciting methods to test your BASH skills. In this tutorial, I am going to explain how to test your BASH skills by playing command line games. Well, technically these are not actual games like Super TuxKart, NFS, or Counterstrike etc. These are just gamified versions of Linux command training lessons. You will be given a task to complete by follow certain instructions in the game itself. - -Now, we will see few games that will help you to learn and practice Linux commands in real-time. These are not a time-passing or mind-boggling games. These games will help you to get a hands-on experience of terminal commands. Read on. - -### Test BASH Skills with “Wargames” - -It is an online game, so you must have an active Internet connection. These games helps you to learn and practice Linux commands in the form of fun-filled games. Wargames are collection of shell games and each game has many levels. You can access the next levels only by solving previous levels. Not to be worried! Each game provides clear and concise instructions about how to access the next levels. - -To play the Wargames, go the following link: - -![][2] - -As you can see, there many shell games listed on the left side. Each shell game has its own SSH port. So, you will have to connect to the game via SSH from your local system. You can find the information about how to connect to each game using SSH in the top left corner of the Wargames website. - -For instance, let us play the **Bandit** game. To do so, click on the Bandit link on the Wargames homepage. On the top left corner, you will see SSH information of the Bandit game. - -![][3] - -As you see in the above screenshot, there are many levels. To go to each level, click on the respective link on the left column. Also, there are instructions for the beginners on the right side. Read them if you have any questions about how to play this game. - -Now, let us go to the level 0 by clicking on it. In the next screen, you will SSH information of this level. - -![][4] - -As you can see on the above screenshot, you need to connect is **bandit.labs.overthewire.org** , on port 2220 via SSH. The username is **bandit0** and the password is **bandit0**. - -Let us connect to Bandit game level 0. - -Enter the password i.e **bandit0** - -Sample output will be: - -![][5] - -Once logged in, type **ls** command to see what’s in their or go to the **Level 1 page** to find out how to beat Level 1 and so on. The list of suggested command have been provided in every level. So, you can pick and use any suitable command to solve the each level. - -I must admit that Wargames are addictive and really fun to solve each level. However some levels are really challenging, so you may need to google to know how to solve it. Give it a try, you will really like it. - -### Test BASH Skills with “Terminus” game - -This is a yet another browser-based online CLI game which can be used to improve or test your Linux command skills. To play this game, open up your web browser and navigate to the following URL. - -Once you entered in the game, you see the instructions to learn how to play it. Unlike Wargames, you don’t need to connect to their game server to play the games. Terminus has a built-in CLI where you can find the instructions about how to play it. - -You can look at your surroundings with the command **“ls”** , move to a new location with the command **“cd LOCATION”** , go back with the command **“cd ..”** , interact with things in the world with the command **“less ITEM”** and so on. To know your current location, just type **“pwd”**. - -![][6] - -### Test BASH Skills with “clmystery” game - -Unlike the above games, you can play this game locally. You don’t need to be connected with any remote system. This is completely offline game. - -Trust me, this is an interesting game folks. You are going to play a detective role to solve a mystery case by following the given instructions. - -First, clone the repository: -``` -$ git clone https://github.com/veltman/clmystery.git - -``` - -Or, download it as a zip file from [**here**][7]. Extract it and go to the location where you have the files. Finally, solve the mystery case by reading the “instructions” file. -``` -[sk@sk]: clmystery-master>$ ls -cheatsheet.md cheatsheet.pdf encoded hint1 hint2 hint3 hint4 hint5 hint6 hint7 hint8 instructions LICENSE.md mystery README.md solution - -``` - -Here is the instructions to play this game: - -There’s been a murder in Terminal City, and TCPD needs your help. You need to help them to figure out who did the crime. - -To find out who did it, you need to go to the **‘mystery’** subdirectory and start working from there. You might need to look into all clues at the crime scene (the **‘crimescene’** file). The officers on the scene are pretty meticulous, so they’ve written down EVERYTHING in their officer reports. Fortunately the sergeant went through and marked the real clues with the word “CLUE” in all caps. - -If you get stuck at anywhere, open one of the hint files such as hint1, hint2 etc. You can open the hint files using cat command like below. -``` -$ cat hint1 - -$ cat hint2 - -``` - -To check your answer or find out the solution, open the file ‘solution’ in the clmystery directory. -``` -$ cat solution - -``` - -To get started on how to use the command line, refer **cheatsheet.md** or **cheatsheet.pdf** (from the command line, you can type ‘nano cheatsheet.md’). Don’t use a text editor to view any files except these instructions, the cheatsheet, and hints. - -For more details, refer the [**clmystery GitHub**][8] page. - -**Recommended read:** - -And, that’s all I can remember now. I will keep adding more games if I came across anything in future. Bookmark this link and do visit from time to time. If you know any other similar games, please let me know in the comment section below. I will test and update this guide. - -More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/test-your-bash-skills-by-playing-command-line-games/ - -作者:[SK][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/author/sk/ -[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]:http://www.ostechnix.com/wp-content/uploads/2018/03/Wargames-1.png -[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-game.png -[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-level-0.png -[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-level-0-ssh-1.png -[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/Terminus.png -[7]:https://github.com/veltman/clmystery/archive/master.zip -[8]:https://github.com/veltman/clmystery From 86129718d05c7af277c9a3b0c5bfa540ac89fbdc Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 20 Mar 2018 22:50:04 +0800 Subject: [PATCH 0028/1057] Create 20180308 Test Your BASH Skills By Playing Command Line Games.md --- ...SH Skills By Playing Command Line Games.md | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md diff --git a/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md b/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md new file mode 100644 index 0000000000..08836db9a0 --- /dev/null +++ b/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md @@ -0,0 +1,124 @@ +通过玩命令行游戏来测试你的 BASH 技能 +===== + + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Test-your-bash-skills-1-720x340.png) + +如果我们经常在实际场景中使用 Linux 命令,我们倾向于更有效的学习和记忆它们。除非你经常使用 Linux 命令,否则你可能会在一段时间内忘记它们。无论你是新手还是中级用户,总会有一些令人兴奋的方法来测试你的 BASH 技能。在本教程中,我将解释如何通过玩命令行游戏来测试你的 BASH 技能。其实从技术上讲,这些并不是真正的游戏,如 Super TuxKart,NFS 或 Counterstrike 等等。这些只是 Linux 命令培训课程的游戏化版本。你将根据游戏本身的某些指示来完成一个任务。 + +现在,我们将看到几款能帮助你实时学习和练习 Linux 命令的游戏。这些游戏不是消磨时间或者令人惊诧的,这些游戏将帮助你获得终端命令的真实体验。请继续阅读: + +### 使用 “Wargames” 来测试 BASH 技能 + +这是一个在线游戏,所以你必须和互联网保持连接。这些游戏可以帮助你以充满乐趣的游戏形式学习和练习 Linux 命令。Wargames 是 shell 游戏的集合,每款游戏有很多关卡。只有通过解决先前的关卡才能访问下一个关卡。不要担心!每个游戏都提供了有关如何进入下一关的清晰简洁说明。 + +要玩 Wargames,请点击以下链接: + +![][2] + +如你所见,左边列出了许多 shell 游戏。每个 shell 游戏都有自己的 SSH 端口。所以,你必须通过本地系统配置 SSH 连接到游戏,你可以在 Wargames 网站的左上角找到关于如何使用 SSH 连接到每个游戏的信息。 + +例如,让我们来玩 **Bandit** 游戏吧。为此,单击 Wargames 主页上的 Bandit 链接。在左上角,你会看到 Bandit 游戏的 SSH 信息。 + +![][3] + +正如你在上面的屏幕截图中看到的,有很多关卡。要进入每个关卡,请单机左侧列中的相应链接。此外,右侧还有适合初学者的说明。如果你对如何玩此游戏有任何疑问,请阅读它们。 + +现在,让我们点击它进入关卡 0。在下一个屏幕中,你将获得该关卡的 SSH 信息。 + +![][4] + +正如你在上面的屏幕截图中看到的,你需要配置 SSH 端口 2220 连接 **bandit.labs.overthewire.org**,用户名是 **bandit0**,密码是 **bandit0**。 + +让我们连接到 Bandit 游戏关卡 0。 + +输入密码 **bandit0** + +示例输出将是: + +![][5] + +登录后,输入 **ls** 命令查看内容或者进入 **关卡 1 页面**,了解如何通过关卡 1 等等。建议的命令列表已在每个关卡提供。所以,你可以选择和使用任何合适的命令来解决每个关卡。 + +我必须承认,Wargames 是令人上瘾的,并且解决每个关卡是非常有趣的。 尽管有些关卡确实很具挑战性,你可能需要谷歌才能知道如何解决问题。 试一试,你会很喜欢它。 + +### 使用 “Terminus” 来测试 BASH 技能 + +这是另一个基于浏览器的在线 CLI 游戏(译注:CLI 命令行界面),可用于改进或测试你的 Linux 命令技能。要玩这个游戏,请打开你的 web 浏览器并导航到以下 URL。 + +一旦你进入游戏,你会看到有关如何玩游戏的说明。与 Wargames 不同,你不需要连接到它们的游戏服务器来玩游戏。Terminus 有一个内置的 CLI,你可以在其中找到有关如何使用它的说明。 + +你可以使用命令 **“ls”** 查看周围的环境,使用命令 **“cd LOCATION”** 移动到新的位置,返回使用命令 **“cd ..”**,与这个世界进行交互使用命令 **“less ITEM”** 等等。要知道你当前的位置,只需输入 **“pwd”**。 + +![][6] + +### 使用 “clmystery” 来测试 BASH 技能 + +与上述游戏不同,你可以在本地玩这款游戏。你不需要连接任何远程系统,这是完全离线的游戏。 + +相信我,这是一个有趣的游戏人。按照给定的说明,你将扮演一个侦探角色来解决一个神秘案件。 + +首先,克隆仓库: +``` +$ git clone https://github.com/veltman/clmystery.git + +``` + +或者,从 [这里][7] 将其作为 zip 文件下载。解压缩并切换到下载文件的地方。左后,通过阅读 “instructions” 文件来解决神秘案例。 +``` +[sk@sk]: clmystery-master>$ ls +cheatsheet.md cheatsheet.pdf encoded hint1 hint2 hint3 hint4 hint5 hint6 hint7 hint8 instructions LICENSE.md mystery README.md solution + +``` + +这里是玩这个游戏的说明: + +终端城发生了一起谋杀案,TCPD 需要你的帮助。你需要帮助它们弄清楚是谁犯罪了。 + +为了查明是谁干的,你需要到 **‘mystery’** 子目录并从那里开始工作。你可能需要查看犯罪现场的所有线索( **‘crimescene’** 文件)。现场的警官相当谨慎,所以他们在警官报告中写下了一切。幸运的是,警官在所有的帽子里都用了 “CLUE” 一词,并把真正的线索标记了出来。 + +如果里遇到任何问题,请打开其中一个提示文件,例如 hint1,hint2 等。你可以使用下面的 cat 命令打开提示文件。 +``` +$ cat hint1 + +$ cat hint2 + +``` + +要检查你的答案或找出解决方案,请在 clmystery 目录中打开文件 “solution”。 +``` +$ cat solution + +``` + +要开始如何使用命令行,请参阅 **cheatsheet.md** 或 **cheatsheet.pdf** (在命令行中,你可以输入 ‘nano cheatsheet.md’)。请勿使用文本编辑器查看除说明,备忘录和提示以外的任何文件。 + +有关更多详细信息,请参阅 [**clmystery GitHub**][8] 页面。 + +**推荐阅读:** + +而这就是我现在所能记得的。如果将来遇到任何问题,我会继续添加更多游戏。将此链接加入书签并不时访问。如果你知道其他类似的游戏,请在下面的评论部分告诉我,我将测试和更新本指南。 + +还有更多好东西,敬请关注! + +干杯! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/test-your-bash-skills-by-playing-command-line-games/ + +作者:[SK][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]:http://www.ostechnix.com/wp-content/uploads/2018/03/Wargames-1.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-game.png +[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-level-0.png +[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-level-0-ssh-1.png +[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/Terminus.png +[7]:https://github.com/veltman/clmystery/archive/master.zip +[8]:https://github.com/veltman/clmystery From af9cc952403bc1be6b4d37c4827e5e9ba17d6682 Mon Sep 17 00:00:00 2001 From: wyxplus <32919297+wyxplus@users.noreply.github.com> Date: Tue, 20 Mar 2018 23:13:32 +0800 Subject: [PATCH 0029/1057] transalting by wyxplus --- sources/tech/20180104 4 Tools for Network Snooping on Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180104 4 Tools for Network Snooping on Linux.md b/sources/tech/20180104 4 Tools for Network Snooping on Linux.md index 0ba60006ee..7fcb10a6fc 100644 --- a/sources/tech/20180104 4 Tools for Network Snooping on Linux.md +++ b/sources/tech/20180104 4 Tools for Network Snooping on Linux.md @@ -1,3 +1,4 @@ +transalting by wyxplus 4 Tools for Network Snooping on Linux ====== Computer networking data has to be exposed, because packets can't travel blindfolded, so join us as we use `whois`, `dig`, `nmcli`, and `nmap` to snoop networks. From bf411b56e8e81f3f65d85a8f204621dc680caccf Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Wed, 21 Mar 2018 07:17:48 +0800 Subject: [PATCH 0030/1057] the job is done --- sources/talk/20180201 How I coined the term open source.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180201 How I coined the term open source.md b/sources/talk/20180201 How I coined the term open source.md index 7d41259cc3..c8e72e917c 100644 --- a/sources/talk/20180201 How I coined the term open source.md +++ b/sources/talk/20180201 How I coined the term open source.md @@ -33,7 +33,7 @@ 在这个镇上,Eric 把前瞻协会(Foresight) 作为行动的大本营。他一开始访问行程,他就被几个网景法律和市场部门的员工通电话。当他挂电话后,我被要求带着电话跟他们——一男一女,可能是 Mitchell Baker——这样我才能谈论对于新术语的需求。他们原则上是立即同意了,但详细条款并未达成协议。 -在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”。 虽然那不是完美的,但我觉得足够好了。I ran it by at least four others: Eric Drexler, Mark Miller, and Todd Anderson liked it, 然而一个从事市场公关的朋友觉得术语 “open” 被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 +在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”。 虽然那不是完美的,但我觉得足够好了。我依靠至少另外四个人运营这个项目:Eric Drexler、Mark Miller,以及 Todd Anderson 和他这样的人,然而一个从事市场公关的朋友觉得术语 “open” 被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 From 13b65b6992b1c09345060ec3eceff9044a73a743 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Wed, 21 Mar 2018 07:23:32 +0800 Subject: [PATCH 0031/1057] mv article --- .../talk/20180201 How I coined the term open source.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/talk/20180201 How I coined the term open source.md (100%) diff --git a/sources/talk/20180201 How I coined the term open source.md b/translated/talk/20180201 How I coined the term open source.md similarity index 100% rename from sources/talk/20180201 How I coined the term open source.md rename to translated/talk/20180201 How I coined the term open source.md From 20fe007c9277ecb4542253b10cd6cf09a21e1ab6 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 21 Mar 2018 08:45:40 +0800 Subject: [PATCH 0032/1057] translated --- ... Record - Play Terminal IO and Sessions.md | 94 ------------------- ... Record - Play Terminal IO and Sessions.md | 92 ++++++++++++++++++ 2 files changed, 92 insertions(+), 94 deletions(-) delete mode 100644 sources/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md create mode 100644 translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md diff --git a/sources/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md b/sources/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md deleted file mode 100644 index 617a8ea13a..0000000000 --- a/sources/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md +++ /dev/null @@ -1,94 +0,0 @@ -translating---geekpi - -Tlog - A Tool to Record / Play Terminal IO and Sessions -====== -Tlog is a terminal I/O recording and playback package for Linux Distros. It's suitable for implementing centralized user session recording. It logs everything that passes through as JSON messages. The primary purpose of logging in JSON format is to eventually deliver the recorded data to a storage service such as Elasticsearch, where it can be searched and queried, and from where it can be played back. At the same time, they retain all the passed data and timing. - -Tlog contains three tools namely tlog-rec, tlog-rec-session and tlog-play. - - * `Tlog-rec tool` is used for recording terminal input or output of programs or shells in general. - * `Tlog-rec-session tool` is used for recording I/O of whole terminal sessions, with protection from recorded users. - * `Tlog-play tool` for playing back the recordings. - - - -In this article, I'll explain how to install Tlog on a CentOS 7.4 server. - -### Installation - -Before proceeding with the install, we need to ensure that our system meets all the software requirements for compiling and installing the application. On the first step, update your system repositories and software packages by using the below command. -``` -#yum update -``` - -We need to install the required dependencies for this software installation. I've installed all dependency packages with these commands prior to the installation. -``` -#yum install wget gcc -#yum install systemd-devel json-c-devel libcurl-devel m4 -``` - -After completing these installations, we can download the [source package][1] for this tool and extract it on your server as required: -``` -#wget https://github.com/Scribery/tlog/releases/download/v3/tlog-3.tar.gz -#tar -xvf tlog-3.tar.gz -# cd tlog-3 -``` - -Now you can start building this tool using our usual configure and make approach. -``` -#./configure --prefix=/usr --sysconfdir=/etc && make -#make install -#ldconfig -``` - -Finally, you need to run `ldconfig`. It creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib). - -### Tlog workflow chart - -![Tlog working process][2] - -Firstly, a user authenticates to login via PAM. The Name Service Switch (NSS) provides the information as `tlog` is a shell to the user. This initiates the tlog section and it collects the information from the Env/config files about the actual shell and starts the actual shell in a PTY. Then it starts logging everything passing between the terminal and the PTY via syslog or sd-journal. - -### Usage - -You can test if session recording and playback work in general with a freshly installed tlog, by recording a session into a file with `tlog-rec` and then playing it back with `tlog-play`. - -#### Recording to a file - -To record a session into a file, execute `tlog-rec` on the command line as such: -``` -tlog-rec --writer=file --file-path=tlog.log -``` - -This command will record our terminal session to a file named tlog.log and save it in the path specified in the command. - -#### Playing back from a file - -You can playback the recorded session during or after recording using `tlog-play` command. -``` -tlog-play --reader=file --file-path=tlog.log -``` - -This command reads the previously recorded file tlog.log from the file path mentioned in the command line. - -### Wrapping up - -Tlog is an open-source package which can be used for implementing centralized user session recording. This is mainly intended to be used as part of a larger user session recording solution but is designed to be independent and reusable.This tool can be a great help for recording everything users do and store it somewhere on the server side safe for the future reference. You can get more details about this package usage in this [documentation][3]. I hope this article is useful to you. Please post your valuable suggestions and comments on this. - -### About Saheetha Shameer(the author) -I'm working as a Senior System Administrator. I'm a quick learner and have a slight inclination towards following the current and emerging trends in the industry. My hobbies include hearing music, playing strategy computer games, reading and gardening. I also have a high passion for experimenting with various culinary delights :-) - --------------------------------------------------------------------------------- - -via: https://linoxide.com/linux-how-to/tlog-tool-record-play-terminal-io-sessions/ - -作者:[Saheetha Shameer][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://linoxide.com/author/saheethas/ -[1]:https://github.com/Scribery/tlog/releases/download/v3/tlog-3.tar.gz -[2]:https://linoxide.com/wp-content/uploads/2018/01/Tlog-working-process.png -[3]:https://github.com/Scribery/tlog/blob/master/README.md diff --git a/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md b/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md new file mode 100644 index 0000000000..5868263f18 --- /dev/null +++ b/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md @@ -0,0 +1,92 @@ +Tlog - 录制/播放终端 IO 和会话的工具 +====== +Tlog 是 Linux 中终端 I/O 录制和回放软件包。它用于实现集中式用户会话录制。它将所有经过的消息录制为 JSON 消息。录制为 JSON 格式的主要目的是将数据传送到 Elasticsearch 之类的存储服务,可以从中搜索和查询,以及回放。同时,他们保留所有通过的数据和时序。 + +Tlog 包含三个工具,分别是 tlog-rec、tlog-rec-session 和 tlog-play。 + + * `Tlog-rec tool` 一般用于录制终端、程序或 shell 的输入或输出。 + * `Tlog-rec-session tool` 用于录制整个终端会话的 I/O,并保护录制的用户。 + * `Tlog-rec-session tool` 用于回放录制。 + + + +在本文中,我将解释如何在 CentOS 7.4 服务器上安装 Tlog。 + +### 安装 + +在安装之前,我们需要确保我们的系统满足编译和安装程序的所有软件要求。在第一步中,使用以下命令更新系统仓库和软件包。 +``` +#yum update +``` + +我们需要安装此软件安装所需的依赖项。在安装之前,我已经使用这些命令安装了所有依赖包。 +``` +#yum install wget gcc +#yum install systemd-devel json-c-devel libcurl-devel m4 +``` + +完成这些安装后,我们可以下载该工具的[源码包][1]并根据需要将其解压到服务器上: +``` +#wget https://github.com/Scribery/tlog/releases/download/v3/tlog-3.tar.gz +#tar -xvf tlog-3.tar.gz +# cd tlog-3 +``` + +现在,你可以使用我们通常的配置和制作方法开始构建此工具。 +``` +#./configure --prefix=/usr --sysconfdir=/etc && make +#make install +#ldconfig +``` + +最后,你需要运行 `ldconfig`。它会创建必要的链接,并缓存命令行中指定目录中最近的共享库。( /etc/ld.so.conf 中的文件,以及信任的目录 (/lib and /usr/lib)) + +### Tlog 工作流程图 + +![Tlog working process][2] + +首先,用户通过 PAM 进行身份验证登录。名称服务交换机(NSS)提供的 `tlog` 信息是用户的 shell。这初始化了 tlog 部分,并从环境变量/配置文件收集关于实际 shell 的信息,并以 PTY 的形式启动实际的 shell。然后通过 syslog 或 sd-journal 开始录制在终端和 PTY 之间传递的所有内容。 + +### 用法 + +你可以使用 `tlog-rec` 录制一个会话并使用 `tlog-play` 回放它来测试新安装的 tlog 是否能够正常录制和回放会话。 + +#### 录制到文件中 + +要将会话录制到文件中,请在命令行中执行 `tlog-rec`,如下所示: +``` +tlog-rec --writer=file --file-path=tlog.log +``` + +该命令会将我们的终端会话录制到名为 tlog.log 的文件中,并将其保存在命令中指定的路径中。 + +#### 从文件中回放 + +你可以在录制过程中或录制后使用 `tlog-play` 命令回放录制的会话。 +``` +tlog-play --reader=file --file-path=tlog.log +``` + +该命令从指定的路径读取先前录制的文件 tlog.log。 + +### 总结 + +Tlog 是一个开源软件包,可用于实现集中式用户会话录制。它主要是作为一个更大的用户会话录制解决方案的一部分使用,但它被设计为独立且可重用的。该工具可以帮助录制用户所做的一切并将其存储在服务器的某个位置,以备将来参考。你可以从这个[文档][3]中获得关于这个软件包使用的更多细节。我希望这篇文章对你有用。请发表你的宝贵建议和意见。 + +### 关于 Saheetha Shameer (作者) +我正在担任高级系统管理员。我是一名快速学习者,有轻微的倾向跟随行业中目前和正在出现的趋势。我的爱好包括听音乐、玩策略游戏、阅读和园艺。我对尝试各种美食也有很高的热情 :-) + +-------------------------------------------------------------------------------- + +via: https://linoxide.com/linux-how-to/tlog-tool-record-play-terminal-io-sessions/ + +作者:[Saheetha Shameer][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://linoxide.com/author/saheethas/ +[1]:https://github.com/Scribery/tlog/releases/download/v3/tlog-3.tar.gz +[2]:https://linoxide.com/wp-content/uploads/2018/01/Tlog-working-process.png +[3]:https://github.com/Scribery/tlog/blob/master/README.md From 67c3de8a33da06f274f204e8bd3ebc6df2c35860 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 21 Mar 2018 08:53:05 +0800 Subject: [PATCH 0033/1057] translating --- sources/tech/20180312 Continuous integration in Fedora.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180312 Continuous integration in Fedora.md b/sources/tech/20180312 Continuous integration in Fedora.md index 59c8978d62..64d87baf81 100644 --- a/sources/tech/20180312 Continuous integration in Fedora.md +++ b/sources/tech/20180312 Continuous integration in Fedora.md @@ -1,3 +1,5 @@ +translating---geekpi + Continuous integration in Fedora ====== From 1a90d55a6351c33d0a19bbb7e30360a77384b4a7 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 21 Mar 2018 09:29:00 +0800 Subject: [PATCH 0034/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Protecting=20Co?= =?UTF-8?q?de=20Integrity=20with=20PGP=20=E2=80=94=20Part=205:=20Moving=20?= =?UTF-8?q?Subkeys=20to=20a=20Hardware=20Device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... 5- Moving Subkeys to a Hardware Device.md | 303 ++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 sources/tech/20180314 Protecting Code Integrity with PGP - Part 5- Moving Subkeys to a Hardware Device.md diff --git a/sources/tech/20180314 Protecting Code Integrity with PGP - Part 5- Moving Subkeys to a Hardware Device.md b/sources/tech/20180314 Protecting Code Integrity with PGP - Part 5- Moving Subkeys to a Hardware Device.md new file mode 100644 index 0000000000..ac862ff64e --- /dev/null +++ b/sources/tech/20180314 Protecting Code Integrity with PGP - Part 5- Moving Subkeys to a Hardware Device.md @@ -0,0 +1,303 @@ +Protecting Code Integrity with PGP — Part 5: Moving Subkeys to a Hardware Device +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/pgp-keys.jpg?itok=aS6IWGpq) + +In this tutorial series, we're providing practical guidelines for using PGP. If you missed the previous article, you can catch up with the links below. But, in this article, we'll continue our discussion about securing your keys and look at some tips for moving your subkeys to a specialized hardware device. + +[Part 1: Basic Concepts and Tools][1] + +[Part 2: Generating Your Master Key][2] + +[Part 3: Generating PGP Subkeys][3] + +[Part 4: Moving Your Master Key to Offline Storage][4] + +### Checklist + + * Get a GnuPG-compatible hardware device (NICE) + + * Configure the device to work with GnuPG (NICE) + + * Set the user and admin PINs (NICE) + + * Move your subkeys to the device (NICE) + + + + +### Considerations + +Even though the master key is now safe from being leaked or stolen, the subkeys are still in your home directory. Anyone who manages to get their hands on those will be able to decrypt your communication or fake your signatures (if they know the passphrase). Furthermore, each time a GnuPG operation is performed, the keys are loaded into system memory and can be stolen from there by sufficiently advanced malware (think Meltdown and Spectre). + +The best way to completely protect your keys is to move them to a specialized hardware device that is capable of smartcard operations. + +#### The benefits of smartcards + +A smartcard contains a cryptographic chip that is capable of storing private keys and performing crypto operations directly on the card itself. Because the key contents never leave the smartcard, the operating system of the computer into which you plug in the hardware device is not able to retrieve the private keys themselves. This is very different from the encrypted USB storage device we used earlier for backup purposes -- while that USB device is plugged in and decrypted, the operating system is still able to access the private key contents. Using external encrypted USB media is not a substitute to having a smartcard-capable device. + +Some other benefits of smartcards: + + * They are relatively cheap and easy to obtain + + * They are small and easy to carry with you + + * They can be used with multiple devices + + * Many of them are tamper-resistant (depends on manufacturer) + + + + +#### Available smartcard devices + +Smartcards started out embedded into actual wallet-sized cards, which earned them their name. You can still buy and use GnuPG-capable smartcards, and they remain one of the cheapest available devices you can get. However, actual smartcards have one important downside: they require a smartcard reader, and very few laptops come with one. + +For this reason, manufacturers have started providing small USB devices, the size of a USB thumb drive or smaller, that either have the microsim-sized smartcard pre-inserted, or that simply implement the smartcard protocol features on the internal chip. Here are a few recommendations: + + * [Nitrokey Start][5]: Open hardware and Free Software: one of the cheapest options for GnuPG use, but with fewest extra security features + + * [Nitrokey Pro][6]: Similar to the Nitrokey Start, but is tamper-resistant and offers more security features (but not U2F, see the Fido U2F section of the guide) + + * [Yubikey 4][7]: Proprietary hardware and software, but cheaper than Nitrokey Pro and comes available in the USB-C form that is more useful with newer laptops; also offers additional security features such as U2F + + + + +Our recommendation is to pick a device that is capable of both smartcard functionality and U2F, which, at the time of writing, means a Yubikey 4. + +#### Configuring your smartcard device + +Your smartcard device should Just Work (TM) the moment you plug it into any modern Linux or Mac workstation. You can verify it by running: +``` +$ gpg --card-status + +``` + +If you didn't get an error, but a full listing of the card details, then you are good to go. Unfortunately, troubleshooting all possible reasons why things may not be working for you is way beyond the scope of this guide. If you are having trouble getting the card to work with GnuPG, please seek support via your operating system's usual support channels. + +##### PINs don't have to be numbers + +Note, that despite having the name "PIN" (and implying that it must be a "number"), neither the user PIN nor the admin PIN on the card need to be numbers. + +Your device will probably have default user and admin PINs set up when it arrives. For Yubikeys, these are 123456 and 12345678, respectively. If those don't work for you, please check any accompanying documentation that came with your device. + +##### Quick setup + +To configure your smartcard, you will need to use the GnuPG menu system, as there are no convenient command-line switches: +``` +$ gpg --card-edit +[...omitted...] +gpg/card> admin +Admin commands are allowed +gpg/card> passwd + +``` + +You should set the user PIN (1), Admin PIN (3), and the Reset Code (4). Please make sure to record and store these in a safe place -- especially the Admin PIN and the Reset Code (which allows you to completely wipe the smartcard). You so rarely need to use the Admin PIN, that you will inevitably forget what it is if you do not record it. + +Getting back to the main card menu, you can also set other values (such as name, sex, login data, etc), but it's not necessary and will additionally leak information about your smartcard should you lose it. + +#### Moving the subkeys to your smartcard + +Exit the card menu (using "q") and save all changes. Next, let's move your subkeys onto the smartcard. You will need both your PGP key passphrase and the admin PIN of the card for most operations. Remember, that [fpr] stands for the full 40-character fingerprint of your key. +``` +$ gpg --edit-key [fpr] + +Secret subkeys are available. + +pub rsa4096/AAAABBBBCCCCDDDD + created: 2017-12-07 expires: 2019-12-07 usage: C + trust: ultimate validity: ultimate +ssb rsa2048/1111222233334444 + created: 2017-12-07 expires: never usage: E +ssb rsa2048/5555666677778888 + created: 2017-12-07 expires: never usage: S +[ultimate] (1). Alice Engineer +[ultimate] (2) Alice Engineer + +gpg> + +``` + +Using --edit-key puts us into the menu mode again, and you will notice that the key listing is a little different. From here on, all commands are done from inside this menu mode, as indicated by gpg>. + +First, let's select the key we'll be putting onto the card -- you do this by typing key 1 (it's the first one in the listing, our [E] subkey): +``` +gpg> key 1 + +``` + +The output should be subtly different: +``` +pub rsa4096/AAAABBBBCCCCDDDD + created: 2017-12-07 expires: 2019-12-07 usage: C + trust: ultimate validity: ultimate +ssb* rsa2048/1111222233334444 + created: 2017-12-07 expires: never usage: E +ssb rsa2048/5555666677778888 + created: 2017-12-07 expires: never usage: S +[ultimate] (1). Alice Engineer +[ultimate] (2) Alice Engineer + +``` + +Notice the * that is next to the ssb line corresponding to the key -- it indicates that the key is currently "selected." It works as a toggle, meaning that if you type key 1 again, the * will disappear and the key will not be selected any more. + +Now, let's move that key onto the smartcard: +``` +gpg> keytocard +Please select where to store the key: + (2) Encryption key +Your selection? 2 + +``` + +Since it's our [E] key, it makes sense to put it into the Encryption slot. When you submit your selection, you will be prompted first for your PGP key passphrase, and then for the admin PIN. If the command returns without an error, your key has been moved. + +**Important:** Now type key 1 again to unselect the first key, and key 2 to select the [S] key: +``` +gpg> key 1 +gpg> key 2 +gpg> keytocard +Please select where to store the key: + (1) Signature key + (3) Authentication key +Your selection? 1 + +``` + +You can use the [S] key both for Signature and Authentication, but we want to make sure it's in the Signature slot, so choose (1). Once again, if your command returns without an error, then the operation was successful. + +Finally, if you created an [A] key, you can move it to the card as well, making sure first to unselect key 2. Once you're done, choose "q": +``` +gpg> q +Save changes? (y/N) y + +``` + +Saving the changes will delete the keys you moved to the card from your home directory (but it's okay, because we have them in our backups should we need to do this again for a replacement smartcard). + +##### Verifying that the keys were moved + +If you perform --list-secret-keys now, you will see a subtle difference in the output: +``` +$ gpg --list-secret-keys +sec# rsa4096 2017-12-06 [C] [expires: 2019-12-06] + 111122223333444455556666AAAABBBBCCCCDDDD +uid [ultimate] Alice Engineer +uid [ultimate] Alice Engineer +ssb> rsa2048 2017-12-06 [E] +ssb> rsa2048 2017-12-06 [S] + +``` + +The > in the ssb> output indicates that the subkey is only available on the smartcard. If you go back into your secret keys directory and look at the contents there, you will notice that the .key files there have been replaced with stubs: +``` +$ cd ~/.gnupg/private-keys-v1.d +$ strings *.key + +``` + +The output should contain shadowed-private-key to indicate that these files are only stubs and the actual content is on the smartcard. + +#### Verifying that the smartcard is functioning + +To verify that the smartcard is working as intended, you can create a signature: +``` +$ echo "Hello world" | gpg --clearsign > /tmp/test.asc +$ gpg --verify /tmp/test.asc + +``` + +This should ask for your smartcard PIN on your first command, and then show "Good signature" after you run gpg --verify. + +Congratulations, you have successfully made it extremely difficult to steal your digital developer identity! + +### Other common GnuPG operations + +Here is a quick reference for some common operations you'll need to do with your PGP key. + +In all of the below commands, the [fpr] is your key fingerprint. + +#### Mounting your master key offline storage + +You will need your master key for any of the operations below, so you will first need to mount your backup offline storage and tell GnuPG to use it. First, find out where the media got mounted, for example, by looking at the output of the mount command. Then, locate the directory with the backup of your GnuPG directory and tell GnuPG to use that as its home: +``` +$ export GNUPGHOME=/media/disk/name/gnupg-backup +$ gpg --list-secret-keys + +``` + +You want to make sure that you see sec and not sec# in the output (the # means the key is not available and you're still using your regular home directory location). + +##### Updating your regular GnuPG working directory + +After you make any changes to your key using the offline storage, you will want to import these changes back into your regular working directory: +``` +$ gpg --export | gpg --homedir ~/.gnupg --import +$ unset GNUPGHOME + +``` + +#### Extending key expiration date + +The master key we created has the default expiration date of 2 years from the date of creation. This is done both for security reasons and to make obsolete keys eventually disappear from keyservers. + +To extend the expiration on your key by a year from current date, just run: +``` +$ gpg --quick-set-expire [fpr] 1y + +``` + +You can also use a specific date if that is easier to remember (e.g. your birthday, January 1st, or Canada Day): +``` +$ gpg --quick-set-expire [fpr] 2020-07-01 + +``` + +Remember to send the updated key back to keyservers: +``` +$ gpg --send-key [fpr] + +``` + +#### Revoking identities + +If you need to revoke an identity (e.g., you changed employers and your old email address is no longer valid), you can use a one-liner: +``` +$ gpg --quick-revoke-uid [fpr] 'Alice Engineer ' + +``` + +You can also do the same with the menu mode using gpg --edit-key [fpr]. + +Once you are done, remember to send the updated key back to keyservers: +``` +$ gpg --send-key [fpr] + +``` + +Next time, we'll look at how Git supports multiple levels of integration with PGP. + +Learn more about Linux through the free ["Introduction to Linux" ][8]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-5-moving-subkeys-hardware-device + +作者:[KONSTANTIN RYABITSEV][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/mricon +[1]:https://www.linux.com/blog/learn/2018/2/protecting-code-integrity-pgp-part-1-basic-pgp-concepts-and-tools +[2]:https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-part-2-generating-and-protecting-your-master-pgp-key +[3]:https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-part-3-generating-pgp-subkeys +[4]:https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-4-moving-your-master-key-offline-storage +[5]:https://shop.nitrokey.com/shop/product/nitrokey-start-6 +[6]:https://shop.nitrokey.com/shop/product/nitrokey-pro-3 +[7]:https://www.yubico.com/product/yubikey-4-series/ +[8]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 84acab6aa5f03c38eb8c0f6036098478f171d680 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 21 Mar 2018 09:31:42 +0800 Subject: [PATCH 0035/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Caffeinated=206?= =?UTF-8?q?.828:=20Exercise:=20Shell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0107 Caffeinated 6.828- Exercise- Shell.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md diff --git a/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md b/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md new file mode 100644 index 0000000000..8134eeea3d --- /dev/null +++ b/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md @@ -0,0 +1,104 @@ +Caffeinated 6.828: Exercise: Shell +====== + +This assignment will make you more familiar with the Unix system call interface and the shell by implementing several features in a small shell. You can do this assignment on any operating system that supports the Unix API (a Linux Athena machine, your laptop with Linux or Mac OS, etc.). Please submit your shell to the the [submission web site][1] at any time before the first lecture. + +While you shouldn't be shy about emailing the [staff mailing list][2] if you get stuck or don't understand something in this exercise, we do expect you to be able to handle this level of C programming on your own for the rest of the class. If you're not very familiar with C, consider this a quick check to see how familiar you are. Again, do feel encouraged to ask us for help if you have any questions. + +Download the [skeleton][3] of the xv6 shell, and look it over. The skeleton shell contains two main parts: parsing shell commands and implementing them. The parser recognizes only simple shell commands such as the following: +``` +ls > y +cat < y | sort | uniq | wc > y1 +cat y1 +rm y1 +ls | sort | uniq | wc +rm y + +``` + +Cut and paste these commands into a file `t.sh` + +You can compile the skeleton shell as follows: +``` +$ gcc sh.c + +``` + +which produces a file named `a.out`, which you can run: +``` +$ ./a.out < t.sh + +``` + +This execution will panic because you have not implemented several features. In the rest of this assignment you will implement those features. + +### Executing simple commands + +Implement simple commands, such as: +``` +$ ls + +``` + +The parser already builds an `execcmd` for you, so the only code you have to write is for the ' ' case in `runcmd`. To test that you can run "ls". You might find it useful to look at the manual page for `exec`; type `man 3 exec`. + +You do not have to implement quoting (i.e., treating the text between double-quotes as a single argument). + +### I/O redirection + +Implement I/O redirection commands so that you can run: +``` +echo "6.828 is cool" > x.txt +cat < x.txt + +``` + +The parser already recognizes '>' and '<', and builds a `redircmd` for you, so your job is just filling out the missing code in `runcmd` for those symbols. Make sure your implementation runs correctly with the above test input. You might find the man pages for `open` (`man 2 open`) and `close` useful. + +Note that this shell will not process quotes in the same way that `bash`, `tcsh`, `zsh` or other UNIX shells will, and your sample file `x.txt` is expected to contain the quotes. + +### Implement pipes + +Implement pipes so that you can run command pipelines such as: +``` +$ ls | sort | uniq | wc + +``` + +The parser already recognizes "|", and builds a `pipecmd` for you, so the only code you must write is for the '|' case in `runcmd`. Test that you can run the above pipeline. You might find the man pages for `pipe`, `fork`, `close`, and `dup` useful. + +Now you should be able the following command correctly: +``` +$ ./a.out < t.sh + +``` + +Don't forget to submit your solution to the [submission web site][1], with or without challenge solutions. + +### Challenge exercises + +If you'd like to experiment more, you can add any feature of your choice to your shell. You might try one of the following suggestions: + + * Implement lists of commands, separated by `;` + * Implement subshells by implementing `(` and `)` + * Implement running commands in the background by supporting `&` and `wait` + * Implement quoting of arguments + + + +All of these require making changing to the parser and the `runcmd` function. + +-------------------------------------------------------------------------------- + +via: https://sipb.mit.edu/iap/6.828/lab/shell/ + +作者:[mit][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://sipb.mit.edu +[1]:https://exokernel.scripts.mit.edu/submit/ +[2]:mailto:sipb-iap-6.828@mit.edu +[3]:https://sipb.mit.edu/iap/6.828/files/sh.c From 92cd0a9f9a021de38935576b84200ff8864d65e6 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 21 Mar 2018 09:37:25 +0800 Subject: [PATCH 0036/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Lessons=20Learn?= =?UTF-8?q?ed=20from=20Growing=20an=20Open=20Source=20Project=20Too=20Fast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Growing an Open Source Project Too Fast.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md diff --git a/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md b/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md new file mode 100644 index 0000000000..6ae7cbea2c --- /dev/null +++ b/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md @@ -0,0 +1,40 @@ +Lessons Learned from Growing an Open Source Project Too Fast +====== +![open source project][1] + +Are you managing an open source project or considering launching one? If so, it may come as a surprise that one of the challenges you can face is rapid growth. Matt Butcher, Principal Software Development Engineer at Microsoft, addressed this issue in a presentation at Open Source Summit North America. His talk covered everything from teamwork to the importance of knowing your goals and sticking to them. + +Butcher is no stranger to managing open source projects. As [Microsoft invests more deeply into open source][2], Butcher has been involved with many projects, including toolkits for Kubernetes and QueryPath, the jQuery-like library for PHP. + +Butcher described a case study involving Kubernetes Helm, a package system for Kubernetes. Helm arose from a company team-building hackathon, with an original team of three people giving birth to it. Within 18 months, the project had hundreds of contributors and thousands of active users. + +### Teamwork + +“We were stretched to our limits as we learned to grow,” Butcher said. “When you’re trying to set up your team of core maintainers and they’re all trying to work together, you want to spend some actual time trying to optimize for a process that lets you be cooperative. You have to adjust some expectations regarding how you treat each other. When you’re working as a group of open source collaborators, the relationship is not employer/employee necessarily. It’s a collaborative effort.” + +In addition to focusing on the right kinds of teamwork, Butcher and his collaborators learned that managing governance and standards is an ongoing challenge. “You want people to understand who makes decisions, how they make decisions and why they make the decisions that they make,” he said. “When we were a small project, there might have been two paragraphs in one of our documents on standards, but as a project grows and you get growing pains, these documented things gain a life of their own. They get their very own repositories, and they just keep getting bigger along with the project.” + +Should all discussion surrounding a open source project go on in public, bathed in the hot lights of community scrutiny? Not necessarily, Butcher noted. “A minor thing can get blown into catastrophic proportions in a short time because of misunderstandings and because something that should have been done in private ended up being public,” he said. “Sometimes we actually make architectural recommendations as a closed group. The reason we do this is that we don’t want to miscue the community. The people who are your core maintainers are core maintainers because they’re experts, right? These are the people that have been selected from the community because they understand the project. They understand what people are trying to do with it. They understand the frustrations and concerns of users.” + +### Acknowledge Contributions + +Butcher added that it is essential to acknowledge people’s contributions to keep the environment surrounding a fast-growing project from becoming toxic. “We actually have an internal rule in our core maintainers guide that says, ‘Make sure that at least one comment that you leave on a code review, if you’re asking for changes, is a positive one,” he said. “It sounds really juvenile, right? But it serves a specific purpose. It lets somebody know, ‘I acknowledge that you just made a gift of your time and your resources.” + +Want more tips on successfully launching and managing open source projects? Stay tuned for more insight from Matt Butcher’s talk, in which he provides specific project management issues faced by Kubernetes Helm. + +For more information, be sure to check out [The Linux Foundation’s growing list of Open Source Guides for the Enterprise][3], covering topics such as starting an open source project, improving your open source impact, and participating in open source communities. + +-------------------------------------------------------------------------------- + +via: https://www.linuxfoundation.org/blog/lessons-learned-from-growing-an-open-source-project-too-fast/ + +作者:[Sam Dean][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxfoundation.org/author/sdean/ +[1]:https://www.linuxfoundation.org/wp-content/uploads/2018/03/huskies-2279627_1920.jpg +[2]:https://thenewstack.io/microsoft-shifting-emphasis-open-source/ +[3]:https://www.linuxfoundation.org/resources/open-source-guides/ From 994711f3501165566997540497cc563190237568 Mon Sep 17 00:00:00 2001 From: lontow <1423131852@qq.com> Date: Wed, 21 Mar 2018 10:08:49 +0800 Subject: [PATCH 0037/1057] translated[fixed some mistakes] --- .../talk/20170210 Evolutional Steps of Computer Systems.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translated/talk/20170210 Evolutional Steps of Computer Systems.md b/translated/talk/20170210 Evolutional Steps of Computer Systems.md index 2a71fd7f17..80fdb66927 100644 --- a/translated/talk/20170210 Evolutional Steps of Computer Systems.md +++ b/translated/talk/20170210 Evolutional Steps of Computer Systems.md @@ -2,7 +2,7 @@ ====== 纵观现代计算机的历史,从与系统的交互方式方面,可以划分为数个进化阶段。而我更倾向于将之归类为以下几个阶段: - 1. 数字系统 +1. 数字系统 2. 专用应用系统 3. 应用中心系统 4. 信息中心系统 @@ -47,7 +47,7 @@ 松散型应用中心系统(通过文件管理器来提取文件)应用而生。在这种系统下,当打开一个文件的时候,操作系统会自动启动与之相关的应用程序。这是一次小而精妙的用法转变。这种应用中心系统的用法模式一直是个人电脑的主要用法模式。 - 然而,这种模式有很多的缺点。例如,对于一个给定的项目,为了防止数据提取出现问题,需要维护一个包含所有相关文件的严格文件夹层次结构。不幸的是,人们并不总能这样做。当然,也有可能因为[ 文件数量规模还不是很大 ][8]。 桌面搜索引擎和高级数据组织工具(像[ tagstore ][9])可以起到一点改善作用。正如研究显示的那样,只有一少部分人正在使用那些高级文件提取工具。大多数的用户不使用替代提取工具或者辅助提取技术在文件系统中寻找文件。 + 然而,这种模式有很多的缺点。例如,对于一个给定的项目,为了防止数据提取出现问题,需要维护一个包含所有相关文件的严格文件夹层次结构。不幸的是,人们并不总能这样做。更进一步说,[ 这种模式不能很好的扩展 ][8]。 桌面搜索引擎和高级数据组织工具(像[ tagstore ][9])可以起到一点改善作用。正如研究显示的那样,只有一少部分人正在使用那些高级文件提取工具。大多数的用户不使用替代提取工具或者辅助提取技术在文件系统中寻找文件。 ### 信息中心系统 @@ -70,7 +70,7 @@ 我能想到这样一类操作系统,我称之为无应用系统。在下一步的发展中,系统将不需要单域应用程序,即使它们能和 Org-mode 一样出色。计算机直接提供一个处理信息和使用功能的友好用户接口,而不通过文件和程序。甚至连传统的操作系统也不需要。 -无应用系统也可能和 [人工智能][21] 联系起来。把它想象成 [2001太空漫游][23] 中的 02[HAL 9000][22] 和星际迷航中的 [LCARS][24]一类的东西就可以了。 +无应用系统也可能和 [人工智能][21] 联系起来。把它想象成 [2001太空漫游][23] 中的 [HAL 9000][22] 和星际迷航中的 [LCARS][24]一类的东西就可以了。 从基于应用的,基于供应商的软件文化到无应用系统的转化让人很难相信。 或许,缓慢但却不断发展的开源环境,可以使一个由各种各样组织和人们贡献的真正无应用环境成型。 From 8fb37853fa73ff107f2c5c308eead2b12068b42c Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 21 Mar 2018 11:11:32 +0800 Subject: [PATCH 0038/1057] PRF:20180204 Python Hello World and String Manipulation.md @geekpi --- ...hon Hello World and String Manipulation.md | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/translated/tech/20180204 Python Hello World and String Manipulation.md b/translated/tech/20180204 Python Hello World and String Manipulation.md index 3c5bb2ac04..6763873658 100644 --- a/translated/tech/20180204 Python Hello World and String Manipulation.md +++ b/translated/tech/20180204 Python Hello World and String Manipulation.md @@ -1,113 +1,113 @@ -Python 中的 Hello World 和字符串操作 +初识 Python:Hello World 和字符串操作 ====== ![](https://process.filestackapi.com/cache=expiry:max/resize=width:700/compress/eadkmsrBTcWSyCeA4qti) -开始之前,说一下本文中的[代码][1]和[视频][2]可以在我的 github 上找到。 +开始之前,说一下本文中的[代码][1]和[视频][2]可以在我的 GitHub 上找到。 -那么,让我们开始吧!如果你糊涂了,我建议你在单独的选项卡中打开下面的[视频][3]。 +那么,让我们开始吧!如果你糊涂了,我建议你在单独的选项卡中打开下面的视频。 -[Python 的 Hello World 和字符串操作视频][2] +- [Python 的 Hello World 和字符串操作视频][2] -#### ** 开始 (先决条件) +### 开始 (先决条件) -在你的操作系统上安装 Anaconda(Python)。你可以从[官方网站][4]下载 anaconda 并自行安装,或者你可以按照以下这些 anaconda 安装教程进行安装。 +首先在你的操作系统上安装 Anaconda (Python)。你可以从[官方网站][4]下载 anaconda 并自行安装,或者你可以按照以下这些 anaconda 安装教程进行安装。 -在 Windows 上安装 Anaconda: [链接[5] +- 在 Windows 上安装 Anaconda: [链接[5] +- 在 Mac 上安装 Anaconda: [链接][6] +- 在 Ubuntu (Linux) 上安装 Anaconda:[链接][7] -在 Mac 上安装 Anaconda: [链接][6] - -在 Ubuntu (Linux) 上安装 Anaconda:[链接][7] - -#### 打开一个 Jupyter Notebook +### 打开一个 Jupyter Notebook 打开你的终端(Mac)或命令行,并输入以下内容([请参考视频中的 1:16 处][8])来打开 Jupyter Notebook: + ``` jupyter notebook - ``` -#### 打印语句/Hello World +### 打印语句/Hello World + +在 Jupyter 的单元格中输入以下内容并按下 `shift + 回车`来执行代码。 -在 Jupyter 的单元格中输入以下内容并按下 **shift + 回车**来执行代码。 ``` # This is a one line comment print('Hello World!') - ``` -![][9] -打印输出 “Hello World!” +![](https://cdn-images-1.medium.com/max/1600/1*tRRBPYjREydsRIcKFa9NPQ.png) -#### 字符串和字符串操作 +*打印输出 “Hello World!”* + +### 字符串和字符串操作 + +字符串是 Python 类的一种特殊类型。作为对象,在类中,你可以使用 `.methodName()` 来调用字符串对象的方法。字符串类在 Python 中默认是可用的,所以你不需要 `import` 语句来使用字符串对象接口。 -字符串是 python 类的一种特殊类型。作为对象,在类中,你可以使用 .methodName() 来调用字符串对象的方法。字符串类在 python 中默认是可用的,所以你不需要 import 语句来使用字符串对象接口。 ``` # Create a variable # Variables are used to store information to be referenced # and manipulated in a computer program. firstVariable = 'Hello World' print(firstVariable) - ``` -![][9] -输出打印变量 firstVariable +![](https://cdn-images-1.medium.com/max/1600/1*f0aXyvLgXb7PCV1Xao_D8Q.png) + +*输出打印变量 firstVariable* + ``` # Explore what various string methods print(firstVariable.lower()) print(firstVariable.upper()) print(firstVariable.title()) - ``` -![][9] -使用 .lower()、.upper() 和 title() 方法输出 +![](https://cdn-images-1.medium.com/max/1600/1*8dZfNBBABBSTuXxqE9mI3g.png) + +*使用 .lower()、.upper() 和 title() 方法输出* + ``` # Use the split method to convert your string into a list print(firstVariable.split(' ')) - ``` -![][9] -使用 split 方法输出(此例中以空格分隔) +![](https://cdn-images-1.medium.com/max/1600/1*gG7KFXpkNjbYjQgZwgtGTQ.png) + +*使用 split 方法输出(此例中以空格分隔)* + ``` # You can add strings together. a = "Fizz" + "Buzz" print(a) - ``` -![][9] -字符串连接 +![](https://cdn-images-1.medium.com/max/1600/1*p7y9qCsQmXAbae7Cf9t_3w.png) -#### 查询方法的功能 +*字符串连接* + +### 查询方法的功能 对于新程序员,他们经常问你如何知道每种方法的功能。Python 提供了两种方法来实现。 - 1.(在不在 Jupyter Notebook 中都可用)使用 **help** 查询每个方法的功能。 +1、(在不在 Jupyter Notebook 中都可用)使用 `help` 查询每个方法的功能。 +![](https://cdn-images-1.medium.com/max/1600/1*3Mz8PtPFypNrptb9JqyOqA.png) +*查询每个方法的功能* -![][9] - 查询每个方法的功能 - - 2. (Jupyter Notebook exclusive) You can also look up what a method does by having a question mark after a method. - 2.(Jupyter Notebook 专用)你也可以通过在方法之后添加问号来查找方法的功能。 - +2.(Jupyter Notebook 专用)你也可以通过在方法之后添加问号来查找方法的功能。 ``` # To look up what each method does in jupyter (doesnt work outside of jupyter) firstVariable.lower? - ``` -![][9] -在 Jupyter 中查找每个方法的功能 +![](https://cdn-images-1.medium.com/max/1600/1*VrLofndKpFcsKNAsv5vz9Q.png) -#### 结束语 +*在 Jupyter 中查找每个方法的功能* -如果你对本文或在[ YouTube 视频][2]的评论部分有任何疑问,请告诉我们。文章中的代码也可以在我的 [github][1] 上找到。本系列教程的第 2 部分是[简单的数学操作][10]。 +### 结束语 + +如果你对本文或在 [YouTube 视频][2]的评论部分有任何疑问,请告诉我们。文章中的代码也可以在我的 [GitHub][1] 上找到。本系列教程的第 2 部分是[简单的数学操作][10]。 -------------------------------------------------------------------------------- @@ -115,7 +115,7 @@ via: https://www.codementor.io/mgalarny/python-hello-world-and-string-manipulati 作者:[Michael][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 61f25590da4d5f2f1ddda4283ec110d8a3c3561d Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 21 Mar 2018 11:40:27 +0800 Subject: [PATCH 0039/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Quic?= =?UTF-8?q?kly=20Monitor=20Multiple=20Hosts=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Quickly Monitor Multiple Hosts In Linux.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md diff --git a/sources/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md b/sources/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md new file mode 100644 index 0000000000..f5aa60e7aa --- /dev/null +++ b/sources/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md @@ -0,0 +1,108 @@ +How To Quickly Monitor Multiple Hosts In Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/rwho-1-720x340.png) +There are plenty of monitoring tools out there to monitor local and remote Linux systems. One fine example is [**Cockpit**][1]. Those tools, however, are either bit complicated to install and use, at least for the newbie admins. The newbie admin might need to spend some time to figure out how to configure those tools to monitor the systems. If you want a quick and dirty way to monitor multiple hosts at a time in your local area network, you might need to check **“rwho”** tool. It will instantly and quickly will monitor the local and remote systems as soon as you install rwho utility. You configure nothing! All you have to do is to install “rwho” tool on the systems that you want to monitor. + +Please don’t think of rwho as a feature-rich, and complete monitoring tool. This is just a simple tool that monitors only the **uptime** , **load** and **logged in users** of a remote system. Using “rwho” utility, we can find who is logged in on which computer, a list of monitored computers with uptime (time since last reboot), how many users are logged in and the load averages for the past 1, 5, and 15 minutes. Nothing more! Nothing less! Also, it will only monitor the systems that are in the same subnet. hence, it is ideal for small and home office network. + +### Monitor Multiple Hosts In Linux + +Let me explain how rwho works. Every system that uses rwho on the network will broadcast information about itself. The other computers can access these information using rwhod-daemon. So, every computer on the network must have rwho installed. Also, the rwhod-port (e.g. Port 513/UDP) must be allowed through your firewall/router in-order to distribute or access the information of other hosts. + +Alright, let us install it. + +I tested in on Ubuntu 16.04 LTS server. rwho is available in the default repositories, so we can install it using the APT package manager like below. +``` +$ sudo apt-get install rwho + +``` + +On RPM based systems such as CentOS, Fedora, RHEL, use this command to install it: +``` +$ sudo yum install rwho + +``` + +Make sure you have allowed the rwhod-port 513 if you are behind a firewall/router. Also, verify if the rwhod-daemon is running or not using command: + +$ sudo systemctl status rwhod + +If it is not started already, run the following commands to enable and start rwhod service: +``` +$ sudo systemctl enable rwhod +$ sudo systemctl start rwhod + +``` + +Now, it is time to monitor the systems. Run the following command to find out who is logged on which computer: +``` +$ rwho +ostechni ostechnix:pts/5 Mar 12 17:41 +root server:pts/0 Mar 12 17:42 + +``` + +As you can see, currently there are two systems on my local area network. The local system user is **ostechnix** (Ubuntu 16.04 LTS) and remote system’s user is **root** (CentOS 7). As you might guessed already, rwho is similar to “who” command, but it will monitor the remote systems too. + +And, we can find the uptime of all running systems on the network, using command: +``` +$ ruptime +ostechnix up 2:17, 1 user, load 0.09, 0.03, 0.01 +server up 1:54, 1 user, load 0.00, 0.01, 0.05 + +``` + +Here, ruptime (similar to “uptime” command) displays the total uptime of my Ubuntu (local) and CentOS (remote) systems. Got it? Great! Here is the sample screenshot from my Ubuntu 16.04 LTS system: + +![][3] + +You can find the information about all other machines in the local area network in the following location: +``` +$ ls /var/spool/rwho/ +whod.ostechnix whod.server + +``` + +This is a small, yet very useful to find out who is logged in on which computer and the uptime along with system load details. + +**Suggested read:** + +Please be mindful that this method has one serious loophole. Since information about every computer is broadcasted over the net, everyone in the subnet could potentially get this information. It is okay normally but on the other side this can be a unwanted side-effect when information about the network is distributed to non-authorized users. So, It is strongly recommended to use it in a trusted and protected local area network. + +For more details, refer man pages. +``` +$ man rwho + +``` + +And, that’s all for now. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/ + +作者:[SK][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/author/sk/ +[1]:https://www.ostechnix.com/cockpit-monitor-administer-linux-servers-via-web-browser/ +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/rwho.png +[4]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=reddit (Click to share on Reddit) +[5]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=twitter (Click to share on Twitter) +[6]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=facebook (Click to share on Facebook) +[7]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=google-plus-1 (Click to share on Google+) +[8]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=linkedin (Click to share on LinkedIn) +[9]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=pocket (Click to share on Pocket) +[10]:https://api.whatsapp.com/send?text=How%20To%20Quickly%20Monitor%20Multiple%20Hosts%20In%20Linux%20https%3A%2F%2Fwww.ostechnix.com%2Fhow-to-quickly-monitor-multiple-hosts-in-linux%2F (Click to share on WhatsApp) +[11]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=telegram (Click to share on Telegram) +[12]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=email (Click to email this to a friend) +[13]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/#print (Click to print) From 51d1c0ca530e0082801a3fa9c485e02682e7234c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= <24203166+fuzheng1998@users.noreply.github.com> Date: Wed, 21 Mar 2018 21:21:20 +0800 Subject: [PATCH 0040/1057] Apply for translating fuzheng1998 translating --- ...06 Why Linux is better than Windows or macOS for security.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index 8f9fd53c8a..3bd77c01a5 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -1,3 +1,5 @@ +fuzheng1998 translating + Why Linux is better than Windows or macOS for security ====== From 8073ebaa7f7f288262f61c36a8fd8b9ce68e7a3f Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 21 Mar 2018 21:30:39 +0800 Subject: [PATCH 0041/1057] PUB:20180204 Python Hello World and String Manipulation.md @geekpi --- .../20180204 Python Hello World and String Manipulation.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180204 Python Hello World and String Manipulation.md (100%) diff --git a/translated/tech/20180204 Python Hello World and String Manipulation.md b/published/20180204 Python Hello World and String Manipulation.md similarity index 100% rename from translated/tech/20180204 Python Hello World and String Manipulation.md rename to published/20180204 Python Hello World and String Manipulation.md From f88c62df59a5beb46c08372125d81710fb88bf45 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 21 Mar 2018 22:42:23 +0800 Subject: [PATCH 0042/1057] PRF:20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md @Flowsnow --- ...n Framework That Thinks Like a Sysadmin.md | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/translated/tech/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md b/translated/tech/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md index 4ec27aeaa0..4c85c4f811 100644 --- a/translated/tech/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md +++ b/translated/tech/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md @@ -1,72 +1,72 @@ Ansible:像系统管理员一样思考的自动化框架 ====== -这些年来,我已经写了许多关于DevOps工具的文章,也培训了这方面的人员,尽管这些工具很棒,但很明显,大多数都是按照开发人员的思路设计出来的。这也没有什么问题,因为以编程的方式接近配置管理是重点。不过,直到我开始接触Ansible,我才觉得这才是系统管理员喜欢的东西。 +这些年来,我已经写了许多关于 DevOps 工具的文章,也培训了这方面的人员。尽管这些工具很棒,但很明显,大多数都是按照开发人员的思路设计出来的。这也没有什么问题,因为以编程的方式接近配置管理是重点。不过,直到我开始接触 Ansible,我才觉得这才是系统管理员喜欢的东西。 -喜欢的一部分原因是Ansible与客户端计算机通信的方式,是通过SSH的。作为系统管理员,你们都非常熟悉通过SSH连接到计算机,所以从单词“去”的角度来看,你对Ansible的了解要比其他选择更好。 +喜欢的一部分原因是 Ansible 与客户端计算机通信的方式,是通过 SSH 的。作为系统管理员,你们都非常熟悉通过 SSH 连接到计算机,所以从单词“去”的角度来看,相对于其它选择,你更容易理解 Ansible。 -考虑到这一点,我打算写一些文章,探讨如何使用Ansible。这是一个很好的系统,但是当我第一次接触到这个系统的时候,不知道如何开始。也不是学习曲线陡峭。事实上,问题是在开始使用Ansible之前,我并没有太多的东西要学,这才是让人感到困惑的。例如,如果您不必安装客户端程序(Ansible没有在客户端计算机上安装任何软件),那么您将如何启动? +考虑到这一点,我打算写一些文章,探讨如何使用 Ansible。这是一个很好的系统,但是当我第一次接触到这个系统的时候,不知道如何开始。这并不是学习曲线陡峭。事实上,问题是在开始使用 Ansible 之前,我并没有太多的东西要学,这才是让人感到困惑的。例如,如果您不必安装客户端程序(Ansible 没有在客户端计算机上安装任何软件),那么您将如何启动? ### 踏出第一步 -起初Ansible对我来说非常困难的原因在于配置服务器/客户端的关系是非常灵活的,我不知道我该从何入手。事实是,Ansible并不关心你如何设置SSH系统。它会利用你现有的任何配置。需要考虑以下几件事情: +起初 Ansible 对我来说非常困难的原因在于配置服务器/客户端的关系是非常灵活的,我不知道我该从何入手。事实是,Ansible 并不关心你如何设置 SSH 系统。它会利用你现有的任何配置。需要考虑以下几件事情: -1. Ansible需要通过SSH连接到客户端计算机。 -2. 连接后,Ansible需要提升权限才能配置系统,安装软件包等等。 +1. Ansible 需要通过 SSH 连接到客户端计算机。 +2. 连接后,Ansible 需要提升权限才能配置系统,安装软件包等等。 -不幸的是,这两个考虑真的带来了一堆蠕虫。连接到远程计算机并提升权限是一件可怕的事情。出于某种原因,当您只需在远程计算机上安装代理并使用Chef或Puppet处理特权升级问题时,感觉就不那么差了。 Ansible并非不安全,而是安全的决定权在你手中。 +不幸的是,这两个考虑真的带来了一堆蠕虫。连接到远程计算机并提升权限是一件可怕的事情。当您在远程计算机上安装代理并使用 Chef 或 Puppet 处理特权升级问题时,似乎感觉就没那么可怕了。 Ansible 并非不安全,而是安全的决定权在你手中。 -接下来,我将列出一系列潜在的配置,以及每个配置的优缺点。这不是一个详尽的清单,但是你会受到正确的启发,去思考在你自己的环境中什么是理想的配置。也需要注意,我不会提到像Vagrant这样的系统,因为尽管Vagrant在构建测试和开发的敏捷架构时非常棒,但是和一堆服务器是非常不同的,因此考虑因素是极不相似的。 +接下来,我将列出一系列潜在的配置,以及每个配置的优缺点。这不是一个详尽的清单,但是你会受到正确的启发,去思考在你自己的环境中什么是理想的配置。也需要注意,我不会提到像 Vagrant 这样的系统,因为尽管 Vagrant 在构建测试和开发的敏捷架构时非常棒,但是和一堆服务器是非常不同的,因此考虑因素是极不相似的。 -### 一些SSH场景 +### 一些 SSH 场景 -1)在Ansible配置中,以root用户密码进入远程计算机。 +#### 1)在 Ansible 配置中,root 用户以密码进入远程计算机。 -拥有这个想法是一个非常可怕的开始。这个设置的“优点”是它消除了对特权提升的需要,并且远程服务器上不需要其他用户帐户。 但是,这种便利的成本是不值得的。 首先,大多数系统不会让你在不改变默认配置的情况下以root身份进行SSH登录。 由于默认的配置都在固定的位置,坦率地说,允许root用户远程连接是一个不好的主意。 其次,将root密码放在Ansible机器上的纯文本配置文件中是不合适的。 真的,我提到了这种可能性,因为这是可能的,但这是应该避免的。 请记住,Ansible允许你自己配置连接,它可以让你做真正愚蠢的事情。 但是请不要这么做。 +拥有这个想法是一个非常可怕的开始。这个设置的“优点”是它消除了对特权提升的需要,并且远程服务器上不需要其他用户帐户。 但是,这种便利的成本是不值得的。 首先,大多数系统不会让你在不改变默认配置的情况下以 root 身份进行 SSH 登录。默认的配置之所以如此,坦率地说,是因为允许 root 用户远程连接是一个不好的主意。 其次,将 root 密码放在 Ansible 机器上的纯文本配置文件中是不合适的。 真的,我提到了这种可能性,因为这是可以的,但这是应该避免的。 请记住,Ansible 允许你自己配置连接,它可以让你做真正愚蠢的事情。 但是请不要这么做。 -2)使用存储在Ansible配置中的密码,以普通用户的身份进入远程计算机。 +#### 2)使用存储在 Ansible 配置中的密码,以普通用户的身份进入远程计算机。 -这种情况的一个优点是它不需要太多的客户端配置。 大多数用户默认情况下都可以使用SSH,因此Ansible应该能够使用凭据并且能够正常登录。 我个人不喜欢在配置文件中以纯文本形式存储密码,但至少不是root密码。 如果您使用此方法,请务必考虑远程服务器上的权限提升方式。 我知道我还没有谈到权限提升,但是如果你在配置文件中配置了一个密码,这个密码可能会被用来获得sudo访问权限。 因此,一旦发生泄露,您不仅已经泄露了远程用户的帐户,还可能泄露整个系统。 +这种情况的一个优点是它不需要太多的客户端配置。 大多数用户默认情况下都可以使用 SSH,因此 Ansible 应该能够使用用户凭据并且能够正常登录。 我个人不喜欢在配置文件中以纯文本形式存储密码,但至少它不是 root 密码。 如果您使用此方法,请务必考虑远程服务器上的权限提升方式。 我知道我还没有谈到权限提升,但是如果你在配置文件中配置了一个密码,这个密码可能会被用来获得 sudo 访问权限。 因此,一旦发生泄露,您不仅已经泄露了远程用户的帐户,还可能泄露整个系统。 -3)以普通用户身份进入远程计算机,使用具有空密码的密钥对进行身份验证。 +#### 3)使用具有空密码的密钥对进行身份验证,以普通用户身份进入远程计算机。 这消除了将密码存储在配置文件中的弊端,至少在登录的过程中消除了。 没有密码的密钥对并不理想,但这是我经常做的事情。 在我的个人内部网络中,我通常使用没有密码的密钥对来自动执行许多事情,如需要身份验证的定时任务。 这不是最安全的选择,因为私钥泄露意味着可以无限制地访问远程用户的帐户,但是相对于在配置文件中存储密码我更喜欢这种方式。 -4)以普通用户的身份通过SSH连接到远程计算机,使用通过密码保护的密钥对进行身份验证。 +#### 4)使用通过密码保护的密钥对进行身份验证,以普通用户的身份通过 SSH 连接到远程计算机。 -这是处理远程访问的一种非常安全的方式,因为它需要两种不同的身份验证因素来解密:私钥和密码。 如果你只是以交互方式运行Ansible,这可能是理想的设置。 当你运行命令时,Ansible会提示你输入私钥,然后使用密钥对登录到远程系统。 是的,只需使用标准密码登录并且不用在配置文件中指定密码即可完成,但是如果不管怎样都要在命令行上输入密码,那为什么不在保护层添加密钥对呢? +这是处理远程访问的一种非常安全的方式,因为它需要两种不同的身份验证因素来解密:私钥和密码。 如果你只是以交互方式运行 Ansible,这可能是理想的设置。 当你运行命令时,Ansible 会提示你输入私钥的密码,然后使用密钥对登录到远程系统。 是的,只需使用标准密码登录并且不用在配置文件中指定密码即可完成,但是如果不管怎样都要在命令行上输入密码,那为什么不在保护层添加密钥对呢? -5)使用密码保护密钥对进行SSH连接,但是使用ssh-agent“解锁”私钥。 +#### 5)使用密码保护密钥对进行 SSH 连接,但是使用 ssh-agent “解锁”私钥。 -这并不能完美地解决无人值守,自动化的Ansible命令的问题,但是它确实也使安全设置变得相当方便。 ssh-agent程序一次验证密码,然后使用该验证进行后续连接。当我使用Ansible时,这是我想要做的事情。如果我是完全值得信任的,我通常仍然使用没有密码的密钥对,但是这通常是因为我在我的家庭服务器上工作,是不是容易受到攻击的。 +这并不能完美地解决无人值守、自动化的 Ansible 命令的问题,但是它确实也使安全设置变得相当方便。 ssh-agent 程序一次验证密码,然后使用该验证进行后续连接。当我使用 Ansible 时,这是我想要做的事情。如果我是完全值得信任的,我通常仍然使用没有密码的密钥对,但是这通常是因为我在我的家庭服务器上工作,是不是容易受到攻击的。 -在配置SSH环境时还要记住一些其他注意事项。 也许你可以限制Ansible用户(通常是你的本地用户名),以便它只能从一个特定的IP地址登录。 也许您的Ansible服务器可以位于不同的子网中,位于强大的防火墙之后,因此其私钥更难以远程访问。 也许Ansible服务器本身没有安装SSH服务器,所以根本没法访问。 同样,Ansible的优势之一是它使用SSH协议进行通信,而且这是一个协议,你有多年的时间把你的系统调整到最适合你的环境的效果。 我不是宣传“最佳实践”的忠实粉丝,因为实际上最好的做法是考虑你的环境,并选择最适合你情况的设置。 +在配置 SSH 环境时还要记住一些其他注意事项。 也许你可以限制 Ansible 用户(通常是你的本地用户),以便它只能从一个特定的 IP 地址登录。 也许您的 Ansible 服务器可以位于不同的子网中,位于强大的防火墙之后,因此其私钥更难以远程访问。 也许 Ansible 服务器本身没有安装 SSH 服务器,所以根本没法访问。 同样,Ansible 的优势之一是它使用 SSH 协议进行通信,而且这是一个你用了多年的协议,你已经把你的系统调整到最适合你的环境了。 我不是宣传“最佳实践”的忠实粉丝,因为实际上最好的做法是考虑你的环境,并选择最适合你情况的设置。 ### 权限提升 -一旦您的Ansible服务器通过SSH连接到它的客户端,就需要能够提升特权。 如果你选择了上面的选项1,那么你已经是root了,这是一个有争议的问题。 但是由于没有人选择选项1(对吧?),您需要考虑客户端计算机上的普通用户如何获得访问权限。 Ansible支持各种权限提升的系统,但在Linux中,最常用的选项是sudo和su。 和SSH一样,有几种情况需要考虑,虽然肯定还有其他选择。 +一旦您的 Ansible 服务器通过 SSH 连接到它的客户端,就需要能够提升特权。 如果你选择了上面的选项 1,那么你已经是 root 了,这是一个有争议的问题。 但是由于没有人选择选项 1(对吧?),您需要考虑客户端计算机上的普通用户如何获得访问权限。 Ansible 支持各种权限提升的系统,但在 Linux 中,最常用的选项是 `sudo` 和 `su`。 和 SSH 一样,有几种情况需要考虑,虽然肯定还有其他选择。 -1)使用su提升权限。 +#### 1)使用 su 提升权限。 -对于RedHat/CentOS用户来说,可能默认是使用su来获得系统访问权限。 默认情况下,这些系统在安装过程中配置了root密码,要想获得特殊访问权限,您需要输入该密码。使用su的问题在于,虽说它可以让您完全访问远程系统,不过您确实可以完全访问远程系统。 (是的,这是讽刺。)另外,su程序没有使用密钥对进行身份验证的能力,所以密码必须以交互方式输入或存储在配置文件中。 由于它实际上是root密码,因此将其存储在配置文件中听起来像一个可怕的想法,因为它就是。 +对于 RedHat/CentOS 用户来说,可能默认是使用 `su` 来获得系统访问权限。 默认情况下,这些系统在安装过程中配置了 root 密码,要想获得特殊访问权限,您需要输入该密码。使用 `su` 的问题在于,虽说它可以给了您完全访问远程系统,而您确实也可以完全访问远程系统。 (是的,这是讽刺。)另外,`su` 程序没有使用密钥对进行身份验证的能力,所以密码必须以交互方式输入或存储在配置文件中。 由于它实际上是 root 密码,因此将其存储在配置文件中听起来像、也确实是一个可怕的想法。 -2)使用sudo提升权限。 +#### 2)使用 sudo 提升权限。 -这就是Debian/Ubuntu系统的配置方式。 正常用户组中的用户可以使用sudo命令并使用root权限执行该命令。 随之而来的是,这仍然存在密码存储或交互式输入的问题。 由于在配置文件中存储用户的密码看起来不太可怕,我猜这是使用su的一个步骤,但是如果密码被泄露,仍然可以完全访问系统。 (毕竟,输入`sudo`和`su -`都将允许用户成为root用户,就像拥有root密码一样。) +这就是 Debian/Ubuntu 系统的配置方式。 正常用户组中的用户可以使用 `sudo` 命令并使用 root 权限执行该命令。 随之而来的是,这仍然存在密码存储或交互式输入的问题。 由于在配置文件中存储用户的密码看起来不太可怕,我猜这是使用 `su` 的一个进步,但是如果密码被泄露,仍然可以完全访问系统。 (毕竟,输入 `sudo` 和 `su -` 都将允许用户成为 root 用户,就像拥有 root 密码一样。) -3) 使用sudo提升权限,并在sudoers文件中配置NOPASSWD。 +#### 3) 使用 sudo 提升权限,并在 sudoers 文件中配置 NOPASSWD。 -再者,在我的本地环境中,我就是这么做的。 这并不完美,因为它给予用户帐户无限制的root权限,并且不需要任何密码。 但是,当我这样做并且使用没有密码短语的SSH密钥对时,我可以让Ansible命令更轻松的自动化。 我会再次注意到,虽然这很方便,但这不是一个非常安全的想法。 +再次,在我的本地环境中,我就是这么做的。 这并不完美,因为它给予用户帐户无限制的 root 权限,并且不需要任何密码。 但是,当我这样做并且使用没有密码短语的 SSH 密钥对时,我可以让 Ansible 命令更轻松的自动化。 再次提示,虽然这很方便,但这不是一个非常安全的想法。 -4)使用sudo提升权限,并在特定的可执行文件上配置NOPASSWD。 +#### 4)使用 sudo 提升权限,并在特定的可执行文件上配置 NOPASSWD。 -这个想法可能是安全性和便利性的最佳折衷。 基本上,如果你知道你打算用Ansible做什么,那么你可以为远程用户使用的那些应用程序提供NOPASSWD权限。 这可能会让人有些困惑,因为Ansible使用Python来处理很多事情,但是有足够的尝试和错误,你应该能够弄清原理。 这是额外的工作,但确实消除了一些明显的安全漏洞。 +这个想法可能是安全性和便利性的最佳折衷。 基本上,如果你知道你打算用 Ansible 做什么,那么你可以为远程用户使用的那些应用程序提供 NOPASSWD 权限。 这可能会让人有些困惑,因为 Ansible 使用 Python 来处理很多事情,但是经过足够的尝试和错误,你应该能够弄清原理。 这是额外的工作,但确实消除了一些明显的安全漏洞。 ### 计划实施 -一旦你决定如何处理Ansible认证和权限提升,就需要设置它。 在熟悉Ansible之后,您可能会使用该工具来帮助“引导”新客户端,但首先手动配置客户端非常重要,以便您知道发生了什么事情。 将你熟悉的事情变得自动化比从自动化开始要好。 +一旦你决定如何处理 Ansible 认证和权限提升,就需要设置它。 在熟悉 Ansible 之后,您可能会使用该工具来帮助“引导”新客户端,但首先手动配置客户端非常重要,以便您知道发生了什么事情。 将你熟悉的事情变得自动化比从头开始自动化要好。 -我已经写过关于SSH密钥对的文章,网上有无数的设置类的文章。 来自Ansible服务器的简短版本看起来像这样: +我已经写过关于 SSH 密钥对的文章,网上有无数的设置类的文章。 来自 Ansible 服务器的简短版本看起来像这样: ``` # ssh-keygen @@ -76,49 +76,49 @@ Ansible:像系统管理员一样思考的自动化框架 如果您在创建密钥对时选择不使用密码,最后一步您应该可以直接进入远程计算机,而不用输入密码或密钥串。 -为了在sudo中设置权限提升,您需要编辑sudoers文件。 你不应该直接编辑文件,而是使用: +为了在 `sudo` 中设置权限提升,您需要编辑 `sudoers` 文件。 你不应该直接编辑文件,而是使用: ``` # sudo visudo ``` -这将打开sudoers文件并允许您安全地进行更改(保存时会进行错误检查,所以您不会意外地因为输入错误将自己锁住)。 这个文件中有一些例子,所以你应该能够弄清楚如何分配你想要的确切的权限。 +这将打开 `sudoers` 文件并允许您安全地进行更改(保存时会进行错误检查,所以您不会意外地因为输入错误将自己锁住)。 这个文件中有一些例子,所以你应该能够弄清楚如何分配你想要的确切的权限。 -一旦配置完成,您应该在使用Ansible之前进行手动测试。 尝试SSH到远程客户端,然后尝试使用您选择的任何方法提升权限。 一旦你确认配置的这种方式可以连接,就可以安装Ansible了。 +一旦配置完成,您应该在使用 Ansible 之前进行手动测试。 尝试 SSH 到远程客户端,然后尝试使用您选择的任何方法提升权限。 一旦你确认配置的方式可以连接,就可以安装 Ansible 了。 -### Ansible安装 +### 安装 Ansible -由于Ansible程序仅安装在一台计算机上,因此开始并不是一件繁重的工作。 Red Hat/Ubuntu系统的软件包安装有点不同,但都不是很困难。 +由于 Ansible 程序仅安装在一台计算机上,因此开始并不是一件繁重的工作。 Red Hat/Ubuntu 系统的软件包安装有点不同,但都不是很困难。 -在Red Hat/CentOS中,首先启用EPEL库: +在 Red Hat/CentOS 中,首先启用 EPEL 库: ``` sudo yum install epel-release ``` -然后安装Ansible: +然后安装 Ansible: ``` sudo yum install ansible ``` -在Ubuntu中,首先启用Ansible PPA: +在 Ubuntu 中,首先启用 Ansible PPA: ``` sudo apt-add-repository spa:ansible/ansible (press ENTER to access the key and add the repo) ``` -然后安装Ansible: +然后安装 Ansible: ``` sudo apt-get update sudo apt-get install ansible ``` -### Ansible主机文件配置 +### Ansible 主机文件配置 -Ansible系统无法知道您希望它控制哪个客户端,除非您给它一个计算机列表。 该列表非常简单,看起来像这样: +Ansible 系统无法知道您希望它控制哪个客户端,除非您给它一个计算机列表。 该列表非常简单,看起来像这样: ``` # file /etc/ansible/hosts @@ -132,7 +132,7 @@ mysql_1 ansible_host=192.168.1.22 pgsql_1 ansible_host=192.168.1.23 ``` -括号内的部分是指定组。 单个主机可以列在多个组中,而Ansible可以指向单个主机或组。 这也是配置文件,比如纯文本密码的东西将被存储,如果这是你计划的那种设置。 配置文件中的每一行配置一个主机地址,并且可以在ansible_host语句之后添加多个声明。 一些有用的选项是: +方括号内的部分是指定的组。 单个主机可以列在多个组中,而 Ansible 可以指向单个主机或组。 这也是配置文件,比如纯文本密码的东西将被存储,如果这是你计划的那种设置。 配置文件中的每一行配置一个主机地址,并且可以在 `ansible_host` 语句之后添加多个声明。 一些有用的选项是: ``` ansible_ssh_pass @@ -142,29 +142,29 @@ ansible_become_user ansible_become_pass ``` -### Ansible Vault保险库 +### Ansible 保险库Vault -(译者注:Vault作为 ansible 的一项新功能可将例如passwords,keys等敏感数据文件进行加密,而非明文存放) +(LCTT 译注:Vault 作为 ansible 的一项新功能可将例如密码、密钥等敏感数据文件进行加密,而非明文存放) -我也应该注意到,尽管安装程序比较复杂,而且不是在您首次进入Ansible世界时可能会做的事情,但该程序确实提供了一种方法来加密保险库中的密码。 一旦您熟悉Ansible,并且希望将其投入生产,将这些密码存储在加密的Ansible库中是非常理想的。 但是本着先学会爬再学会走的精神,我建议首先在非生产环境下使用无密码方法。 +我也应该注意到,尽管安装程序比较复杂,而且这不是在您首次进入 Ansible 世界时可能会做的事情,但该程序确实提供了一种加密保险库中的密码的方法。 一旦您熟悉 Ansible,并且希望将其投入生产,将这些密码存储在加密的 Ansible 保险库中是非常理想的。 但是本着先学会爬再学会走的精神,我建议首先在非生产环境下使用无密码方法。 ### 系统测试 -最后,你应该测试你的系统,以确保客户端可以正常连接。 ping测试将确保Ansible计算机可以ping每个主机: +最后,你应该测试你的系统,以确保客户端可以正常连接。 `ping` 测试将确保 Ansible 计算机可以 `ping` 每个主机: ``` ansible -m ping all ``` -运行后,如果ping成功,您应该看到每个定义的主机显示ping的消息:pong。 这实际上并没有测试认证,只是测试网络连接。 试试这个来测试你的认证: +运行后,如果 `ping` 成功,您应该看到每个定义的主机显示 `ping` 的消息:`pong`。 这实际上并没有测试认证,只是测试网络连接。 试试这个来测试你的认证: ``` ansible -m shell -a 'uptime' webservers ``` -您应该可以看到webservers组中每个主机的运行时间命令的结果。 +您应该可以看到 webservers 组中每个主机的运行时间命令的结果。 -在后续文章中,我计划开始深入Ansible管理远程计算机的功能。 我将介绍各种模块,以及如何使用ad-hoc模式来完成一些按键操作,这些操作在命令行上单独处理都需要很长时间。 如果您没有从上面的示例Ansible命令中获得预期的结果,请花些时间确保身份验证正在运行。 如果遇到困难,请查阅[Ansible文档][1]获取更多帮助。 +在后续文章中,我计划开始深入 Ansible 管理远程计算机的功能。 我将介绍各种模块,以及如何使用 ad-hoc 模式来完成一些按键操作,这些操作在命令行上单独处理都需要很长时间。 如果您没有从上面的示例 Ansible 命令中获得预期的结果,请花些时间确保身份验证可以工作。 如果遇到困难,请查阅 [Ansible 文档][1]获取更多帮助。 -------------------------------------------------------------------------------- @@ -172,7 +172,7 @@ via: http://www.linuxjournal.com/content/ansible-automation-framework-thinks-sys 作者:[Shawn Powers][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 6a7bc98bff1ab1dcb3071ad695842ccd12f979ad Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 21 Mar 2018 22:42:45 +0800 Subject: [PATCH 0043/1057] PUB:20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md @Flowsnow https://linux.cn/article-9466-1.html --- ...sible- the Automation Framework That Thinks Like a Sysadmin.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md (100%) diff --git a/translated/tech/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md b/published/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md similarity index 100% rename from translated/tech/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md rename to published/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md From 86e340a24574b7026139e8683e831a5829d0f489 Mon Sep 17 00:00:00 2001 From: HankChow Date: Thu, 22 Mar 2018 00:04:56 +0800 Subject: [PATCH 0044/1057] translated --- ...0180313 Running DOS on the Raspberry Pi.md | 87 ------------------- ...0180313 Running DOS on the Raspberry Pi.md | 84 ++++++++++++++++++ 2 files changed, 84 insertions(+), 87 deletions(-) delete mode 100644 sources/tech/20180313 Running DOS on the Raspberry Pi.md create mode 100644 translated/tech/20180313 Running DOS on the Raspberry Pi.md diff --git a/sources/tech/20180313 Running DOS on the Raspberry Pi.md b/sources/tech/20180313 Running DOS on the Raspberry Pi.md deleted file mode 100644 index 86600463bd..0000000000 --- a/sources/tech/20180313 Running DOS on the Raspberry Pi.md +++ /dev/null @@ -1,87 +0,0 @@ -hankchow translating - -Running DOS on the Raspberry Pi -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/wings_freedos_game.jpg?itok=7j8x-A-w) -You may be familiar with [The FreeDOS Project][1]. FreeDOS is a complete, free, DOS-compatible operating system that you can use to play classic DOS games, run legacy business software, or develop embedded PC applications. Any program that works on MS-DOS should also run on FreeDOS. - -As the founder and project coordinator of the FreeDOS Project, I'm often the go-to person when users ask questions. And one question I seem to get a lot lately is: "Can you run FreeDOS on the Raspberry Pi?" - -This question isn't surprising. After all, Linux runs great on the Raspberry Pi, and FreeDOS is an older operating system that requires fewer resources than Linux, so why shouldn't FreeDOS run on the Raspberry Pi. - -**[Enter our[Raspberry Pi week giveaway][2] for a chance at this arcade gaming kit.]** - -The simple answer is that FreeDOS cannot run on a Raspberry Pi by itself because of the CPU architecture. Like any DOS, FreeDOS requires an Intel x86 CPU and a BIOS to provide basic runtime services. But the Raspberry Pi is a completely different architecture. The Raspberry Pi runs an ARM CPU, which is not binary compatible with the Intel CPU and does not include a BIOS. So FreeDOS cannot run on the Raspberry Pi at the "bare hardware" level. - -Fortunately, it's possible to run FreeDOS on the Raspberry Pi through PC emulation. Maybe that's not as cool as running FreeDOS natively, but it's a great way to run DOS applications on the Raspberry Pi. - -### What about DOSBox? - -Some might ask, "Why not use DOSBox instead?" DOSBox is an open source x86 emulator that runs on a variety of systems, including Linux. It is a great system that provides a DOS-like environment, mostly aimed at running games. So if you just want to run a classic DOS game, DOSBox can do that for you. But if you run want to run DOS applications, DOSBox isn't the best platform. And if you ask the DOSBox forums, they'll tell you DOSBox is really meant for games. - -For most users, it's a matter of preference. It shouldn't be a surprise that I prefer to install FreeDOS to run classic DOS games and other programs. I find the full DOS experience gives me greater flexibility and control than running DOSBox. I use DOSBox for a few games, but for most things I prefer to run a full FreeDOS instead. - -### Installing FreeDOS on Raspberry Pi - -[QEMU][3] (short for Quick EMUlator) is an open source virtual machine software system that can run DOS as a "guest" operating system on Linux. Most popular Linux systems include QEMU by default. QEMU is available for Raspbian, the Linux distribution I'm using on my Raspberry Pi. I took the QEMU screenshots in this article with my Raspberry Pi running [Raspbian GNU/Linux 9 (Stretch)][4]. - -Last year, I wrote an article about [how to run DOS programs in Linux][5] using QEMU. The steps to install and run FreeDOS using QEMU are basically the same on the Raspberry Pi as they were for my GNOME-based system. - -In QEMU, you need to "build" your virtual system by instructing QEMU to add each component of the virtual machine. Let's start by defining a virtual disk image that we'll use to install and run DOS. The `qemu-img` command lets you create virtual disk images. For FreeDOS, we won't need much room, so I created my virtual disk with 200 megabytes: -``` -qemu-img create freedos.img 200M - -``` - -Unlike PC emulator systems like VMware or VirtualBox, you need to "build" your virtual system by instructing QEMU to add each component of the virtual machine. Although this may seem laborious, it's not that hard. I used these parameters to run QEMU to install FreeDOS on my Raspberry Pi: -``` -qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=d - -``` - -You can find the full description of that command line in my other [article][5]. In brief, the command line defines an Intel i386-compatible virtual machine with 16 megabytes of memory, a US/English keyboard, and a real-time clock based on my local system time. The command line also defines a classic Sound Blaster 16 sound card, Adlib digital music card, and standard Cirrus Logic VGA card. The file `freedos.img` is defined as the first hard drive (`C:`) and the `FD12CD.iso` image as the CD-ROM (`D:`) drive. QEMU is set to boot from that `D:` CD-ROM drive. - -The FreeDOS 1.2 distribution is easy to install. Just follow the prompts. - -However, it takes forever to install because of the heavy disk I/O when you install the operating system, and the microSD card isn't exactly fast. - -### Running FreeDOS on Raspberry Pi - -Your results may vary depending on the microSD card you use. I used a SanDisk Ultra 64GB microSDXC UHS-I U1A1 card. The U1 is designed to support 1080p video recording (such as you might use in a GoPro camera) at minimum serial write speeds of 10MB/s. By comparison, a V60 is aimed at cameras that do 4K video and has a minimum sequential write speed of 60MB/s. If your Pi has a V60 microSD card or even a V30 (30MB/s), you'll see noticeably better disk I/O performance than I did. - -After installing FreeDOS, you may prefer to boot directly from the virtual `C:` drive. Modify your QEMU command line to change the boot order, using `-boot order=c`, like this: -``` -​qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=c​ - -``` - -Once you have installed FreeDOS in QEMU on the Raspberry Pi, you shouldn't notice any performance issues. For example, games usually load maps, sprites, sounds, and other data when you start each level. While starting a new level in a game might take a while, I didn't notice any performance lag while playing DOS games in FreeDOS on the Raspberry Pi. - -The FreeDOS 1.2 distribution includes many games and other applications that might interest you. You may need to run the `FDIMPLES` package manager program to install these extra packages. My favorite game in FreeDOS 1.2 is WING, a space-shooter game that's very reminiscent of the classic arcade game Galaga. (The name WING is a recursive acronym for Wing Is Not Galaga.) - -One of my favorite DOS programs is the shareware As-Easy-As spreadsheet program. It was a popular spreadsheet application from the 1980s and 1990s, which does the same job Microsoft Excel and LibreOffice Calc fulfill today or that the DOS-based Lotus 1-2-3 spreadsheet did back in the day. As-Easy-As and Lotus 1-2-3 both saved data as WKS files, which newer versions of Microsoft Excel can't read, but LibreOffice Calc may still support, depending on compatibility. While the original version of As-Easy-As was shareware, TRIUS Software made the [activation code for As-Easy-As 5.7][6] available for free. - -I'm also quite fond of the GNU Emacs editor, and FreeDOS includes a similar Emacs-like text editor called Freemacs. If you want a more powerful editor than the default FreeDOS Edit and desire an experience like GNU Emacs, then Freemacs is for you. You can install Freemacs using the `FDIMPLES` package manager in the FreeDOS 1.2 distribution. - -### Yes, you can run DOS on the Raspberry Pi (sort of) - -While you can't run DOS on "bare hardware" on the Raspberry Pi, it's nice to know that you can still run DOS on the Raspberry Pi via an emulator. Thanks to the QEMU PC emulator and FreeDOS, it's possible to play classic DOS games and run other DOS programs on the Raspberry Pi. Expect a slight performance hit when doing any disk I/O, especially if you're doing something intensive on the disk, like writing large amounts of data, but things will run fine after that. Once you've set up QEMU as the virtual machine emulator and installed FreeDOS, you are all set to enjoy your favorite classic DOS programs on the Raspberry Pi. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/can-you-run-dos-raspberry-pi - -作者:[Jim Hall][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/jim-hall -[1]:http://www.freedos.org/ -[2]:https://opensource.com/article/18/3/raspberry-pi-week-giveaway -[3]:https://www.qemu.org/ -[4]:https://www.raspberrypi.org/downloads/ -[5]:https://opensource.com/article/17/10/run-dos-applications-linux -[6]:http://www.triusinc.com/forums/viewtopic.php?t=10 diff --git a/translated/tech/20180313 Running DOS on the Raspberry Pi.md b/translated/tech/20180313 Running DOS on the Raspberry Pi.md new file mode 100644 index 0000000000..688927d918 --- /dev/null +++ b/translated/tech/20180313 Running DOS on the Raspberry Pi.md @@ -0,0 +1,84 @@ +在树莓派上运行 DOS 系统 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/wings_freedos_game.jpg?itok=7j8x-A-w) +[FreeDOS][1] 对大家来说也许并不陌生。它是一个完整、免费并且对 DOS 兼容良好的操作系统,它可以运行一些比较老旧的 DOS 游戏或者商用软件,也可以开发嵌入式的应用。只要在 MS-DOS 上能够运行的程序,在 FreeDOS 上都可以运行。 + +作为 FreeDOS 的发起者和项目协调人员,很多用户会把我作为内行人士进行发问。而我最常被问到的问题是:“FreeDOS 可以在树莓派上运行吗?” + +这个问题并不令人意外。毕竟 Linux 在树莓派上能够很好地运行,而 FreeDOS 和 Linux 相比是一个更古老、占用资源更少的操作系统,那 FreeDOS 为啥不能树莓派上运行呢? + +简单来说。由于 CPU 架构的原因,FreeDOS 并不能在树莓派中独立运行。和其它 DOS 类的系统一样,FreeDOS 需要英特尔 x86 架构 CPU 以及 BIOS 来提供基础的运行时服务。而树莓派运行在 ARM 架构的 CPU 上,与英特尔 CPU 二进制不兼容,也没有 BIOS。因此树莓派在硬件层面就不支持 FreeDOS。 + +不过通过 PC 模拟器还是能在树莓派上运行 FreeDOS 的,虽然这样也许稍有不足,但也不失为一个能在树莓派上运行 FreeDOS 的方法。 + +### DOSBox怎么样? + +有人可能会问:“为什么不用 DOSBox 呢?” DOSBox 是一个开源的跨平台 x86 模拟器,在 Linux 上也能使用,它能够为应用软件尤其是游戏软件提供了一个类 DOS 的运行环境,所以如果你只是想玩 DOS 游戏的话,DOSBox是一个不错的选择。但在大众眼中,DOSBox 是专为 DOS 游戏而设的,而在运行一些别的 DOS 应用软件方面,DOSBox 只是表现平平。 + +对多数人来说,这只是个人偏好的问题,我喜欢用 FreeDOS 来运行 DOS 游戏和其它程序,完整的 DOS 系统和 DOSBox 相比能让我体验到更好的灵活性和操控性。我只用 DOSBox 来玩游戏,在其它方面还是选择完整的 FreeDOS。 + +### 在树莓派上安装 FreeDOS + +[QEMU][3](Quick EMUlator)是一款能在 Linux 系统上运行 DOS 系统的开源的虚拟机软件。很多流行的 Linux 系统都自带 QEMU。QEMU 在我树莓派上的 Raspbian 系统中也同样能够运行,下文就有一些我在树莓派 [Raspbian GNU/Linux 9 (Stretch)][4] 系统中使用 QEMU 的截图。 + +去年我在写了一篇关于[如何在 Linux 系统中运行 DOS 程序][5]的文章的时候就用到了 QEMU,在树莓派上使用 QEMU 来安装运行 FreeDOS 的步骤基本上和在别的基于 GNOME 的系统上没有什么太大的区别。 + +在 QEMU 中你需要通过添加各种组件来搭建虚拟机。先指定一个用来安装运行 DOS 的虚拟磁盘镜像,通过`qemu-img` 命令来创建一个虚拟磁盘镜像,对于 FreeDOS 来说不需要太大的空间,所以我只创建了一个 200MB 的虚拟磁盘: +``` +qemu-img create freedos.img 200M + +``` + +和 VMware 或者 VirtualBox 这些 PC 模拟器不同,使用 QEMU 需要通过添加各种组件来搭建虚拟机,尽管有点麻烦,但是并不困难。我使用了以下这些参数来在树莓派上使用 QEMU 安装 FreeDOS 系统: +``` +qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=d + +``` + +你可以在我其它的[文章][5]中找到这些命令的完整介绍。简单来说,上面这条命令指定了一个英特尔 i386 兼容虚拟机,并且分配了 16MB 内存、一个英文输入键盘、一个基于系统时间的实时时钟、一个声卡、一个音乐卡以及一个 VGA 卡。文件 `freedos.img` 指定为第一个硬盘(`C:`),`FD12CD.iso` 镜像作为 CD-ROM (`D:`)驱动。QEMU 设定为从`D:`的 CD-ROM 启动。 + +你只需要按照提示就可以轻松安装好 FreeDOS 1.2 了。但是由于 microSD 卡在面对大量的 I/O 时速度比较慢,所以安装操作系统需要花费很长时间。 + + +### 在树莓派上运行 FreeDOS + +你的运行情况取决于使用哪一种 microSD 卡。我用的是 SanDisk Ultra 64GB microSDXC UHS-I U1A1 ,其中 U1 这种型号专用于支持 1080p 的视频录制(例如 GoPro),它的最低串行写速度能够达到 10MB/s。相比之下,V60 型号专用于 4K 视频录制,最低连续写入速度能达到 60MB/s。如果你的树莓派使用的是 V60 的 microSD 卡甚至是 V30(也能达到 30MB/s),你就能明显看到它的 I/O 性能会比我的好。 + +FreeDOS 安装好之后,你可以直接从`C:`进行启动。只需要按照下面的命令用`-boot order=c`来指定 QEMU 的启动顺序即可: +``` +​qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=c​ + +``` + +只要树莓派的 QEMU 上安装了 FreeDOS,就不会出现明显的性能问题。例如游戏通常在每一关开始的时候会加载地图、怪物、声音等一系列的数据,尽管这些内容需要加载一段时间,但在正常玩的时候并没有出现性能不足的现象。 + +FreeDOS 1.2 自带了很多游戏以及其它应用软件,可以使用`FDIMPLES`包管理程序来安装它们。FreeDOS 1.2 里面我最喜欢的是一款叫 WING 的太空射击游戏,让人想起经典的街机游戏 Galaga(WING 就是 Wing Is Not Galaga 的递归缩写词)。 + +As-Easy-As 是我最喜欢的一个 DOS 应用程序,作为20世纪8、90年代流行的电子表格程序,它和当时的 Lotus 1-2-3 以及现在的 Microsoft Excel、LibreOffice Calc 一样具有强大的威力。As-Easy-As 和 Lotus 1-2-3 都将数据保存为 WKS 文件,现在新版本的 Microsoft Excel 已经无法读取这种文件了,而 LibreOffice Calc 是兼容性而定有可能支持。鉴于 As-Easy-As 的初始版本是一个共享软件,TRIUS 仍然为 As-Easy-As 5.7 免费提供[激活码][6]。 + +我也非常喜欢 GNU Emacs 编辑器,FreeDOS 也自带了一个叫 Freemacs 的类 Emacs 的文本编辑器。它比 FreeDOS 默认的 FreeDOS Edit 编辑器更强大,也能带来 GNU Emacs 的体验。如果你也需要,可以在 FreeDOS 1.2 中通过`FDIMPLES`包管理程序来安装。 + +### 是的,你或许真的可以在树莓派上运行 DOS + +While you can't run DOS on "bare hardware" on the Raspberry Pi, it's nice to know that you can still run DOS on the Raspberry Pi via an emulator. Thanks to the QEMU PC emulator and FreeDOS, it's possible to play classic DOS games and run other DOS programs on the Raspberry Pi. Expect a slight performance hit when doing any disk I/O, especially if you're doing something intensive on the disk, like writing large amounts of data, but things will run fine after that. Once you've set up QEMU as the virtual machine emulator and installed FreeDOS, you are all set to enjoy your favorite classic DOS programs on the Raspberry Pi. + +即使树莓派在硬件上不支持 DOS,但是在模拟器的帮助下,DOS 还是能够在树莓派上运行。得益于 QEMU PC 模拟器,一些经典的 DOS 游戏和 DOS 应用程序能够运行在树莓派上。在执行磁盘 I/O ,尤其是大量密集操作(例如写入大量数据)的时候,性能可能会受到轻微的影响。当你使用 QEMU 并且在虚拟机里安装好 FreeDOS 之后,你就可以尽情享受经典的 DOS 程序了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/can-you-run-dos-raspberry-pi + +作者:[Jim Hall][a] +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/jim-hall +[1]:http://www.freedos.org/ +[2]:https://opensource.com/article/18/3/raspberry-pi-week-giveaway +[3]:https://www.qemu.org/ +[4]:https://www.raspberrypi.org/downloads/ +[5]:https://opensource.com/article/17/10/run-dos-applications-linux +[6]:http://www.triusinc.com/forums/viewtopic.php?t=10 From 6a74f0fe2984ba0af43d55aae111ca8e659a570f Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 00:45:40 +0800 Subject: [PATCH 0045/1057] PRF:20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md @MjSeven --- ...rams installed from source and dotfiles.md | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/translated/tech/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md b/translated/tech/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md index ef8cf715e6..306684f885 100644 --- a/translated/tech/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md +++ b/translated/tech/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md @@ -1,59 +1,62 @@ -如何使用 GNU Stow 来管理从源代码和 dotfiles 安装的程序 +如何使用 GNU Stow 来管理从源代码安装的程序和点文件 ===== -dotfiles(**.**开头的文件在 *nix 下默认为隐藏文件) + ### 目的 -使用 GNU Stow 轻松管理从源代码和 dotfiles 安装的程序 +使用 GNU Stow 轻松管理从源代码安装的程序和点文件(LCTT 译注:点文件dotfile,即以 `.` 开头的文件,在 *nix 下默认为隐藏文件,常用于存储程序的配置信息。) ### 要求 * root 权限 - ### 难度 简单 ### 约定 -* **#** \- 要求直接以 root 用户身份或使用 `sudo` 命令以 root 权限执行给定的命令 -* **$** \- 给定的命令将作为普通的非特权用户来执行 +* `#` - 给定的命令要求直接以 root 用户身份或使用 `sudo` 命令以 root 权限执行 +* `$` - 给定的命令将作为普通的非特权用户来执行 ### 介绍 -有时候我们必须从源代码安装程序,因为它们也许不能通过标准渠道获得,或者我们可能需要特定版本的软件。 GNU Stow 是一个非常不错的 `symlinks factory` 程序,它可以帮助我们保持文件的整洁,易于维护。 +有时候我们必须从源代码安装程序,因为它们也许不能通过标准渠道获得,或者我们可能需要特定版本的软件。 GNU Stow 是一个非常不错的符号链接工厂symlinks factory程序,它可以帮助我们保持文件的整洁,易于维护。 ### 获得 stow 你的 Linux 发行版本很可能包含 `stow`,例如在 Fedora,你安装它只需要: + ``` # dnf install stow ``` -在 Ubuntu/Debian 中,安装 stow 需要执行: +在 Ubuntu/Debian 中,安装 `stow` 需要执行: + ``` # apt install stow ``` -在某些 Linux 发行版中,stow 在标准库中是不可用的,但是可以通过一些额外的软件源(例如 Rhel 和 CentOS7 中的epel )轻松获得,或者,作为最后的手段,你可以从源代码编译它。只需要很少的依赖关系。 +在某些 Linux 发行版中,`stow` 在标准库中是不可用的,但是可以通过一些额外的软件源(例如 RHEL 和 CentOS7 中的EPEL )轻松获得,或者,作为最后的手段,你可以从源代码编译它。只需要很少的依赖关系。 ### 从源代码编译 最新的可用 stow 版本是 `2.2.2`。源码包可以在这里下载:`https://ftp.gnu.org/gnu/stow/`。 一旦你下载了源码包,你就必须解压它。切换到你下载软件包的目录,然后运行: + ``` $ tar -xvpzf stow-2.2.2.tar.gz ``` -解压源文件后,切换到 stow-2.2.2 目录中,然后编译该程序,只需运行: +解压源文件后,切换到 `stow-2.2.2` 目录中,然后编译该程序,只需运行: + ``` $ ./configure $ make - ``` 最后,安装软件包: + ``` # make install ``` @@ -64,57 +67,60 @@ $ make ### stow 是如何工作的? -stow 背后主要的概念在程序手册中有很好的解释: -``` -Stow 使用的方法是将每个软件包安装到自己的树中,然后使用符号链接使它看起来像文件一样安装在普通树中 +`stow` 背后主要的概念在程序手册中有很好的解释: -``` +> Stow 使用的方法是将每个软件包安装到自己的目录树中,然后使用符号链接使它看起来像文件一样安装在公共的目录树中 为了更好地理解这个软件的运作,我们来分析一下它的关键概念: #### stow 文件目录 -stow 目录是包含所有 `stow 包` 的根目录,每个包都有自己的子目录。典型的 stow 目录是 `/usr/local/stow`:在其中,每个子目录代表一个 `package`。 +stow 目录是包含所有 stow 软件包的根目录,每个包都有自己的子目录。典型的 stow 目录是 `/usr/local/stow`:在其中,每个子目录代表一个软件包。 -#### stow 包 +#### stow 软件包 -如上所述,stow 目录包含多个 "包",每个包都位于自己单独的子目录中,通常以程序本身命名。包不过是与特定软件相关的文件和目录列表,作为实体进行管理。 +如上所述,stow 目录包含多个“软件包”,每个软件包都位于自己单独的子目录中,通常以程序本身命名。包就是与特定软件相关的文件和目录列表,作为一个实体进行管理。 #### stow 目标目录 -stow 目标目录解释起来是一个非常简单的概念。它是包文件必须安装的目录。默认情况下,stow 目标目录被认为是从目录调用 stow 的目录。这种行为可以通过使用 `-t` 选项( --target 的简写)轻松改变,这使我们可以指定一个替代目录。 +stow 目标目录解释起来是一个非常简单的概念。它是包文件应该安装到的目录。默认情况下,stow 目标目录被视作是调用 stow 的目录。这种行为可以通过使用 `-t` 选项( `--target` 的简写)轻松改变,这使我们可以指定一个替代目录。 ### 一个实际的例子 -我相信一个好的例子胜过 1000 句话,所以让我来展示 stow 如何工作。假设我们想编译并安装 `libx264`,首先我们克隆包含其源代码的仓库: +我相信一个好的例子胜过 1000 句话,所以让我来展示 `stow` 如何工作。假设我们想编译并安装 `libx264`,首先我们克隆包含其源代码的仓库: + ``` $ git clone git://git.videolan.org/x264.git ``` -运行该命令几秒钟后,将创建 "x264" 目录,并且它将包含准备编译的源代码。我们切换到 "x264" 目录中并运行 `configure` 脚本,将 `--prefix` 指定为 /usr/local/stow/libx264 目录。 +运行该命令几秒钟后,将创建 `x264` 目录,它将包含准备编译的源代码。我们切换到 `x264` 目录中并运行 `configure` 脚本,将 `--prefix` 指定为 `/usr/local/stow/libx264` 目录。 + ``` $ cd x264 && ./configure --prefix=/usr/local/stow/libx264 ``` 然后我们构建该程序并安装它: + ``` $ make # make install ``` -x264 目录应该在 stow 目录内创建:它包含所有通常直接安装在系统中的东西。 现在,我们所要做的就是调用 stow。 我们必须从 stow 目录内运行这个命令,通过使用 `-d` 选项来手动指定 stow 目录的路径(默认为当前目录),或者通过如前所述用 `-t` 指定目标。我们还应该提供要作为参数存储的包的名称。 在这种情况下,我们从 stow 目录运行程序,所以我们需要输入的内容是: +`x264` 目录应该创建在 `stow` 目录内:它包含了所有通常直接安装在系统中的东西。 现在,我们所要做的就是调用 `stow`。 我们必须从 `stow` 目录内运行这个命令,通过使用 `-d` 选项来手动指定 `stow` 目录的路径(默认为当前目录),或者通过如前所述用 `-t` 指定目标。我们还应该提供要作为参数存储的软件包的名称。 在这里,我们从 `stow` 目录运行程序,所以我们需要输入的内容是: + ``` # stow libx264 ``` -libx264 软件包中包含的所有文件和目录现在已经在调用 stow 的父目录 (/usr/local) 中进行了符号链接,因此,例如在 `/usr/local/ stow/x264/bin` 中包含的 libx264 二进制文件现在在 `/usr/local/bin` 中符号链接,`/usr/local/stow/x264/etc` 中的文件现在符号链接在 `/usr/local/etc` 中等等。通过这种方式,系统将显示文件已正常安装,并且我们可以容易地跟踪我们编译和安装的每个程序。要恢复该操作,我们只需使用 `-D` 选项: +libx264 软件包中包含的所有文件和目录现在已经在调用 stow 的父目录 (/usr/local) 中进行了符号链接,因此,例如在 `/usr/local/ stow/x264/bin` 中包含的 libx264 二进制文件现在符号链接在 `/usr/local/bin` 之中,`/usr/local/stow/x264/etc` 中的文件现在符号链接在 `/usr/local/etc` 之中等等。通过这种方式,系统将显示文件已正常安装,并且我们可以容易地跟踪我们编译和安装的每个程序。要反转该操作,我们只需使用 `-D` 选项: + ``` # stow -d libx264 ``` -完成了!符号链接不再存在:我们只是“卸载”了一个 stow 包,使我们的系统保持在一个干净且一致的状态。 在这一点上,我们应该清楚为什么 stow 还用于管理 dotfiles。 通常的做法是在 git 仓库中包含用户特定的所有配置文件,以便轻松管理它们并使它们在任何地方都可用,然后使用 stow 将它们放在适当位置,如放在用户主目录中。 +完成了!符号链接不再存在:我们只是“卸载”了一个 stow 包,使我们的系统保持在一个干净且一致的状态。 在这一点上,我们应该清楚为什么 stow 还可以用于管理点文件。 通常的做法是在 git 仓库中包含用户特定的所有配置文件,以便轻松管理它们并使它们在任何地方都可用,然后使用 stow 将它们放在适当位置,如放在用户主目录中。 -Stow 还会阻止你错误地覆盖文件:如果目标文件已经存在并且没有指向 Stow 目录中的包时,它将拒绝创建符号链接。 这种情况在 Stow 术语中称为冲突。 +stow 还会阻止你错误地覆盖文件:如果目标文件已经存在,并且没有指向 stow 目录中的包时,它将拒绝创建符号链接。 这种情况在 stow 术语中称为冲突。 就是这样!有关选项的完整列表,请参阅 stow 帮助页,并且不要忘记在评论中告诉我们你对此的看法。 @@ -124,7 +130,7 @@ via: https://linuxconfig.org/how-to-use-gnu-stow-to-manage-programs-installed-fr 作者:[Egidio Docile][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 5a38e108f33e8ca7073de61c2853716b2b3326cc Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 00:46:05 +0800 Subject: [PATCH 0046/1057] PUB: 20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md @MjSeven --- ... Stow to manage programs installed from source and dotfiles.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md (100%) diff --git a/translated/tech/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md b/published/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md similarity index 100% rename from translated/tech/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md rename to published/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md From fe1aeabdb5c0ca25f130d7420d28205875179641 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 22 Mar 2018 08:31:23 +0800 Subject: [PATCH 0047/1057] translated --- ...ok inside Facebooks open source program.md | 70 ------------------- ...ok inside Facebooks open source program.md | 70 +++++++++++++++++++ 2 files changed, 70 insertions(+), 70 deletions(-) delete mode 100644 sources/tech/20180129 A look inside Facebooks open source program.md create mode 100644 translated/tech/20180129 A look inside Facebooks open source program.md diff --git a/sources/tech/20180129 A look inside Facebooks open source program.md b/sources/tech/20180129 A look inside Facebooks open source program.md deleted file mode 100644 index c76a524026..0000000000 --- a/sources/tech/20180129 A look inside Facebooks open source program.md +++ /dev/null @@ -1,70 +0,0 @@ -translating---geekpi - -A look inside Facebook's open source program -============================================================ - -### Facebook developer Christine Abernathy discusses how open source helps the company share insights and boost innovation. - -![A look inside Facebook's open source program](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe "A look inside Facebook's open source program") -Image by : opensource.com - - -Open source becomes more ubiquitous every year, appearing everywhere from [government municipalities][11] to [universities][12]. Companies of all sizes are also increasingly turning to open source software. In fact, some companies are taking open source a step further by supporting projects financially or working with developers. - -Facebook's open source program, for example, encourages others to release their code as open source, while working and engaging with the community to support open source projects. [Christine Abernathy][13], a Facebook developer, open source advocate, and member of the company's open source team, visited the Rochester Institute of Technology last November, presenting at the [November edition][14] of the FOSS Talks speaker series. In her talk, Abernathy explained how Facebook approaches open source and why it's an important part of the work the company does. - -### Facebook and open source - -Abernathy said that open source plays a fundamental role in Facebook's mission to create community and bring the world closer together. This ideological match is one motivating factor for Facebook's participation in open source. Additionally, Facebook faces unique infrastructure and development challenges, and open source provides a platform for the company to share solutions that could help others. Open source also provides a way to accelerate innovation and create better software, helping engineering teams produce better software and work more transparently. Today, Facebook's 443 projects on GitHub comprise 122,000 forks, 292,000 commits, and 732,000 followers. - - - -![open source projects by Facebook](https://opensource.com/sites/default/files/images/life-uploads/blog-article-facebook-open-source-projects.png "open source projects by Facebood") - -Some of the Facebook projects released as open source include React, GraphQL, Caffe2, and others. (Image by Christine Abernathy, used with permission) - -### Lessons learned - -Abernathy emphasized that Facebook has learned many lessons from the open source community, and it looks forward to learning many more. She identified the three most important ones: - -* Share what's useful - -* Highlight your heroes - -* Fix common pain points - - _Christine Abernathy visited RIT as part of the FOSS Talks speaker series. Every month, a guest speaker from the open source world shares wisdom, insight, and advice about the open source world with students interested in free and open source software. The [FOSS @ MAGIC][3] community is thankful to have Abernathy attend as a speaker._ - -### About the author - - [![Picture of Justin W. Flory](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/october_2017_cropped_0.jpg?itok=gV-RgINC)][15] Justin W. Flory - Justin is a student at the [Rochester Institute of Technology][4]majoring in Networking and Systems Administration. He is currently a contributor to the [Fedora Project][5]. In Fedora, Justin is the editor-in-chief of the [Fedora Magazine][6], the lead of the [Community... ][7][more about Justin W. Flory][8][More about me][9] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/inside-facebooks-open-source-program - -作者:[Justin W. Flory ][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/jflory -[1]:https://opensource.com/file/383786 -[2]:https://opensource.com/article/18/1/inside-facebooks-open-source-program?rate=H9_bfSwXiJfi2tvOLiDxC_tbC2xkEOYtCl-CiTq49SA -[3]:http://foss.rit.edu/ -[4]:https://www.rit.edu/ -[5]:https://fedoraproject.org/wiki/Overview -[6]:https://fedoramagazine.org/ -[7]:https://fedoraproject.org/wiki/CommOps -[8]:https://opensource.com/users/jflory -[9]:https://opensource.com/users/jflory -[10]:https://opensource.com/user/74361/feed -[11]:https://opensource.com/article/17/8/tirana-government-chooses-open-source -[12]:https://opensource.com/article/16/12/2016-election-night-hackathon -[13]:https://twitter.com/abernathyca -[14]:https://www.eventbrite.com/e/fossmagic-talks-open-source-facebook-with-christine-abernathy-tickets-38955037566# -[15]:https://opensource.com/users/jflory -[16]:https://opensource.com/users/jflory -[17]:https://opensource.com/users/jflory -[18]:https://opensource.com/article/18/1/inside-facebooks-open-source-program#comments \ No newline at end of file diff --git a/translated/tech/20180129 A look inside Facebooks open source program.md b/translated/tech/20180129 A look inside Facebooks open source program.md new file mode 100644 index 0000000000..87749076fb --- /dev/null +++ b/translated/tech/20180129 A look inside Facebooks open source program.md @@ -0,0 +1,70 @@ +深入看看 Facebook 的开源计划 +============================================================ + +### Facebook 开发人员 Christine Abernathy 讨论了开源如何帮助公司分享见解并推动创新。 + +![A look inside Facebook's open source program](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe "A look inside Facebook's open source program") +图像来源:opensource.com + + +开源每年在变得无处不在,从[政府直辖市][11]到[大学] [12]都有。各种规模的公司也越来越多地转向开源软件。事实上,一些公司正在通过财务支持项目或与开发人员合作进一步推进开源。 + +例如,Facebook 的开源计划鼓励其他人开源发布他们的代码,同时与社区合作支持开源项目。 [Christine Abernathy][13],一名 Facebook 开发者,开源支持者,公司开源团队成员,去年 11 月访问了罗切斯特理工学院,在[ 11 月][14] 的 FOSS 系列演讲中发表了演讲。在她的演讲中,Abernathy 解释了 Facebook 如何开源以及为什么它是公司所做工作的重要组成部分。 + +### Facebook 和开源 + +Abernathy 说,开源在 Facebook 创建社区和使世界更加紧密的使命中扮演着重要的角色。这种意识形态的匹配是 Facebook 参与开源的一个激励因素。此外,Facebook 面临着独特的基础设施和开发挑战,而开源则为公司提供了一个平台,以共享可帮助他人的解决方案。开源还提供了一种加速创新和创建更好软件的方法,帮助工程团队生产更好的软件并更透明地工作。今天,Facebook 在 GitHub 上有 443个 项目包括 122,000 个分支,292,000 个提交和 732,000 个关注。 + + +![open source projects by Facebook](https://opensource.com/sites/default/files/images/life-uploads/blog-article-facebook-open-source-projects.png "open source projects by Facebood") + +一些以开源方式发布的 Facebook 项目包括 React、GraphQL、Caffe2 等等。(图片提供:Christine Abernathy 图片,经许可使用) + +### 得到的教训 + +Abernathy 强调说 Facebook 已经从开源社区吸取了很多教训,并期待学到更多。她明确了三个最重要的: + +* 分享有用的东西 + +* 突出你的英雄 + +* 修复常见的痛点 + + _Christine Abernathy 作为 FOSS 演讲系列的嘉宾一员参观了 RIT。每个月,来自开源世界的演讲嘉宾都会与对免费和开源软件感兴趣的学生分享关于开源世界智慧、见解、建议。 [FOSS @MAGIC][3]社区感谢 Abernathy 作为演讲嘉宾出席。_ + +### 关于作者 + + [![Picture of Justin W. Flory](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/october_2017_cropped_0.jpg?itok=gV-RgINC)][15] +Justin 是[罗切斯特理工学院][4]主修网络与系统管理的学生。他目前是 [Fedora Project][5] 的贡献者。在 Fedora 中,Justin 是 [Fedora Magazine][6] 的主编,[社区的领导][7]。。。[更多关于 Justin W. Flory]​​[8] + +[关于我更多][9] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/inside-facebooks-open-source-program + +作者:[Justin W. Flory ][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/jflory +[1]:https://opensource.com/file/383786 +[2]:https://opensource.com/article/18/1/inside-facebooks-open-source-program?rate=H9_bfSwXiJfi2tvOLiDxC_tbC2xkEOYtCl-CiTq49SA +[3]:http://foss.rit.edu/ +[4]:https://www.rit.edu/ +[5]:https://fedoraproject.org/wiki/Overview +[6]:https://fedoramagazine.org/ +[7]:https://fedoraproject.org/wiki/CommOps +[8]:https://opensource.com/users/jflory +[9]:https://opensource.com/users/jflory +[10]:https://opensource.com/user/74361/feed +[11]:https://opensource.com/article/17/8/tirana-government-chooses-open-source +[12]:https://opensource.com/article/16/12/2016-election-night-hackathon +[13]:https://twitter.com/abernathyca +[14]:https://www.eventbrite.com/e/fossmagic-talks-open-source-facebook-with-christine-abernathy-tickets-38955037566# +[15]:https://opensource.com/users/jflory +[16]:https://opensource.com/users/jflory +[17]:https://opensource.com/users/jflory +[18]:https://opensource.com/article/18/1/inside-facebooks-open-source-program#comments \ No newline at end of file From 772145914bc77d7f7c12fed8c707ad55875bc941 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 22 Mar 2018 08:35:27 +0800 Subject: [PATCH 0048/1057] translating --- sources/tech/20180314 Playing with water.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180314 Playing with water.md b/sources/tech/20180314 Playing with water.md index efa4c43c9a..7c354e7975 100644 --- a/sources/tech/20180314 Playing with water.md +++ b/sources/tech/20180314 Playing with water.md @@ -1,3 +1,5 @@ +translating---geekpi + Playing with water ====== ![H2o Flow gradient boosting job][1] From b63abe5a8d09339b047072d3c8cbc0859c52106c Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 08:38:06 +0800 Subject: [PATCH 0049/1057] PRF:20171218 What Are Containers and Why Should You Care-.md @lonaparte --- ...Are Containers and Why Should You Care-.md | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/translated/tech/20171218 What Are Containers and Why Should You Care-.md b/translated/tech/20171218 What Are Containers and Why Should You Care-.md index 8d612dbed0..1a7ce4d948 100644 --- a/translated/tech/20171218 What Are Containers and Why Should You Care-.md +++ b/translated/tech/20171218 What Are Containers and Why Should You Care-.md @@ -1,44 +1,47 @@ 什么是容器?为什么我们关注它? ====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/containers-basics.jpg?itok=ZLH9VSaC) + 什么是容器?你需要它们吗?为什么?在这篇文章中,我们会回答这些基本问题。 但是,为了回答这些问题,我们要提出更多的问题。当你开始考虑怎么用容器适配你的工作时,你需要弄清楚:你在哪开发应用?你在哪测试它?你在哪使用它? -你可能在你的笔记本电脑上开发应用,你的电脑上已经装好了所需要的库文件,扩展包,开发工具,和开发框架。它在一个模拟生产环境的机器上进行测试,然后被用于生产。问题是这三种环境不一定都是一样的;他们没有同样的工具,框架,和库。你在你机器上开发的应用不一定可以在生产环境中正常工作。 +你可能在你的笔记本电脑上开发应用,你的电脑上已经装好了所需要的库文件、扩展包、开发工具和开发框架。它在一个模拟生产环境的机器上进行测试,然后被用于生产环境。问题是这三种环境不一定都是一样的;它们没有同样的工具、框架和库。你在你机器上开发的应用不一定可以在生产环境中正常工作。 -容器解决了这个问题。正如 Docker 解释的,“容器镜像是软件的一个轻量的,独立的,可执行的包,包括了执行它所需要的所有东西:代码,运行环境,系统工具,系统库,设置。” +容器解决了这个问题。正如 Docker 解释的,“容器镜像是软件的一个轻量的、独立的、可执行的包,包括了执行它所需要的所有东西:代码、运行环境、系统工具、系统库、设置。” -这代表着,一旦一个应用被封装成容器,那么它所依赖的下层环境就不再重要了。它可以在任何地方运行,甚至在混合云环境下也可以。这是容器在开发者,执行团队,甚至 CIO (信息主管)中变得如此流行的原因之一。 +这代表着,一旦一个应用被封装成容器,那么它所依赖的下层环境就不再重要了。它可以在任何地方运行,甚至在混合云环境下也可以。这是容器在开发人员,执行团队,甚至 CIO (信息主管)中变得如此流行的原因之一。 -### 容器对开发者的好处 +### 容器对开发人员的好处 -现在开发者或执行者不再需要关注他们要使用什么平台来运行应用。开发者不会再说:“这在我的系统上运行得好好的。” +现在开发人员或运维人员不再需要关注他们要使用什么平台来运行应用。开发人员不会再说:“这在我的系统上运行得好好的。” -容器的另一个重大优势时它的隔离性和安全性。因为容器将应用和运行平台隔离开了,应用以及它周边的东西都会变得安全。同时,不同的团队可以在一台设备上同时运行不同的应用——对于传统应用来说这是不可以的。 +容器的另一个重大优势是它的隔离性和安全性。因为容器将应用和运行平台隔离开了,应用以及它周边的东西都会变得安全。同时,不同的团队可以在一台设备上同时运行不同的应用——对于传统应用来说这是不可以的。 -这不是虚拟机( VM )所提供的吗?是的,也不是。虚拟机可以隔离应用,但它负载太高了。[在一份文献中][1],Canonical 比较了容器和虚拟机,结果是:“容器提供了一种新的虚拟化方法,它有着和传统虚拟机几乎相同的资源隔离水平。但容器的负载更小,它占用更少的内存,更为高效。这意味着可以实现高密度的虚拟化:一旦安装,你可以在相同的硬件上运行更多应用。”另外,虚拟机启动前需要更多的准备,而容器只需几秒就能运行,可以瞬间启动。 +这不是虚拟机( VM )所提供的吗?既是,也不是。虚拟机可以隔离应用,但它负载太高了。[在一份文献中][1],Canonical 比较了容器和虚拟机,结果是:“容器提供了一种新的虚拟化方法,它有着和传统虚拟机几乎相同的资源隔离水平。但容器的负载更小,它占用更少的内存,更为高效。这意味着可以实现高密度的虚拟化:一旦安装,你可以在相同的硬件上运行更多应用。”另外,虚拟机启动前需要更多的准备,而容器只需几秒就能运行,可以瞬间启动。 ### 容器对应用生态的好处 -现在,一个庞大的,由供应商和解决方案组成的生态系统已经允许公司大规模地运用容器,不管是用于编排,监控,记录,或者生命周期管理。 +现在,一个庞大的,由供应商和解决方案组成的生态系统已经可以让公司大规模地运用容器,不管是用于编排、监控、记录或者生命周期管理。 -为了保证容器可以运行在任何地方,容器生态系统一起成立了[开源容器倡议][2](OCI)。这是一个 Linux 基金会的项目,目标在于创建关于容器运行环境和容器镜像格式这两个容器核心部分的规范。这两个规范确保容器空间中不会有任何碎片。 +为了保证容器可以运行在任何地方,容器生态系统一起成立了[开源容器倡议][2](OCI)。这是一个 Linux 基金会的项目,目标在于创建关于容器运行环境和容器镜像格式这两个容器核心部分的规范。这两个规范确保容器领域中不会有任何不一致。 -在很长的一段时间里,容器是专门用于 Linux 内核的,但微软和 Docker 的密切合作将容器带到了微软平台上。现在你可以在 Linux,Windows,Azure,AWS,Google 计算引擎,Rackspace,以及大型计算机上使用容器。甚至 VMware 也正在发展容器,它的 [vSphere Integrated Container][3](VIC)允许 IT 专业人员在他们平台的传统工作负载上运行容器。 +在很长的一段时间里,容器是专门用于 Linux 内核的,但微软和 Docker 的密切合作将容器带到了微软平台上。现在你可以在 Linux、Windows、Azure、AWS、Google 计算引擎、Rackspace,以及大型计算机上使用容器。甚至 VMware 也正在发展容器,它的 [vSphere Integrated Container][3](VIC)允许 IT 专业人员在他们平台的传统工作负载上运行容器。 ### 容器对 CIO 的好处 -容器在开发者中因为以上的原因而变得十分流行,同时他们也给CIO提供了很大的便利。将工作负载迁移到容器中的优势正在改变着公司运行的模式。 +容器在开发人员中因为以上的原因而变得十分流行,同时他们也给 CIO 提供了很大的便利。将工作负载迁移到容器中的优势正在改变着公司运行的模式。 -传统的应用有大约十年的生命周期。新版本的发布需要多年的努力,因为应用是独立于平台的,有时需要经过几年的努力才能看到生产效果。由于这个生命周期,开发者会尽可能在应用里塞满各种功能,这会使应用变得庞大笨拙,漏洞百出。 +传统的应用有大约十年的生命周期。新版本的发布需要多年的努力,因为应用是依赖于平台的,有时几年也不能到达产品阶段。由于这个生命周期,开发人员会尽可能在应用里塞满各种功能,这会使应用变得庞大笨拙,漏洞百出。 这个过程影响了公司内部的创新文化。当人们几个月甚至几年都不能看到他们的创意被实现时,他们就不再有动力了。 -容器解决了这个问题。因为你可以将应用切分成更小的微服务。你可以在几周或几天内开发,测试和部署。新特性可以添加成为新的容器。他们可以在测试结束后以最快的速度被投入生产。公司可以更快转型,超过他们的竞争者。因为想法可以被很快转化为容器并部署,这个方式使得创意爆炸式增长。 +容器解决了这个问题。因为你可以将应用切分成更小的微服务。你可以在几周或几天内开发、测试和部署。新特性可以添加成为新的容器。他们可以在测试结束后以最快的速度被投入生产。公司可以更快转型,超过他们的竞争者。因为想法可以被很快转化为容器并部署,这个方式使得创意爆炸式增长。 ### 结论 -容器解决了许多传统工作负载所面对的问题。但是,它并不能解决所有 IT 专业人员面对的问题。它只是众多解决方案中的一个。在下一篇文章中,我们将会覆盖一些容器的基本属于,然后我们会解释如何开始构建容器。 +容器解决了许多传统工作负载所面对的问题。但是,它并不能解决所有 IT 专业人员面对的问题。它只是众多解决方案中的一个。在下一篇文章中,我们将会覆盖一些容器的基本术语,然后我们会解释如何开始构建容器。 通过 Linux 基金会和 edX 提供的免费的 ["Introduction to Linux" ][4] 课程学习更多 Linux 知识。 @@ -46,9 +49,9 @@ via: https://www.linux.com/blog/intro-to-Linux/2017/12/what-are-containers-and-why-should-you-care -作者:[wapnil Bhartiya][a] +作者:[SWAPNIL BHARTIYA][a] 译者:[lonaparte](https://github.com/lonaparte) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e61e7153096201abecf219719c2e3a6933db272c Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 08:38:37 +0800 Subject: [PATCH 0050/1057] PUB: 20171218 What Are Containers and Why Should You Care-.md @lonaparte --- .../20171218 What Are Containers and Why Should You Care-.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171218 What Are Containers and Why Should You Care-.md (100%) diff --git a/translated/tech/20171218 What Are Containers and Why Should You Care-.md b/published/20171218 What Are Containers and Why Should You Care-.md similarity index 100% rename from translated/tech/20171218 What Are Containers and Why Should You Care-.md rename to published/20171218 What Are Containers and Why Should You Care-.md From dfd3433e53542ccc482ff089f4663b216408efab Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 08:52:20 +0800 Subject: [PATCH 0051/1057] PRF:20180123 Never miss a Magazine-s article, build your own RSS notification system.md @qhwdw --- ... build your own RSS notification system.md | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/translated/tech/20180123 Never miss a Magazine-s article, build your own RSS notification system.md b/translated/tech/20180123 Never miss a Magazine-s article, build your own RSS notification system.md index acd94006d8..feb3acbe71 100644 --- a/translated/tech/20180123 Never miss a Magazine-s article, build your own RSS notification system.md +++ b/translated/tech/20180123 Never miss a Magazine-s article, build your own RSS notification system.md @@ -1,4 +1,4 @@ -构建你自己的 RSS 提示系统——让杂志文章一篇也不会错过 +用 Python 构建你自己的 RSS 提示系统 ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/01/learn-python-rss-notifier.png-945x400.jpg) @@ -7,9 +7,9 @@ ### Fedora 和 Python —— 入门知识 -Python 3.6 在 Fedora 中是默认安装的,它包含了 Python 的很多标准库。标准库提供了一些可以让我们的任务更加简单完成的模块的集合。例如,在我们的案例中,我们将使用 [**sqlite3**][1] 模块在数据库中去创建表、添加和读取数据。在这个案例中,我们试图去解决的是在标准库中没有的特定的问题,也有可能已经有人为我们开发了这样一个模块。最好是使用像大家熟知的 [PyPI][2] Python 包索引去搜索一下。在我们的示例中,我们将使用 [**feedparser**][3] 去解析 RSS 源。 +Python 3.6 在 Fedora 中是默认安装的,它包含了 Python 的很多标准库。标准库提供了一些可以让我们的任务更加简单完成的模块的集合。例如,在我们的案例中,我们将使用 [sqlite3][1] 模块在数据库中去创建表、添加和读取数据。在这个案例中,我们试图去解决的是这样的一个特定问题,在标准库中没有包含,而有可能已经有人为我们开发了这样一个模块。最好是使用像大家熟知的 [PyPI][2] Python 包索引去搜索一下。在我们的示例中,我们将使用 [feedparser][3] 去解析 RSS 源。 -因为 **feedparser** 并不是标准库,我们需要将它安装到我们的系统上。幸运的是,在 Fedora 中有这个 RPM 包,因此,我们可以运行如下的命令去安装 **feedparser**: +因为 feedparser 并不是标准库,我们需要将它安装到我们的系统上。幸运的是,在 Fedora 中有这个 RPM 包,因此,我们可以运行如下的命令去安装 feedparser: ``` $ sudo dnf install python3-feedparser ``` @@ -18,11 +18,12 @@ $ sudo dnf install python3-feedparser ### 存储源数据 -我们需要存储已经发布的文章的数据,这样我们的系统就可以只提示新发布的文章。我们要保存的数据将是用来辨别一篇文章的唯一方法。因此,我们将存储文章的**标题**和**发布日期**。 +我们需要存储已经发布的文章的数据,这样我们的系统就可以只提示新发布的文章。我们要保存的数据将是用来辨别一篇文章的唯一方法。因此,我们将存储文章的标题和发布日期。 -因此,我们来使用 Python **sqlite3** 模块和一个简单的 SQL 语句来创建我们的数据库。同时也添加一些后面将要用到的模块(**feedparse**,**smtplib**,和 **email**)。 +因此,我们来使用 Python sqlite3 模块和一个简单的 SQL 语句来创建我们的数据库。同时也添加一些后面将要用到的模块(feedparse,smtplib,和 email)。 #### 创建数据库 + ``` #!/usr/bin/python3 import sqlite3 @@ -34,14 +35,14 @@ import feedparser db_connection = sqlite3.connect('/var/tmp/magazine_rss.sqlite') db = db_connection.cursor() db.execute(' CREATE TABLE IF NOT EXISTS magazine (title TEXT, date TEXT)') - ``` -这几行代码创建一个新的保存在一个名为 'magazine_rss.sqlite' 文件中的 sqlite 数据库,然后在数据库创建一个名为 'magazine' 的新表。这个表有两个列 —— 'title' 和 'date' —— 它们能存诸 TEXT 类型的数据,也就是说每个列的值都是文本字符。 +这几行代码创建一个名为 `magazine_rss.sqlite` 文件的新 sqlite 数据库,然后在数据库创建一个名为 `magazine` 的新表。这个表有两个列 —— `title` 和 `date` —— 它们能存诸 TEXT 类型的数据,也就是说每个列的值都是文本字符。 #### 检查数据库中的旧文章 由于我们仅希望增加新的文章到我们的数据库中,因此我们需要一个功能去检查 RSS 源中的文章在数据库中是否存在。我们将根据它来判断是否发送(有新文章的)邮件提示。Ok,现在我们来写这个功能的代码。 + ``` def article_is_not_db(article_title, article_date): """ Check if a given pair of article title and date @@ -60,13 +61,14 @@ def article_is_not_db(article_title, article_date): return False ``` -这个功能的主要部分是一个 SQL 查询,我们运行它去搜索数据库。我们使用一个 SELECT 命令去定义我们将要在哪个列上运行这个查询。我们使用 `*` 符号去选取所有列(title 和 date)。然后,我们使用查询的 WHERE 条件 `article_title` and `article_date` 去匹配标题和日期列中的值,以检索出我们需要的内容。 +这个功能的主要部分是一个 SQL 查询,我们运行它去搜索数据库。我们使用一个 `SELECT` 命令去定义我们将要在哪个列上运行这个查询。我们使用 `*` 符号去选取所有列(`title` 和 `date`)。然后,我们使用查询的 `WHERE` 条件 `article_title` 和 `article_date` 去匹配标题和日期列中的值,以检索出我们需要的内容。 最后,我们使用一个简单的返回 `True` 或者 `False` 的逻辑来表示是否在数据库中找到匹配的文章。 #### 在数据库中添加新文章 现在我们可以写一些代码去添加新文章到数据库中。 + ``` def add_article_to_db(article_title, article_date): """ Add a new article title and date to the database @@ -78,13 +80,14 @@ def add_article_to_db(article_title, article_date): db_connection.commit() ``` -这个功能很简单,我们使用了一个 SQL 查询去插入一个新行到 'magazine' 表的 article_title 和 article_date 列中。然后提交它到数据库中永久保存。 +这个功能很简单,我们使用了一个 SQL 查询去插入一个新行到 `magazine` 表的 `article_title` 和 `article_date` 列中。然后提交它到数据库中永久保存。 这些就是在数据库中所需要的东西,接下来我们看一下,如何使用 Python 实现提示系统和发送电子邮件。 ### 发送电子邮件提示 -我们来使用 Python 标准库模块 **smtplib** 来创建一个发送电子邮件的功能。我们也可以使用标准库中的 **email** 模块去格式化我们的电子邮件信息。 +我们使用 Python 标准库模块 smtplib 来创建一个发送电子邮件的功能。我们也可以使用标准库中的 email 模块去格式化我们的电子邮件信息。 + ``` def send_notification(article_title, article_url): """ Add a new article title and date to the database @@ -113,6 +116,7 @@ def send_notification(article_title, article_url): ### 读取 Fedora Magazine 的 RSS 源 我们已经有了在数据库中存储文章和发送提示电子邮件的功能,现在来创建一个解析 Fedora Magazine RSS 源并提取文章数据的功能。 + ``` def read_article_feed(): """ Get articles from RSS feed """ @@ -127,25 +131,26 @@ if __name__ == '__main__': db_connection.close() ``` -在这里我们将使用 **feedparser.parse** 功能。这个功能返回一个用字典表示的 RSS 源,对于 **feedparser** 的完整描述可以参考它的 [文档][5]。 +在这里我们将使用 `feedparser.parse` 功能。这个功能返回一个用字典表示的 RSS 源,对于 feedparser 的完整描述可以参考它的 [文档][5]。 RSS 源解析将返回最后的 10 篇文章作为 `entries`,然后我们提取以下信息:标题、链接、文章发布日期。因此,我们现在可以使用前面定义的检查文章是否在数据库中存在的功能,然后,发送提示电子邮件并将这个文章添加到数据库中。 -当运行我们的脚本时,最后的 if 语句运行我们的 `read_article_feed` 功能,然后关闭数据库连接。 +当运行我们的脚本时,最后的 `if` 语句运行我们的 `read_article_feed` 功能,然后关闭数据库连接。 ### 运行我们的脚本 -给脚本文件赋于正确运行权限。接下来,我们使用 **cron** 实用程序去每小时自动运行一次我们的脚本。**cron** 是一个作业计划程序,我们可以使用它在一个固定的时间去运行一个任务。 +给脚本文件赋于正确运行权限。接下来,我们使用 cron 实用程序去每小时自动运行一次我们的脚本。cron 是一个作业计划程序,我们可以使用它在一个固定的时间去运行一个任务。 + ``` $ chmod a+x my_rss_notifier.py $ sudo cp my_rss_notifier.py /etc/cron.hourly ``` -**为了使该教程保持简单**,我们使用了 cron.hourly 目录每小时运行一次我们的脚本,如果你想学习关于 **cron** 的更多知识以及如何配置 **crontab**,请阅读 **cron** 的 wikipedia [页面][6]。 +为了使该教程保持简单,我们使用了 `cron.hourly` 目录每小时运行一次我们的脚本,如果你想学习关于 cron 的更多知识以及如何配置 crontab,请阅读 cron 的 wikipedia [页面][6]。 ### 总结 -在本教程中,我们学习了如何使用 Python 去创建一个简单的 sqlite 数据库、解析一个 RSS 源、以及发送电子邮件。我希望通过这篇文章能够向你展示,**使用 Python 和 Fedora 构建你自己的应用程序是件多么容易的事**。 +在本教程中,我们学习了如何使用 Python 去创建一个简单的 sqlite 数据库、解析一个 RSS 源、以及发送电子邮件。我希望通过这篇文章能够向你展示,使用 Python 和 Fedora 构建你自己的应用程序是件多么容易的事。 这个脚本在 [GitHub][7] 上可以找到。 @@ -155,7 +160,7 @@ via: https://fedoramagazine.org/never-miss-magazines-article-build-rss-notificat 作者:[Clément Verna][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 a41d9aaf7d0fb2c8f8102028dd8bdb56acc4682d Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 08:52:40 +0800 Subject: [PATCH 0052/1057] PUB:20180123 Never miss a Magazine-s article, build your own RSS notification system.md @qhwdw --- ... Magazine-s article, build your own RSS notification system.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180123 Never miss a Magazine-s article, build your own RSS notification system.md (100%) diff --git a/translated/tech/20180123 Never miss a Magazine-s article, build your own RSS notification system.md b/published/20180123 Never miss a Magazine-s article, build your own RSS notification system.md similarity index 100% rename from translated/tech/20180123 Never miss a Magazine-s article, build your own RSS notification system.md rename to published/20180123 Never miss a Magazine-s article, build your own RSS notification system.md From 86286789ec24a4945b87d903b1a07b0c09c58e1e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 22 Mar 2018 08:58:28 +0800 Subject: [PATCH 0053/1057] Update 20171218 What Are Containers and Why Should You Care-.md --- .../20171218 What Are Containers and Why Should You Care-.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/published/20171218 What Are Containers and Why Should You Care-.md b/published/20171218 What Are Containers and Why Should You Care-.md index 1a7ce4d948..32e8af76b0 100644 --- a/published/20171218 What Are Containers and Why Should You Care-.md +++ b/published/20171218 What Are Containers and Why Should You Care-.md @@ -51,7 +51,7 @@ via: https://www.linux.com/blog/intro-to-Linux/2017/12/what-are-containers-and-w 作者:[SWAPNIL BHARTIYA][a] 译者:[lonaparte](https://github.com/lonaparte) -校对:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From befa056888f23ca9b84d95a33bb71c7c64e455ea Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 09:06:00 +0800 Subject: [PATCH 0054/1057] PRF:20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md @geekpi --- ...x PC for Meltdown or Spectre Vulnerability.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/translated/tech/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md b/translated/tech/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md index 069058b917..0a940e1ccd 100644 --- a/translated/tech/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md +++ b/translated/tech/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md @@ -1,18 +1,18 @@ -如何检查你的 Linux PC 是否存在 Meltdown 或者 Spectre 漏洞 +如何检查你的 Linux 系统是否存在 Meltdown 或者 Spectre 漏洞 ====== ![](https://www.maketecheasier.com/assets/uploads/2018/01/lmc-feat.jpg) Meltdown 和 Specter 漏洞的最恐怖的现实之一是它们涉及非常广泛。几乎每台现代计算机都会受到一些影响。真正的问题是_你_是否受到了影响?每个系统都处于不同的脆弱状态,具体取决于已经或者还没有打补丁的软件。 -由于 Meltdown 和 Spectre 都是相当新的,并且事情正在迅速发展,所以告诉你需要注意什么或在系统上修复了什么并非易事。有一些工具可以提供帮助。它们并不完美,但它们可以帮助你找出你需要知道的东西。 +由于 Meltdown 和 Spectre 都是相当新的漏洞,并且事情正在迅速发展,所以告诉你需要注意什么或在系统上修复了什么并非易事。有一些工具可以提供帮助。它们并不完美,但它们可以帮助你找出你需要知道的东西。 ### 简单测试 顶级的 Linux 内核开发人员之一提供了一种简单的方式来检查系统在 Meltdown 和 Specter 漏洞方面的状态。它是简单的,也是最简洁的,但它不适用于每个系统。有些发行版不支持它。即使如此,也值得一试。 + ``` grep . /sys/devices/system/cpu/vulnerabilities/* - ``` ![Kernel Vulnerability Check][1] @@ -24,24 +24,24 @@ grep . /sys/devices/system/cpu/vulnerabilities/* 如果上面的方法不适合你,或者你希望看到更详细的系统报告,一位开发人员已创建了一个 shell 脚本,它将检查你的系统来查看系统收到什么漏洞影响,还有做了什么来减轻 Meltdown 和 Spectre 的影响。 要得到脚本,请确保你的系统上安装了 Git,然后将脚本仓库克隆到一个你不介意运行它的目录中。 + ``` cd ~/Downloads git clone https://github.com/speed47/spectre-meltdown-checker.git - ``` 这不是一个大型仓库,所以它应该只需要几秒钟就克隆完成。完成后,输入新创建的目录并运行提供的脚本。 + ``` cd spectre-meltdown-checker ./spectre-meltdown-checker.sh - ``` -你会在中断看到很多输出。别担心,它不是太难查看。首先,脚本检查你的硬件,然后运行三个漏洞:Specter v1、Spectre v2 和 Meltdown。每个漏洞都有自己的部分。在这之间,脚本明确地告诉你是否受到这三个漏洞的影响。 +你会在终端看到很多输出。别担心,它不是太难理解。首先,脚本检查你的硬件,然后运行三个漏洞检查:Specter v1、Spectre v2 和 Meltdown。每个漏洞都有自己的部分。在这之间,脚本明确地告诉你是否受到这三个漏洞的影响。 ![Meltdown Spectre Check Script Ubuntu][2] -每个部分为你提供潜在的可用的缓解方案,以及它们是否已被应用。这里需要你的一点常识。它给出的决定可能看起来有冲突。研究一下,看看它所说的修复是否实际上完全缓解了这个问题。 +每个部分为你提供了潜在的可用的缓解方案,以及它们是否已被应用。这里需要你的一点常识。它给出的决定可能看起来有冲突。研究一下,看看它所说的修复是否实际上完全缓解了这个问题。 ### 这意味着什么 @@ -53,7 +53,7 @@ via: https://www.maketecheasier.com/check-linux-meltdown-spectre-vulnerability/ 作者:[Nick Congleton][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 8856f82622d07c70bc46d04a78dbd57fcfba3b16 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 22 Mar 2018 09:06:26 +0800 Subject: [PATCH 0055/1057] PUB:20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md @geekpi --- ...o Check Your Linux PC for Meltdown or Spectre Vulnerability.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md (100%) diff --git a/translated/tech/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md b/published/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md similarity index 100% rename from translated/tech/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md rename to published/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md From a86203a3c26b6cb87d7eb7bd60f832c4a68b746f Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Thu, 22 Mar 2018 10:20:34 +0800 Subject: [PATCH 0056/1057] 2018-03-22 --- ... better than Windows or macOS for security.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index 3bd77c01a5..e1a5449a2e 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -1,6 +1,6 @@ fuzheng1998 translating -Why Linux is better than Windows or macOS for security +为什么 Linux 比 Windows 和 macOS 的安全性好 ====== ![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg) @@ -13,7 +13,7 @@ This raises a question that every IT person should be able to answer: Which oper We asked some experts what they think of the security of these three choices: Windows, the ever-more-complex platform that’s easily the most popular desktop system; macOS X, the FreeBSD Unix-based operating system that powers Apple Macintosh systems; and Linux, by which we mean all the various Linux distributions and related Unix-based systems. -### How we got here +### 我们怎么会这样How we got here One reason enterprises might not have evaluated the security of the OS they deployed to the workforce is that they made the choice years ago. Go back far enough and all operating systems were reasonably safe, because the business of hacking into them and stealing data or installing malware was in its infancy. And once an OS choice is made, it’s hard to consider a change. Few IT organizations would want the headache of moving a globally dispersed workforce to an entirely new OS. Heck, they get enough pushback when they move users to a new version of their OS of choice. @@ -23,7 +23,7 @@ Certainly the threats confronting enterprise systems have changed in the last fe Like many of you, I have firsthand experience of the threats that are out there: I have been infected by malware and viruses on numerous Windows computers, and I even had macro viruses that infected files on my Mac. More recently, a widespread automated hack circumvented the security on my website and infected it with malware. The effects of such malware were always initially subtle, something you wouldn’t even notice, until the malware ended up so deeply embedded in the system that performance started to suffer noticeably. One striking thing about the infestations was that I was never specifically targeted by the miscreants; nowadays, it’s as easy to attack 100,000 computers with a botnet as it is to attack a dozen. -### Does the OS really matter? +### 操作系统真的重要吗?Does the OS really matter? The OS you deploy to your users does make a difference for your security stance, but it isn’t a sure safeguard. For one thing, a breach these days is more likely to come about because an attacker probed your users, not your systems. A [survey][1] of hackers who attended a recent DEFCON conference revealed that “84 percent use social engineering as part of their attack strategy.” Deploying a secure operating system is an important starting point, but without user education, strong firewalls and constant vigilance, even the most secure networks can be invaded. And of course there’s always the risk of user-downloaded software, extensions, utilities, plug-ins and other software that appears benign but becomes a path for malware to appear on the system. @@ -35,7 +35,7 @@ Because the bottom line is that every decision you make regarding your systems w **[ To comment on this story, visit[Computerworld's Facebook page][3]. ]** -### Windows, the popular choice +### Windows,流行之选 If you’re a security manager, it is extremely likely that the questions raised by this article could be rephrased like so: Would we be more secure if we moved away from Microsoft Windows? To say that Windows dominates the enterprise market is to understate the case. [NetMarketShare][4] estimates that a staggering 88% of all computers on the internet are running a version of Windows. @@ -46,7 +46,7 @@ As Troy Wilkinson, CEO of Axiom Cyber Solutions, explains, “Windows always com It’s certainly true that, from Melissa to WannaCry and beyond, much of the malware the world has seen has been aimed at Windows systems. -### macOS X and security through obscurity +### macOS X 以及用默默无闻换取的安全security through obscurity If the most popular OS is always going to be the biggest target, then can using a less popular option ensure security? That idea is a new take on the old — and entirely discredited — concept of “security through obscurity,” which held that keeping the inner workings of software proprietary and therefore secret was the best way to defend against attacks. @@ -58,7 +58,7 @@ Security researcher Lee Muson of Comparitech says that “macOS is likely to be Joe Moore of Wolf Solutions gives Apple a bit more credit, saying that “off the shelf, macOS X has a great track record when it comes to security, in part because it isn’t as widely targeted as Windows and in part because Apple does a pretty good job of staying on top of security issues.” -### And the winner is … +### 最终胜者是 … You probably knew this from the beginning: The clear consensus among experts is that Linux is the most secure operating system. But while it’s the OS of choice for servers, enterprises deploying it on the desktop are few and far between. @@ -78,7 +78,7 @@ Another factor cited by PC World is Linux’s better user privileges model: Wind Noyes also noted that the diversity possible within Linux environments is a better hedge against attacks than the typical Windows monoculture: There are simply a lot of different distributions of Linux available. And some of them are differentiated in ways that specifically address security concerns. Security Researcher Lee Muson of Comparitech offers this suggestion for a Linux distro: “The[Qubes OS][7] is as good a starting point with Linux as you can find right now, with an [endorsement from Edward Snowden][8] massively overshadowing its own extremely humble claims.” Other security experts point to specialized secure Linux distributions such as [Tails Linux][9], designed to run securely and anonymously directly from a USB flash drive or similar external device. -### Building security momentum +### 构建安全性的动力Building security momentum Inertia is a powerful force. Although there is clear consensus that Linux is the safest choice for the desktop, there has been no stampede to dump Windows and Mac machines in favor of it. Nonetheless, a small but significant increase in Linux adoption would probably result in safer computing for everyone, because in market share loss is one sure way to get Microsoft’s and Apple’s attention. In other words, if enough users switch to Linux on the desktop, Windows and Mac PCs are very likely to become more secure platforms. @@ -87,7 +87,7 @@ Inertia is a powerful force. Although there is clear consensus that Linux is the via: https://www.computerworld.com/article/3252823/linux/why-linux-is-better-than-windows-or-macos-for-security.html 作者:[Dave Taylor][a] -译者:[译者ID](https://github.com/译者ID) +译者:[fuzheng1998](https://github.com/fuzheng1998) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 43082074e2b72bd2ee1049b7641ca44315e3045c Mon Sep 17 00:00:00 2001 From: Liu Yansui Date: Thu, 22 Mar 2018 13:30:32 +0800 Subject: [PATCH 0057/1057] Update 20171012 7 Best eBook Readers for Linux.md --- sources/tech/20171012 7 Best eBook Readers for Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171012 7 Best eBook Readers for Linux.md b/sources/tech/20171012 7 Best eBook Readers for Linux.md index 5198f1bdc0..55f3ced24e 100644 --- a/sources/tech/20171012 7 Best eBook Readers for Linux.md +++ b/sources/tech/20171012 7 Best eBook Readers for Linux.md @@ -1,3 +1,5 @@ +[translating for laujinseoi] + 7 Best eBook Readers for Linux ====== **Brief:** In this article, we are covering some of the best ebook readers for Linux. These apps give a better reading experience and some will even help in managing your ebooks. From 4e5e884932299200d65389d056ad6ae3d8e4d51e Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 22 Mar 2018 13:39:26 +0800 Subject: [PATCH 0058/1057] Update 20180209 How to setup and configure network bridge on Debian Linux.md --- ...How to setup and configure network bridge on Debian Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md b/sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md index e133e9057d..7c869b6494 100644 --- a/sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md +++ b/sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md @@ -1,3 +1,5 @@ +Translating by MjSeven + How to setup and configure network bridge on Debian Linux ====== From df7d82cbd17f572a5b2c09de3ce01f1ca7559655 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 17:31:57 +0800 Subject: [PATCH 0059/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Migrating=20to?= =?UTF-8?q?=20Linux:=20Installing=20Software?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Migrating to Linux- Installing Software.md | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 sources/tech/20180320 Migrating to Linux- Installing Software.md diff --git a/sources/tech/20180320 Migrating to Linux- Installing Software.md b/sources/tech/20180320 Migrating to Linux- Installing Software.md new file mode 100644 index 0000000000..ad1ec095c2 --- /dev/null +++ b/sources/tech/20180320 Migrating to Linux- Installing Software.md @@ -0,0 +1,81 @@ +Migrating to Linux: Installing Software +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/birds-1835510_1920.jpg?itok=8i6mBStG) +With all the attention you are seeing on Linux and its use on the Internet and in devices like Arduino, Beagle, and Raspberry Pi boards and more, perhaps you are thinking it's time to try it out. This series will help you successfully make the transition to Linux. If you missed the earlier articles in the series, you can find them here: + +[Part 1 - An Introduction][1] + +[Part 2 - Disks, Files, and Filesystems][2] + +[Part 3 - Graphical Environments][3] + +[Part 4 - The Command Line][4] + +[Part 5 - Using sudo][5] + +### Installing software + +To get new software on your computer, the typical approach used to be to get a software product from a vendor and then run an install program. The software product, in the past, would come on physical media like a CD-ROM or DVD. Now we often download the software product from the Internet instead. + +With Linux, software is installed more like it is on your smartphone. Just like going to your phone's app store, on Linux there is a central repository of open source software tools and programs. Just about any program you might want will be in a list of available packages that you can install. + +There isn't a separate install program that you run for each program. Instead you use the package management tools that come with your distribution of Linux. (Remember a Linux distribution is the Linux you install such as Ubuntu, Fedora, Debian, etc.) Each distribution has its own centralized place on the Internet (called a repository) where they store thousands of pre-built applications for you to install. + +You may note that there are a few exceptions to how software is installed on Linux. Sometimes, you will still need to go to a vendor to get their software as the program doesn't exist in your distribution's central repository. This typically is the case when the software isn't open source and/or not free. + +Also keep in mind that if you end up wanting to install a program that is not in your distribution's repositories, things aren't so simple, even if you are installing free and open source programs. This post doesn't get into these more complicated scenarios, and it's best to follow online directions. + +With all the Linux packaging systems and tools out there, it may be confusing to know what's going on. This article should help clear up a few things. + +### Package Managers + +Several packaging systems to manage, install, and remove software compete for use in Linux distributions. The folks behind each distribution choose a package management system to use. Red Hat, Fedora, CentOS, Scientific Linux, SUSE, and others use the Red Hat Package Manager (RPM). Debian, Ubuntu, Linux Mint, and more use the Debian package system, or DPKG for short. Other package systems exist as well, while RPM and DPKG are the most common. + +![](https://www.linux.com/sites/lcom/files/styles/floated_images/public/package-installer.png?itok=V9OU1Q0u) + +Regardless of the package manager you are using, they typically come with a set of tools that are layered on top of one another (Figure 1). At the lowest level is a command-line tool that lets you do anything and everything related to installed software. You can list installed programs, remove programs, install package files, and more. + +This low-level tool isn't always the most convenient to use, so typically there is a command line tool that will find the package in the distribution's central repositories and download and install it along with any dependencies using a single command. Finally, there is usually a graphical application that lets you select what you want with a mouse and click an 'install'' button. +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/package-kit.png?itok=YimOq2Je) + +For Red Hat based distributions, which includes Fedora, CentOS, Scientific Linux, and more, the low-level tool is rpm. The high-level tool is called dnf (or yum on older systems). And the graphical installer is called PackageKit (Figure 2) and may appear as "Add/Remove Software" under System Administration. +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ubuntu-software.png?itok=5QSctLEW) + +For Debian based distributions, which includes Debian, Ubuntu, Linux Mint, Elementary OS, and more, the low-level, command-line tool is dpkg. The high-level tool is called apt. The graphical tool to manage installed software on Ubuntu is Ubuntu Software (Figure 3). For Debian and Linux Mint, the graphical tool is called Synaptic, which can also be installed on Ubuntu. + +You can also install a text-based graphical tool on Debian related distributions called aptitude. It is more powerful than Synaptic, and works even if you only have access to the command line. You can try that one if you want access to all the bells and whistles, though with more options, it is more complicated to use than Synaptic. Other distributions may have their own unique tools. + +### Command Line + +Online instructions for installing software on Linux usually describe commands to type in the command line. The instructions are usually easier to understand and can be followed without making a mistake by copying and pasting the command into your command line window. This is opposed to following instructions like, "open this menu, select this program, enter in this search pattern, click this tab, select this program, and click this button," which often get lost in translation. + +Sometimes the Linux installation you are using doesn't have a graphical environment, so it's good to be familiar with installing software packages from the command line. Tables 1 and 2 a few common operations and their associated commands for both RPM and DPKG based systems. + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/table_1_0.png?itok=hQ_o5Oh2) + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/table_2.png?itok=yl3UPQDw) + +Note that SUSE, which uses RPM like Redhat and Fedora, doesn't have dnf or yum. Instead, it uses a program called zypper for the high-level, command-line tool. Other distributions may have different tools as well, such as, pacman on Arch Linux or emerge on Gentoo. There are many package tools out there, so you may need to look up what works on your distribution. + +These tips should give you a much better idea on how to install programs on your new Linux installation and a better idea how the various package methods on your Linux installation relate to one another. + +Learn more about Linux through the free ["Introduction to Linux"][6]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2018/3/migrating-linux-installing-software + +作者:[JOHN BONESIO][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/johnbonesio +[1]:https://www.linux.com/blog/learn/intro-to-linux/2017/10/migrating-linux-introduction +[2]:https://www.linux.com/blog/learn/intro-to-linux/2017/11/migrating-linux-disks-files-and-filesystems +[3]:https://www.linux.com/blog/learn/2017/12/migrating-linux-graphical-environments +[4]:https://www.linux.com/blog/learn/2018/1/migrating-linux-command-line +[5]:https://www.linux.com/blog/learn/2018/3/migrating-linux-using-sudo +[6]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 7c6085b1e7598bb1b792cef7a15ef5091a7f1ed9 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 17:35:17 +0800 Subject: [PATCH 0060/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20The=20Command?= =?UTF-8?q?=20line=20Personal=20Assistant=20For=20Your=20Linux=20System?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ersonal Assistant For Your Linux System.md | 411 ++++++++++++++++++ 1 file changed, 411 insertions(+) create mode 100644 sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md diff --git a/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md b/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md new file mode 100644 index 0000000000..f5c180ca41 --- /dev/null +++ b/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md @@ -0,0 +1,411 @@ +The Command line Personal Assistant For Your Linux System +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Yoda-720x340.png) +A while ago, we wrote about a command line virtual assistant named [**“Betty”**][1]. Today, I stumbled upon a similar utility called **“Yoda”**. Yoda is a command line personal assistant who can help you to do some trivial tasks in Linux. It is a free, open source application written in Python. In this guide, we will see how to install and use Yoda in GNU/Linux. + +### Installing Yoda, the command line personal assistant + +Yoda requires **Python 2** and PIP. If PIP is not installed in your Linux box, refer the following guide to install it. Just make sure you have installed **python2-pip.** Yoda may not support Python 3. + +**Note:** I recommend you to try Yoda under a virtual environment. Not just Yoda, always try any Python applications in a virtual environment, so they won’t interfere with globally installed packages. You can setup a virtual environment as described in the above link under the section titled “Creating Virtual Environments”. + +Once you have installed pip on your system, git clone Yoda repository. +``` +$ git clone https://github.com/yoda-pa/yoda + +``` + +The above command will create a directory named “yoda” in your current working directory and clone all contents in it. Go to the Yoda directory: +``` +$ cd yoda/ + +``` + +Run the following command to install Yoda application. +``` +$ pip install . + +``` + +Please note the dot (.) at the end. Now, all required packages will be downloaded and installed. + +### Configure Yoda + +First, setup configuration to save your information on your local system. + +To do so, run: +``` +$ yoda setup new + +``` + +Answer the following questions: +``` +Enter your name: +Senthil Kumar +What's your email id? +[email protected] +What's your github username? +sk +Enter your github password: +Password: +Where shall your config be stored? (Default: ~/.yoda/) + +A configuration file already exists. Are you sure you want to overwrite it? (y/n) +y + +``` + +Your password is saved in the config file after encrypting, so don’t worry about it. + +To check the current configuration, run: +``` +$ yoda setup check + +``` + +You will see an output something like below. +``` +Name: Senthil Kumar +Email: [email protected] +Github username: sk + +``` + +By default, your information is stored in **~/.yoda** directory. + +To delete the existing configuration, do: +``` +$ yoda setup delete + +``` + +### Usage + +Yoda contains a simple chat bot. You can interact with it using **chat** command like below. +``` +$ yoda chat who are you + +``` + +Sample output: +``` +Yoda speaks: +I'm a virtual agent + +$ yoda chat how are you +Yoda speaks: +I'm doing very well. Thanks! + +``` + +Here is the list of things we can do with Yoda: + +**Test Internet speed** + +Let us ask Yoda about the Internet speed. To do so, run: +``` +$ yoda speedtest +Speed test results: +Ping: 108.45 ms +Download: 0.75 Mb/s +Upload: 1.95 Mb/s + +``` + +**Shorten and expand URLs** + +Yoda also helps to shorten any URL. +``` +$ yoda url shorten https://www.ostechnix.com/ +Here's your shortened URL: +https://goo.gl/hVW6U0 + +``` + +To expand the shortened URL: +``` +$ yoda url expand https://goo.gl/hVW6U0 +Here's your original URL: +https://www.ostechnix.com/ + +``` + +**Read Hacker News** + +I am regular visitor of Hacker News website. If you’re anything like me, you can read the news from Hacker News website using Yoda like below. +``` +$ yoda hackernews +News-- 1/513 + +Title-- Show HN: a Yelp for iOS developers +Description-- I came up with this idea "a Yelp for developers" when talking with my colleagues. My hypothesis is that, it would be very helpful if we know more about a library before choosing to use it. It's similar to that we want to know more about a restaurant by checki… +url-- https://news.ycombinator.com/item?id=16636071 + +Continue? [press-"y"] + +``` + +Yoda will display one item at a time. To read the next news, simply type “y” and hit ENTER. + +**Manage personal diaries** + +We can also maintain a personal diary to note important events. + +Create a new diary using command: +``` +$ yoda diary nn +Input your entry for note: +Today I learned about Yoda + +``` + +To create a new note, run the above command again. + +To view all notes: +``` +$ yoda diary notes +Today's notes: +---------------- + Time | Note +--------|----- +16:41:41| Today I learned about Yoda + +``` + +Not just notes, Yoda can also help you to create tasks. + +To create a new task, run: +``` +$ yoda diary nt +Input your entry for task: +Write an article about Yoda and publish it on OSTechNix + +``` + +To view the list of tasks, run: +``` +$ yoda diary tasks +Today's agenda: +---------------- +Status | Time | Text +-------|---------|----- + O | 16:44:03: Write an article about Yoda and publish it on OSTechNix +---------------- + +Summary: +---------------- +Incomplete tasks: 1 +Completed tasks: 0 + +``` + +As you see above, I have one incomplete task. To mark it as completed, run the following command and type the completed task serial number and hit ENTER: +``` +$ yoda diary ct +Today's agenda: +---------------- +Number | Time | Task +-------|---------|----- + 1 | 16:44:03: Write an article about Yoda and publish it on OSTechNix +Enter the task number that you would like to set as completed +1 + +``` + +You can analyze the current month’s tasks at any time using command: +``` +$ yoda diary analyze +Percentage of incomplete task : 0 +Percentage of complete task : 100 +Frequency of adding task (Task/Day) : 3 + +``` + +Sometimes, you may want to maintain a profile about a person you love, admire. + +**Take notes about loved ones** + +First, you need to setup configuration to store your friend’s details. To do so, run: +``` +$ yoda love setup + +``` + +Enter the details of your friend: +``` +Enter their name: +Abdul Kalam +Enter sex(M/F): +M +Where do they live? +Rameswaram + +``` + +To view the details of the person, run: +``` +$ yoda love status +{'place': 'Rameswaram', 'name': 'Abdul Kalam', 'sex': 'M'} + +``` + +To add the birthday of your love one: +``` +$ yoda love addbirth +Enter birthday +15-10-1931 + +``` + +To view the birth date: +``` +$ yoda love showbirth +Birthday is 15-10-1931 + +``` + +You could even add notes about that person: +``` +$ yoda love note +Avul Pakir Jainulabdeen Abdul Kalam better known as A. P. J. Abdul Kalam, was the 11th President of India from 2002 to 2007. + +``` + +You can view the notes using command: +``` +$ yoda love notes +Notes: +1: Avul Pakir Jainulabdeen Abdul Kalam better known as A. P. J. Abdul Kalam, was the 11th President of India from 2002 to 2007. + +``` + +You can also write the things that person like: +``` +$ yoda love like +Add things they like +Physics, Aerospace +Want to add more things they like? [y/n] +n + +``` + +To view the things they like, run: +``` +$ yoda love likes +Likes: +1: Physics, Aerospace + +``` + +**Tracking money expenses** + +You don’t need a separate tool to maintain your financial expenditure. Yoda got your back. + +First, setup configuration for your money expenses using command: +``` +$ yoda money setup + +``` + +Enter your currency code and the initial amount: +``` +Enter default currency code: +INR +{u'USD': 0.015338, u'IDR': 211.06, u'BGN': 0.024436, u'ISK': 1.5305, u'ILS': 0.053402, u'GBP': 0.010959, u'DKK': 0.093063, u'CAD': 0.020041, u'MXN': 0.28748, u'HUF': 3.8873, u'RON': 0.058302, u'MYR': 0.060086, u'SEK': 0.12564, u'SGD': 0.020208, u'HKD': 0.12031, u'AUD': 0.019908, u'CHF': 0.014644, u'KRW': 16.429, u'CNY': 0.097135, u'TRY': 0.06027, u'HRK': 0.092986, u'NZD': 0.021289, u'THB': 0.47854, u'EUR': 0.012494, u'NOK': 0.11852, u'RUB': 0.88518, u'JPY': 1.6332, u'CZK': 0.31764, u'BRL': 0.050489, u'PLN': 0.052822, u'PHP': 0.79871, u'ZAR': 0.1834} +₹ +Indian rupee +Enter initial amount: +10000 + +``` + +To view the money configuration, just run:`` +``` +$ yoda money status +{'initial_money': 10000, 'currency_code': 'INR'} + +``` + +Let us say you bought a book that costs 250 INR. To add this expense, run: +``` +$ yoda money exp +Spend 250 INR on books +output: + +``` + +To view the expenses, run: +``` +$ yoda money exps +2018-03-21 17:12:31 INR 250 books + +``` + +**Creating Idea lists** + +To create a new idea: +``` +$ yoda ideas add --task --inside + +``` + +List the ideas: +``` +$ yoda ideas show + +``` + +To remove a idea from the project: +``` +$ yoda ideas remove --task --inside + +``` + +To remove the idea completely, run: +``` +$ yoda ideas remove --project + +``` + +**Learning English Vocabulary** + +Yoda helps you to learn random English words and track your learning progress. + +To learn a new word, type: +``` +$ yoda vocabulary word + +``` + +It will display a random word. Press ENTER to display the meaning of the word. Again, Yoda asks you if you already know the meaning of the word. If you know it already, type “yes”. If you don’t know, type “no”. This can help you to track your progress. Use the following command to know your progress. +``` +$ yoda vocabulary accuracy + +``` + +Also, Yoda can help you to do few other things like finding the definition of a word and creating flashcards to easily learn anything. For more details and list of available options, refer the help section. +``` +$ yoda --help + +``` + +More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/yoda-the-command-line-personal-assistant-for-your-linux-system/ + +作者:[SK][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/author/sk/ +[1]:https://www.ostechnix.com/betty-siri-like-commandline-virtual-assistant-linux/ From e69a086609422058bc45b8e5d4b78f7f3bc49268 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 20:24:37 +0800 Subject: [PATCH 0061/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=208=20tips=20for?= =?UTF-8?q?=20better=20agile=20retrospective=20meetings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...for better agile retrospective meetings.md | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sources/talk/20180321 8 tips for better agile retrospective meetings.md diff --git a/sources/talk/20180321 8 tips for better agile retrospective meetings.md b/sources/talk/20180321 8 tips for better agile retrospective meetings.md new file mode 100644 index 0000000000..ec45bf17f0 --- /dev/null +++ b/sources/talk/20180321 8 tips for better agile retrospective meetings.md @@ -0,0 +1,66 @@ +8 tips for better agile retrospective meetings +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_meeting.png?itok=4_CivQgp) +I’ve often thought that retrospectives should be called prospectives, as that term concerns the future rather than focusing on the past. The retro itself is truly future-looking: It’s the space where we can ask the question, “With what we know now, what’s the next experiment we need to try for improving our lives, and the lives of our customers?” + +### What’s a retro supposed to look like? + +There are two significant loops in product development: One produces the desired potentially shippable nugget. The other is where we examine how we’re working—not only to avoid doing what didn’t work so well, but also to determine how we can amplify the stuff we do well—and devise an experiment to pull into the next production loop to improve how our team is delighting our customers. This is the loop on the right side of this diagram: + + +![Retrospective 1][2] + +### When retros implode + +While attending various teams' iteration retrospective meetings, I saw a common thread of malcontent associated with a relentless focus on continuous improvement. + +One of the engineers put it bluntly: “[Our] continuous improvement feels like we are constantly failing.” + +The teams talked about what worked, restated the stuff that didn’t work (perhaps already feeling like they were constantly failing), nodded to one another, and gave long sighs. Then one of the engineers (already late for another meeting) finally summed up the meeting: “Ok, let’s try not to submit all of the code on the last day of the sprint.” There was no opportunity to amplify the good, as the good was not discussed. + +In effect, here’s what the retrospective felt like: + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/retro_2.jpg?itok=HrDkppCG) + +The anti-pattern is where retrospectives become dreaded sessions where we look back at the last iteration, make two columns—what worked and what didn’t work—and quickly come to some solution for the next iteration. There is no [scientific method][3] involved. There is no data gathering and research, no hypothesis, and very little deep thought. The result? You don’t get an experiment or a potential improvement to pull into the next iteration. + +### 8 tips for better retrospectives + + 1. Amplify the good! Instead of focusing on what didn’t work well, why not begin the retro by having everyone mention one positive item first? + 2. Don’t jump to a solution. Thinking about a problem deeply instead of trying to solve it right away might be a better option. + 3. If the retrospective doesn’t make you feel excited about an experiment, maybe you shouldn’t try it in the next iteration. + 4. If you’re not analyzing how to improve, ([5 Whys][4], [force-field analysis][5], [impact mapping][6], or [fish-boning][7]), you might be jumping to solutions too quickly. + 5. Vary your methods. If every time you do a retrospective you ask, “What worked, what didn’t work?” and then vote on the top item from either column, your team will quickly get bored. [Retromat][8] is a great free retrospective tool to help vary your methods. + 6. End each retrospective by asking for feedback on the retro itself. This might seem a bit meta, but it works: Continually improving the retrospective is recursively improving as a team. + 7. Remove the impediments. Ask how you are enabling the team's search for improvement, and be prepared to act on any feedback. + 8. There are no "iteration police." Take breaks as needed. Deriving hypotheses from analysis and coming up with experiments involves creativity, and it can be taxing. Every once in a while, go out as a team and enjoy a nice retrospective lunch. + + + +This article was inspired by [Retrospective anti-pattern: continuous improvement should not feel like constantly failing][9], posted at [Podojo.com][10]. + +**[See our related story,[How to build a business case for DevOps transformation][11].]** + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/tips-better-agile-retrospective-meetings + +作者:[Catherine Louis][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/catherinelouis +[1]:/file/389021 +[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/retro_1.jpg?itok=bggmHN1Q (Retrospective 1) +[3]:https://en.wikipedia.org/wiki/Scientific_method +[4]:https://en.wikipedia.org/wiki/5_Whys +[5]:https://en.wikipedia.org/wiki/Force-field_analysis +[6]:https://opensource.com/open-organization/17/6/experiment-impact-mapping +[7]:https://en.wikipedia.org/wiki/Ishikawa_diagram +[8]:https://plans-for-retrospectives.com/en/?id=28 +[9]:http://www.podojo.com/retrospective-anti-pattern-continuous-improvement-should-not-feel-like-constantly-failing/ +[10]:http://www.podojo.com/ +[11]:https://opensource.com/article/18/2/how-build-business-case-devops-transformation From 7a5c37633b42bf065c622557a9586b4caa191e4c Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 20:28:00 +0800 Subject: [PATCH 0062/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20use?= =?UTF-8?q?=20Ansible=20to=20patch=20systems=20and=20install=20application?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... patch systems and install applications.md | 205 ++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 sources/tech/20180321 How to use Ansible to patch systems and install applications.md diff --git a/sources/tech/20180321 How to use Ansible to patch systems and install applications.md b/sources/tech/20180321 How to use Ansible to patch systems and install applications.md new file mode 100644 index 0000000000..9debeedc1e --- /dev/null +++ b/sources/tech/20180321 How to use Ansible to patch systems and install applications.md @@ -0,0 +1,205 @@ +How to use Ansible to patch systems and install applications +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4) +Have you ever wondered how to patch your systems, reboot, and continue working? + +If so, you'll be interested in [Ansible][1] , a simple configuration management tool that can make some of the hardest work easy. For example, system administration tasks that can be complicated, take hours to complete, or have complex requirements for security. + +In my experience, one of the hardest parts of being a sysadmin is patching systems. Every time you get a Common Vulnerabilities and Exposure (CVE) notification or Information Assurance Vulnerability Alert (IAVA) mandated by security, you have to kick into high gear to close the security gaps. (And, believe me, your security officer will hunt you down unless the vulnerabilities are patched.) + +Ansible can reduce the time it takes to patch systems by running [packaging modules][2]. To demonstrate, let's use the [yum module][3] to update the system. Ansible can install, update, remove, or install from another location (e.g., `rpmbuild` from continuous integration/continuous development). Here is the task for updating the system: +``` +  - name: update the system + +    yum: + +      name: "*" + +      state: latest + +``` + +In the first line, we give the task a meaningful `name` so we know what Ansible is doing. In the next line, the `yum module` updates the CentOS virtual machine (VM), then `name: "*"` tells yum to update everything, and, finally, `state: latest` updates to the latest RPM. + +After updating the system, we need to restart and reconnect: +``` +  - name: restart system to reboot to newest kernel + +    shell: "sleep 5 && reboot" + +    async: 1 + +    poll: 0 + + + +  - name: wait for 10 seconds + +    pause: + +      seconds: 10 + + + +  - name: wait for the system to reboot + +    wait_for_connection: + +      connect_timeout: 20 + +      sleep: 5 + +      delay: 5 + +      timeout: 60 + + + +  - name: install epel-release + +    yum: + +      name: epel-release + +      state: latest + +``` + +The `shell module` puts the system to sleep for 5 seconds then reboots. We use `sleep` to prevent the connection from breaking, `async` to avoid timeout, and `poll` to fire & forget. We pause for 10 seconds to wait for the VM to come back and use `wait_for_connection` to connect back to the VM as soon as it can make a connection. Then we `install epel-release` to test the RPM installation. You can run this playbook multiple times to show the `idempotent`, and the only task that will show as changed is the reboot since we are using the `shell` module. You can use `changed_when: False` to ignore the change when using the `shell` module if you expect no actual changes. + +So far we've learned how to update a system, restart the VM, reconnect, and install a RPM. Next we will install NGINX using the role in [Ansible Lightbulb][4]. +``` +  - name: Ensure nginx packages are present + +    yum: + +      name: nginx, python-pip, python-devel, devel + +      state: present + +    notify: restart-nginx-service + + + +  - name: Ensure uwsgi package is present + +    pip: + +      name: uwsgi + +      state: present + +    notify: restart-nginx-service + + + +  - name: Ensure latest default.conf is present + +    template: + +      src: templates/nginx.conf.j2 + +      dest: /etc/nginx/nginx.conf + +      backup: yes + +    notify: restart-nginx-service + + + +  - name: Ensure latest index.html is present + +    template: + +      src: templates/index.html.j2 + +      dest: /usr/share/nginx/html/index.html + + + +  - name: Ensure nginx service is started and enabled + +    service: + +      name: nginx + +      state: started + +      enabled: yes + + + +  - name: Ensure proper response from localhost can be received + +    uri: + +      url: "http://localhost:80/" + +      return_content: yes + +    register: response + +    until: 'nginx_test_message in response.content' + +    retries: 10 + +    delay: 1 + +``` + +And the handler that restarts the nginx service: +``` +# handlers file for nginx-example + +  - name: restart-nginx-service + +    service: + +      name: nginx + +      state: restarted + +``` + +In this role, we install the RPMs `nginx`, `python-pip`, `python-devel`, and `devel` and install `uwsgi` with PIP. Next, we use the `template` module to copy over the `nginx.conf` and `index.html` for the page to display. After that, we make sure the service is enabled on boot and started. Then we use the `uri` module to check the connection to the page. + +Here is a playbook showing an example of updating, restarting, and installing an RPM. Then continue installing nginx. This can be done with any other roles/applications you want. +``` +  - hosts: all + +    roles: + +      - centos-update + +      - nginx-simple + +``` + +Watch this demo video for more insight on the process. + +[demo](https://asciinema.org/a/166437/embed?) + +This was just a simple example of how to update, reboot, and continue. For simplicity, I added the packages without [variables][5]. Once you start working with a large number of hosts, you will need to change a few settings: + +This is because on your production environment you might want to update one system at a time (not fire & forget) and actually wait a longer time for your system to reboot and continue. + +For more ways to automate your work with this tool, take a look at the other [Ansible articles on Opensource.com][6]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/ansible-patch-systems + +作者:[Jonathan Lozada De La Matta][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/jlozadad +[1]:https://www.ansible.com/overview/how-ansible-works +[2]:https://docs.ansible.com/ansible/latest/list_of_packaging_modules.html +[3]:https://docs.ansible.com/ansible/latest/yum_module.html +[4]:https://github.com/ansible/lightbulb/tree/master/examples/nginx-role +[5]:https://docs.ansible.com/ansible/latest/playbooks_variables.html +[6]:https://opensource.com/tags/ansible From b7ea70c93f611783231096d369b9d0b90e77f11d Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 20:29:09 +0800 Subject: [PATCH 0063/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Protecting=20Co?= =?UTF-8?q?de=20Integrity=20with=20PGP=20=E2=80=94=20Part=206:=20Using=20P?= =?UTF-8?q?GP=20with=20Git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...y with PGP - Part 6- Using PGP with Git.md | 318 ++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 sources/tech/20180321 Protecting Code Integrity with PGP - Part 6- Using PGP with Git.md diff --git a/sources/tech/20180321 Protecting Code Integrity with PGP - Part 6- Using PGP with Git.md b/sources/tech/20180321 Protecting Code Integrity with PGP - Part 6- Using PGP with Git.md new file mode 100644 index 0000000000..0169d96ad6 --- /dev/null +++ b/sources/tech/20180321 Protecting Code Integrity with PGP - Part 6- Using PGP with Git.md @@ -0,0 +1,318 @@ +Protecting Code Integrity with PGP — Part 6: Using PGP with Git +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/global-network.jpg?itok=h_hhZc36) +In this tutorial series, we're providing practical guidelines for using PGP, including basic concepts and generating and protecting your keys. If you missed the previous articles, you can catch up below. In this article, we look at Git's integration with PGP, starting with signed tags, then introducing signed commits, and finally adding support for signed pushes. + +[Part 1: Basic Concepts and Tools][1] + +[Part 2: Generating Your Master Key][2] + +[Part 3: Generating PGP Subkeys][3] + +[Part 4: Moving Your Master Key to Offline Storage][4] + +[Part 5: Moving Subkeys to a Hardware Device][5] + +One of the core features of Git is its decentralized nature -- once a repository is cloned to your system, you have full history of the project, including all of its tags, commits and branches. However, with hundreds of cloned repositories floating around, how does anyone verify that the repository you downloaded has not been tampered with by a malicious third party? You may have cloned it from GitHub or some other official-looking location, but what if someone had managed to trick you? + +Or what happens if a backdoor is discovered in one of the projects you've worked on, and the "Author" line in the commit says it was done by you, while you're pretty sure you had [nothing to do with it][6]? + +To address both of these issues, Git introduced PGP integration. Signed tags prove the repository integrity by assuring that its contents are exactly the same as on the workstation of the developer who created the tag, while signed commits make it nearly impossible for someone to impersonate you without having access to your PGP keys. + +### Checklist + + * Understand signed tags, commits, and pushes (ESSENTIAL) + + * Configure git to use your key (ESSENTIAL) + + * Learn how tag signing and verification works (ESSENTIAL) + + * Configure git to always sign annotated tags (NICE) + + * Learn how commit signing and verification works (ESSENTIAL) + + * Configure git to always sign commits (NICE) + + * Configure gpg-agent options (ESSENTIAL) + + + + +### Considerations + +Git implements multiple levels of integration with PGP, first starting with signed tags, then introducing signed commits, and finally adding support for signed pushes. + +#### Understanding Git Hashes + +Git is a complicated beast, but you need to know what a "hash" is in order to have a good grasp on how PGP integrates with it. We'll narrow it down to two kinds of hashes: tree hashes and commit hashes. + +##### Tree hashes + +Every time you commit a change to a repository, git records checksum hashes of all objects in it -- contents (blobs), directories (trees), file names and permissions, etc, for each subdirectory in the repository. It only does this for trees and blobs that have changed with each commit, so as not to re-checksum the entire tree unnecessarily if only a small part of it was touched. + +Then it calculates and stores the checksum of the toplevel tree, which will inevitably be different if any part of the repository has changed. + +##### Commit hashes + +Once the tree hash has been created, git will calculate the commit hash, which will include the following information about the repository and the change being made: + + * The checksum hash of the tree + + * The checksum hash of the tree before the change (parent) + + * Information about the author (name, email, time of authorship) + + * Information about the committer (name, email, time of commit) + + * The commit message + + + + +##### Hashing function + +At the time of writing, git still uses the SHA1 hashing mechanism to calculate checksums, though work is under way to transition to a stronger algorithm that is more resistant to collisions. Note, that git already includes collision avoidance routines, so it is believed that a successful collision attack against git remains impractical. + +#### Annotated tags and tag signatures + +Git tags allow developers to mark specific commits in the history of each git repository. Tags can be "lightweight" \-- more or less just a pointer at a specific commit, or they can be "annotated," which becomes its own object in the git tree. An annotated tag object contains all of the following information: + + * The checksum hash of the commit being tagged + + * The tag name + + * Information about the tagger (name, email, time of tagging) + + * The tag message + + + + +A PGP-signed tag is simply an annotated tag with all these entries wrapped around in a PGP signature. When a developer signs their git tag, they effectively assure you of the following: + + * Who they are (and why you should trust them) + + * What the state of their repository was at the time of signing: + + * The tag includes the hash of the commit + + * The commit hash includes the hash of the toplevel tree + + * Which includes hashes of all files, contents, and subtrees + * It also includes all information about authorship + + * Including exact times when changes were made + + + + +When you clone a git repository and verify a signed tag, that gives you cryptographic assurance that all contents in the repository, including all of its history, are exactly the same as the contents of the repository on the developer's computer at the time of signing. + +#### Signed commits + +Signed commits are very similar to signed tags -- the contents of the commit object are PGP-signed instead of the contents of the tag object. A commit signature also gives you full verifiable information about the state of the developer's tree at the time the signature was made. Tag signatures and commit PGP signatures provide exact same security assurances about the repository and its entire history. + +#### Signed pushes + +This is included here for completeness' sake, since this functionality needs to be enabled on the server receiving the push before it does anything useful. As we saw above, PGP-signing a git object gives verifiable information about the developer's git tree, but not about their intent for that tree. + +For example, you can be working on an experimental branch in your own git fork trying out a promising cool feature, but after you submit your work for review, someone finds a nasty bug in your code. Since your commits are properly signed, someone can take the branch containing your nasty bug and push it into master, introducing a vulnerability that was never intended to go into production. Since the commit is properly signed with your key, everything looks legitimate and your reputation is questioned when the bug is discovered. + +Ability to require PGP-signatures during git push was added in order to certify the intent of the commit, and not merely verify its contents. + +#### Configure git to use your PGP key + +If you only have one secret key in your keyring, then you don't really need to do anything extra, as it becomes your default key. + +However, if you happen to have multiple secret keys, you can tell git which key should be used ([fpr] is the fingerprint of your key): +``` +$ git config --global user.signingKey [fpr] + +``` + +NOTE: If you have a distinct gpg2 command, then you should tell git to always use it instead of the legacy gpg from version 1: +``` +$ git config --global gpg.program gpg2 + +``` + +#### How to work with signed tags + +To create a signed tag, simply pass the -s switch to the tag command: +``` +$ git tag -s [tagname] + +``` + +Our recommendation is to always sign git tags, as this allows other developers to ensure that the git repository they are working with has not been maliciously altered (e.g. in order to introduce backdoors). + +##### How to verify signed tags + +To verify a signed tag, simply use the verify-tag command: +``` +$ git verify-tag [tagname] + +``` + +If you are verifying someone else's git tag, then you will need to import their PGP key. Please refer to the "Trusted Team communication" document in the same repository for guidance on this topic. + +##### Verifying at pull time + +If you are pulling a tag from another fork of the project repository, git should automatically verify the signature at the tip you're pulling and show you the results during the merge operation: +``` +$ git pull [url] tags/sometag + +``` + +The merge message will contain something like this: +``` +Merge tag 'sometag' of [url] + +[Tag message] + +# gpg: Signature made [...] +# gpg: Good signature from [...] + +``` + +#### Configure git to always sign annotated tags + +Chances are, if you're creating an annotated tag, you'll want to sign it. To force git to always sign annotated tags, you can set a global configuration option: +``` +$ git config --global tag.forceSignAnnotated true + +``` + +Alternatively, you can just train your muscle memory to always pass the -s switch: +``` +$ git tag -asm "Tag message" tagname + +``` + +#### How to work with signed commits + +It is easy to create signed commits, but it is much more difficult to incorporate them into your workflow. Many projects use signed commits as a sort of "Committed-by:" line equivalent that records code provenance -- the signatures are rarely verified by others except when tracking down project history. In a sense, signed commits are used for "tamper evidence," and not to "tamper-proof" the git workflow. + +To create a signed commit, you just need to pass the -S flag to the git commit command (it's capital -S due to collision with another flag): +``` +$ git commit -S + +``` + +Our recommendation is to always sign commits and to require them of all project members, regardless of whether anyone is verifying them (that can always come at a later time). + +##### How to verify signed commits + +To verify a single commit you can use verify-commit: +``` +$ git verify-commit [hash] + +``` + +You can also look at repository logs and request that all commit signatures are verified and shown: +``` +$ git log --pretty=short --show-signature + +``` + +##### Verifying commits during git merge + +If all members of your project sign their commits, you can enforce signature checking at merge time (and then sign the resulting merge commit itself using the -S flag): +``` +$ git merge --verify-signatures -S merged-branch + +``` + +Note, that the merge will fail if there is even one commit that is not signed or does not pass verification. As it is often the case, technology is the easy part -- the human side of the equation is what makes adopting strict commit signing for your project difficult. + +##### If your project uses mailing lists for patch management + +If your project uses a mailing list for submitting and processing patches, then there is little use in signing commits, because all signature information will be lost when sent through that medium. It is still useful to sign your commits, just so others can refer to your publicly hosted git trees for reference, but the upstream project receiving your patches will not be able to verify them directly with git. + +You can still sign the emails containing the patches, though. + +#### Configure git to always sign commits + +You can tell git to always sign commits: +``` +git config --global commit.gpgSign true + +``` + +Or you can train your muscle memory to always pass the -S flag to all git commit operations (this includes --amend). + +#### Configure gpg-agent options + +The GnuPG agent is a helper tool that will start automatically whenever you use the gpg command and run in the background with the purpose of caching the private key passphrase. This way you only have to unlock your key once to use it repeatedly (very handy if you need to sign a bunch of git operations in an automated script without having to continuously retype your passphrase). + +There are two options you should know in order to tweak when the passphrase should be expired from cache: + + * default-cache-ttl (seconds): If you use the same key again before the time-to-live expires, the countdown will reset for another period. The default is 600 (10 minutes). + + * max-cache-ttl (seconds): Regardless of how recently you've used the key since initial passphrase entry, if the maximum time-to-live countdown expires, you'll have to enter the passphrase again. The default is 30 minutes. + + + + +If you find either of these defaults too short (or too long), you can edit your ~/.gnupg/gpg-agent.conf file to set your own values: +``` +# set to 30 minutes for regular ttl, and 2 hours for max ttl +default-cache-ttl 1800 +max-cache-ttl 7200 + +``` + +##### Bonus: Using gpg-agent with ssh + +If you've created an [A] (Authentication) key and moved it to the smartcard, you can use it with ssh for adding 2-factor authentication for your ssh sessions. You just need to tell your environment to use the correct socket file for talking to the agent. + +First, add the following to your ~/.gnupg/gpg-agent.conf: +``` +enable-ssh-support + +``` + +Then, add this to your .bashrc: +``` +export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) + +``` + +You will need to kill the existing gpg-agent process and start a new login session for the changes to take effect: +``` +$ killall gpg-agent +$ bash +$ ssh-add -L + +``` + +The last command should list the SSH representation of your PGP Auth key (the comment should say cardno:XXXXXXXX at the end to indicate it's coming from the smartcard). + +To enable key-based logins with ssh, just add the ssh-add -L output to ~/.ssh/authorized_keys on remote systems you log in to. Congratulations, you've just made your ssh credentials extremely difficult to steal. + +As a bonus, you can get other people's PGP-based ssh keys from public keyservers, should you need to grant them ssh access to anything: +``` +$ gpg --export-ssh-key [keyid] + +``` + +This can come in super handy if you need to allow developers access to git repositories over ssh. Next time, we'll provide tips for protecting your email accounts as well as your PGP keys. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-6-using-pgp-git + +作者:[KONSTANTIN RYABITSEV][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/mricon +[1]:https://www.linux.com/blog/learn/2018/2/protecting-code-integrity-pgp-part-1-basic-pgp-concepts-and-tools +[2]:https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-part-2-generating-and-protecting-your-master-pgp-key +[3]:https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-part-3-generating-pgp-subkeys +[4]:https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-4-moving-your-master-key-offline-storage +[5]:https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-5-moving-subkeys-hardware-device +[6]:https://github.com/jayphelps/git-blame-someone-else From 7b5beb51a6adfbc2b73d30395062b441b813bf95 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 21:53:35 +0800 Subject: [PATCH 0064/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Can=20we=20buil?= =?UTF-8?q?d=20a=20social=20network=20that=20serves=20users=20rather=20tha?= =?UTF-8?q?n=20advertisers=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...at serves users rather than advertisers.md | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sources/talk/20180320 Can we build a social network that serves users rather than advertisers.md diff --git a/sources/talk/20180320 Can we build a social network that serves users rather than advertisers.md b/sources/talk/20180320 Can we build a social network that serves users rather than advertisers.md new file mode 100644 index 0000000000..9ea639c4e5 --- /dev/null +++ b/sources/talk/20180320 Can we build a social network that serves users rather than advertisers.md @@ -0,0 +1,70 @@ +Can we build a social network that serves users rather than advertisers? +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_team_community_group.png?itok=Nc_lTsUK) + +Today, open source software is far-reaching and has played a key role driving innovation in our digital economy. The world is undergoing radical change at a rapid pace. People in all parts of the world need a purpose-built, neutral, and transparent online platform to meet the challenges of our time. + +And open principles might just be the way to get us there. What would happen if we married digital innovation with social innovation using open-focused thinking? + +This question is at the heart of our work at [Human Connection][1], a forward-thinking, Germany-based knowledge and action network with a mission to create a truly social network that serves the world. We're guided by the notion that human beings are inherently generous and sympathetic, and that they thrive on benevolent actions. But we haven't seen a social network that has fully supported our natural tendency towards helpfulness and cooperation to promote the common good. Human Connection aspires to be the platform that allows everyone to become an active changemaker. + +In order to achieve the dream of a solution-oriented platform that enables people to take action around social causes by engaging with charities, community groups, and social change activists, Human Connection embraces open values as a vehicle for social innovation. + +Here's how. + +### Transparency first + +Transparency is one of Human Connection's guiding principles. Human Connection invites programmers around the world to jointly work on the platform's source code (JavaScript, Vue, nuxt) by [making their source code available on Github][2] and support the idea of a truly social network by contributing to the code or programming additional functions. + +But our commitment to transparency extends beyond our development practices. In fact—when it comes to building a new kind of social network that promotes true connection and interaction between people who are passionate about changing the world for the better—making the source code available is just one step towards being transparent. + +To facilitate open dialogue, the Human Connection team holds [regular public meetings online][3]. Here we answer questions, encourage suggestions, and respond to potential concerns. Our Meet The Team events are also recorded and made available to the public afterwards. By being fully transparent with our process, our source code, and our finances, we can protect ourselves against critics or other potential backlashes. + +The commitment to transparency also means that all user contributions that shared publicly on Human Connection will be released under a Creative Commons license and can eventually be downloaded as a data pack. By making crowd knowledge available, especially in a decentralized way, we create the opportunity for social pluralism. + +Guiding all of our organizational decisions is one question: "Does it serve the people and the greater good?" And we use the [UN Charter][4] and the Universal Declaration of Human Rights as a foundation for our value system. As we'll grow bigger, especially with our upcoming open beta launch, it's important for us to stay accountable to that mission. I'm even open to the idea of inviting the Chaos Computer Club or other hacker clubs to verify the integrity of our code and our actions by randomly checking into our platform. + +When it comes to building a new kind of social network that promotes true connection and interaction between people who are passionate about changing the world for the better, making the source code available is just one step towards being transparent. + +### A collaborative community + +A [collaborative, community-centered approach][5] to programming the Human Connection platform is the foundation for an idea that extends beyond the practical applications of a social network. Our team is driven by finding an answer to the question: "What makes a social network truly social?" + +A network that abandons the idea of a profit-driven algorithm serving advertisers instead of end-users can only thrive by turning to the process of peer production and collaboration. Organizations like [Code Alliance][6] and [Code for America][7], for example, have demonstrated how technology can be created in an open source environment to benefit humanity and disrupt the status quo. Community-driven projects like the map-based reporting platform [FixMyStreet][8] or the [Tasking Manager][9] built for the Humanitarian OpenStreetMap initiative have embraced crowdsourcing as a way to move their mission forward. + +Our approach to building Human Connection has been collaborative from the start. To gather initial data on the necessary functions and the purpose of a truly social network, we collaborated with the National Institute for Oriental Languages and Civilizations (INALCO) at the University Sorbonne in Paris and the Stuttgart Media University in Germany. Research findings from both projects were incorporated into the early development of Human Connection. Thanks to that research, [users will have a whole new set of functions available][10] that put them in control of what content they see and how they engage with others. As early supporters are [invited to the network's alpha version][10], they can experience the first available noteworthy functions. Here are just a few: + + * Linking information to action was one key theme emerging from our research sessions. Current social networks leave users in the information stage. Student groups at both universities saw a need for an action-oriented component that serves our human instinct of working together to solve problems. So we built a ["Can Do" function][11] into our platform. It's one of the ways individuals can take action after reading about a certain topic. "Can Do's" are user-suggested activities in the "Take Action" area that everyone can implement. + * The "Versus" function is another defining result. Where traditional social networks are limited to a comment function, our student groups saw the need for a more structured and useful way to engage in discussions and arguments. A "Versus" is a counter-argument to a public post that is displayed separately and provides an opportunity to highlight different opinions around an issue. + * Today's social networks don't provide a lot of options to filter content. Research has shown that a filtering option by emotions can help us navigate the social space in accordance with our daily mood and potentially protect our emotional wellbeing by not displaying sad or upsetting posts on a day where we want to see uplifting content only. + + + +Human Connection invites changemakers to collaborate on the development of a network with the potential to mobilize individuals and groups around the world to turn negative news into "Can Do's"—and participate in social innovation projects in conjunction with charities and non-profit organizations. + +[Subscribe to our weekly newsletter][12] to learn more about open organizations. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/18/3/open-social-human-connection + +作者:[Dennis Hack][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/dhack +[1]:https://human-connection.org/en/ +[2]:https://github.com/human-connection/ +[3]:https://youtu.be/tPcYRQcepYE +[4]:http://www.un.org/en/charter-united-nations/index.html +[5]:https://youtu.be/BQHBno-efRI +[6]:http://codealliance.org/ +[7]:https://www.codeforamerica.org/ +[8]:http://fixmystreet.org/ +[9]:https://tasks.hotosm.org/ +[10]:https://youtu.be/AwSx06DK2oU +[11]:https://youtu.be/g2gYLNx686I +[12]:https://opensource.com/open-organization/resources/newsletter From abc9e0c998e3dff040f0c4438e06851ac82930b2 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 21:55:08 +0800 Subject: [PATCH 0065/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=206=20common=20qu?= =?UTF-8?q?estions=20about=20agile=20development=20practices=20for=20teams?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...t agile development practices for teams.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 sources/talk/20180319 6 common questions about agile development practices for teams.md diff --git a/sources/talk/20180319 6 common questions about agile development practices for teams.md b/sources/talk/20180319 6 common questions about agile development practices for teams.md new file mode 100644 index 0000000000..0de7cda81c --- /dev/null +++ b/sources/talk/20180319 6 common questions about agile development practices for teams.md @@ -0,0 +1,59 @@ +6 common questions about agile development practices for teams +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard.png?itok=kBeRTFL1) +"Any questions?" + +You’ve probably heard a speaker ask this question at the end of their presentation. This is the most important part of the presentation—after all, you didn't attend just to hear a lecture but to participate in a conversation and a community. + +Recently I had the opportunity to hear my fellow Red Hatters present a session called "[Agile in Practice][1]" to a group of technical students at a local university. During the session, software engineer Tomas Tomecek and agile practitioners Fernando Colleone and Pavel Najman collaborated to explain the foundations of agile methodology and showcase best practices for day-to-day activities. + +### 1\. What is the perfect team size? + +Knowing that students attended this session to learn what agile practice is and how to apply it to projects, I wondered how the students' questions would compare to those I hear every day as an agile practitioner at Red Hat. It turns out that the students asked the same questions as my colleagues. These questions drive straight into the core of agile in practice. + +Students wanted to know the size of a small team versus a large team. This issue is relevant to anyone who has ever teamed up to work on a project. Based on Tomas's experience as a tech leader, 12 people working on a project would be considered a large team. In the real world, team size is not often directly correlated to productivity. In some cases, a smaller team located in a single location or time zone might be more productive than a larger team that's spread around the world. Ultimately, the presenters suggested that the ideal team size is probably five people (which aligns with scrum 7, +-2). + +### 2\. What operational challenges do teams face? + +The presenters compared projects supported by local teams (teams with all members in one office or within close proximity to each other) with distributed teams (teams located in different time zones). Engineers prefer local teams when the project requires close cooperation among team members because delays caused by time differences can destroy the "flow" of writing software. At the same time, distributed teams can bring together skill sets that may not be available locally and are great for certain development use cases. Also, there are various best practices to improve cooperation in distributed teams. + +### 3\. How much time is needed to groom the backlog? + +Because this was an introductory talk targeting students who were new to agile, the speakers focused on [Scrum][2] and [Kanban][3] as ways to make agile specific for them. They used the Scrum framework to illustrate a method of writing software and Kanban for a communication and work planning system. On the question of time needed to groom a project's backlog, the speakers explained that there is no fixed rule. Rather, practice makes perfect: During the early stages of development, when a project is new—and especially if some members of the team are new to agile—grooming can consume several hours per week. Over time and with practice, it becomes more efficient. + +### 4\. Is a product owner necessary? What is their role? + +Product owners help facilitate scaling; however, what matters is not the job title, but that you have someone on your team who represents the customer's voice and goals. In many teams, especially those that are part of a larger group of engineering teams working on a single output, a lead engineer can serve as the product owner. + +### 5\. What agile tools do you suggest using? Is specific software necessary to implement Scrum or Kanban in practice? + +Although using proprietary software such as Jira or Trello can be helpful, especially when working with large numbers of contributors working on big enterprise projects, they are not required. Scrum and Kanban can be done with tools as simple as paper cards. The key is to have a clear source of information and strong communication across the entire team. That said, two excellent open source kanban tools are [Taiga][4] and [Wekan][5]. For more information, see [5 open source alternatives to Trello][6] and [Top 7 open source project management tools for agile teams][7]. + +### 6\. How can students use agile techniques for school projects? + +The presenters encouraged students to use kanban to visualize and outline tasks to be completed before the end of the project. The key is to create a common board so the entire team can see the status of the project. By using kanban or a similar high-visibility strategy, students won’t get to the end of the project and discover that any particular team member has not been keeping up. + +Scrum practices such as sprints and daily standups are also excellent ways to ensure that everyone is making progress and that the various parts of the project will work together at the end. Regular check-ins and information-sharing are also essential. To learn more about Scrum, see [What is scrum?][8]. + +Remember that Kanban and Scrum are just two of many tools and frameworks that make up agile. They may not be the best approach for every situation. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/agile-mindset + +作者:[Dominika Bula][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/dominika +[1]:http://zijemeit.cz/sessions/agile-in-practice/ +[2]:https://www.scrum.org/resources/what-is-scrum +[3]:https://en.wikipedia.org/wiki/Kanban +[4]:https://taiga.io/ +[5]:https://wekan.github.io/ +[6]:https://opensource.com/alternatives/trello +[7]:https://opensource.com/article/18/2/agile-project-management-tools +[8]:https://opensource.com/resources/scrum From 41523bbb608bd674911bab8528a2d0e8a140a6aa Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 21:56:33 +0800 Subject: [PATCH 0066/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Mana?= =?UTF-8?q?ge=20Disk=20Partitions=20Using=20Parted=20Command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ge Disk Partitions Using Parted Command.md | 435 ++++++++++++++++++ 1 file changed, 435 insertions(+) create mode 100644 sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md diff --git a/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md b/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md new file mode 100644 index 0000000000..141e86cc1d --- /dev/null +++ b/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md @@ -0,0 +1,435 @@ +How To Manage Disk Partitions Using Parted Command +====== +We all knows disk partitions is one of the important task for Linux administrator. They can not survive without knowing this. + +In worst cases, at least once in a week they would get this request from dependent team but in big environment admins used to get this request very often. + +You may ask why we need to use parted instead of fdisk? What is the difference? It’s a good question, i will give you more details about this. + + * Parted allow users to create a partition when the disk size is larger than 2TB but fdisk doesn’t allow. + * Parted is a higher-level tool than fdisk. + * It supports multiple partition table which includes GPT. + * It allows users to resize the partition but while shrinking the partition it does not worked as expected and i got error most of the time so, i would advise users to do not shrink the partition. + + + +### What Is Parted + +Parted is a program to manipulate disk partitions. It supports multiple partition table formats, including MS-DOS and GPT. + +It allows user to create, delete, resize, shrink, move and copy partitions, reorganizing disk usage, and copying data to new hard disks. GParted is a GUI frontend of parted. + +### How To Install Parted + +Parted package is pre-installed on most of the Linux distribution. If not, use the following commands to install parted package. + +For **`Debian/Ubuntu`** , use [APT-GET Command][1] or [APT Command][2] to install parted. +``` +$ sudo apt install parted + +``` + +For **`RHEL/CentOS`** , use [YUM Command][3] to install parted. +``` +$ sudo yum install parted + +``` + +For **`Fedora`** , use [DNF Command][4] to install parted. +``` +$ sudo dnf install parted + +``` + +For **`Arch Linux`** , use [Pacman Command][5] to install parted. +``` +$ sudo pacman -S parted + +``` + +For **`openSUSE`** , use [Zypper Command][6] to install parted. +``` +$ sudo zypper in parted + +``` + +### How To Launch Parted + +The below parted command picks the `/dev/sda` disk automatically, because this is the first hard drive in this system. +``` +$ sudo parted +GNU Parted 3.2 +Using /dev/sda +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) + +``` + +Also we can go to the corresponding disk by selecting the appropriate disk using below command. +``` +(parted) select /dev/sdb +Using /dev/sdb +(parted) + +``` + +If you wants to go to particular disk, use the following format. In our case we are going to use `/dev/sdb`. +``` +$ sudo parted [Device Name] + +$ sudo parted /dev/sdb +GNU Parted 3.2 +Using /dev/sdb +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) + +``` + +### How To List Available Disks Using Parted Command + +If you don’t know what are the disks are added in your system. Just run the following command, which will display all the available disks name, and other useful information such as Disk Size, Model, Sector Size, Partition Table, Disk Flags, and partition information. +``` +$ sudo parted -l +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sda: 32.2GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 32.2GB 32.2GB primary ext4 boot + + +Error: /dev/sdb: unrecognised disk label +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: unknown +Disk Flags: + +``` + +The above error message clearly shows there is no valid disk label for the disk `/dev/sdb`. Hence, we have to set `disk label` first as it doesn’t take any label automatically. + +### How To Create Disk Partition Using Parted Command + +Parted allows us to create primary or extended partition. Procedure is same for both but make sure you have to pass an appropriate partition type like `primary` or `extended` while creating the partition. + +To perform this activity, we have added a new `50GB` hard disk in the system, which falls under `/dev/sdb`. + +In two ways we can create a partition, one is detailed way and other one is single command. In the below example we are going to add one primary partition in detailed way. Make a note, we should set `disk label` first as it doesn’t take any label automatically. + +We are going to create a new partition with `10GB` of disk in the below example. +``` +$ sudo parted /dev/sdb +GNU Parted 3.2 +Using /dev/sdb +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) mklabel msdos +(parted) unit GB +(parted) mkpart +Partition type? primary/extended? primary +File system type? [ext2]? ext4 +Start? 0.00GB +End? 10.00GB +(parted) print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 0.00GB 10.0GB 10.0GB primary ext4 lba + +(parted) quit +Information: You may need to update /etc/fstab. + +``` + +Alternatively we can create a new partition using single parted command. + +We are going to create second partition with `10GB` of disk in the below example. +``` +$ sudo parted [Disk Name] [mkpart] [Partition Type] [Filesystem Type] [Partition Start Size] [Partition End Size] + +$ sudo parted /dev/sdb mkpart primary ext4 10.0GB 20.0GB +Information: You may need to update /etc/fstab. + +``` + +### How To Create A Partition With All Remaining Space + +You have created all required partitions except `/home` and you wants to use all the remaining space to `/home` partition, how to do that? use the following command to create a partition. + +The below command create a new partition with 33.7GB, which starts from `20GB` and ends with `53GB`. `100%` end size will allow users to create a new partition with remaining all available space in the disk. +``` +$ sudo parted [Disk Name] [mkpart] [Partition Type] [Filesystem Type] [Partition Start Size] [Partition End Size] + +$ sudo parted /dev/sdb mkpart primary ext4 20.0GB 100% +Information: You may need to update /etc/fstab. + +``` + +### How To List All Partitions using Parted + +As you aware of, we have created three partitions in the above step and if you want to list all available partitions on the disk use the print command. +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 53.7GB 33.7GB primary ext4 + +``` + +### How To Create A File System On Partition Using mkfs + +Users can create a file system on the partition using mkfs. Follow the below procedure to create a filesystem using mkfs. +``` +$ sudo mkfs.ext4 /dev/sdb1 +mke2fs 1.43.4 (31-Jan-2017) +Creating filesystem with 2621440 4k blocks and 656640 inodes +Filesystem UUID: 415cf467-634c-4403-8c9f-47526bbaa381 +Superblock backups stored on blocks: + 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 + +Allocating group tables: done +Writing inode tables: done +Creating journal (16384 blocks): done +Writing superblocks and filesystem accounting information: done + +``` + +Do the same for other partitions as well. +``` +$ sudo mkfs.ext4 /dev/sdb2 +$ sudo mkfs.ext4 /dev/sdb3 + +``` + +Create necessary folders and mount the partitions on that. +``` +$ sudo mkdir /par1 /par2 /par3 + +$ sudo mount /dev/sdb1 /par1 +$ sudo mount /dev/sdb2 /par2 +$ sudo mount /dev/sdb3 /par3 + +``` + +Run the following command to check newly mounted partitions. +``` +$ df -h /dev/sdb[1-3] +Filesystem Size Used Avail Use% Mounted on +/dev/sdb1 9.2G 37M 8.6G 1% /par1 +/dev/sdb2 9.2G 37M 8.6G 1% /par2 +/dev/sdb3 31G 49M 30G 1% /par3 + +``` + +### How To Check Free Space On The Disk + +Run the following command to check available free space on the disk. This disk has `25.7GB` of free disk space. +``` +$ sudo parted /dev/sdb print free +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 32.3kB 1049kB 1016kB Free Space + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 28.0GB 8001MB primary ext4 + 28.0GB 53.7GB 25.7GB Free Space + +``` + +### How To Resize Partition Using Parted Command + +Parted allow users to resize the partitions to big and smaller size. As i told in the beginning of the article, do not shrink partitions because this leads to face disk error issue. + +Run the following command to check disk partitions and available free space. I could see `25.7GB` of free space on this disk. +``` +$ sudo parted /dev/sdb print free +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 32.3kB 1049kB 1016kB Free Space + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 28.0GB 8001MB primary ext4 + 28.0GB 53.7GB 25.7GB Free Space + +``` + +Run the following command to resize the partition. We are going to resize (increase) the partition 3 end size from `28GB to 33GB`. +``` +$ sudo parted [Disk Name] [resizepart] [Partition Number] [Partition New End Size] + +$ sudo parted /dev/sdb resizepart 3 33.0GB +Information: You may need to update /etc/fstab. + +``` + +Run the following command to verify whether this partition is increased or not. Yes, i could see the partition 3 got increased from `8GB to 13GB`. +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 33.0GB 13.0GB primary ext4 + +``` + +Resize the file system to grow the resized partition. +``` +$ sudo resize2fs /dev/sdb3 +resize2fs 1.43.4 (31-Jan-2017) +Resizing the filesystem on /dev/sdb3 to 3173952 (4k) blocks. +The filesystem on /dev/sdb3 is now 3173952 (4k) blocks long. + +``` + +Finally, check whether the mount point has been successfully increased or not. +``` +$ df -h /dev/sdb[1-3] +Filesystem Size Used Avail Use% Mounted on +/dev/sdb1 9.2G 5.1G 3.6G 59% /par1 +/dev/sdb2 9.2G 2.1G 6.6G 24% /par2 +/dev/sdb3 12G 1.1G 11G 10% /par3 + +``` + +### How To Remove Partition Using Parted Command + +We can simple remove the unused partition (if the partition is no longer use) using rm command. See the procedure below. We are going to remove partition 3 `/dev/sdb3` in this example. +``` +$ sudo parted [Disk Name] [rm] [Partition Number] + +$ sudo parted /dev/sdb rm 3 +Warning: Partition /dev/sdb3 is being used. Are you sure you want to continue? +Yes/No? Yes +Error: Partition(s) 3 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. +You should reboot now before making further changes. +Ignore/Cancel? Ignore +Information: You may need to update /etc/fstab. + +``` + +We can check the same using below command. Yes, i could see that partition 3 has been removed successfully. +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + +``` + +### How To Set/Change Partition Flag Using Parted Command + +We can easily change the partition flag using below command. We are going to set `lvm` flag to partition 2 `/dev/sdb2`. +``` +$ sudo parted [Disk Name] [set] [Partition Number] [Flags Name] [Flag On/Off] + +$ sudo parted /dev/sdb set 2 lvm on +Information: You may need to update /etc/fstab. + +``` + +We can verify this modification by listing disk partitions. +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 lvm + +``` + +To know list of available flags, use the following command. +``` +$ (parted) help set + set NUMBER FLAG STATE change the FLAG on partition NUMBER + + NUMBER is the partition number used by Linux. On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards. + FLAG is one of: boot, root, swap, hidden, raid, lvm, lba, hp-service, palo, prep, msftres, bios_grub, atvrecv, diag, legacy_boot, msftdata, irst, esp + STATE is one of: on, off + +``` + +If you want to know the available options in parted, just navigate to `help` page. +``` +$ sudo parted +GNU Parted 3.2 +Using /dev/sda +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) help + align-check TYPE N check partition N for TYPE(min|opt) alignment + help [COMMAND] print general help, or help on COMMAND + mklabel,mktable LABEL-TYPE create a new disklabel (partition table) + mkpart PART-TYPE [FS-TYPE] START END make a partition + name NUMBER NAME name partition NUMBER as NAME + print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition + quit exit program + rescue START END rescue a lost partition near START and END + resizepart NUMBER END resize partition NUMBER + rm NUMBER delete partition NUMBER + select DEVICE choose the device to edit + disk_set FLAG STATE change the FLAG on selected device + disk_toggle [FLAG] toggle the state of FLAG on selected device + set NUMBER FLAG STATE change the FLAG on partition NUMBER + toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER + unit UNIT set the default unit to UNIT + version display the version number and copyright information of GNU Parted +(parted) quit + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-manage-disk-partitions-using-parted-command/ + +作者:[Magesh Maruthamuthu][a] +译者:[译者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/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[2]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[3]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[4]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[5]:https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[6]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ From 45b8d68bc3c99a269e612a0411bc67ed53725814 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 22 Mar 2018 21:59:44 +0800 Subject: [PATCH 0067/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Edit?= =?UTF-8?q?=20Multiple=20Files=20Using=20Vim=20Editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...To Edit Multiple Files Using Vim Editor.md | 347 ++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md diff --git a/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md b/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md new file mode 100644 index 0000000000..8e78bb8477 --- /dev/null +++ b/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md @@ -0,0 +1,347 @@ +How To Edit Multiple Files Using Vim Editor +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Edit-Multiple-Files-Using-Vim-Editor-720x340.png) +Sometimes, you will find yourself in a situation where you want to make changes in multiple files or you might want to copy the contents of one file to another. If you’re on GUI mode, you could simply open the files in any graphical text editor, like gedit, and use CTRL+C and CTRL+V to copy/paste the contents. In CLI mode, you can’t use such editors. No worries! Where there is vim editor, there is a way! In this tutorial, we are going to learn to edit multiple files at the same time using Vim editor. Trust me, this is very interesting read. + +### Installing Vim + +Vim editor is available in the official repositories of most Linux distributions. So you can install it using the default package manager. For example, on Arch Linux and its variants you can install it using command: +``` +$ sudo pacman -S vim + +``` + +On Debian, Ubuntu: +``` +$ sudo apt-get install vim + +``` + +On RHEL, CentOS: +``` +$ sudo yum install vim + +``` + +On Fedora: +``` +$ sudo dnf install vim + +``` + +On openSUSE: +``` +$ sudo zypper install vim + +``` + +### Edit multiple files at a time using Vim editor in Linux + +Let us now get down to the business. We can do this in two methods. + +#### Method 1 + +I have two files namely **file1.txt** and **file2.txt** , with a bunch of random words. Let us have a look at them. +``` +$ cat file1.txt +ostechnix +open source +technology +linux +unix + +$ cat file2.txt +line1 +line2 +line3 +line4 +line5 + +``` + +Now, let us edit these two files at a time. To do so, run: +``` +$ vim file1.txt file2.txt + +``` + +Vim will display the contents of the files in an order. The first file’s contents will be shown first and then second file and so on. + +![][2] + +**Switch between files** + +To move to the next file, type: +``` +:n + +``` + +![][3] + +To go back to previous file, type: +``` +:N + +``` + +Vim won’t allow you to move to the next file if there are any unsaved changes. To save the changes in the current file, type: +``` +ZZ + +``` + +Please note that it is double capital letters ZZ (SHIFT+zz). + +To abandon the changes and move to the previous file, type: +``` +:N! + +``` + +To view the files which are being currently edited, type: +``` +:buffers + +``` + +![][4] + +You will see the list of loaded files at the bottom. + +![][5] + +To switch to the next file, type **:buffer** followed by the buffer number. For example, to switch to the first file, type: +``` +:buffer 1 + +``` + +![][6] + +**Opening additional files for editing** + +We are currently editing two files namely file1.txt, file2.txt. I want to open another file named **file3.txt** for editing. +What will you do? It’s easy! Just type **:e** followed by the file name like below. +``` +:e file3.txt + +``` + +![][7] + +Now you can edit file3.txt. + +To view how many files are being edited currently, type: +``` +:buffers + +``` + +![][8] + +Please note that you can not switch between opened files with **:e** using either **:n** or **:N**. To switch to another file, type **:buffer** followed by the file buffer number. + +**Copying contents of one file into another** + +You know how to open and edit multiple files at the same time. Sometimes, you might want to copy the contents of one file into another. It is possible too. Switch to a file of your choice. For example, let us say you want to copy the contents of file1.txt into file2.txt. + +To do so, first switch to file1.txt: +``` +:buffer 1 + +``` + +Place the move cursor in-front of a line that wants to copy and type **yy** to yank(copy) the line. Then. move to file2.txt: +``` +:buffer 2 + +``` + +Place the mouse cursor where you want to paste the copied lines from file1.txt and type **p**. For example, you want to paste the copied line between line2 and line3. To do so, put the mouse cursor before line and type **p**. + +Sample output: +``` +line1 +line2 +ostechnix +line3 +line4 +line5 + +``` + +![][9] + +To save the changes made in the current file, type: +``` +ZZ + +``` + +Again, please note that this is double capital ZZ (SHIFT+z). + +To save the changes in all files and exit vim editor. type: +``` +:wq + +``` + +Similarly, you can copy any line from any file to other files. + +**Copying entire file contents into another** + +We know how to copy a single line. What about the entire file contents? That’s also possible. Let us say, you want to copy the entire contents of file1.txt into file2.txt. + +To do so, open the file2.txt first: +``` +$ vim file2.txt + +``` + +If the files are already loaded, you can switch to file2.txt by typing: +``` +:buffer 2 + +``` + +Move the cursor to the place where you wanted to copy the contents of file1.txt. I want to copy the contents of file1.txt after line5 in file2.txt, so I moved the cursor to line 5. Then, type the following command and hit ENTER key: +``` +:r file1.txt + +``` + +![][10] + +Here, **r** means **read**. + +Now you will see the contents of file1.txt is pasted after line5 in file2.txt. +``` +line1 +line2 +line3 +line4 +line5 +ostechnix +open source +technology +linux +unix + +``` + +![][11] + +To save the changes in the current file, type: +``` +ZZ + +``` + +To save all changes in all loaded files and exit vim editor, type: +``` +:wq + +``` + +#### Method 2 + +The another method to open multiple files at once is by using either **-o** or **-O** flags. + +To open multiple files in horizontal windows, run: +``` +$ vim -o file1.txt file2.txt + +``` + +![][12] + +To switch between windows, press **CTRL-w w** (i.e Press **CTRL+w** and again press **w** ). Or, you the following shortcuts to move between windows. + + * **CTRL-w k** – top window + * **CTRL-w j** – bottom window + + + +To open multiple files in vertical windows, run: +``` +$ vim -O file1.txt file2.txt file3.txt + +``` + +![][13] + +To switch between windows, press **CTRL-w w** (i.e Press **CTRL+w** and again press **w** ). Or, use the following shortcuts to move between windows. + + * **CTRL-w l** – left window + * **CTRL-w h** – right window + + + +Everything else is same as described in method 1. + +For example, to list currently loaded files, run: +``` +:buffers + +``` + +To switch between files: +``` +:buffer 1 + +``` + +To open an additional file, type: +``` +:e file3.txt + +``` + +To copy entire contents of a file into another: +``` +:r file1.txt + +``` + +The only difference in method 2 is once you saved the changes in the current file using **ZZ** , the file will automatically close itself. Also, you need to close the files one by one by typing **:wq**. But, had you followed the method 1, when typing **:wq** all changes will be saved in all files and all files will be closed at once. + +For more details, refer man pages. +``` +$ man vim + +``` + +**Suggested read:** + +You know now how to edit multiples files using vim editor in Linux. As you can see, editing multiple files is not that difficult. Vim editor has more powerful features. We will write more about Vim editor in the days to come. + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-edit-multiple-files-using-vim-editor/ + +作者:[SK][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/author/sk/ +[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-1-1.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-2.png +[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-5.png +[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-6.png +[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-7.png +[7]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-8.png +[8]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-10-1.png +[9]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-11.png +[10]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-12.png +[11]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-13.png +[12]:http://www.ostechnix.com/wp-content/uploads/2018/03/Edit-multiple-files-16.png +[13]:http://www.ostechnix.com/wp-content/uploads/2018/03/Edit-multiple-files-17.png From c6db15a43739e4cbe2afa0dea4e93de4a96fac6e Mon Sep 17 00:00:00 2001 From: HankChow Date: Thu, 22 Mar 2018 22:38:10 +0800 Subject: [PATCH 0068/1057] hankchow translating --- ...314 How to measure particulate matter with a Raspberry Pi.md | 2 ++ ... to use Ansible to patch systems and install applications.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md b/sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md index 5db092a557..e1dea7af9f 100644 --- a/sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md +++ b/sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md @@ -1,3 +1,5 @@ +hankchow translating + How to measure particulate matter with a Raspberry Pi ====== diff --git a/sources/tech/20180321 How to use Ansible to patch systems and install applications.md b/sources/tech/20180321 How to use Ansible to patch systems and install applications.md index 9debeedc1e..8e52f39f76 100644 --- a/sources/tech/20180321 How to use Ansible to patch systems and install applications.md +++ b/sources/tech/20180321 How to use Ansible to patch systems and install applications.md @@ -1,3 +1,5 @@ +hankchow translating + How to use Ansible to patch systems and install applications ====== From 9a80c91e169f85c8f48907895aadad25e1845088 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 22 Mar 2018 23:36:43 +0800 Subject: [PATCH 0069/1057] Delete 20180209 How to setup and configure network bridge on Debian Linux.md --- ...onfigure network bridge on Debian Linux.md | 123 ------------------ 1 file changed, 123 deletions(-) delete mode 100644 sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md diff --git a/sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md b/sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md deleted file mode 100644 index 7c869b6494..0000000000 --- a/sources/tech/20180209 How to setup and configure network bridge on Debian Linux.md +++ /dev/null @@ -1,123 +0,0 @@ -Translating by MjSeven - -How to setup and configure network bridge on Debian Linux -====== - -I am new Debian Linux user. I want to setup Bridge for virtualised environments (KVM) running on Debian Linux. How do I setup network bridging in /etc/network/interfaces on Debian Linux 9.x server? - -If you want to assign IP addresses to your virtual machines and make them accessible from your LAN you need to setup network bridge. By default, a private network bridge created when using KVM. You need to set up interfaces manually, avoiding conflicts with, network manager. - -### How to install the brctl - -Type the following [nixcmdn name=”apt”]/[apt-get command][1]: -`$ sudo apt install bridge-utils` - -### How to setup network bridge on Debian Linux - -You need to edit /etc/network/interface file. However, I recommend to drop a brand new config in /etc/network/interface.d/ directory. The procedure to configure network bridge on Debian Linux is as follows: - -#### Step 1 – Find out your physical interface - -Use the [ip command][2]: -`$ ip -f inet a s` -Sample outputs: -``` -2: eno1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - inet 192.168.2.23/24 brd 192.168.2.255 scope global eno1 - valid_lft forever preferred_lft forever -``` - - -eno1 is my physical interface. - -#### Step 2 – Update /etc/network/interface file - -Make sure only lo (loopback is active in /etc/network/interface). Remove any config related to eno1. Here is my config file printed using [cat command][3]: -`$ cat /etc/network/interface` -``` -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). -  -source /etc/network/interfaces.d/* -  -# The loopback network interface -auto lo -iface lo inet loopback -``` - - -#### Step 3 – Configuring bridging (br0) in /etc/network/interfaces.d/br0 - -Create a text file using a text editor such as vi command: -`$ sudo vi /etc/network/interfaces.d/br0` -Append the following config: -``` -## static ip config file for br0 ## -auto br0 -iface br0 inet static - address 192.168.2.23 - broadcast 192.168.2.255 - netmask 255.255.255.0 - gateway 192.168.2.254 - # If the resolvconf package is installed, you should not edit - # the resolv.conf configuration file manually. Set name server here - #dns-nameservers 192.168.2.254 - # If you have muliple interfaces such as eth0 and eth1 - # bridge_ports eth0 eth1 - bridge_ports eno1 - bridge_stp off # disable Spanning Tree Protocol - bridge_waitport 0 # no delay before a port becomes available - bridge_fd 0 # no forwarding delay -``` - -If you want bridge to get an IP address using DHCP: -``` -## DHCP ip config file for br0 ## -auto br0 -  -# Bridge setup - iface br0 inet dhcp - bridge_ports eno1 -``` - - -[Save and close the file in vi/vim][4]. - -#### Step 4 – [Restart networking service in Linux][5] - -Before you restart the networking service make sure firewall is disabled. The firewall may refer to older interface such as eno1. Once service restarted, you must update firewall rule for interface br0. Type the following restart the networking service: -`$ sudo systemctl restart network-manager` -Verify that service has been restarted: -`$ systemctl status network-manager` -Look for new br0 interface and routing table with the help of [ip command][2]: -`$ ip a s $ ip r $ ping -c 2 cyberciti.biz` -Sample outputs: -![](https://www.cyberciti.biz/media/new/faq/2018/02/How-to-setup-and-configure-network-bridge-on-Debian-Linux.jpg) -You can also use the brctl command to view info about your bridges: -`$ brctl show` -Show current bridges: -`$ bridge link` -![](https://www.cyberciti.biz/media/new/faq/2018/02/Show-current-bridges-and-what-interfaces-they-are-connected-to-on-Linux.jpg) - -### About the author - -The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the **latest tutorials on SysAdmin, Linux/Unix and open source topics via[RSS/XML feed][6]** or [weekly email newsletter][7]. - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/faq/how-to-configuring-bridging-in-debian-linux/ - -作者:[Vivek GIte][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz/ -[1]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) -[2]:https://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/ (See Linux/Unix ip command examples for more info) -[3]:https://www.cyberciti.biz/faq/linux-unix-appleosx-bsd-cat-command-examples/ (See Linux/Unix cat command examples for more info) -[4]:https://www.cyberciti.biz/faq/linux-unix-vim-save-and-quit-command/ -[5]:https://www.cyberciti.biz/faq/linux-restart-network-interface/ -[6]:https://www.cyberciti.biz/atom/atom.xml -[7]:https://www.cyberciti.biz/subscribe-to-weekly-linux-unix-newsletter-for-sysadmin/ From 44c0bc85e012102448ac0d8252940f299f7ba684 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 22 Mar 2018 23:37:06 +0800 Subject: [PATCH 0070/1057] Create 20180209 How to setup and configure network bridge on Debian Linux.md --- ...onfigure network bridge on Debian Linux.md | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md diff --git a/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md b/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md new file mode 100644 index 0000000000..c5962155af --- /dev/null +++ b/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md @@ -0,0 +1,120 @@ +如何在 Debian Linux 上设置和配置网桥 +===== + +我是一个新 Debian Linux 用户,我想为 Debian Linux 上运行的虚拟化环境(KVM)设置网桥。那么我该如何在 Debian Linux 9.x 服务器上的 /etc/network/interfaces 中设置桥接网络呢? + +如何你想为你的虚拟机分配 IP 地址并使其可从你的局域网访问,则需要设置网络桥接器。默认情况下,虚拟机使用 KVM 创建的专用网桥。但你需要手动设置接口,避免与网络管理员发生冲突。 + +### 怎样安装 brctl + +输入以下命令 [nixcmdn name=”apt”]/[apt-get 命令][1]: +`$ sudo apt install bridge-utils` + +### 怎样在 Debian Linux 上设置网桥 + +你需要编辑 /etc/network/interface 文件。不过,我建议在 /etc/network/interface.d/ 目录下放置一个全新的配置。在 Debian Linux 配置网桥的过程如下: + +#### 步骤 1 - 找出你的物理接口 + +使用 [ip 命令][2]: +`$ ip -f inet a s` +示例输出如下: +``` +2: eno1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + inet 192.168.2.23/24 brd 192.168.2.255 scope global eno1 + valid_lft forever preferred_lft forever +``` + +eno1 是我的物理网卡。 + +#### 步骤 2 - 更新 /etc/network/interface 文件 + +确保只有 lo(loopback 在 /etc/network/interface 中处于活动状态)。(译注:loopback 指本地环回接口,也称为回送地址)删除与 eno1 相关的任何配置。这是我使用 [cat 命令][3] 打印的配置文件: +`$ cat /etc/network/interface` +``` +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). +  +source /etc/network/interfaces.d/* +  +# The loopback network interface +auto lo +iface lo inet loopback +``` + + +#### 步骤 3 - 在 /etc/network/interfaces.d/br0 中配置网桥(br0) + +使用文本编辑器创建一个 text 文件,比如 vi 命令: +`$ sudo vi /etc/network/interfaces.d/br0` +在其中添加配置: +``` +## static ip config file for br0 ## +auto br0 +iface br0 inet static + address 192.168.2.23 + broadcast 192.168.2.255 + netmask 255.255.255.0 + gateway 192.168.2.254 + # If the resolvconf package is installed, you should not edit + # the resolv.conf configuration file manually. Set name server here + #dns-nameservers 192.168.2.254 + # If you have muliple interfaces such as eth0 and eth1 + # bridge_ports eth0 eth1 + bridge_ports eno1 + bridge_stp off # disable Spanning Tree Protocol + bridge_waitport 0 # no delay before a port becomes available + bridge_fd 0 # no forwarding delay +``` + +如果你想使用 DHCP 来获得 IP 地址: +``` +## DHCP ip config file for br0 ## +auto br0 +  +# Bridge setup + iface br0 inet dhcp + bridge_ports eno1 +``` + +[在 vi/vim 中保存并关闭文件][4]。 + +#### 步骤 4 - [重新启动网络服务][5] + +在重新启动网络服务之前,请确保防火墙已关闭。防火墙可能会引用较老的接口,例如 eno1。一旦服务重新启动,你必须更新 br0 接口的防火墙规则。键入以下命令重新启动防火墙: +`$ sudo systemctl restart network-manager` +确认服务已经重新启动: +`$ systemctl status network-manager` +借助 [ip 命令][2]寻找新的 br0 接口和路由表: +`$ ip a s $ ip r $ ping -c 2 cyberciti.biz` +示例输出: +![](https://www.cyberciti.biz/media/new/faq/2018/02/How-to-setup-and-configure-network-bridge-on-Debian-Linux.jpg) +你可以使用 brctl 命令查看网桥有关信息: +`$ brctl show` +显示当前网桥: +`$ bridge link` +![](https://www.cyberciti.biz/media/new/faq/2018/02/Show-current-bridges-and-what-interfaces-they-are-connected-to-on-Linux.jpg) + + +### 关于作者 + +作者是 nixCraft 的创建者,也是经验丰富的系统管理员,DevOps 工程师以及 Linux 操作系统/ Unix shell 脚本的培训师。通过订阅 [RSS/XML feed][6] 或者 [weekly email newsletter][7]获得**关于 SysAdmin, Linux/Unix 和开源主题的最新教程。** + +-------------------------------------------------------------------------------- + +via: https://www.cyberciti.biz/faq/how-to-configuring-bridging-in-debian-linux/ + +作者:[Vivek GIte][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz/ +[1]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) +[2]:https://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/ (See Linux/Unix ip command examples for more info) +[3]:https://www.cyberciti.biz/faq/linux-unix-appleosx-bsd-cat-command-examples/ (See Linux/Unix cat command examples for more info) +[4]:https://www.cyberciti.biz/faq/linux-unix-vim-save-and-quit-command/ +[5]:https://www.cyberciti.biz/faq/linux-restart-network-interface/ +[6]:https://www.cyberciti.biz/atom/atom.xml +[7]:https://www.cyberciti.biz/subscribe-to-weekly-linux-unix-newsletter-for-sysadmin/ From 81dd558d617f5f393af489c9ad678f68f5bcb4a9 Mon Sep 17 00:00:00 2001 From: HankChow Date: Fri, 23 Mar 2018 00:47:02 +0800 Subject: [PATCH 0071/1057] =?UTF-8?q?20180314=20How=20to=20measure=20parti?= =?UTF-8?q?culate=20matter=20with=20a=20Raspberry=20Pi.md=20=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... particulate matter with a Raspberry Pi.md | 195 ------------------ ... particulate matter with a Raspberry Pi.md | 188 +++++++++++++++++ 2 files changed, 188 insertions(+), 195 deletions(-) delete mode 100644 sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md create mode 100644 translated/20180314 How to measure particulate matter with a Raspberry Pi.md diff --git a/sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md b/sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md deleted file mode 100644 index e1dea7af9f..0000000000 --- a/sources/tech/20180314 How to measure particulate matter with a Raspberry Pi.md +++ /dev/null @@ -1,195 +0,0 @@ -hankchow translating - -How to measure particulate matter with a Raspberry Pi -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bubblehands_fromRHT_520_0612LL.png?itok=_iQ2dO3S) -We regularly measure particulate matter in the air at our school in Southeast Asia. The values here are very high, particularly between February and May, when weather conditions are very dry and hot, and many fields burn. These factors negatively affect the quality of the air. In this article, I will show you how to measure particulate matter using a Raspberry Pi. - -### What is particulate matter? - -Particulate matter is fine dust or very small particles in the air. A distinction is made between PM10 and PM2.5: PM10 refers to particles that are smaller than 10µm; PM2.5 refers to particles that are smaller than 2.5µm. The smaller the particles—i.e., anything smaller than 2.5µm—the more dangerous they are to one's health, as they can penetrate into the alveoli and impact the respiratory system. - -The World Health Organization recommends [limiting particulate matter][1] to the following values: - - * Annual average PM10 20 µg/m³ - * Annual average PM2,5 10 µg/m³ per year - * Daily average PM10 50 µg/m³ without permitted days on which exceeding is possible. - * Daily average PM2,5 25 µg/m³ without permitted days on which exceeding is possible. - - - -These values are below the limits set in most countries. In the European Union, an annual average of 40 µg/m³ for PM10 is allowed. - -### What is the Air Quality Index (AQI)? - -The Air Quality Index indicates how “good” or “bad” air is based on its particulate measurement. Unfortunately, there is no uniform standard for AQI because not all countries calculate it the same way. The Wikipedia article on the [Air Quality Index][2] offers a helpful overview. At our school, we are guided by the classification established by the United States' [Environmental Protection Agency][3]. - - -![Air quality index][5] - -Air quality index - -### What do we need to measure particulate matter? - -Measuring particulate matter requires only two things: - - * A Raspberry Pi (every model works; a model with WiFi is best) - * A particulates sensor SDS011 - - - -![Particulate sensor][7] - -Particulate sensor - -If you are using a Raspberry Pi Zero W, you will also need an adapter cable to a standard USB port because the Zero has only a Micro USB. These are available for about $20. The sensor comes with a USB adapter for the serial interface. - -### Installation - -For our Raspberry Pi we download the corresponding Raspbian Lite Image and [write it on the Micro SD card][8]. (I will not go into the details of setting up the WLAN connection; many tutorials are available online). - -If you want to have SSH enabled after booting, you need to create an empty file named `ssh` in the boot partition. The IP of the Raspberry Pi can best be obtained via your own router/DHCP server. You can then log in via SSH (the default password is raspberry): -``` -$ ssh pi@192.168.1.5 - -``` - -First we need to install some packages on the Pi: -``` -$ sudo apt install git-core python-serial python-enum lighttpd - -``` - -Before we can start, we need to know which serial port the USB adapter is connected to. `dmesg` helps us: -``` -$ dmesg - -[ 5.559802] usbcore: registered new interface driver usbserial - -[ 5.559930] usbcore: registered new interface driver usbserial_generic - -[ 5.560049] usbserial: USB Serial support registered for generic - -[ 5.569938] usbcore: registered new interface driver ch341 - -[ 5.570079] usbserial: USB Serial support registered for ch341-uart - -[ 5.570217] ch341 1–1.4:1.0: ch341-uart converter detected - -[ 5.575686] usb 1–1.4: ch341-uart converter now attached to ttyUSB0 - -``` - -In the last line, you can see our interface: `ttyUSB0`. We now need a small Python script that reads the data and saves it in a JSON file, and then we will create a small HTML page that reads and displays the data. - -### Reading data on the Raspberry Pi - -We first create an instance of the sensor and then read the sensor every 5 minutes, for 30 seconds. These values can, of course, be adjusted. Between the measuring intervals, we put the sensor into a sleep mode to increase its lifespan (according to the manufacturer, the lifespan totals approximately 8000 hours). - -We can download the script with this command: -``` -$ wget -O /home/pi/aqi.py https://raw.githubusercontent.com/zefanja/aqi/master/python/aqi.py - -``` - -For the script to run without errors, two small things are still needed: -``` -$ sudo chown pi:pi /var/wwww/html/ - -$ echo[] > /var/wwww/html/aqi.json - -``` - -Now you can start the script: -``` -$ chmod +x aqi.py - -$ ./aqi.py - -PM2.5:55.3, PM10:47.5 - -PM2.5:55.5, PM10:47.7 - -PM2.5:55.7, PM10:47.8 - -PM2.5:53.9, PM10:47.6 - -PM2.5:53.6, PM10:47.4 - -PM2.5:54.2, PM10:47.3 - -… - -``` - -### Run the script automatically - -So that we don’t have to start the script manually every time, we can let it start with a cronjob, e.g., with every restart of the Raspberry Pi. To do this, open the crontab file: -``` -$ crontab -e - -``` - -and add the following line at the end: -``` -@reboot cd /home/pi/ && ./aqi.py - -``` - -Now our script starts automatically with every restart. - -### HTML page for displaying measured values and AQI - -We have already installed a lightweight webserver, `lighttpd`. So we need to save our HTML, JavaScript, and CSS files in the directory `/var/www/html/` so that we can access the data from another computer or smartphone. With the next three commands, we simply download the corresponding files: -``` -$ wget -O /var/wwww/html/index.html https://raw.githubusercontent.com/zefanja/aqi/master/html/index.html - -$ wget -O /var/wwww/html/aqi.js https://raw.githubusercontent.com/zefanja/aqi/master/html/aqi.js - -$ wget -O /var/wwww/html/style.css https://raw.githubusercontent.com/zefanja/aqi/master/html/style.css - -``` - -The main work is done in the JavaScript file, which opens our JSON file, takes the last value, and calculates the AQI based on this value. Then the background colors are adjusted according to the scale of the EPA. - -Now you simply open the address of the Raspberry Pi in your browser and look at the current particulates values, e.g., [http://192.168.1.5:][9] - -The page is very simple and can be extended, for example, with a chart showing the history of the last hours, etc. Pull requests are welcome. - -The complete [source code is available on Github][10]. - -**[Enter our[Raspberry Pi week giveaway][11] for a chance at this arcade gaming kit.]** - -### Wrapping up - -For relatively little money, we can measure particulate matter with a Raspberry Pi. There are many possible applications, from a permanent outdoor installation to a mobile measuring device. At our school, we use both: There is a sensor that measures outdoor values day and night, and a mobile sensor that checks the effectiveness of the air conditioning filters in our classrooms. - -[Luftdaten.info][12] offers guidance to build a similar sensor. The software is delivered ready to use, and the measuring device is even more compact because it does not use a Raspberry Pi. Great project! - -Creating a particulates sensor is an excellent project to do with students in computer science classes or a workshop. - -What do you use a [Raspberry Pi][13] for? - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-measure-particulate-matter-raspberry-pi - -作者:[Stephan Tetzel][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/stephan -[1]:https://en.wikipedia.org/wiki/Particulates -[2]:https://en.wikipedia.org/wiki/Air_quality_index -[3]:https://en.wikipedia.org/wiki/United_States_Environmental_Protection_Agency -[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/air_quality_index.png?itok=FwmGf1ZS (Air quality index) -[7]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/particulate_sensor.jpg?itok=ddH3bBwO (Particulate sensor) -[8]:https://www.raspberrypi.org/documentation/installation/installing-images/README.md -[9]:http://192.168.1.5/ -[10]:https://github.com/zefanja/aqi -[11]:https://opensource.com/article/18/3/raspberry-pi-week-giveaway -[12]:http://luftdaten.info/ -[13]:https://openschoolsolutions.org/shutdown-servers-case-power-failure%e2%80%8a-%e2%80%8aups-nut-co/ diff --git a/translated/20180314 How to measure particulate matter with a Raspberry Pi.md b/translated/20180314 How to measure particulate matter with a Raspberry Pi.md new file mode 100644 index 0000000000..0ca5af0fcf --- /dev/null +++ b/translated/20180314 How to measure particulate matter with a Raspberry Pi.md @@ -0,0 +1,188 @@ +如何使用树莓派测定颗粒物 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bubblehands_fromRHT_520_0612LL.png?itok=_iQ2dO3S) +我们在东南亚的学校定期测定空气中的颗粒物。这里的测定值非常高,尤其是在二到五月之间,干燥炎热、土地干旱等各种因素都对空气质量产生了不利的影响。我将会在这篇文章中展示如何使用树莓派来测定颗粒物。 + +### 什么是颗粒物? + +颗粒物就是粉尘或者空气中的微小颗粒。其中 PM10 和 PM2.5 之间的差别就是 PM10 指的是粒径小于10微米的颗粒,而 PM2.5 指的是粒径小于2.5微米的颗粒。在粒径小于2.5微米的的情况下,由于它们能被吸入肺泡中并且对呼吸系统造成影响,因此颗粒越小,对人的健康危害越大。 + +世界卫生组织的建议[颗粒物浓度][1]是: + + * 年均 PM10 不高于20 µg/m³ + * 年均 PM2.5 不高于10 µg/m³ + * 不允许超标时,日均 PM10 不高于50 µg/m³ + * 不允许超标时,日均 PM2.5 不高于25 µg/m³ + +以上数值实际上是低于大多数国家的标准的,例如欧盟对于 PM10 所允许的年均值是不高于40 µg/m³。 + +### 什么是空气质量指数(AQI, Air Quality Index)? + +空气质量指数按照颗粒物的测定值来评价空气质量的好坏,然而由于各国之间的计算方式有所不同,这个指数并没有统一的标准。维基百科上关于[空气质量指数][2]的词条对此给出了一个概述。我们学校则以[美国环境保护协会][3](EPA, Environment Protection Agency)建立的分类法来作为依据。 + +![空气质量指数][5] + +空气质量指数 + +### 测定颗粒物需要哪些准备? + +测定颗粒物只需要以下两种器材: + * 树莓派(款式不限,最好带有 WiFi) + * SDS011 颗粒物传感器 + + + +![颗粒物传感器][7] + +颗粒物传感器 + +如果是只带有 Micro USB的树莓派Zero W,那还需要一根连接到标准 USB 端口的适配线,只需要20美元,而传感器则自带适配串行接口的 USB 适配器。 + +### 安装过程 + +对于树莓派,只需要下载对应的 Raspbian Lite 镜像并且[写入到 Micro SD 卡][8]上就可以了(网上很多教程都有介绍如何设置 WLAN 连接,我就不细说了)。 + +如果要使用 SSH,那还需要在启动分区建立一个名为 `ssh` 的空文件。树莓派的 IP 通过路由器或者 DHCP 服务器获取,随后就可以通过 SSH 登录到树莓派了(默认密码是 raspberry): +``` +$ ssh pi@192.168.1.5 + +``` + +首先我们需要在树莓派上安装一下这些包: +``` +$ sudo apt install git-core python-serial python-enum lighttpd + +``` + +在开始之前,我们可以用 `dmesg` 来获取 USB 适配器连接的串行接口: +``` +$ dmesg + +[ 5.559802] usbcore: registered new interface driver usbserial + +[ 5.559930] usbcore: registered new interface driver usbserial_generic + +[ 5.560049] usbserial: USB Serial support registered for generic + +[ 5.569938] usbcore: registered new interface driver ch341 + +[ 5.570079] usbserial: USB Serial support registered for ch341-uart + +[ 5.570217] ch341 1–1.4:1.0: ch341-uart converter detected + +[ 5.575686] usb 1–1.4: ch341-uart converter now attached to ttyUSB0 + +``` + +在最后一行,可以看到接口 `ttyUSB0`。然后我们需要写一个 Python 脚本来读取传感器的数据并以 JSON 格式存储,在通过一个 HTML 页面就可以把数据展示出来了。 + +### 在树莓派上读取数据 + +首先创建一个传感器实例,每5分钟读取一次传感器的数据,持续30秒,这些数值后续都可以调整。在每两次测定的间隔,我们把传感器调到睡眠模式以延长它的使用寿命(厂商认为元件的寿命大约8000小时)。 + +我们可以使用以下命令来下载 Python 脚本: +``` +$ wget -O /home/pi/aqi.py https://raw.githubusercontent.com/zefanja/aqi/master/python/aqi.py + +``` + +另外还需要执行以下两条命令来保证脚本正常运行: +``` +$ sudo chown pi:pi /var/wwww/html/ + +$ echo[] > /var/wwww/html/aqi.json + +``` + +下面就可以执行脚本了: +``` +$ chmod +x aqi.py + +$ ./aqi.py + +PM2.5:55.3, PM10:47.5 + +PM2.5:55.5, PM10:47.7 + +PM2.5:55.7, PM10:47.8 + +PM2.5:53.9, PM10:47.6 + +PM2.5:53.6, PM10:47.4 + +PM2.5:54.2, PM10:47.3 + +… + +``` + +### 自动化执行脚本 + +只需要使用诸如 crontab 的服务,我们就不需要每次都手动启动脚本了。按照以下命令打开 crontab 文件: +``` +$ crontab -e + +``` + +在文件末尾添加这一行: +``` +@reboot cd /home/pi/ && ./aqi.py + +``` + +现在我们的脚本就会在树莓派每次重启后自动执行了。 + +### 展示颗粒物测定值和空气质量指数的 HTML 页面 + +我们在前面已经安装了一个轻量级的 web 服务器 `lighttpd`,所以我们需要把 HTML、JavaScript、CSS 文件放置在 `/var/www/html` 目录中,这样就能通过电脑和智能手机访问到相关数据了。执行下面的三条命令,可以下载到对应的文件: + +``` +$ wget -O /var/wwww/html/index.html https://raw.githubusercontent.com/zefanja/aqi/master/html/index.html + +$ wget -O /var/wwww/html/aqi.js https://raw.githubusercontent.com/zefanja/aqi/master/html/aqi.js + +$ wget -O /var/wwww/html/style.css https://raw.githubusercontent.com/zefanja/aqi/master/html/style.css + +``` + +在 JavaScript 文件中,实现了打开 JSON 文件、提取数据、计算空气质量指数的过程,随后页面的背景颜色将会根据 EPA 的划分标准而变化。 + +你只需要用浏览器访问树莓派的地址,就可以看到当前颗粒物浓度值等数据了。[http://192.168.1.5:][9] + +这个页面比较简单而且可扩展,比如可以添加一个展示过去数小时历史数据的表格等等。 + +这是[Github上的完整源代码][10]。 + +### 总结 + +在资金相对紧张的情况下,树莓派是一种选择。除此以外,还有很多可以用来测定颗粒物的应用,包括室外固定装置、移动测定设备等等。我们学校则同时采用了这两种:固定装置在室外测定全天颗粒物浓度,而移动测定设备在室内检测空调过滤器的效果。 + +[Luftdaten.info][12]提供了一个如何设计类似的传感器的介绍,其中的软件效果出众,而且因为它没有使用树莓派,所以硬件更是小巧。 + +对于学生来说,设计一个颗粒物传感器确实算得上是一个优秀的课外项目。 + +你又打算如何使用你的[树莓派][13]呢? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/how-measure-particulate-matter-raspberry-pi + +作者:[Stephan Tetzel][a] +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/stephan +[1]:https://en.wikipedia.org/wiki/Particulates +[2]:https://en.wikipedia.org/wiki/Air_quality_index +[3]:https://en.wikipedia.org/wiki/United_States_Environmental_Protection_Agency +[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/air_quality_index.png?itok=FwmGf1ZS (Air quality index) +[7]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/particulate_sensor.jpg?itok=ddH3bBwO (Particulate sensor) +[8]:https://www.raspberrypi.org/documentation/installation/installing-images/README.md +[9]:http://192.168.1.5/ +[10]:https://github.com/zefanja/aqi +[11]:https://opensource.com/article/18/3/raspberry-pi-week-giveaway +[12]:http://luftdaten.info/ +[13]:https://openschoolsolutions.org/shutdown-servers-case-power-failure%e2%80%8a-%e2%80%8aups-nut-co/ From a7a422b6b860b307f11a7b9a3bbd19405ee7268d Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Fri, 23 Mar 2018 07:57:43 +0800 Subject: [PATCH 0072/1057] 2018-03-23 --- ... Why Linux is better than Windows or macOS for security.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index e1a5449a2e..dba0f2cd76 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -9,9 +9,9 @@ Enterprises invest a lot of time, effort and money in keeping their systems secu But how many have given much thought to one of the cornerstones of their digital operations: the operating systems deployed on the workforce’s PCs? Was security even a factor when the desktop OS was selected? -This raises a question that every IT person should be able to answer: Which operating system is the most secure for general deployment? +这就产生了一个 IT 人士都应该能回答的问题:哪种操作系统对于一般性使用最安全呢? -We asked some experts what they think of the security of these three choices: Windows, the ever-more-complex platform that’s easily the most popular desktop system; macOS X, the FreeBSD Unix-based operating system that powers Apple Macintosh systems; and Linux, by which we mean all the various Linux distributions and related Unix-based systems. +我们问了一些专家他们对于以下三种选项的看法:Windows, the ever-more-complex platform that’s easily the most popular desktop system; macOS X, the FreeBSD Unix-based operating system that powers Apple Macintosh systems; and Linux, by which we mean all the various Linux distributions and related Unix-based systems. ### 我们怎么会这样How we got here From 139ab606d28fab79893745e19c4f206ed6315c12 Mon Sep 17 00:00:00 2001 From: amwps290 Date: Fri, 23 Mar 2018 08:02:04 +0800 Subject: [PATCH 0073/1057] translating by amwps290 --- ... The Command line Personal Assistant For Your Linux System.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md b/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md index f5c180ca41..b9e00f75fd 100644 --- a/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md +++ b/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md @@ -1,3 +1,4 @@ +translating by amwps290 The Command line Personal Assistant For Your Linux System ====== From 5c995a6fa1041c0fbfc1a6d0d9647540ca8ead4a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 23 Mar 2018 08:17:00 +0800 Subject: [PATCH 0074/1057] Rename translated/20180314 How to measure particulate matter with a Raspberry Pi.md to translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md --- ...80314 How to measure particulate matter with a Raspberry Pi.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/{ => tech}/20180314 How to measure particulate matter with a Raspberry Pi.md (100%) diff --git a/translated/20180314 How to measure particulate matter with a Raspberry Pi.md b/translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md similarity index 100% rename from translated/20180314 How to measure particulate matter with a Raspberry Pi.md rename to translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md From d5e89126f141e33625290fa8009d738aa254481f Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 23 Mar 2018 08:52:46 +0800 Subject: [PATCH 0075/1057] translated --- ...olve mount.nfs- Stale file handle error.md | 98 ------------------- 1 file changed, 98 deletions(-) delete mode 100644 sources/tech/20170101 How to resolve mount.nfs- Stale file handle error.md diff --git a/sources/tech/20170101 How to resolve mount.nfs- Stale file handle error.md b/sources/tech/20170101 How to resolve mount.nfs- Stale file handle error.md deleted file mode 100644 index 2206abe7d7..0000000000 --- a/sources/tech/20170101 How to resolve mount.nfs- Stale file handle error.md +++ /dev/null @@ -1,98 +0,0 @@ -translating---geekpi - -How to resolve mount.nfs: Stale file handle error -====== -Learn how to resolve mount.nfs: Stale file handle error on Linux platform. This is Network File System error can be resolved from client or server end. - - _![][1]_ - -When you are using Network File System in your environment, you must have seen`mount.nfs: Stale file handle` error at times. This error denotes that NFS share is unable to mount since something has changed since last good known configuration. - -Whenever you reboot NFS server or some of the NFS processes are not running on client or server or share is not properly exported at server; these can be reasons for this error. Moreover its irritating when this error comes to previously mounted NFS share. Because this means configuration part is correct since it was previously mounted. In such case once can try following commands: - -Make sure NFS service are running good on client and server. - -``` -# service nfs status -rpc.svcgssd is stopped -rpc.mountd (pid 11993) is running... -nfsd (pid 12009 12008 12007 12006 12005 12004 12003 12002) is running... -rpc.rquotad (pid 11988) is running... -``` - -> Stay connected to your favorite windows applications from anywhere on any device with [ windows 7 cloud desktop ][2] from CloudDesktopOnline.com. Get Office 365 with expert support and free migration from [ Apps4Rent.com ][3]. - -If NFS share currently mounted on client, then un-mount it forcefully and try to remount it on NFS client. Check if its properly mounted by `df` command and changing directory inside it. - -``` -# umount -f /mydata_nfs - -# mount -t nfs server:/nfs_share /mydata_nfs - -#df -k ------- output clipped ----- -server:/nfs_share 41943040 892928 41050112 3% /mydata_nfs -``` - -In above mount command, server can be IP or [hostname ][4]of NFS server. - -If you are getting error while forcefully un-mounting like below : - -``` -# umount -f /mydata_nfs -umount2: Device or resource busy -umount: /mydata_nfs: device is busy -umount2: Device or resource busy -umount: /mydata_nfs: device is busy -``` -Then you can check which all processes or users are using that mount point with `lsof` command like below: - -``` -# lsof |grep mydata_nfs -lsof: WARNING: can't stat() nfs file system /mydata_nfs - Output information may be incomplete. -su 3327 root cwd unknown /mydata_nfs/dir (stat: Stale NFS file handle) -bash 3484 grid cwd unknown /mydata_nfs/MYDB (stat: Stale NFS file handle) -bash 20092 oracle11 cwd unknown /mydata_nfs/MPRP (stat: Stale NFS file handle) -bash 25040 oracle11 cwd unknown /mydata_nfs/MUYR (stat: Stale NFS file handle) -``` - -If you see in above example that 4 PID are using some files on said mount point. Try killing them off to free mount point. Once done you will be able to un-mount it properly. - -Sometimes it still give same error for mount command. Then try mounting after restarting NFS service at client using below command. - -``` -# service nfs restart -Shutting down NFS daemon: [ OK ] -Shutting down NFS mountd: [ OK ] -Shutting down NFS quotas: [ OK ] -Shutting down RPC idmapd: [ OK ] -Starting NFS services: [ OK ] -Starting NFS quotas: [ OK ] -Starting NFS mountd: [ OK ] -Starting NFS daemon: [ OK ] -``` - -Also read : [How to restart NFS step by step in HPUX][5] - -Even if this didnt solve your issue, final step is to restart services at NFS server. Caution! This will disconnect all NFS shares which are exported from NFS server. All clients will see mount point disconnect. This step is where 99% you will get your issue resolved. If not then [NFS configurations][6] must be checked, provided you have changed configuration and post that you started seeing this error. - -Outputs in above post are from RHEL6.3 server. Drop us your comments related to this post. - --------------------------------------------------------------------------------- - -via: https://kerneltalks.com/troubleshooting/resolve-mount-nfs-stale-file-handle-error/ - -作者:[KernelTalks][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://kerneltalks.com -[1]:http://kerneltalks.com/wp-content/uploads/2017/01/nfs_error-2-150x150.png -[2]:https://www.clouddesktoponline.com/ -[3]:http://www.apps4rent.com -[4]:https://kerneltalks.com/linux/all-you-need-to-know-about-hostname-in-linux/ -[5]:http://kerneltalks.com/hpux/restart-nfs-in-hpux/ -[6]:http://kerneltalks.com/linux/nfs-configuration-linux-hpux/ From a9e3a1c720ff571815b934b4404f15719aefdd45 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 23 Mar 2018 08:55:49 +0800 Subject: [PATCH 0076/1057] translated --- ...olve mount.nfs- Stale file handle error.md | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 translated/tech/20170101 How to resolve mount.nfs- Stale file handle error.md diff --git a/translated/tech/20170101 How to resolve mount.nfs- Stale file handle error.md b/translated/tech/20170101 How to resolve mount.nfs- Stale file handle error.md new file mode 100644 index 0000000000..274d4ccf5c --- /dev/null +++ b/translated/tech/20170101 How to resolve mount.nfs- Stale file handle error.md @@ -0,0 +1,96 @@ +如何解决 mount.nfs:失效的文件句柄错误 +====== +了解如何解决 mount.nfs:Linux 平台上的失效文件句柄错误。它是可以在客户端或者服务端解决的网络文件系统错误。 + + _![][1]_ + +当你在你的环境中使用网络文件系统时,你一定不时看到 `mount.nfs:Stale file handle` 错误。此错误表示 NFS 共享无法挂载,因为自上次配置后有些东西已经更改。 + +无论何时你重启 NFS 服务器或某些 NFS 进程未在客户端或服务器上运行,或者共享未在服务器上正确导出,这些都可能是这个错误的原因。此外,当这个错误发生在先前挂载的 NFS 共享上时,它会它令人不快。因为这意味着配置部分是正确的,因为是以前挂载的。在这种情况下,可以尝试下面的命令: + +确保 NFS 服务在客户端和服务器上运行良好。 + +``` +# service nfs status +rpc.svcgssd is stopped +rpc.mountd (pid 11993) is running... +nfsd (pid 12009 12008 12007 12006 12005 12004 12003 12002) is running... +rpc.rquotad (pid 11988) is running... +``` + +>通过 CloudDesktopOnline.com 上的[ Windows 7 云桌面][2]在任意位置的任何设备上保持与你最喜爱的 Windows 程序的连接。从 [Apps4Rent.com][3] 获得有专家支持的 Office 365 和免费迁移。 + +如果 NFS 共享目前挂载在客户端上,则强制卸载它并尝试在 NFS 客户端上重新挂载它。通过 `df` 命令检查它是否正确挂载,并更改其中的目录。 + +``` +# umount -f /mydata_nfs + +# mount -t nfs server:/nfs_share /mydata_nfs + +#df -k +------ output clipped ----- +server:/nfs_share 41943040 892928 41050112 3% /mydata_nfs +``` + +在上面的挂载命令中,服务器可以是 NFS 服务器的 IP 或[主机名][4]。 + +如果你在强制取消挂载时遇到像下面错误: + +``` +# umount -f /mydata_nfs +umount2: Device or resource busy +umount: /mydata_nfs: device is busy +umount2: Device or resource busy +umount: /mydata_nfs: device is busy +``` +然后你可以用 `lsof` 命令来检查哪个进程或用户正在使用该挂载点,如下所示: + +``` +# lsof |grep mydata_nfs +lsof: WARNING: can't stat() nfs file system /mydata_nfs + Output information may be incomplete. +su 3327 root cwd unknown /mydata_nfs/dir (stat: Stale NFS file handle) +bash 3484 grid cwd unknown /mydata_nfs/MYDB (stat: Stale NFS file handle) +bash 20092 oracle11 cwd unknown /mydata_nfs/MPRP (stat: Stale NFS file handle) +bash 25040 oracle11 cwd unknown /mydata_nfs/MUYR (stat: Stale NFS file handle) +``` + +如果你在上面的示例中看到共有 4 个 PID 正在使用该挂载点上的某些文件。尝试杀死它们以释放挂载点。完成后,你将能够正确卸载它。 + +有时 mount 命令会有相同的错误。接着使用下面的命令在客户端重启 NFS 服务后挂载。 + +``` +# service nfs restart +Shutting down NFS daemon: [ OK ] +Shutting down NFS mountd: [ OK ] +Shutting down NFS quotas: [ OK ] +Shutting down RPC idmapd: [ OK ] +Starting NFS services: [ OK ] +Starting NFS quotas: [ OK ] +Starting NFS mountd: [ OK ] +Starting NFS daemon: [ OK ] +``` + +另请阅读:[如何在 HPUX 中逐步重启 NFS][5] + +即使这没有解决你的问题,最后一步是在 NFS 服务器上重启服务。警告!这将断开从该 NFS 服务器导出的所有 NFS 共享。所有客户端将看到挂载点断开。这一步将 99% 解决你的问题。如果没有,请务必检查[ NFS 配置][6],提供你修改的配置并发布你启动时看到的错误。 + +上面文章中的输出来自 RHEL6.3 服务器。请将你的评论发送给我们。 + +-------------------------------------------------------------------------------- + +via: https://kerneltalks.com/troubleshooting/resolve-mount-nfs-stale-file-handle-error/ + +作者:[KernelTalks][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://kerneltalks.com +[1]:http://kerneltalks.com/wp-content/uploads/2017/01/nfs_error-2-150x150.png +[2]:https://www.clouddesktoponline.com/ +[3]:http://www.apps4rent.com +[4]:https://kerneltalks.com/linux/all-you-need-to-know-about-hostname-in-linux/ +[5]:http://kerneltalks.com/hpux/restart-nfs-in-hpux/ +[6]:http://kerneltalks.com/linux/nfs-configuration-linux-hpux/ From d81460ff8bdc977ef2998010e448a5411ce76553 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 23 Mar 2018 08:57:37 +0800 Subject: [PATCH 0077/1057] translating --- ...313 The Type Command Tutorial With Examples For Beginners.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md b/sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md index b1565efc7f..688322322f 100644 --- a/sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md +++ b/sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md @@ -1,3 +1,5 @@ +translating---geekpi + The Type Command Tutorial With Examples For Beginners ====== From 7be643c5187713a79ca0b2155bb63cb177f4c53e Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Fri, 23 Mar 2018 12:03:47 +0800 Subject: [PATCH 0078/1057] Update 20180111 How to install software applications on Linux.md --- .../20180111 How to install software applications on Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180111 How to install software applications on Linux.md b/sources/tech/20180111 How to install software applications on Linux.md index 6414bd19be..166293cb18 100644 --- a/sources/tech/20180111 How to install software applications on Linux.md +++ b/sources/tech/20180111 How to install software applications on Linux.md @@ -1,3 +1,5 @@ +Translating By MjSeven + How to install software applications on Linux ====== From e8db3f057963f167165e6949b054b36a54811562 Mon Sep 17 00:00:00 2001 From: amwps290 Date: Fri, 23 Mar 2018 13:46:08 +0800 Subject: [PATCH 0079/1057] Delete 20180321 The Command line Personal Assistant For Your Linux System.md --- ...ersonal Assistant For Your Linux System.md | 412 ------------------ 1 file changed, 412 deletions(-) delete mode 100644 sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md diff --git a/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md b/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md deleted file mode 100644 index b9e00f75fd..0000000000 --- a/sources/tech/20180321 The Command line Personal Assistant For Your Linux System.md +++ /dev/null @@ -1,412 +0,0 @@ -translating by amwps290 -The Command line Personal Assistant For Your Linux System -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/03/Yoda-720x340.png) -A while ago, we wrote about a command line virtual assistant named [**“Betty”**][1]. Today, I stumbled upon a similar utility called **“Yoda”**. Yoda is a command line personal assistant who can help you to do some trivial tasks in Linux. It is a free, open source application written in Python. In this guide, we will see how to install and use Yoda in GNU/Linux. - -### Installing Yoda, the command line personal assistant - -Yoda requires **Python 2** and PIP. If PIP is not installed in your Linux box, refer the following guide to install it. Just make sure you have installed **python2-pip.** Yoda may not support Python 3. - -**Note:** I recommend you to try Yoda under a virtual environment. Not just Yoda, always try any Python applications in a virtual environment, so they won’t interfere with globally installed packages. You can setup a virtual environment as described in the above link under the section titled “Creating Virtual Environments”. - -Once you have installed pip on your system, git clone Yoda repository. -``` -$ git clone https://github.com/yoda-pa/yoda - -``` - -The above command will create a directory named “yoda” in your current working directory and clone all contents in it. Go to the Yoda directory: -``` -$ cd yoda/ - -``` - -Run the following command to install Yoda application. -``` -$ pip install . - -``` - -Please note the dot (.) at the end. Now, all required packages will be downloaded and installed. - -### Configure Yoda - -First, setup configuration to save your information on your local system. - -To do so, run: -``` -$ yoda setup new - -``` - -Answer the following questions: -``` -Enter your name: -Senthil Kumar -What's your email id? -[email protected] -What's your github username? -sk -Enter your github password: -Password: -Where shall your config be stored? (Default: ~/.yoda/) - -A configuration file already exists. Are you sure you want to overwrite it? (y/n) -y - -``` - -Your password is saved in the config file after encrypting, so don’t worry about it. - -To check the current configuration, run: -``` -$ yoda setup check - -``` - -You will see an output something like below. -``` -Name: Senthil Kumar -Email: [email protected] -Github username: sk - -``` - -By default, your information is stored in **~/.yoda** directory. - -To delete the existing configuration, do: -``` -$ yoda setup delete - -``` - -### Usage - -Yoda contains a simple chat bot. You can interact with it using **chat** command like below. -``` -$ yoda chat who are you - -``` - -Sample output: -``` -Yoda speaks: -I'm a virtual agent - -$ yoda chat how are you -Yoda speaks: -I'm doing very well. Thanks! - -``` - -Here is the list of things we can do with Yoda: - -**Test Internet speed** - -Let us ask Yoda about the Internet speed. To do so, run: -``` -$ yoda speedtest -Speed test results: -Ping: 108.45 ms -Download: 0.75 Mb/s -Upload: 1.95 Mb/s - -``` - -**Shorten and expand URLs** - -Yoda also helps to shorten any URL. -``` -$ yoda url shorten https://www.ostechnix.com/ -Here's your shortened URL: -https://goo.gl/hVW6U0 - -``` - -To expand the shortened URL: -``` -$ yoda url expand https://goo.gl/hVW6U0 -Here's your original URL: -https://www.ostechnix.com/ - -``` - -**Read Hacker News** - -I am regular visitor of Hacker News website. If you’re anything like me, you can read the news from Hacker News website using Yoda like below. -``` -$ yoda hackernews -News-- 1/513 - -Title-- Show HN: a Yelp for iOS developers -Description-- I came up with this idea "a Yelp for developers" when talking with my colleagues. My hypothesis is that, it would be very helpful if we know more about a library before choosing to use it. It's similar to that we want to know more about a restaurant by checki… -url-- https://news.ycombinator.com/item?id=16636071 - -Continue? [press-"y"] - -``` - -Yoda will display one item at a time. To read the next news, simply type “y” and hit ENTER. - -**Manage personal diaries** - -We can also maintain a personal diary to note important events. - -Create a new diary using command: -``` -$ yoda diary nn -Input your entry for note: -Today I learned about Yoda - -``` - -To create a new note, run the above command again. - -To view all notes: -``` -$ yoda diary notes -Today's notes: ----------------- - Time | Note ---------|----- -16:41:41| Today I learned about Yoda - -``` - -Not just notes, Yoda can also help you to create tasks. - -To create a new task, run: -``` -$ yoda diary nt -Input your entry for task: -Write an article about Yoda and publish it on OSTechNix - -``` - -To view the list of tasks, run: -``` -$ yoda diary tasks -Today's agenda: ----------------- -Status | Time | Text --------|---------|----- - O | 16:44:03: Write an article about Yoda and publish it on OSTechNix ----------------- - -Summary: ----------------- -Incomplete tasks: 1 -Completed tasks: 0 - -``` - -As you see above, I have one incomplete task. To mark it as completed, run the following command and type the completed task serial number and hit ENTER: -``` -$ yoda diary ct -Today's agenda: ----------------- -Number | Time | Task --------|---------|----- - 1 | 16:44:03: Write an article about Yoda and publish it on OSTechNix -Enter the task number that you would like to set as completed -1 - -``` - -You can analyze the current month’s tasks at any time using command: -``` -$ yoda diary analyze -Percentage of incomplete task : 0 -Percentage of complete task : 100 -Frequency of adding task (Task/Day) : 3 - -``` - -Sometimes, you may want to maintain a profile about a person you love, admire. - -**Take notes about loved ones** - -First, you need to setup configuration to store your friend’s details. To do so, run: -``` -$ yoda love setup - -``` - -Enter the details of your friend: -``` -Enter their name: -Abdul Kalam -Enter sex(M/F): -M -Where do they live? -Rameswaram - -``` - -To view the details of the person, run: -``` -$ yoda love status -{'place': 'Rameswaram', 'name': 'Abdul Kalam', 'sex': 'M'} - -``` - -To add the birthday of your love one: -``` -$ yoda love addbirth -Enter birthday -15-10-1931 - -``` - -To view the birth date: -``` -$ yoda love showbirth -Birthday is 15-10-1931 - -``` - -You could even add notes about that person: -``` -$ yoda love note -Avul Pakir Jainulabdeen Abdul Kalam better known as A. P. J. Abdul Kalam, was the 11th President of India from 2002 to 2007. - -``` - -You can view the notes using command: -``` -$ yoda love notes -Notes: -1: Avul Pakir Jainulabdeen Abdul Kalam better known as A. P. J. Abdul Kalam, was the 11th President of India from 2002 to 2007. - -``` - -You can also write the things that person like: -``` -$ yoda love like -Add things they like -Physics, Aerospace -Want to add more things they like? [y/n] -n - -``` - -To view the things they like, run: -``` -$ yoda love likes -Likes: -1: Physics, Aerospace - -``` - -**Tracking money expenses** - -You don’t need a separate tool to maintain your financial expenditure. Yoda got your back. - -First, setup configuration for your money expenses using command: -``` -$ yoda money setup - -``` - -Enter your currency code and the initial amount: -``` -Enter default currency code: -INR -{u'USD': 0.015338, u'IDR': 211.06, u'BGN': 0.024436, u'ISK': 1.5305, u'ILS': 0.053402, u'GBP': 0.010959, u'DKK': 0.093063, u'CAD': 0.020041, u'MXN': 0.28748, u'HUF': 3.8873, u'RON': 0.058302, u'MYR': 0.060086, u'SEK': 0.12564, u'SGD': 0.020208, u'HKD': 0.12031, u'AUD': 0.019908, u'CHF': 0.014644, u'KRW': 16.429, u'CNY': 0.097135, u'TRY': 0.06027, u'HRK': 0.092986, u'NZD': 0.021289, u'THB': 0.47854, u'EUR': 0.012494, u'NOK': 0.11852, u'RUB': 0.88518, u'JPY': 1.6332, u'CZK': 0.31764, u'BRL': 0.050489, u'PLN': 0.052822, u'PHP': 0.79871, u'ZAR': 0.1834} -₹ -Indian rupee -Enter initial amount: -10000 - -``` - -To view the money configuration, just run:`` -``` -$ yoda money status -{'initial_money': 10000, 'currency_code': 'INR'} - -``` - -Let us say you bought a book that costs 250 INR. To add this expense, run: -``` -$ yoda money exp -Spend 250 INR on books -output: - -``` - -To view the expenses, run: -``` -$ yoda money exps -2018-03-21 17:12:31 INR 250 books - -``` - -**Creating Idea lists** - -To create a new idea: -``` -$ yoda ideas add --task --inside - -``` - -List the ideas: -``` -$ yoda ideas show - -``` - -To remove a idea from the project: -``` -$ yoda ideas remove --task --inside - -``` - -To remove the idea completely, run: -``` -$ yoda ideas remove --project - -``` - -**Learning English Vocabulary** - -Yoda helps you to learn random English words and track your learning progress. - -To learn a new word, type: -``` -$ yoda vocabulary word - -``` - -It will display a random word. Press ENTER to display the meaning of the word. Again, Yoda asks you if you already know the meaning of the word. If you know it already, type “yes”. If you don’t know, type “no”. This can help you to track your progress. Use the following command to know your progress. -``` -$ yoda vocabulary accuracy - -``` - -Also, Yoda can help you to do few other things like finding the definition of a word and creating flashcards to easily learn anything. For more details and list of available options, refer the help section. -``` -$ yoda --help - -``` - -More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/yoda-the-command-line-personal-assistant-for-your-linux-system/ - -作者:[SK][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/author/sk/ -[1]:https://www.ostechnix.com/betty-siri-like-commandline-virtual-assistant-linux/ From fd9161ec440b2d8a3e33e01466052bc45600adb8 Mon Sep 17 00:00:00 2001 From: amwps290 Date: Fri, 23 Mar 2018 13:54:00 +0800 Subject: [PATCH 0080/1057] Translating by amwps290 --- ...ersonal Assistant For Your Linux System.md | 459 ++++++++++++++++++ 1 file changed, 459 insertions(+) create mode 100644 translated/tech/20180321 The Command line Personal Assistant For Your Linux System.md diff --git a/translated/tech/20180321 The Command line Personal Assistant For Your Linux System.md b/translated/tech/20180321 The Command line Personal Assistant For Your Linux System.md new file mode 100644 index 0000000000..a96ed69bc4 --- /dev/null +++ b/translated/tech/20180321 The Command line Personal Assistant For Your Linux System.md @@ -0,0 +1,459 @@ +# 您的 Linux 系统命令行个人助理 + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Yoda-720x340.png) + +不久前,我们写了一个名为 [**“Betty”**][1] 的命令行虚拟助手。今天,我偶然发现了一个类似的实用程序,叫做 **“Yoda”**。Yoda 是一个命令行个人助理,可以帮助您在 Linux 中完成一些琐碎的任务。它是用 Python 编写的一个免费的开源应用程序。在本指南中,我们将了解如何在 GNU/Linux 中安装和使用 Yoda。 + +### 安装 Yoda,命令行私人助理。 + +Yoda 需要 **Python 2** 和 PIP 。如果在您的 Linux 中没有安装 PIP,请参考下面的指南来安装它。只要确保已经安装了 **python2-pip** 。Yoda 可能不支持 Python 3。 + +**注意**:我建议你在虚拟环境下试用 Yoda。 不仅仅是 Yoda,总是在虚拟环境中尝试任何 Python 应用程序,让它们不会干扰全局安装的软件包。 您可以按照上文链接中标题为“创建虚拟环境”一节中所述设置虚拟环境。 + +在您的系统上安装了 pip 之后,使用下面的命令克隆 Yoda 库。 + +``` +$ git clone https://github.com/yoda-pa/yoda + +``` + +上面的命令将在当前工作目录中创建一个名为 “yoda” 的目录,并在其中克隆所有内容。转到 Yoda 目录: + +``` +$ cd yoda/ + +``` + +运行以下命令安装Yoda应用程序。 + +``` +$ pip install . + +``` + +请注意最后的点(.)。 现在,所有必需的软件包将被下载并安装。 + +### 配置 Yoda + +首先,设置配置以将您的信息保存在本地系统上。 + +运行下面的命令: + +``` +$ yoda setup new + +``` + +填写下列的问题: + +``` +Enter your name: +Senthil Kumar +What's your email id? +[email protected] +What's your github username? +sk +Enter your github password: +Password: +Where shall your config be stored? (Default: ~/.yoda/) + +A configuration file already exists. Are you sure you want to overwrite it? (y/n) +y + +``` + +你的密码在加密后保存在配置文件中,所以不用担心。 + +要检查当前配置,请运行: + +``` +$ yoda setup check + +``` + +你会看到如下的输出。 + +``` +Name: Senthil Kumar +Email: [email protected] +Github username: sk + +``` + +默认情况下,您的信息存储在 **~/.yoda** 目录中。 + +要删除现有配置,请执行以下操作: + +``` +$ yoda setup delete + +``` + +### 用法 + +Yoda 包含一个简单的聊天机器人。您可以使用下面的聊天命令与它交互。 + +``` +$ yoda chat who are you + +``` + +样例输出: + +``` +Yoda speaks: +I'm a virtual agent + +$ yoda chat how are you +Yoda speaks: +I'm doing very well. Thanks! + +``` + +以下是我们可以用 Yoda 做的事情: + +**测试网络速度** + +让我们问一下 Yoda 关于互联网速度的问题。运行: + +``` +$ yoda speedtest +Speed test results: +Ping: 108.45 ms +Download: 0.75 Mb/s +Upload: 1.95 Mb/s + +``` + +**缩短并展开网址** + +Yoda 还有助于缩短任何网址。 + +``` +$ yoda url shorten https://www.ostechnix.com/ +Here's your shortened URL: +https://goo.gl/hVW6U0 + +``` + +要展开缩短的网址: + +``` +$ yoda url expand https://goo.gl/hVW6U0 +Here's your original URL: +https://www.ostechnix.com/ + +``` + + +**阅读黑客新闻** + +我是 Hacker News 网站的常客。 如果你像我一样,你可以使用 Yoda 从下面的 Hacker News 网站阅读新闻。 + +``` +$ yoda hackernews +News-- 1/513 + +Title-- Show HN: a Yelp for iOS developers +Description-- I came up with this idea "a Yelp for developers" when talking with my colleagues. My hypothesis is that, it would be very helpful if we know more about a library before choosing to use it. It's similar to that we want to know more about a restaurant by checki… +url-- https://news.ycombinator.com/item?id=16636071 + +Continue? [press-"y"] + +``` + +Yoda 将一次显示一个项目。 要阅读下一条新闻,只需输入 “y” 并按下 ENTER。 + +**管理个人日记** + +我们也可以保留个人日记以记录重要事件。 + +使用命令创建一个新的日记: + +``` +$ yoda diary nn +Input your entry for note: +Today I learned about Yoda + +``` + +要创建新笔记,请再次运行上述命令。 + +查看所有笔记: + +``` +$ yoda diary notes +Today's notes: +---------------- + Time | Note +--------|----- +16:41:41| Today I learned about Yoda + +``` + +不仅仅是笔记,Yoda 还可以帮助你创建任务。 + +要创建新任务,请运行: + +``` +$ yoda diary nt +Input your entry for task: +Write an article about Yoda and publish it on OSTechNix + +``` + +要查看任务列表,请运行: + +``` +$ yoda diary tasks +Today's agenda: +---------------- +Status | Time | Text +-------|---------|----- + O | 16:44:03: Write an article about Yoda and publish it on OSTechNix +---------------- + +Summary: +---------------- +Incomplete tasks: 1 +Completed tasks: 0 + +``` + +正如你在上面看到的,我有一个未完成的任务。 要将其标记为已完成,请运行以下命令并输入已完成的任务序列号并按下 ENTER 键: + +``` +$ yoda diary ct +Today's agenda: +---------------- +Number | Time | Task +-------|---------|----- + 1 | 16:44:03: Write an article about Yoda and publish it on OSTechNix +Enter the task number that you would like to set as completed +1 + +``` + +您可以随时使用命令分析当前月份的任务: + +``` +$ yoda diary analyze +Percentage of incomplete task : 0 +Percentage of complete task : 100 +Frequency of adding task (Task/Day) : 3 + +``` + +有时候,你可能想要记录一个关于你爱的或者敬佩的人的个人资料。 + +**记录关于爱人的笔记** + +首先,您需要设置配置来存储朋友的详细信息。 请运行: + +``` +$ yoda love setup + +``` + +输入你的朋友的详细信息: + +``` +Enter their name: +Abdul Kalam +Enter sex(M/F): +M +Where do they live? +Rameswaram + +``` + +要查看此人的详细信息,请运行: + +``` +$ yoda love status +{'place': 'Rameswaram', 'name': 'Abdul Kalam', 'sex': 'M'} + +``` + +要添加你的爱人的生日: + +``` +$ yoda love addbirth +Enter birthday +15-10-1931 + +``` + +查看生日: + +``` +$ yoda love showbirth +Birthday is 15-10-1931 + +``` + +你甚至可以添加关于该人的笔记: + +``` +$ yoda love note +Avul Pakir Jainulabdeen Abdul Kalam better known as A. P. J. Abdul Kalam, was the 11th President of India from 2002 to 2007. + +``` + +您可以使用命令查看笔记: + +``` +$ yoda love notes +Notes: +1: Avul Pakir Jainulabdeen Abdul Kalam better known as A. P. J. Abdul Kalam, was the 11th President of India from 2002 to 2007. + +``` + +你也可以写下这个人喜欢的东西: + +``` +$ yoda love like +Add things they like +Physics, Aerospace +Want to add more things they like? [y/n] +n + +``` + +要查看他们喜欢的东西,请运行: + +``` +$ yoda love likes +Likes: +1: Physics, Aerospace + +``` + +**** + +**跟踪资金费用** + +您不需要单独的工具来维护您的财务支出。 Yoda 会替您处理好。 + +首先,使用命令设置您的金钱支出配置: + +``` +$ yoda money setup + +``` + +输入您的货币代码和初始金额: + +``` +Enter default currency code: +INR +{u'USD': 0.015338, u'IDR': 211.06, u'BGN': 0.024436, u'ISK': 1.5305, u'ILS': 0.053402, u'GBP': 0.010959, u'DKK': 0.093063, u'CAD': 0.020041, u'MXN': 0.28748, u'HUF': 3.8873, u'RON': 0.058302, u'MYR': 0.060086, u'SEK': 0.12564, u'SGD': 0.020208, u'HKD': 0.12031, u'AUD': 0.019908, u'CHF': 0.014644, u'KRW': 16.429, u'CNY': 0.097135, u'TRY': 0.06027, u'HRK': 0.092986, u'NZD': 0.021289, u'THB': 0.47854, u'EUR': 0.012494, u'NOK': 0.11852, u'RUB': 0.88518, u'JPY': 1.6332, u'CZK': 0.31764, u'BRL': 0.050489, u'PLN': 0.052822, u'PHP': 0.79871, u'ZAR': 0.1834} +₹ +Indian rupee +Enter initial amount: +10000 + +``` + +要查看金钱配置,只需运行: + +``` +$ yoda money status +{'initial_money': 10000, 'currency_code': 'INR'} + +``` + +让我们假设你买了一本价值 250 卢比的书。 要添加此费用,请运行: + +``` +$ yoda money exp +Spend 250 INR on books +output: + +``` + +要查看花费,请运行: + +``` +$ yoda money exps +2018-03-21 17:12:31 INR 250 books + +``` + +**** + +**创建想法列表** + +创建一个新的想法: + +``` +$ yoda ideas add --task --inside + +``` + +列出想法: + +``` +$ yoda ideas show + +``` + +从任务中移除一个想法: + +``` +$ yoda ideas remove --task --inside + +``` + +要完全删除这个想法,请运行: + +``` +$ yoda ideas remove --project + +``` + +**** + +**学习英语词汇** + +Yoda 帮助你学习随机英语单词并追踪你的学习进度。 + +要学习一个新单词,请输入: + +``` +$ yoda vocabulary word + +``` + +它会随机显示一个单词。 按 ENTER 键显示单词的含义。 再一次,Yoda 问你是否已经知道这个词的意思。 如果您已经知道,请输入“是”。 如果您不知道,请输入“否”。 这可以帮助你跟踪你的进度。 使用以下命令来了解您的进度。 + +``` +$ yoda vocabulary accuracy + +``` + +此外,Yoda 可以帮助您做其他一些事情,比如找到单词的定义和创建插卡以轻松学习任何内容。 有关更多详细信息和可用选项列表,请参阅帮助部分。 + +``` +$ yoda --help + +``` + +更多好的东西来了。请继续关注! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/yoda-the-command-line-personal-assistant-for-your-linux-system/ + +作者:[SK][a] +译者:[amwps290](https://github.com/amwps290) +校对:[校对者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/betty-siri-like-commandline-virtual-assistant-linux/ From 4a3b8654b339409335aeb4cc61d44422157223a1 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 23 Mar 2018 16:54:45 +0800 Subject: [PATCH 0081/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20chkservice=20?= =?UTF-8?q?=E2=80=93=20A=20Tool=20For=20Managing=20Systemd=20Units=20From?= =?UTF-8?q?=20Linux=20Terminal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...aging Systemd Units From Linux Terminal.md | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md diff --git a/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md b/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md new file mode 100644 index 0000000000..9bffa5fed1 --- /dev/null +++ b/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md @@ -0,0 +1,110 @@ +chkservice – A Tool For Managing Systemd Units From Linux Terminal +====== +systemd stand for system daemon is a new init system and system manager which is become very popular and widely adapted new standard init system by most of Linux distributions. + +Systemctl is a systemd utility which is help us to manage systemd daemons. It control system startup and services, uses parallelization, socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and automount points. + +Also it offers logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. + +### What Is chkservice + +[chkservice][1] is an ncurses-based tool for managing systemd units from the terminal. It provides the user with a comprehensive view of all systemd services and allows them to be changed easily. + +It requires super user privileges to make changes into unit states or sysv scripts. + +### How To Install chkservice In Linux + +We can install chkservice in two ways, either package or manual method. + +For **`Debian/Ubuntu`** , use [APT-GET Command][2] or [APT Command][3]to install chkservice. +``` +$ sudo add-apt-repository ppa:linuxenko/chkservice +$ sudo apt-get update +$ sudo apt-get install chkservice + +``` + +For **`Arch Linux`** based systems, use [Yaourt Command][4] or [Packer Command][5] to install chkservice from AUR repository. +``` +$ yaourt -S chkservice +or +$ packer -S chkservice + +``` + +For **`Fedora`** , use [DNF Command][6] to install chkservice. +``` +$ sudo dnf copr enable srakitnican/default +$ sudo dnf install chkservice + +``` + +For **`Debian Based Systems`** , use [DPKG Command][7] to install chkservice. +``` +$ wget https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.deb +$ sudo dpkg -i chkservice_0.1.0-amd64.deb + +``` + +For **`RPM Based Systems`** , use [DNF Command][8] to install chkservice. +``` +$ sudo yum install https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.rpm + +``` + +### How To Use chkservice + +Just fire the following command to launch the chkservice tool. The output is split to four parts. + + * **`First Part:`** This part shows about daemons status like, enabled [X] or disabled [] or static [s] or masked -m- + * **`Second Part:`** This part shows daemons status like, started [ >] or stopped [=] + * **`Third Part:`** This part shows the unit name + * **`Fourth Part:`** This part showing the unit short description + + +``` +$ sudo chkservice + +``` + +![][10] + +To view help page, hit `?` button. This will shows you available options to manage the systemd services. +![][11] + +Select the units, which you want to enable or disable then hit `Space Bar` button. +![][12] + +Select the units, which you want to start or stop then hit `s` button. +![][13] + +Select the units, which you want to reload then hit `r` button. After hit `r` key, you can see the `updated` message at the top. +![][14] + +Hit `q` button to quit the utility. + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/chkservice-a-tool-for-managing-systemd-units-from-linux-terminal/ + +作者:[Ramya Nuvvula][a] +译者:[译者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/ramya/ +[1]:https://github.com/linuxenko/chkservice +[2]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[3]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[4]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ +[5]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ +[6]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[7]:https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/ +[8]:https://www.2daygeek.com/rpm-command-examples/ +[9]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[10]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-1.png +[11]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-2.png +[12]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-3.png +[13]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-4.png +[14]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-5.png From 492420edd2be71befa940e04e62eef82bc711c0f Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 23 Mar 2018 16:55:47 +0800 Subject: [PATCH 0082/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Simple=20Load?= =?UTF-8?q?=20Balancing=20with=20DNS=20on=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Simple Load Balancing with DNS on Linux.md | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 sources/tech/20180322 Simple Load Balancing with DNS on Linux.md diff --git a/sources/tech/20180322 Simple Load Balancing with DNS on Linux.md b/sources/tech/20180322 Simple Load Balancing with DNS on Linux.md new file mode 100644 index 0000000000..f57eea67b5 --- /dev/null +++ b/sources/tech/20180322 Simple Load Balancing with DNS on Linux.md @@ -0,0 +1,139 @@ +Simple Load Balancing with DNS on Linux +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/american-robin-920.jpg?itok=_B_RRbfj) +When you have server back ends built of multiple servers, such as clustered or mirrowed web or file servers, a load balancer provides a single point of entry. Large busy shops spend big money on high-end load balancers that perform a wide range of tasks: proxy, caching, health checks, SSL processing, configurable prioritization, traffic shaping, and lots more. + +But you don't want all that. You need a simple method for distributing workloads across all of your servers and providing a bit of failover and don't care whether it is perfectly efficient. DNS round-robin and subdomain delegation with round-robin provide two simple methods to achieve this. + +DNS round-robin is mapping multiple servers to the same hostname, so that when users visit foo.example.com multiple servers are available to handle their requests. + +Subdomain delegation with round-robin is useful when you have multiple subdomains or when your servers are geographically dispersed. You have a primary nameserver, and then your subdomains have their own nameservers. Your primary nameserver refers all subdomain requests to their own nameservers. This usually improves response times, as the DNS protocol will automatically look for the fastest links. + +### Round-Robin DNS + +Round-robin has nothing to do with robins. According to my favorite librarian, it was originally a French phrase, _ruban rond_ , or round ribbon. Way back in olden times, French government officials signed grievance petitions in non-hierarchical circular, wavy, or spoke patterns to conceal whoever originated the petition. + +Round-robin DNS is also non-hierarchical, a simple configuration that takes a list of servers and sends requests to each server in turn. It does not perform true load-balancing as it does not measure loads, and does no health checks, so if one of the servers is down, requests are still sent to that server. Its virtue lies in simplicity. If you have a little cluster of file or web servers and want to spread the load between them in the simplest way, then round-robin DNS is for you. + +All you do is create multiple A or AAAA records, mapping multiple servers to a single host name. This BIND example uses both IPv4 and IPv6 private address classes: +``` +fileserv.example.com. IN A 172.16.10.10 +fileserv.example.com. IN A 172.16.10.11 +fileserv.example.com. IN A 172.16.10.12 + +fileserv.example.com. IN AAAA fd02:faea:f561:8fa0:1::10 +fileserv.example.com. IN AAAA fd02:faea:f561:8fa0:1::11 +fileserv.example.com. IN AAAA fd02:faea:f561:8fa0:1::12 + +``` + +Dnsmasq uses _/etc/hosts_ for A and AAAA records: +``` +172.16.1.10 fileserv fileserv.example.com +172.16.1.11 fileserv fileserv.example.com +172.16.1.12 fileserv fileserv.example.com +fd02:faea:f561:8fa0:1::10 fileserv fileserv.example.com +fd02:faea:f561:8fa0:1::11 fileserv fileserv.example.com +fd02:faea:f561:8fa0:1::12 fileserv fileserv.example.com + +``` + +Note that these examples are simplified, and there are multiple ways to resolve fully-qualified domain names, so please study up on configuring DNS. + +Use the `dig` command to check your work. Replace `ns.example.com` with your name server: +``` +$ dig @ns.example.com fileserv A fileserv AAA + +``` + +That should display both IPv4 and IPv6 round-robin records. + +### Subdomain Delegation and Round-Robin + +Subdomain delegation combined with round-robin is more work to set up, but it has some advantages. Use this when you have multiple subdomains or geographically-dispersed servers. Response times are often quicker, and a down server will not respond, so clients will not get hung up waiting for a reply. A short TTL, such as 60 seconds, helps this. + +This approach requires multiple name servers. In the simplest scenario, you have a primary name server and two subdomains, each with its own name server. Configure your round-robin entries on the subdomain servers, then configure the delegations on your primary server. + +In BIND on your primary name server, you'll need at least two additional configurations, a zone statement, and A/AAAA records in your zone data file. The delegation looks something like this on your primary name server: +``` +ns1.sub.example.com. IN A 172.16.1.20 +ns1.sub.example.com. IN AAAA fd02:faea:f561:8fa0:1::20 +ns2.sub.example.com. IN A 172.16.1.21 +ns2.sub.example.com. IN AAA fd02:faea:f561:8fa0:1::21 + +sub.example.com. IN NS ns1.sub.example.com. +sub.example.com. IN NS ns2.sub.example.com. + +``` + +Then each of the subdomain servers have their own zone files. The trick here is for each server to return its own IP address. The zone statement in `named.conf` is the same on both servers: +``` +zone "sub.example.com" { + type master; + file "db.sub.example.com"; +}; + +``` + +Then the data files are the same, except that the A/AAAA records use the server's own IP address. The SOA (start of authority) refers to the primary name server: +``` +; first subdomain name server +$ORIGIN sub.example.com. +$TTL 60 +sub.example.com IN SOA ns1.example.com. admin.example.com. ( + 2018123456 ; serial + 3H ; refresh + 15 ; retry + 3600000 ; expire +) + +sub.example.com. IN NS ns1.sub.example.com. +sub.example.com. IN A 172.16.1.20 +ns1.sub.example.com. IN AAAA fd02:faea:f561:8fa0:1::20 + +; second subdomain name server +$ORIGIN sub.example.com. +$TTL 60 +sub.example.com IN SOA ns1.example.com. admin.example.com. ( + 2018234567 ; serial + 3H ; refresh + 15 ; retry + 3600000 ; expire +) + +sub.example.com. IN NS ns1.sub.example.com. +sub.example.com. IN A 172.16.1.21 +ns2.sub.example.com. IN AAAA fd02:faea:f561:8fa0:1::21 + +``` + +Next, make your round-robin entries on the subdomain name servers, and you're done. Now you have multiple name servers handling requests for your subdomains. Again, BIND is complex and has multiple ways to do the same thing, so your homework is to ensure that your configuration fits with the way you use it. + +Subdomain delegations are easier in Dnsmasq. On your primary server, add lines like this in `dnsmasq.conf` to point to the name servers for the subdomains: +``` +server=/sub.example.com/172.16.1.20 +server=/sub.example.com/172.16.1.21 +server=/sub.example.com/fd02:faea:f561:8fa0:1::20 +server=/sub.example.com/fd02:faea:f561:8fa0:1::21 + +``` + +Then configure round-robin on the subdomain name servers in `/etc/hosts`. + +For way more details and help, refer to these resources: + +Learn more about Linux through the free ["Introduction to Linux" ][1]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/3/simple-load-balancing-dns-linux + +作者:[CARLA SCHRODER][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/cschroder +[1]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From f9b241aaef01f51ac5a3408e7eec19ff50319053 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 23 Mar 2018 17:08:46 +0800 Subject: [PATCH 0083/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Learn=20Blockch?= =?UTF-8?q?ains=20by=20Building=20One?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...71024 Learn Blockchains by Building One.md | 702 ++++++++++++++++++ 1 file changed, 702 insertions(+) create mode 100644 sources/tech/20171024 Learn Blockchains by Building One.md diff --git a/sources/tech/20171024 Learn Blockchains by Building One.md b/sources/tech/20171024 Learn Blockchains by Building One.md new file mode 100644 index 0000000000..d8a2069b0b --- /dev/null +++ b/sources/tech/20171024 Learn Blockchains by Building One.md @@ -0,0 +1,702 @@ +Learn Blockchains by Building One +====== + +![](https://cdn-images-1.medium.com/max/2000/1*zutLn_-fZZhy7Ari-x-JWQ.jpeg) +You’re here because, like me, you’re psyched about the rise of Cryptocurrencies. And you want to know how Blockchains work—the fundamental technology behind them. + +But understanding Blockchains isn’t easy—or at least wasn’t for me. I trudged through dense videos, followed porous tutorials, and dealt with the amplified frustration of too few examples. + +I like learning by doing. It forces me to deal with the subject matter at a code level, which gets it sticking. If you do the same, at the end of this guide you’ll have a functioning Blockchain with a solid grasp of how they work. + +### Before you get started… + +Remember that a blockchain is an _immutable, sequential_ chain of records called Blocks. They can contain transactions, files or any data you like, really. But the important thing is that they’re _chained_ together using _hashes_ . + +If you aren’t sure what a hash is, [here’s an explanation][1]. + + **_Who is this guide aimed at?_** You should be comfy reading and writing some basic Python, as well as have some understanding of how HTTP requests work, since we’ll be talking to our Blockchain over HTTP. + + **_What do I need?_** Make sure that [Python 3.6][2]+ (along with `pip`) is installed. You’ll also need to install Flask and the wonderful Requests library: + +``` + pip install Flask==0.12.2 requests==2.18.4 +``` + +Oh, you’ll also need an HTTP Client, like [Postman][3] or cURL. But anything will do. + + **_Where’s the final code?_** The source code is [available here][4]. + +* * * + +### Step 1: Building a Blockchain + +Open up your favourite text editor or IDE, personally I ❤️ [PyCharm][5]. Create a new file, called `blockchain.py`. We’ll only use a single file, but if you get lost, you can always refer to the [source code][6]. + +#### Representing a Blockchain + +We’ll create a `Blockchain` class whose constructor creates an initial empty list (to store our blockchain), and another to store transactions. Here’s the blueprint for our class: + +``` +class Blockchain(object): + def __init__(self): + self.chain = [] + self.current_transactions = [] + + def new_block(self): + # Creates a new Block and adds it to the chain + pass + + def new_transaction(self): + # Adds a new transaction to the list of transactions + pass + + @staticmethod + def hash(block): + # Hashes a Block + pass + + @property + def last_block(self): + # Returns the last Block in the chain +pass +``` + + +Our Blockchain class is responsible for managing the chain. It will store transactions and have some helper methods for adding new blocks to the chain. Let’s start fleshing out some methods. + +#### What does a Block look like? + +Each Block has an index, a timestamp (in Unix time), a list of transactions, a proof (more on that later), and the hash of the previous Block. + +Here’s an example of what a single Block looks like: + +``` +block = { + 'index': 1, + 'timestamp': 1506057125.900785, + 'transactions': [ + { + 'sender': "8527147fe1f5426f9dd545de4b27ee00", + 'recipient': "a77f5cdfa2934df3954a5c7c7da5df1f", + 'amount': 5, + } + ], + 'proof': 324984774000, + 'previous_hash': "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" +} +``` + +At this point, the idea of a chain should be apparent—each new block contains within itself, the hash of the previous Block. This is crucial because it’s what gives blockchains immutability: If an attacker corrupted an earlier Block in the chain then all subsequent blocks will contain incorrect hashes. + +Does this make sense? If it doesn’t, take some time to let it sink in—it’s the core idea behind blockchains. + +#### Adding Transactions to a Block + +We’ll need a way of adding transactions to a Block. Our new_transaction() method is responsible for this, and it’s pretty straight-forward: + +``` +class Blockchain(object): + ... + + def new_transaction(self, sender, recipient, amount): + """ + Creates a new transaction to go into the next mined Block + :param sender: Address of the Sender + :param recipient: Address of the Recipient + :param amount: Amount + :return: The index of the Block that will hold this transaction + """ + + self.current_transactions.append({ + 'sender': sender, + 'recipient': recipient, + 'amount': amount, + }) + +return self.last_block['index'] + 1 +``` + +After new_transaction() adds a transaction to the list, it returns the index of the block which the transaction will be added to—the next one to be mined. This will be useful later on, to the user submitting the transaction. + +#### Creating new Blocks + +When our Blockchain is instantiated we’ll need to seed it with a genesis block—a block with no predecessors. We’ll also need to add a “proof” to our genesis block which is the result of mining (or proof of work). We’ll talk more about mining later. + +In addition to creating the genesis block in our constructor, we’ll also flesh out the methods for new_block(), new_transaction() and hash(): + +``` +import hashlib +import json +from time import time + + +class Blockchain(object): + def __init__(self): + self.current_transactions = [] + self.chain = [] + + # Create the genesis block + self.new_block(previous_hash=1, proof=100) + + def new_block(self, proof, previous_hash=None): + """ + Create a new Block in the Blockchain + :param proof: The proof given by the Proof of Work algorithm + :param previous_hash: (Optional) Hash of previous Block + :return: New Block + """ + + block = { + 'index': len(self.chain) + 1, + 'timestamp': time(), + 'transactions': self.current_transactions, + 'proof': proof, + 'previous_hash': previous_hash or self.hash(self.chain[-1]), + } + + # Reset the current list of transactions + self.current_transactions = [] + + self.chain.append(block) + return block + + def new_transaction(self, sender, recipient, amount): + """ + Creates a new transaction to go into the next mined Block + :param sender: Address of the Sender + :param recipient: Address of the Recipient + :param amount: Amount + :return: The index of the Block that will hold this transaction + """ + self.current_transactions.append({ + 'sender': sender, + 'recipient': recipient, + 'amount': amount, + }) + + return self.last_block['index'] + 1 + + @property + def last_block(self): + return self.chain[-1] + + @staticmethod + def hash(block): + """ + Creates a SHA-256 hash of a Block + :param block: Block + :return: + """ + + # We must make sure that the Dictionary is Ordered, or we'll have inconsistent hashes + block_string = json.dumps(block, sort_keys=True).encode() +return hashlib.sha256(block_string).hexdigest() +``` + +The above should be straight-forward—I’ve added some comments and docstrings to help keep it clear. We’re almost done with representing our blockchain. But at this point, you must be wondering how new blocks are created, forged or mined. + +#### Understanding Proof of Work + +A Proof of Work algorithm (PoW) is how new Blocks are created or mined on the blockchain. The goal of PoW is to discover a number which solves a problem. The number must be difficult to find but easy to verify—computationally speaking—by anyone on the network. This is the core idea behind Proof of Work. + +We’ll look at a very simple example to help this sink in. + +Let’s decide that the hash of some integer x multiplied by another y must end in 0\. So, hash(x * y) = ac23dc...0\. And for this simplified example, let’s fix x = 5\. Implementing this in Python: + +``` +from hashlib import sha256 + +x = 5 +y = 0 # We don't know what y should be yet... + +while sha256(f'{x*y}'.encode()).hexdigest()[-1] != "0": + y += 1 + +print(f'The solution is y = {y}') +``` + +The solution here is y = 21\. Since, the produced hash ends in 0: + +``` +hash(5 * 21) = 1253e9373e...5e3600155e860 +``` + +The network is able to easily verify their solution. + +#### Implementing basic Proof of Work + +Let’s implement a similar algorithm for our blockchain. Our rule will be similar to the example above: + +> Find a number p that when hashed with the previous block’s solution a hash with 4 leading 0s is produced. + +``` +import hashlib +import json + +from time import time +from uuid import uuid4 + + +class Blockchain(object): + ... + + def proof_of_work(self, last_proof): + """ + Simple Proof of Work Algorithm: + - Find a number p' such that hash(pp') contains leading 4 zeroes, where p is the previous p' + - p is the previous proof, and p' is the new proof + :param last_proof: + :return: + """ + + proof = 0 + while self.valid_proof(last_proof, proof) is False: + proof += 1 + + return proof + + @staticmethod + def valid_proof(last_proof, proof): + """ + Validates the Proof: Does hash(last_proof, proof) contain 4 leading zeroes? + :param last_proof: Previous Proof + :param proof: Current Proof + :return: True if correct, False if not. + """ + + guess = f'{last_proof}{proof}'.encode() + guess_hash = hashlib.sha256(guess).hexdigest() +return guess_hash[:4] == "0000" +``` + +To adjust the difficulty of the algorithm, we could modify the number of leading zeroes. But 4 is sufficient. You’ll find out that the addition of a single leading zero makes a mammoth difference to the time required to find a solution. + +Our class is almost complete and we’re ready to begin interacting with it using HTTP requests. + +* * * + +### Step 2: Our Blockchain as an API + +We’re going to use the Python Flask Framework. It’s a micro-framework and it makes it easy to map endpoints to Python functions. This allows us talk to our blockchain over the web using HTTP requests. + +We’ll create three methods: + +* `/transactions/new` to create a new transaction to a block + +* `/mine` to tell our server to mine a new block. + +* `/chain` to return the full Blockchain. + +#### Setting up Flask + +Our “server” will form a single node in our blockchain network. Let’s create some boilerplate code: + +``` +import hashlib +import json +from textwrap import dedent +from time import time +from uuid import uuid4 + +from flask import Flask + + +class Blockchain(object): + ... + + +# Instantiate our Node +app = Flask(__name__) + +# Generate a globally unique address for this node +node_identifier = str(uuid4()).replace('-', '') + +# Instantiate the Blockchain +blockchain = Blockchain() + + +@app.route('/mine', methods=['GET']) +def mine(): + return "We'll mine a new Block" + +@app.route('/transactions/new', methods=['POST']) +def new_transaction(): + return "We'll add a new transaction" + +@app.route('/chain', methods=['GET']) +def full_chain(): + response = { + 'chain': blockchain.chain, + 'length': len(blockchain.chain), + } + return jsonify(response), 200 + +if __name__ == '__main__': +app.run(host='0.0.0.0', port=5000) +``` + +A brief explanation of what we’ve added above: + +* Line 15: Instantiates our Node. Read more about Flask [here][7]. + +* Line 18: Create a random name for our node. + +* Line 21: Instantiate our Blockchain class. + +* Line 24–26: Create the /mine endpoint, which is a GET request. + +* Line 28–30: Create the /transactions/new endpoint, which is a POST request, since we’ll be sending data to it. + +* Line 32–38: Create the /chain endpoint, which returns the full Blockchain. + +* Line 40–41: Runs the server on port 5000. + +#### The Transactions Endpoint + +This is what the request for a transaction will look like. It’s what the user sends to the server: + +``` +{ "sender": "my address", "recipient": "someone else's address", "amount": 5} +``` + +``` +import hashlib +import json +from textwrap import dedent +from time import time +from uuid import uuid4 + +from flask import Flask, jsonify, request + +... + +@app.route('/transactions/new', methods=['POST']) +def new_transaction(): + values = request.get_json() + + # Check that the required fields are in the POST'ed data + required = ['sender', 'recipient', 'amount'] + if not all(k in values for k in required): + return 'Missing values', 400 + + # Create a new Transaction + index = blockchain.new_transaction(values['sender'], values['recipient'], values['amount']) + + response = {'message': f'Transaction will be added to Block {index}'} +return jsonify(response), 201 +``` +A method for creating Transactions + +#### The Mining Endpoint + +Our mining endpoint is where the magic happens, and it’s easy. It has to do three things: + +1. Calculate the Proof of Work + +2. Reward the miner (us) by adding a transaction granting us 1 coin + +3. Forge the new Block by adding it to the chain + +``` +import hashlib +import json + +from time import time +from uuid import uuid4 + +from flask import Flask, jsonify, request + +... + +@app.route('/mine', methods=['GET']) +def mine(): + # We run the proof of work algorithm to get the next proof... + last_block = blockchain.last_block + last_proof = last_block['proof'] + proof = blockchain.proof_of_work(last_proof) + + # We must receive a reward for finding the proof. + # The sender is "0" to signify that this node has mined a new coin. + blockchain.new_transaction( + sender="0", + recipient=node_identifier, + amount=1, + ) + + # Forge the new Block by adding it to the chain + previous_hash = blockchain.hash(last_block) + block = blockchain.new_block(proof, previous_hash) + + response = { + 'message': "New Block Forged", + 'index': block['index'], + 'transactions': block['transactions'], + 'proof': block['proof'], + 'previous_hash': block['previous_hash'], + } +return jsonify(response), 200 +``` + +Note that the recipient of the mined block is the address of our node. And most of what we’ve done here is just interact with the methods on our Blockchain class. At this point, we’re done, and can start interacting with our blockchain. + +### Step 3: Interacting with our Blockchain + +You can use plain old cURL or Postman to interact with our API over a network. + +Fire up the server: + +``` +$ python blockchain.py +``` + +Let’s try mining a block by making a GET request to http://localhost:5000/mine: + +![](https://cdn-images-1.medium.com/max/1600/1*ufYwRmWgQeA-Jxg0zgYLOA.png) +Using Postman to make a GET request + +Let’s create a new transaction by making a POST request tohttp://localhost:5000/transactions/new with a body containing our transaction structure: + +![](https://cdn-images-1.medium.com/max/1600/1*O89KNbEWj1vigMZ6VelHAg.png) +Using Postman to make a POST request + +If you aren’t using Postman, then you can make the equivalent request using cURL: + +``` +$ curl -X POST -H "Content-Type: application/json" -d '{ "sender": "d4ee26eee15148ee92c6cd394edd974e", "recipient": "someone-other-address", "amount": 5}' "http://localhost:5000/transactions/new" +``` +I restarted my server, and mined two blocks, to give 3 in total. Let’s inspect the full chain by requesting http://localhost:5000/chain: +``` +{ + "chain": [ + { + "index": 1, + "previous_hash": 1, + "proof": 100, + "timestamp": 1506280650.770839, + "transactions": [] + }, + { + "index": 2, + "previous_hash": "c099bc...bfb7", + "proof": 35293, + "timestamp": 1506280664.717925, + "transactions": [ + { + "amount": 1, + "recipient": "8bbcb347e0634905b0cac7955bae152b", + "sender": "0" + } + ] + }, + { + "index": 3, + "previous_hash": "eff91a...10f2", + "proof": 35089, + "timestamp": 1506280666.1086972, + "transactions": [ + { + "amount": 1, + "recipient": "8bbcb347e0634905b0cac7955bae152b", + "sender": "0" + } + ] + } + ], + "length": 3 +``` +### Step 4: Consensus + +This is very cool. We’ve got a basic Blockchain that accepts transactions and allows us to mine new Blocks. But the whole point of Blockchains is that they should be decentralized. And if they’re decentralized, how on earth do we ensure that they all reflect the same chain? This is called the problem of Consensus, and we’ll have to implement a Consensus Algorithm if we want more than one node in our network. + +#### Registering new Nodes + +Before we can implement a Consensus Algorithm, we need a way to let a node know about neighbouring nodes on the network. Each node on our network should keep a registry of other nodes on the network. Thus, we’ll need some more endpoints: + +1. /nodes/register to accept a list of new nodes in the form of URLs. + +2. /nodes/resolve to implement our Consensus Algorithm, which resolves any conflicts—to ensure a node has the correct chain. + +We’ll need to modify our Blockchain’s constructor and provide a method for registering nodes: + +``` +... +from urllib.parse import urlparse +... + + +class Blockchain(object): + def __init__(self): + ... + self.nodes = set() + ... + + def register_node(self, address): + """ + Add a new node to the list of nodes + :param address: Address of node. Eg. 'http://192.168.0.5:5000' + :return: None + """ + + parsed_url = urlparse(address) +self.nodes.add(parsed_url.netloc) +``` +A method for adding neighbouring nodes to our Network + +Note that we’ve used a set() to hold the list of nodes. This is a cheap way of ensuring that the addition of new nodes is idempotent—meaning that no matter how many times we add a specific node, it appears exactly once. + +#### Implementing the Consensus Algorithm + +As mentioned, a conflict is when one node has a different chain to another node. To resolve this, we’ll make the rule that the longest valid chain is authoritative. In other words, the longest chain on the network is the de-facto one. Using this algorithm, we reach Consensus amongst the nodes in our network. + +``` +... +import requests + + +class Blockchain(object) + ... + + def valid_chain(self, chain): + """ + Determine if a given blockchain is valid + :param chain: A blockchain + :return: True if valid, False if not + """ + + last_block = chain[0] + current_index = 1 + + while current_index < len(chain): + block = chain[current_index] + print(f'{last_block}') + print(f'{block}') + print("\n-----------\n") + # Check that the hash of the block is correct + if block['previous_hash'] != self.hash(last_block): + return False + + # Check that the Proof of Work is correct + if not self.valid_proof(last_block['proof'], block['proof']): + return False + + last_block = block + current_index += 1 + + return True + + def resolve_conflicts(self): + """ + This is our Consensus Algorithm, it resolves conflicts + by replacing our chain with the longest one in the network. + :return: True if our chain was replaced, False if not + """ + + neighbours = self.nodes + new_chain = None + + # We're only looking for chains longer than ours + max_length = len(self.chain) + + # Grab and verify the chains from all the nodes in our network + for node in neighbours: + response = requests.get(f'http://{node}/chain') + + if response.status_code == 200: + length = response.json()['length'] + chain = response.json()['chain'] + + # Check if the length is longer and the chain is valid + if length > max_length and self.valid_chain(chain): + max_length = length + new_chain = chain + + # Replace our chain if we discovered a new, valid chain longer than ours + if new_chain: + self.chain = new_chain + return True + +return False +``` + +The first method valid_chain() is responsible for checking if a chain is valid by looping through each block and verifying both the hash and the proof. + +resolve_conflicts() is a method which loops through all our neighbouring nodes, downloads their chains and verifies them using the above method. If a valid chain is found, whose length is greater than ours, we replace ours. + +Let’s register the two endpoints to our API, one for adding neighbouring nodes and the another for resolving conflicts: + +``` +@app.route('/nodes/register', methods=['POST']) +def register_nodes(): + values = request.get_json() + + nodes = values.get('nodes') + if nodes is None: + return "Error: Please supply a valid list of nodes", 400 + + for node in nodes: + blockchain.register_node(node) + + response = { + 'message': 'New nodes have been added', + 'total_nodes': list(blockchain.nodes), + } + return jsonify(response), 201 + + +@app.route('/nodes/resolve', methods=['GET']) +def consensus(): + replaced = blockchain.resolve_conflicts() + + if replaced: + response = { + 'message': 'Our chain was replaced', + 'new_chain': blockchain.chain + } + else: + response = { + 'message': 'Our chain is authoritative', + 'chain': blockchain.chain + } + +return jsonify(response), 200 +``` + +At this point you can grab a different machine if you like, and spin up different nodes on your network. Or spin up processes using different ports on the same machine. I spun up another node on my machine, on a different port, and registered it with my current node. Thus, I have two nodes: [http://localhost:5000][9] and http://localhost:5001. + +![](https://cdn-images-1.medium.com/max/1600/1*Dd78u-gmtwhQWHhPG3qMTQ.png) +Registering a new Node + +I then mined some new Blocks on node 2, to ensure the chain was longer. Afterward, I called GET /nodes/resolve on node 1, where the chain was replaced by the Consensus Algorithm: + +![](https://cdn-images-1.medium.com/max/1600/1*SGO5MWVf7GguIxfz6S8NVw.png) +Consensus Algorithm at Work + +And that’s a wrap... Go get some friends together to help test out your Blockchain. + +* * * + +I hope that this has inspired you to create something new. I’m ecstatic about Cryptocurrencies because I believe that Blockchains will rapidly change the way we think about economies, governments and record-keeping. + +**Update:** I’m planning on following up with a Part 2, where we’ll extend our Blockchain to have a Transaction Validation Mechanism as well as discuss some ways in which you can productionize your Blockchain. + + +-------------------------------------------------------------------------------- + +via: https://hackernoon.com/learn-blockchains-by-building-one-117428612f46 + +作者:[Daniel van Flymen][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://hackernoon.com/@vanflymen?source=post_header_lockup +[1]:https://learncryptography.com/hash-functions/what-are-hash-functions +[2]:https://www.python.org/downloads/ +[3]:https://www.getpostman.com +[4]:https://github.com/dvf/blockchain +[5]:https://www.jetbrains.com/pycharm/ +[6]:https://github.com/dvf/blockchain +[7]:http://flask.pocoo.org/docs/0.12/quickstart/#a-minimal-application +[8]:http://localhost:5000/transactions/new +[9]:http://localhost:5000 From 014000d0c20b627cd6468ecf382bd5d9cc3fdbef Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 23 Mar 2018 17:15:14 +0800 Subject: [PATCH 0084/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20Command=20L?= =?UTF-8?q?ine=20Productivity=20Tool=20For=20Tracking=20Work=20Hours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...oductivity Tool For Tracking Work Hours.md | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md diff --git a/sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md b/sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md new file mode 100644 index 0000000000..b9fb95c8bd --- /dev/null +++ b/sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md @@ -0,0 +1,201 @@ +A Command Line Productivity Tool For Tracking Work Hours +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Moro-720x340.jpg) +Keeping track of your work hours will give you an insight about the amount of work you get done in a specific time frame. There are plenty of GUI-based productivity tools available on the Internet for tracking work hours. However, I couldn’t find a good CLI-based tool. Today, I stumbled upon a a simple, yet useful tool named **“Moro”** for tracking work hours. Moro is a Finnish word which means “Hello”. Using Moro, you can find how much time you take to complete a specific task. It is free, open source and written using **NodeJS**. + +### Moro – A Command Line Productivity Tool For Tracking Work Hours + +Since Moro is written using NodeJS, make sure you have installed it on your system. If you haven’t installed it already, follow the link given below to install NodeJS and NPM in your Linux box. + +Once NodeJS and Npm installed, run the following command to install Moro. +``` +$ npm install -g moro + +``` + +### Usage + +Moro’s working concept is very simple. It saves your work staring time, ending time and the break time in your system. At the end of each day, it will tell you how many hours you have worked! + +When you reached to office, just type: +``` +$ moro + +``` + +Sample output: +``` +💙 Moro \o/ + +✔ You clocked in at: 9:20 + +``` + +Moro will register this time as your starting time. + +When you leave the office, again type: +``` +$ moro + +``` + +Sample output: +``` +💙 Moro \o/ + +✔ You clocked out at: 19:22 + +ℹ Today looks like this so far: + +┌──────────────────┬─────────────────────────┐ +│ Today you worked │ 9 Hours and 72 Minutes │ +├──────────────────┼─────────────────────────┤ +│ Clock in │ 9:20 │ +├──────────────────┼─────────────────────────┤ +│ Clock out │ 19:22 │ +├──────────────────┼─────────────────────────┤ +│ Break duration │ 30 minutes │ +├──────────────────┼─────────────────────────┤ +│ Date │ 2018-03-19 │ +└──────────────────┴─────────────────────────┘ +ℹ Run moro --help to learn how to edit your clock in, clock out or break duration for today + +``` + +Moro will registers that time as your ending time. + +Now, More will subtract the starting time from ending time and then subtracts another 30 minutes for break time from the total and gives you the total working hours on that day. Sorry I am really terrible at explaining Math calculations. Let us say you came to work at 10 am in the morning and left 17.30 in the evening. So, the total hours you spent on the office is 7.30 hours (i.e 17.30-10). Then subtract the break time (default is 30 minutes) from the total. Hence, your total working time is 7 hours. Understood? Great! + +**Note:** Don’t confuse “moro” with “more” command like I did while writing this guide. + +To see all your registered hours, run: +``` +$ moro report --all + +``` + +Just in case, you forgot to register the start time or end time, you can specify that later on the same. + +For example, to register 10 am as start time, run: +``` +$ moro hi 10:00 + +💙 Moro \o/ + +✔ You clocked in at: 10:00 + +⏰ Working until 18:00 will make it a full (7.5 hours) day + +``` + +To register 17.30 as end time: +``` +$ moro bye 17:30 + +💙 Moro \o/ + +✔ You clocked out at: 17:30 + +ℹ Today looks like this so far: + +┌──────────────────┬───────────────────────┐ +│ Today you worked │ 7 Hours and 0 Minutes │ +├──────────────────┼───────────────────────┤ +│ Clock in │ 10:00 │ +├──────────────────┼───────────────────────┤ +│ Clock out │ 17:30 │ +├──────────────────┼───────────────────────┤ +│ Break duration │ 30 minutes │ +├──────────────────┼───────────────────────┤ +│ Date │ 2018-03-19 │ +└──────────────────┴───────────────────────┘ +ℹ Run moro --help to learn how to edit your clock in, clock out or break duration for today + +``` + +You already know Moro will subtract 30 minutes for break time, by default. If you wanted to set a custom break time, you could simply set it using command: +``` +$ moro break 45 + +``` + +Now, the break time is 45 minutes. + +To clear all data: +``` +$ moro clear --yes + +💙 Moro \o/ + +✔ Database file deleted successfully + +``` + +**Add notes** + +Sometimes, you may want to add note while working. Don’t look for a separate note taking application. Moro will help you to add notes. To add a note, just run: +``` +$ moro note mynotes + +``` + +To search for the registered notes at later time, simply do: +``` +$ moro search mynotes + +``` + +**Change default settings** + +The default full work day is 7.5 hours. Since the developer is from Finland, it’s the official work hours. You can, however, change this settings as per your country’s work hours. + +Say for example, to set it 7 hours, run: +``` +$ moro config --day 7 + +``` + +Also the default break time can be changed from 30 minutes like below: +``` +$ moro config --break 45 + +``` + +**Backup your data** + +Like I already said, Moro stores the tracking time data in your home directory, and the file name is **.moro-data.db**. + +You can can, however, save the backup database file to different location. To do so, move the **.more-data.db** file to a different location of your choice and tell Moro to use that database file like below. +``` +$ moro config --database-path /home/sk/personal/moro-data.db + +``` + +As per above command, I have assigned the default database file’s location to **/home/sk/personal** directory. + +For help, run: +``` +$ moro --help + +``` + +As you can see, Moro is very simple, yet useful to track how much time you’ve spent to get your work done. It is will be useful for freelancers and also anyone who must get things done under a limited time frame. + +And, that’s all for today. Hope this helps. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/moro-a-command-line-productivity-tool-for-tracking-work-hours/ + +作者:[SK][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/author/sk/ From 5baa408cb7be4e7835dec56223b0b4c55bf4e6c1 Mon Sep 17 00:00:00 2001 From: HankChow Date: Fri, 23 Mar 2018 17:39:45 +0800 Subject: [PATCH 0085/1057] translated --- ... patch systems and install applications.md | 207 ------------------ ... patch systems and install applications.md | 205 +++++++++++++++++ 2 files changed, 205 insertions(+), 207 deletions(-) delete mode 100644 sources/tech/20180321 How to use Ansible to patch systems and install applications.md create mode 100644 translated/tech/20180321 How to use Ansible to patch systems and install applications.md diff --git a/sources/tech/20180321 How to use Ansible to patch systems and install applications.md b/sources/tech/20180321 How to use Ansible to patch systems and install applications.md deleted file mode 100644 index 8e52f39f76..0000000000 --- a/sources/tech/20180321 How to use Ansible to patch systems and install applications.md +++ /dev/null @@ -1,207 +0,0 @@ -hankchow translating - -How to use Ansible to patch systems and install applications -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4) -Have you ever wondered how to patch your systems, reboot, and continue working? - -If so, you'll be interested in [Ansible][1] , a simple configuration management tool that can make some of the hardest work easy. For example, system administration tasks that can be complicated, take hours to complete, or have complex requirements for security. - -In my experience, one of the hardest parts of being a sysadmin is patching systems. Every time you get a Common Vulnerabilities and Exposure (CVE) notification or Information Assurance Vulnerability Alert (IAVA) mandated by security, you have to kick into high gear to close the security gaps. (And, believe me, your security officer will hunt you down unless the vulnerabilities are patched.) - -Ansible can reduce the time it takes to patch systems by running [packaging modules][2]. To demonstrate, let's use the [yum module][3] to update the system. Ansible can install, update, remove, or install from another location (e.g., `rpmbuild` from continuous integration/continuous development). Here is the task for updating the system: -``` -  - name: update the system - -    yum: - -      name: "*" - -      state: latest - -``` - -In the first line, we give the task a meaningful `name` so we know what Ansible is doing. In the next line, the `yum module` updates the CentOS virtual machine (VM), then `name: "*"` tells yum to update everything, and, finally, `state: latest` updates to the latest RPM. - -After updating the system, we need to restart and reconnect: -``` -  - name: restart system to reboot to newest kernel - -    shell: "sleep 5 && reboot" - -    async: 1 - -    poll: 0 - - - -  - name: wait for 10 seconds - -    pause: - -      seconds: 10 - - - -  - name: wait for the system to reboot - -    wait_for_connection: - -      connect_timeout: 20 - -      sleep: 5 - -      delay: 5 - -      timeout: 60 - - - -  - name: install epel-release - -    yum: - -      name: epel-release - -      state: latest - -``` - -The `shell module` puts the system to sleep for 5 seconds then reboots. We use `sleep` to prevent the connection from breaking, `async` to avoid timeout, and `poll` to fire & forget. We pause for 10 seconds to wait for the VM to come back and use `wait_for_connection` to connect back to the VM as soon as it can make a connection. Then we `install epel-release` to test the RPM installation. You can run this playbook multiple times to show the `idempotent`, and the only task that will show as changed is the reboot since we are using the `shell` module. You can use `changed_when: False` to ignore the change when using the `shell` module if you expect no actual changes. - -So far we've learned how to update a system, restart the VM, reconnect, and install a RPM. Next we will install NGINX using the role in [Ansible Lightbulb][4]. -``` -  - name: Ensure nginx packages are present - -    yum: - -      name: nginx, python-pip, python-devel, devel - -      state: present - -    notify: restart-nginx-service - - - -  - name: Ensure uwsgi package is present - -    pip: - -      name: uwsgi - -      state: present - -    notify: restart-nginx-service - - - -  - name: Ensure latest default.conf is present - -    template: - -      src: templates/nginx.conf.j2 - -      dest: /etc/nginx/nginx.conf - -      backup: yes - -    notify: restart-nginx-service - - - -  - name: Ensure latest index.html is present - -    template: - -      src: templates/index.html.j2 - -      dest: /usr/share/nginx/html/index.html - - - -  - name: Ensure nginx service is started and enabled - -    service: - -      name: nginx - -      state: started - -      enabled: yes - - - -  - name: Ensure proper response from localhost can be received - -    uri: - -      url: "http://localhost:80/" - -      return_content: yes - -    register: response - -    until: 'nginx_test_message in response.content' - -    retries: 10 - -    delay: 1 - -``` - -And the handler that restarts the nginx service: -``` -# handlers file for nginx-example - -  - name: restart-nginx-service - -    service: - -      name: nginx - -      state: restarted - -``` - -In this role, we install the RPMs `nginx`, `python-pip`, `python-devel`, and `devel` and install `uwsgi` with PIP. Next, we use the `template` module to copy over the `nginx.conf` and `index.html` for the page to display. After that, we make sure the service is enabled on boot and started. Then we use the `uri` module to check the connection to the page. - -Here is a playbook showing an example of updating, restarting, and installing an RPM. Then continue installing nginx. This can be done with any other roles/applications you want. -``` -  - hosts: all - -    roles: - -      - centos-update - -      - nginx-simple - -``` - -Watch this demo video for more insight on the process. - -[demo](https://asciinema.org/a/166437/embed?) - -This was just a simple example of how to update, reboot, and continue. For simplicity, I added the packages without [variables][5]. Once you start working with a large number of hosts, you will need to change a few settings: - -This is because on your production environment you might want to update one system at a time (not fire & forget) and actually wait a longer time for your system to reboot and continue. - -For more ways to automate your work with this tool, take a look at the other [Ansible articles on Opensource.com][6]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/ansible-patch-systems - -作者:[Jonathan Lozada De La Matta][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/jlozadad -[1]:https://www.ansible.com/overview/how-ansible-works -[2]:https://docs.ansible.com/ansible/latest/list_of_packaging_modules.html -[3]:https://docs.ansible.com/ansible/latest/yum_module.html -[4]:https://github.com/ansible/lightbulb/tree/master/examples/nginx-role -[5]:https://docs.ansible.com/ansible/latest/playbooks_variables.html -[6]:https://opensource.com/tags/ansible diff --git a/translated/tech/20180321 How to use Ansible to patch systems and install applications.md b/translated/tech/20180321 How to use Ansible to patch systems and install applications.md new file mode 100644 index 0000000000..205ce21fc0 --- /dev/null +++ b/translated/tech/20180321 How to use Ansible to patch systems and install applications.md @@ -0,0 +1,205 @@ +如何使用 Ansible 打补丁以及安装应用 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4) +你有没有想过,如何打补丁、重启系统,然后继续工作? + +如果你的回答是肯定的,那就需要了解一下 [Ansible][1] 了。它是一个配置管理工具,对于一些复杂的系统管理任务有时候需要几个小时才能完成,又或者对安全性有比较高要求的时候,使用 Ansible 能够大大简化工作流程。 + +以我作为系统管理员的经验,打补丁是一项最有难度的工作。每次遇到公共漏洞和暴露(CVE, Common Vulnearbilities and Exposure)通知或者信息安全漏洞预警(IAVA, Information Assurance Vulnerability Alert)时都必须要高度关注安全漏洞,否则安全部门将会严肃追究自己的责任。 + +使用 Ansible 可以通过运行[封装模块][2]以缩短打补丁的时间,下面以[yum模块][3]更新系统为例,使用 Ansible 可以执行安装、更新、删除、从其它地方安装(例如持续集成/持续开发中的 `rpmbuild`)。以下是系统更新的任务: +``` + - name: update the system + + yum: + + name: "*" + + state: latest + +``` + +在第一行,我们给这个任务命名,这样可以清楚 Ansible 的工作内容。第二行表示使用 `yum` 模块在CentOS虚拟机中执行更新操作。第三行 `name: "*"` 表示更新所有程序。最后一行 `state: latest` 表示更新到最新的 RPM。 + +系统更新结束之后,需要重新启动并重新连接: +``` + - name: restart system to reboot to newest kernel + + shell: "sleep 5 && reboot" + + async: 1 + + poll: 0 + + + + - name: wait for 10 seconds + + pause: + + seconds: 10 + + + + - name: wait for the system to reboot + + wait_for_connection: + + connect_timeout: 20 + + sleep: 5 + + delay: 5 + + timeout: 60 + + + + - name: install epel-release + + yum: + + name: epel-release + + state: latest + +``` + +`shell` 字段中的命令让系统在5秒休眠之后重新启动,我们使用 `sleep` 来保持连接不断开,使用 `async` 设定最大等待时长以避免发生超时,`poll` 设置为0表示直接执行不需要等待执行结果。等待10秒钟,使用 `wait_for_connection` 在虚拟机恢复连接后尽快连接。随后由 `install epel-release` 任务检查 RPM 的安装情况。你可以对这个剧本执行多次来验证它的幂等性,唯一会显示造成影响的是重启操作,因为我们使用了 `shell` 模块。如果不想造成实际的影响,可以在使用 `shell` 模块的时候 `changed_when: False`。 + +现在我们已经知道如何对系统进行更新、重启虚拟机、重新连接、安装 RPM 包。下面我们通过 [Ansible Lightbulb][4] 来安装 NGINX: +``` + - name: Ensure nginx packages are present + + yum: + + name: nginx, python-pip, python-devel, devel + + state: present + + notify: restart-nginx-service + + + + - name: Ensure uwsgi package is present + + pip: + + name: uwsgi + + state: present + + notify: restart-nginx-service + + + + - name: Ensure latest default.conf is present + + template: + + src: templates/nginx.conf.j2 + + dest: /etc/nginx/nginx.conf + + backup: yes + + notify: restart-nginx-service + + + + - name: Ensure latest index.html is present + + template: + + src: templates/index.html.j2 + + dest: /usr/share/nginx/html/index.html + + + + - name: Ensure nginx service is started and enabled + + service: + + name: nginx + + state: started + + enabled: yes + + + + - name: Ensure proper response from localhost can be received + + uri: + + url: "http://localhost:80/" + + return_content: yes + + register: response + + until: 'nginx_test_message in response.content' + + retries: 10 + + delay: 1 + +``` + +And the handler that restarts the nginx service: +``` +# 安装 nginx 的操作文件 + + - name: restart-nginx-service + + service: + + name: nginx + + state: restarted + +``` + +在这个角色里,我们使用 RPM 安装了 `nginx`、`python-pip`、`python-devel`、`devel`,用 PIP 安装了 `uwsgi`,接下来使用 `template` 模块复制 `nginx.conf` 和 `index.html` 以显示页面,并确保服务在系统启动时启动。然后就可以使用 `uri` 模块检查到页面的连接了。 + +这个是一个系统更新、系统重启、安装 RPM 包的剧本示例,后续可以继续安装 nginx,当然这里可以替换成任何你想要的角色和应用程序。 +``` + - hosts: all + + roles: + + - centos-update + + - nginx-simple + +``` + +观看演示视频了解了解这个过程。 + +[demo](https://asciinema.org/a/166437/embed?) + +这只是关于如何更新系统、重启以及后续工作的示例。简单起见,我只添加了不带[变量][5]的包,当你在操作大量主机的时候,你就需要修改其中的一些设置了: + +这是由于在生产环境中如果你想逐一更新每一台主机的系统,你需要花相当一段时间去等待主机重启才能够继续下去。 + +有关 Ansible 进行自动化工作的更多用法,请查阅[其它文章][6]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/ansible-patch-systems + +作者:[Jonathan Lozada De La Matta][a] +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/jlozadad +[1]:https://www.ansible.com/overview/how-ansible-works +[2]:https://docs.ansible.com/ansible/latest/list_of_packaging_modules.html +[3]:https://docs.ansible.com/ansible/latest/yum_module.html +[4]:https://github.com/ansible/lightbulb/tree/master/examples/nginx-role +[5]:https://docs.ansible.com/ansible/latest/playbooks_variables.html +[6]:https://opensource.com/tags/ansible From fef8630bed76ac2613955a477d8a1cc301ab0af8 Mon Sep 17 00:00:00 2001 From: lontow <1423131852@qq.com> Date: Fri, 23 Mar 2018 17:43:15 +0800 Subject: [PATCH 0086/1057] lontow translating --- ...0180103 5 ways open source can strengthen your job search.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180103 5 ways open source can strengthen your job search.md b/sources/tech/20180103 5 ways open source can strengthen your job search.md index 945465e78e..87c3122729 100644 --- a/sources/tech/20180103 5 ways open source can strengthen your job search.md +++ b/sources/tech/20180103 5 ways open source can strengthen your job search.md @@ -1,3 +1,5 @@ +lontow translating + 5 ways open source can strengthen your job search ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/resume_career_document_general.png?itok=JEaFL2XI) From 83e5699a073aef700892e8c53e94d2a3b6a43224 Mon Sep 17 00:00:00 2001 From: kimii <2545489745@qq.com> Date: Fri, 23 Mar 2018 15:21:38 +0000 Subject: [PATCH 0087/1057] Update 20180221 cTop - A CLI Tool For Container Monitoring.md --- .../tech/20180221 cTop - A CLI Tool For Container Monitoring.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md b/sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md index 9a25f29436..15ada04057 100644 --- a/sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md +++ b/sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md @@ -1,3 +1,4 @@ +translating by kimii cTop - A CLI Tool For Container Monitoring ====== Recent days Linux containers are famous, even most of us already working on it and few of us start learning about it. From 1b1423266e25bb5e41675d8fe03c12b1dc70c44d Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sat, 24 Mar 2018 07:17:01 +0800 Subject: [PATCH 0088/1057] 2018-03-24 --- ... Why Linux is better than Windows or macOS for security.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index dba0f2cd76..f55622720d 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -5,13 +5,13 @@ fuzheng1998 translating ![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg) -Enterprises invest a lot of time, effort and money in keeping their systems secure. The most security-conscious might have a security operations center. They of course use firewalls and antivirus tools. They probably spend a lot of time monitoring their networks, looking for telltale anomalies that could indicate a breach. What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. +企业投入了大量时间、精力和金钱来保障系统的安全性。The most security-conscious might have a security operations center. They of course use firewalls and antivirus tools. They probably spend a lot of time monitoring their networks, looking for telltale anomalies that could indicate a breach. What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. But how many have given much thought to one of the cornerstones of their digital operations: the operating systems deployed on the workforce’s PCs? Was security even a factor when the desktop OS was selected? 这就产生了一个 IT 人士都应该能回答的问题:哪种操作系统对于一般性使用最安全呢? -我们问了一些专家他们对于以下三种选项的看法:Windows, the ever-more-complex platform that’s easily the most popular desktop system; macOS X, the FreeBSD Unix-based operating system that powers Apple Macintosh systems; and Linux, by which we mean all the various Linux distributions and related Unix-based systems. +我们问了一些专家他们对于以下三种选项的看法:Windows, 最复杂的平台也是最易受欢迎的桌面操作系统;macOS X,基于 FreeBSD 的 Unix 操作系统,驱动着苹果的 Macintosh 系列机运行;还有 Linux,这里我们的意思是所有的 Linux 发行版以及与基于 Unix 的操作系统相关的系统。 ### 我们怎么会这样How we got here From 34a1ea878cc1119290695601ed0d0baec984a835 Mon Sep 17 00:00:00 2001 From: amwps290 Date: Sat, 24 Mar 2018 08:18:23 +0800 Subject: [PATCH 0089/1057] Update 20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md --- ...ce - A Tool For Managing Systemd Units From Linux Terminal.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md b/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md index 9bffa5fed1..9c6933c18b 100644 --- a/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md +++ b/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md @@ -1,3 +1,4 @@ +translating by amwps290 chkservice – A Tool For Managing Systemd Units From Linux Terminal ====== systemd stand for system daemon is a new init system and system manager which is become very popular and widely adapted new standard init system by most of Linux distributions. From b78d8b9ec8dca1982ad4303d6893abbde092419e Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 10:50:10 +0800 Subject: [PATCH 0090/1057] PRF:20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md @geekpi --- ... Record - Play Terminal IO and Sessions.md | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md b/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md index 5868263f18..a27b805aad 100644 --- a/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md +++ b/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md @@ -1,79 +1,85 @@ -Tlog - 录制/播放终端 IO 和会话的工具 +Tlog:录制/播放终端 IO 和会话的工具 ====== -Tlog 是 Linux 中终端 I/O 录制和回放软件包。它用于实现集中式用户会话录制。它将所有经过的消息录制为 JSON 消息。录制为 JSON 格式的主要目的是将数据传送到 Elasticsearch 之类的存储服务,可以从中搜索和查询,以及回放。同时,他们保留所有通过的数据和时序。 -Tlog 包含三个工具,分别是 tlog-rec、tlog-rec-session 和 tlog-play。 - - * `Tlog-rec tool` 一般用于录制终端、程序或 shell 的输入或输出。 - * `Tlog-rec-session tool` 用于录制整个终端会话的 I/O,并保护录制的用户。 - * `Tlog-rec-session tool` 用于回放录制。 +Tlog 是 Linux 中终端 I/O 录制和回放软件包。它用于实现一个集中式用户会话录制。它将所有经过的消息录制为 JSON 消息。录制为 JSON 格式的主要目的是将数据传送到 ElasticSearch 之类的存储服务,可以从中搜索和查询,以及回放。同时,它们保留所有通过的数据和时序。 +Tlog 包含三个工具,分别是 `tlog-rec`、tlog-rec-session` 和 `tlog-play`。 + * `tlog-rec` 工具一般用于录制终端、程序或 shell 的输入或输出。 + * `tlog-rec-session` 工具用于录制整个终端会话的 I/O,包括录制的用户。 + * `tlog-play` 工具用于回放录制。 在本文中,我将解释如何在 CentOS 7.4 服务器上安装 Tlog。 ### 安装 在安装之前,我们需要确保我们的系统满足编译和安装程序的所有软件要求。在第一步中,使用以下命令更新系统仓库和软件包。 + ``` -#yum update +# yum update ``` 我们需要安装此软件安装所需的依赖项。在安装之前,我已经使用这些命令安装了所有依赖包。 + ``` -#yum install wget gcc -#yum install systemd-devel json-c-devel libcurl-devel m4 +# yum install wget gcc +# yum install systemd-devel json-c-devel libcurl-devel m4 ``` 完成这些安装后,我们可以下载该工具的[源码包][1]并根据需要将其解压到服务器上: + ``` -#wget https://github.com/Scribery/tlog/releases/download/v3/tlog-3.tar.gz -#tar -xvf tlog-3.tar.gz +# wget https://github.com/Scribery/tlog/releases/download/v3/tlog-3.tar.gz +# tar -xvf tlog-3.tar.gz # cd tlog-3 ``` -现在,你可以使用我们通常的配置和制作方法开始构建此工具。 +现在,你可以使用我们通常的配置和编译方法开始构建此工具。 + ``` -#./configure --prefix=/usr --sysconfdir=/etc && make -#make install -#ldconfig +# ./configure --prefix=/usr --sysconfdir=/etc && make +# make install +# ldconfig ``` -最后,你需要运行 `ldconfig`。它会创建必要的链接,并缓存命令行中指定目录中最近的共享库。( /etc/ld.so.conf 中的文件,以及信任的目录 (/lib and /usr/lib)) +最后,你需要运行 `ldconfig`。它对命令行中指定目录、`/etc/ld.so.conf` 文件,以及信任的目录( `/lib` 和 `/usr/lib`)中最近的共享库创建必要的链接和缓存。 ### Tlog 工作流程图 ![Tlog working process][2] -首先,用户通过 PAM 进行身份验证登录。名称服务交换机(NSS)提供的 `tlog` 信息是用户的 shell。这初始化了 tlog 部分,并从环境变量/配置文件收集关于实际 shell 的信息,并以 PTY 的形式启动实际的 shell。然后通过 syslog 或 sd-journal 开始录制在终端和 PTY 之间传递的所有内容。 +首先,用户通过 PAM 进行身份验证登录。名称服务交换器(NSS)提供的 `tlog` 信息是用户的 shell。这初始化了 tlog 部分,并从环境变量/配置文件收集关于实际 shell 的信息,并在 PTY 中启动实际的 shell。然后通过 syslog 或 sd-journal 开始录制在终端和 PTY 之间传递的所有内容。 ### 用法 -你可以使用 `tlog-rec` 录制一个会话并使用 `tlog-play` 回放它来测试新安装的 tlog 是否能够正常录制和回放会话。 +你可以使用 `tlog-rec` 录制一个会话并使用 `tlog-play` 回放它,以测试新安装的 tlog 是否能够正常录制和回放会话。 #### 录制到文件中 要将会话录制到文件中,请在命令行中执行 `tlog-rec`,如下所示: + ``` tlog-rec --writer=file --file-path=tlog.log ``` -该命令会将我们的终端会话录制到名为 tlog.log 的文件中,并将其保存在命令中指定的路径中。 +该命令会将我们的终端会话录制到名为 `tlog.log` 的文件中,并将其保存在命令中指定的路径中。 #### 从文件中回放 你可以在录制过程中或录制后使用 `tlog-play` 命令回放录制的会话。 + ``` tlog-play --reader=file --file-path=tlog.log ``` -该命令从指定的路径读取先前录制的文件 tlog.log。 +该命令从指定的路径读取先前录制的文件 `tlog.log`。 ### 总结 -Tlog 是一个开源软件包,可用于实现集中式用户会话录制。它主要是作为一个更大的用户会话录制解决方案的一部分使用,但它被设计为独立且可重用的。该工具可以帮助录制用户所做的一切并将其存储在服务器的某个位置,以备将来参考。你可以从这个[文档][3]中获得关于这个软件包使用的更多细节。我希望这篇文章对你有用。请发表你的宝贵建议和意见。 +Tlog 是一个开源软件包,可用于实现集中式用户会话录制。它主要是作为一个更大的用户会话录制解决方案的一部分使用,但它被设计为独立且可重用的。该工具可以帮助录制用户所做的一切,并将其存储在服务器的某个位置,以备将来参考。你可以从这个[文档][3]中获得关于这个软件包使用的更多细节。我希望这篇文章对你有用。请发表你的宝贵建议和意见。 + +**关于 Saheetha Shameer (作者)** -### 关于 Saheetha Shameer (作者) 我正在担任高级系统管理员。我是一名快速学习者,有轻微的倾向跟随行业中目前和正在出现的趋势。我的爱好包括听音乐、玩策略游戏、阅读和园艺。我对尝试各种美食也有很高的热情 :-) -------------------------------------------------------------------------------- @@ -82,7 +88,7 @@ via: https://linoxide.com/linux-how-to/tlog-tool-record-play-terminal-io-session 作者:[Saheetha Shameer][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 5ed8ea9bee5f88fd19df08d9fc5fa602f0bb15ea Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 10:50:37 +0800 Subject: [PATCH 0091/1057] PUB:20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md @geekpi --- ...104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md (100%) diff --git a/translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md b/published/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md similarity index 100% rename from translated/tech/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md rename to published/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md From e28c1f7fea90c04529288f8acc046dd12df45474 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 11:41:08 +0800 Subject: [PATCH 0092/1057] PRF:20180201 How to Run Your Own Public Time Server on Linux.md @qhwdw --- ...un Your Own Public Time Server on Linux.md | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/translated/tech/20180201 How to Run Your Own Public Time Server on Linux.md b/translated/tech/20180201 How to Run Your Own Public Time Server on Linux.md index 70eae1596d..4c59cd5dda 100644 --- a/translated/tech/20180201 How to Run Your Own Public Time Server on Linux.md +++ b/translated/tech/20180201 How to Run Your Own Public Time Server on Linux.md @@ -3,35 +3,36 @@ ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/eddington_a._space_time_and_gravitation._fig._9.jpg?itok=KgNqViyZ) -公共服务最重要的一点就是守时,但是很多人并没有意识到这一点。大多数公共时间服务器都是由志愿者管理,以满足不断增长的需求。学习如何运行你自己的时间服务器,为基本的公共利益做贡献。(查看 [在 Linux 上使用 NTP 保持精确时间][1] 去学习如何设置一台局域网时间服务器) +最重要的公共服务之一就是报时timekeeping,但是很多人并没有意识到这一点。大多数公共时间服务器都是由志愿者管理,以满足不断增长的需求。这里学习一下如何运行你自己的时间服务器,为基础公共利益做贡献。(查看 [在 Linux 上使用 NTP 保持精确时间][1] 去学习如何设置一台局域网时间服务器) ### 著名的时间服务器滥用事件 就像现实生活中任何一件事情一样,即便是像时间服务器这样的公益项目,也会遭受不称职的或者恶意的滥用。 -消费类网络设备的供应商因制造了大混乱而臭名昭著。我回想起的第一件事发生在 2003 年,那时,Netgear 在它们的路由器中硬编码了 University of Wisconsin-Madison 的 NTP 时间服务器地址。使得时间服务器的查询请求突然增加,随着 NetGear 卖出越来越多的路由器,这种情况越发严重。更有意思的是,路由器的程序设置是每秒钟发送一次请求,这将使服务器难堪重负。后来 Netgear 发布了升级固件,但是,升级他们的设备的用户很少,并且他们的其中一些用户的设备,到今天为止,还在不停地每秒钟查询一次 University of Wisconsin-Madison 的 NTP 服务器。Netgear 给 University of Wisconsin-Madison 捐献了一些钱,以帮助弥补他们带来的成本增加,直到这些路由器全部淘汰。类似的事件还有 D-Link、Snapchat、TP-Link 等等。 +消费类网络设备的供应商因制造了大混乱而臭名昭著。我回想起的第一件事发生在 2003 年,那时,NetGear 在它们的路由器中硬编码了威斯康星大学的 NTP 时间服务器地址。使得时间服务器的查询请求突然增加,随着 NetGear 卖出越来越多的路由器,这种情况越发严重。更有意思的是,路由器的程序设置是每秒钟发送一次请求,这将使服务器难堪重负。后来 Netgear 发布了升级固件,但是,升级他们的设备的用户很少,并且他们的其中一些用户的设备,到今天为止,还在不停地每秒钟查询一次威斯康星大学的 NTP 服务器。Netgear 给威斯康星大学捐献了一些钱,以帮助弥补他们带来的成本增加,直到这些路由器全部淘汰。类似的事件还有 D-Link、Snapchat、TP-Link 等等。 -对 NTP 协议进行反射和放大,已经成为发起 DDoS 攻击的一个选择。当攻击者使用一个伪造的源地址向目标受害者发送请求,称为反射;攻击者发送请求到多个服务器,这些服务器将回复请求,这样就使伪造的地址受到轰炸。放大是指一个很小的请求收到大量的回复信息。例如,在 Linux 上,`ntpq` 命令是一个查询你的 NTP 服务器并验证它们的系统时间是否正确的很有用的工具。一些回复,比如,对端列表,是非常大的。组合使用反射和放大,攻击者可以将 10 倍甚至更多带宽的数据量发送到被攻击者。 +对 NTP 协议进行反射和放大,已经成为发起 DDoS 攻击的一个选择。当攻击者使用一个伪造的目标受害者的源地址向时间服务器发送请求,称为反射攻击;攻击者发送请求到多个服务器,这些服务器将回复请求,这样就使伪造的源地址受到轰炸。放大攻击是指一个很小的请求收到大量的回复信息。例如,在 Linux 上,`ntpq` 命令是一个查询你的 NTP 服务器并验证它们的系统时间是否正确的很有用的工具。一些回复,比如,对端列表,是非常大的。组合使用反射和放大,攻击者可以将 10 倍甚至更多带宽的数据量发送到被攻击者。 那么,如何保护提供公益服务的公共 NTP 服务器呢?从使用 NTP 4.2.7p26 或者更新的版本开始,它们可以帮助你的 Linux 发行版不会发生前面所说的这种问题,因为它们都是在 2010 年以后发布的。这个发行版都默认禁用了最常见的滥用攻击。目前,[最新版本是 4.2.8p10][2],它发布于 2017 年。 -你可以采用的另一个措施是,在你的网络上启用入站和出站过滤器。阻塞进入你的网络的数据包,以及拦截发送到伪造地址的出站数据包。入站过滤器帮助你,而出站过滤器则帮助你和其他人。阅读 [BCP38.info][3] 了解更多信息。 +你可以采用的另一个措施是,在你的网络上启用入站和出站过滤器。阻塞宣称来自你的网络的数据包进入你的网络,以及拦截发送到伪造返回地址的出站数据包。入站过滤器可以帮助你,而出站过滤器则帮助你和其他人。阅读 [BCP38.info][3] 了解更多信息。 ### 层级为 0、1、2 的时间服务器 -NTP 有超过 30 年的历史了,它是至今还在使用的最老的因特网协议之一。它的用途是保持计算机与协调世界时间(UTC)的同步。NTP 网络是分层组织的,并且同层的设备是对等的。层次 0 包含主守时设备,比如,原子钟。层级 1 的时间服务器与层级 0 的设备同步。层级 2 的设备与层级 1 的设备同步,层级 3 的设备与层级 2 的设备同步。NTP 协议支持 16 个层级,现实中并没有使用那么多的层级。同一个层级的服务器是相互对等的。 +NTP 有超过 30 年的历史了,它是至今还在使用的最老的因特网协议之一。它的用途是保持计算机与世界标准时间(UTC)的同步。NTP 网络是分层组织的,并且同层的设备是对等的。层次Stratum 0 包含主报时设备,比如,原子钟。层级 1 的时间服务器与层级 0 的设备同步。层级 2 的设备与层级 1 的设备同步,层级 3 的设备与层级 2 的设备同步。NTP 协议支持 16 个层级,现实中并没有使用那么多的层级。同一个层级的服务器是相互对等的。 -过去很长一段时间内,我们都为客户端选择配置单一的 NTP 服务器,而现在更好的做法是使用 [NTP 服务器地址池][4],它使用往返的 DNS 信息去共享负载。池地址只是为客户端服务的,比如单一的 PC 和你的本地局域网 NTP 服务器。当你运行一台自己的公共服务器时,你不能使用这些池中的地址。 +过去很长一段时间内,我们都为客户端选择配置单一的 NTP 服务器,而现在更好的做法是使用 [NTP 服务器地址池][4],它使用轮询的 DNS 信息去共享负载。池地址只是为客户端服务的,比如单一的 PC 和你的本地局域网 NTP 服务器。当你运行一台自己的公共服务器时,你不用使用这些池地址。 ### 公共 NTP 服务器配置 -运行一台公共 NTP 服务器只有两步:设置你的服务器,然后加入到 NTP 服务器池。运行一台公共的 NTP 服务器是一种很高尚的行为,但是你得先知道如何加入到 NTP 服务器池中。加入 NTP 服务器池是一种长期责任,因为即使你加入服务器池后,运行了很短的时间马上退出,然后接下来的很多年你仍然会接收到请求。 +运行一台公共 NTP 服务器只有两步:设置你的服务器,然后申请加入到 NTP 服务器池。运行一台公共的 NTP 服务器是一种很高尚的行为,但是你得先知道这意味着什么。加入 NTP 服务器池是一种长期责任,因为即使你加入服务器池后,运行了很短的时间马上退出,然后接下来的很多年你仍然会接收到请求。 你需要一个静态的公共 IP 地址,一个至少 512Kb/s 带宽的、可靠的、持久的因特网连接。NTP 使用的是 UDP 的 123 端口。它对机器本身要求并不高,很多管理员在其它的面向公共的服务器(比如,Web 服务器)上顺带架设了 NTP 服务。 -配置一台公共的 NTP 服务器与配置一台用于局域网的 NTP 服务器是一样的,只需要几个配置。我们从阅读 [协议规则][5] 开始。遵守规则并注意你的行为;几乎每个时间服务器的维护者都是像你这样的志愿者。然后,从 [StratumTwoTimeServers][6] 中选择 2 台层级为 4-7 的上游服务器。选择的时候,选取地理位置上靠近(小于 300 英里的)你的因特网服务提供商的上游服务器,阅读他们的访问规则,然后,使用 `ping` 和 `mtr` 去找到延迟和跳数最小的服务器。 +配置一台公共的 NTP 服务器与配置一台用于局域网的 NTP 服务器是一样的,只需要几个配置。我们从阅读 [协议规则][5] 开始。遵守规则并注意你的行为;几乎每个时间服务器的维护者都是像你这样的志愿者。然后,从 [StratumTwoTimeServers][6] 中选择 4 到 7 个层级 2 的上游服务器。选择的时候,选取地理位置上靠近(小于 300 英里的)你的因特网服务提供商的上游服务器,阅读他们的访问规则,然后,使用 `ping` 和 `mtr` 去找到延迟和跳数最小的服务器。 以下的 `/etc/ntp.conf` 配置示例文件,包括了 IPv4 和 IPv6,以及基本的安全防护: + ``` # stratum 2 server list server servername_1 iburst @@ -47,10 +48,10 @@ restrict -6 default kod noquery nomodify notrap nopeer limited # Allow ntpq and ntpdc queries only from localhost restrict 127.0.0.1 restrict ::1 - ``` 启动你的 NTP 服务器,让它运行几分钟,然后测试它对远程服务器的查询: + ``` $ ntpq -p remote refid st t when poll reach delay offset jitter @@ -63,21 +64,21 @@ $ ntpq -p ``` 目前表现很好。现在从另一台 PC 上使用你的 NTP 服务器名字进行测试。以下的示例是一个正确的输出。如果有不正确的地方,你将看到一些错误信息。 + ``` -$ ntpdate -q _yourservername_ +$ ntpdate -q yourservername server 66.96.99.10, stratum 2, offset 0.017690, delay 0.12794 server 98.191.213.2, stratum 1, offset 0.014798, delay 0.22887 server 173.49.198.27, stratum 2, offset 0.020665, delay 0.15012 server 129.6.15.28, stratum 1, offset -0.018846, delay 0.20966 26 Jan 11:13:54 ntpdate[17293]: adjust time server 98.191.213.2 offset 0.014798 sec - ``` 一旦你的服务器运行的很好,你就可以向 [manage.ntppool.org][7] 申请加入池中。 -查看官方的手册 [分布式网络时间服务器(NTP)][8] 学习所有的命令、配置选项、以及高级特性,比如,管理、查询、和验证。访问以下的站点学习关于运行一台时间服务器所需要的一切东西。 +查看官方的手册 [分布式网络时间服务器(NTP)][8] 学习所有的命令、配置选项、以及高级特性,比如,管理、查询、和验证。访问以下的站点学习关于运行一台时间服务器所需要的一切东西。 -通过来自 Linux 基金会和 edX 的免费课程 ["Linux 入门" ][9] 学习更多 Linux 的知识。 +通过来自 Linux 基金会和 edX 的免费课程 [“Linux 入门”][9] 学习更多 Linux 的知识。 -------------------------------------------------------------------------------- @@ -85,12 +86,12 @@ via: https://www.linux.com/learn/intro-to-linux/2018/2/how-run-your-own-public-t 作者:[CARLA SCHRODER][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]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/learn/intro-to-linux/2018/1/keep-accurate-time-linux-ntp +[1]:https://linux.cn/article-9462-1.html [2]:http://www.ntp.org/downloads.html [3]:http://www.bcp38.info/index.php/Main_Page [4]:http://www.pool.ntp.org/en/use.html From a20f472dfce9fb42a9ce12b170dca3c74b3443cc Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 11:41:37 +0800 Subject: [PATCH 0093/1057] PUB:20180201 How to Run Your Own Public Time Server on Linux.md @qhwdw https://linux.cn/article-9475-1.html --- .../20180201 How to Run Your Own Public Time Server on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published/201406}/20180201 How to Run Your Own Public Time Server on Linux.md (100%) diff --git a/translated/tech/20180201 How to Run Your Own Public Time Server on Linux.md b/published/201406/20180201 How to Run Your Own Public Time Server on Linux.md similarity index 100% rename from translated/tech/20180201 How to Run Your Own Public Time Server on Linux.md rename to published/201406/20180201 How to Run Your Own Public Time Server on Linux.md From e25ce6fbe8ca2b790748ba2f800d71a9d3e2ad28 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 11:52:28 +0800 Subject: [PATCH 0094/1057] PRF:20180309 How to check your network connections on Linux.md @Flowsnow --- ...check your network connections on Linux.md | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180309 How to check your network connections on Linux.md b/translated/tech/20180309 How to check your network connections on Linux.md index 1e6923b56f..d8225dd4dc 100644 --- a/translated/tech/20180309 How to check your network connections on Linux.md +++ b/translated/tech/20180309 How to check your network connections on Linux.md @@ -1,11 +1,11 @@ -如何在Linux上检查您的网络连接 +解读 ip 命令展示的网络连接信息 ====== ![](https://images.idgesg.net/images/article/2018/03/network-connections-100751906-large.jpg) -**ip**命令有很多可以告诉你网络连接配置和状态的信息,但是所有这些词和数字意味着什么? 让我们深入了解一下,看看所有显示的值都试图告诉你什么。 +`ip` 命令可以告诉你很多网络连接配置和状态的信息,但是所有这些词和数字意味着什么? 让我们深入了解一下,看看所有显示的值都试图告诉你什么。 -当您使用`ip a`(或`ip addr`)命令获取系统上所有网络接口的信息时,您将看到如下所示的内容: +当您使用 `ip a`(或 `ip addr`)命令获取系统上所有网络接口的信息时,您将看到如下所示的内容: ``` $ ip a @@ -23,46 +23,46 @@ $ ip a valid_lft forever preferred_lft forever ``` -这个系统上的两个接口 - 环回(lo)和网络(enp0s25)——显示了很多统计数据。 “lo”接口显然是环回地址。 我们可以在列表中看到环回IPv4地址(127.0.0.1)和环回IPv6( **::1**)。 正常的网络接口更有趣。 +这个系统上的两个接口 - 环回(`lo`)和网络(`enp0s25`)——显示了很多统计数据。 `lo` 接口显然是环回地址loolback。 我们可以在列表中看到环回 IPv4 地址(`127.0.0.1`)和环回 IPv6(`::1`)。 而普通的网络接口更有趣。 -### 为什么是enp0s25而不是eth0 +### 为什么是 enp0s25 而不是 eth0 -如果你想知道为什么它在这个系统上被称为**enp0s25**,而不是可能更熟悉的**eth0**,那我们可以稍微解释一下。 +如果你想知道为什么它在这个系统上被称为 `enp0s25`,而不是可能更熟悉的 `eth0`,那我们可以稍微解释一下。 -新的命名方案被称为“可预测的网络接口”。 它已经在基于systemd的Linux系统上使用了一段时间了。 接口名称取决于硬件的物理位置。 “**en**”仅仅就是“ethernet”的意思就像“eth”用于对于eth0,一样。 “**p**”是以太网卡的总线编号,“**s**”是插槽编号。 所以“enp0s25”告诉我们很多我们正在使用的硬件的信息。 +新的命名方案被称为“可预测的网络接口Predictable Network Interface”。 它已经在基于systemd 的 Linux 系统上使用了一段时间了。 接口名称取决于硬件的物理位置。 `en` 仅仅就是 “ethernet” 的意思,就像 “eth” 用于对应 `eth0`,一样。 `p` 是以太网卡的总线编号,`s` 是插槽编号。 所以 `enp0s25` 告诉我们很多我们正在使用的硬件的信息。 + +`` 这个配置串告诉我们: - 这个配置串告诉我们: ``` BROADCAST 该接口支持广播 MULTICAST 该接口支持多播 UP 网络接口已启用 LOWER_UP 网络电缆已插入,设备已连接至网络 -mtu 1500 最大传输单位(数据包大小)为1,500字节 ``` -列出的其他值也告诉了我们很多关于接口的知识,但我们需要知道“brd”和“qlen”这些词代表什么意思。 所以,这里显示的是上面展示的**ip**信息的其余部分的翻译。 +列出的其他值也告诉了我们很多关于接口的知识,但我们需要知道 `brd` 和 `qlen` 这些词代表什么意思。 所以,这里显示的是上面展示的 `ip` 信息的其余部分的翻译。 ``` -mtu 最大传输单位(数据包大小)为1,500字节 +mtu 1500 最大传输单位(数据包大小)为1,500字节 qdisc pfifo_fast 用于数据包排队 state UP 网络接口已启用 group default 接口组 qlen 1000 传输队列长度 -link/ether 00:1e:4f:c8:43:fc 接口的MAC(硬件)地址 +link/ether 00:1e:4f:c8:43:fc 接口的 MAC(硬件)地址 brd ff:ff:ff:ff:ff:ff 广播地址 -inet 192.168.0.24/24 IPv4地址 +inet 192.168.0.24/24 IPv4 地址 brd 192.168.0.255 广播地址 scope global 全局有效 dynamic enp0s25 地址是动态分配的 -valid_lft 80866sec IPv4地址的有效使用期限 -preferred_lft 80866sec IPv4地址的首选生存期 -inet6 fe80::2c8e:1de0:a862:14fd/64 IPv6地址 +valid_lft 80866sec IPv4 地址的有效使用期限 +preferred_lft 80866sec IPv4 地址的首选生存期 +inet6 fe80::2c8e:1de0:a862:14fd/64 IPv6 地址 scope link 仅在此设备上有效 -valid_lft forever IPv6地址的有效使用期限 -preferred_lft forever IPv6地址的首选生存期 +valid_lft forever IPv6 地址的有效使用期限 +preferred_lft forever IPv6 地址的首选生存期 ``` -您可能已经注意到,ifconfig命令提供的一些信息未包含在**ip a** 命令的输出中 —— 例如传输数据包的统计信息。 如果您想查看发送和接收的数据包数量以及冲突数量的列表,可以使用以下ip命令: +您可能已经注意到,`ifconfig` 命令提供的一些信息未包含在 `ip a` 命令的输出中 —— 例如传输数据包的统计信息。 如果您想查看发送和接收的数据包数量以及冲突数量的列表,可以使用以下 `ip` 命令: ``` $ ip -s link show enp0s25 @@ -74,7 +74,8 @@ $ ip -s link show enp0s25 6131373 78152 0 0 0 0 ``` -另一个**ip**命令提供有关系统路由表的信息。 +另一个 `ip` 命令提供有关系统路由表的信息。 + ``` $ ip route show default via 192.168.0.1 dev enp0s25 proto static metric 100 @@ -82,7 +83,7 @@ default via 192.168.0.1 dev enp0s25 proto static metric 100 192.168.0.0/24 dev enp0s25 proto kernel scope link src 192.168.0.24 metric 100 ``` -**ip**命令是非常通用的。 您可以从**ip**命令及其来自[Red Hat][1]的选项获得有用的备忘单。 +`ip` 命令是非常通用的。 您可以从 `ip` 命令及其来自[Red Hat][1]的选项获得有用的备忘单。 -------------------------------------------------------------------------------- @@ -90,7 +91,7 @@ via: https://www.networkworld.com/article/3262045/linux/checking-your-network-co 作者:[Sandra Henry-Stocker][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 80c8d4c795124d7295c28fd3b566ff4fd9b8d866 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 11:52:53 +0800 Subject: [PATCH 0095/1057] PUB:20180309 How to check your network connections on Linux.md @Flowsnow https://linux.cn/article-9476-1.html --- .../20180309 How to check your network connections on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180309 How to check your network connections on Linux.md (100%) diff --git a/translated/tech/20180309 How to check your network connections on Linux.md b/published/20180309 How to check your network connections on Linux.md similarity index 100% rename from translated/tech/20180309 How to check your network connections on Linux.md rename to published/20180309 How to check your network connections on Linux.md From 68afc98f3dda226852072eea6a57e3850d97dd17 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 24 Mar 2018 11:53:51 +0800 Subject: [PATCH 0096/1057] Rename published/201406/20180201 How to Run Your Own Public Time Server on Linux.md to published/20180201 How to Run Your Own Public Time Server on Linux.md --- .../20180201 How to Run Your Own Public Time Server on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename published/{201406 => }/20180201 How to Run Your Own Public Time Server on Linux.md (100%) diff --git a/published/201406/20180201 How to Run Your Own Public Time Server on Linux.md b/published/20180201 How to Run Your Own Public Time Server on Linux.md similarity index 100% rename from published/201406/20180201 How to Run Your Own Public Time Server on Linux.md rename to published/20180201 How to Run Your Own Public Time Server on Linux.md From 9169f5a17568b5f376bbe72d740c9a0ba68c81ae Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 12:06:58 +0800 Subject: [PATCH 0097/1057] PRF:20180205 A File Transfer Utility To Download Only The New Parts Of A File.md @geekpi --- ...o Download Only The New Parts Of A File.md | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/translated/tech/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md b/translated/tech/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md index 1055aeacf4..444eb923c8 100644 --- a/translated/tech/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md +++ b/translated/tech/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md @@ -1,43 +1,41 @@ -一个仅下载文件新的部分的传输工具 +Zsync:一个仅下载文件新的部分的传输工具 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/02/Linux-1-720x340.png) -仅仅因为网费每天变得越来越便宜,你也不应该重复下载相同的东西来浪费你的流量。一个很好的例子就是下载 Ubuntu 或任何 Linux 镜像的开发版本。如你所知,Ubuntu 开发人员每隔几个月就会发布一次日常构建、alpha、beta 版 ISO 镜像以供测试。在过去,一旦发布我就会下载这些镜像,并审查每个版本。现在不用了!感谢 **Zsync** 文件传输程序。现在可以仅下载 ISO 镜像新的部分。这将为你节省大量时间和 Internet 带宽。不仅时间和带宽,它将为你节省服务端和客户端的资源。 +就算是网费每天变得越来越便宜,你也不应该重复下载相同的东西来浪费你的流量。一个很好的例子就是下载 Ubuntu 或任何 Linux 镜像的开发版本。如你所知,Ubuntu 开发人员每隔几个月就会发布一次日常构建、alpha、beta 版 ISO 镜像以供测试。在过去,一旦发布我就会下载这些镜像,并审查每个版本。现在不用了!感谢 Zsync 文件传输程序。现在可以仅下载 ISO 镜像新的部分。这将为你节省大量时间和 Internet 带宽。不仅时间和带宽,它将为你节省服务端和客户端的资源。 -Zsync 使用与 **Rsync** 相同​​的算法,但它只下载文件的新部分,你会得到一份已有文件旧版本的副本。 Rsync 主要用于在计算机之间同步数据,而 Zsync 则用于分发数据。简单地说,可以使用 Zsync 将中心的一个文件分发给数千个下载者。它在 Artistic License V2 许可证下发布,完全免费且开源。 +Zsync 使用与 Rsync 相同​​的算法,如果你会得到一份已有文件旧版本,它只下载该文件新的部分。 Rsync 主要用于在计算机之间同步数据,而 Zsync 则用于分发数据。简单地说,可以使用 Zsync 将中心的一个文件分发给数千个下载者。它在 Artistic License V2 许可证下发布,完全免费且开源。 ### 安装 Zsync Zsync 在大多数 Linux 发行版的默认仓库中有。 -在 **Arch Linux** 及其衍生版上,使用命令安装它: +在 Arch Linux 及其衍生版上,使用命令安装它: ``` $ sudo pacman -S zsync - ``` -在 **Fedora** 上: +在 Fedora 上,启用 Zsync 仓库: -启用 Zsync 仓库: ``` $ sudo dnf copr enable ngompa/zsync - ``` 并使用命令安装它: + ``` $ sudo dnf install zsync - ``` -在 **Debian、Ubuntu、Linux Mint** 上: +在 Debian、Ubuntu、Linux Mint 上: + ``` $ sudo apt-get install zsync - ``` -对于其他发行版,你可以从 [**Zsync 下载页面**][1]下载二进制文件,并手动编译安装它,如下所示。 +对于其他发行版,你可以从 [Zsync 下载页面][1]下载二进制打包文件,并手动编译安装它,如下所示。 + ``` $ wget http://zsync.moria.org.uk/download/zsync-0.6.2.tar.bz2 $ tar xjf zsync-0.6.2.tar.bz2 @@ -45,44 +43,41 @@ $ cd zsync-0.6.2/ $ configure $ make $ sudo make install - ``` ### 用法 -请注意,**只有当人们提供 zsync 下载时,zsync 才有用**。目前,Debian、Ubuntu(所有版本)的 ISO 镜像都可以用 .zsync 下载。例如,请访问以下链接。 +请注意,只有当人们提供 zsync 下载方式时,zsync 才有用。目前,Debian、Ubuntu(所有版本)的 ISO 镜像都有 .zsync 下载链接。例如,请访问以下链接。 -你可能注意到,Ubuntu 18.04 LTS 每日构建版有直接的 ISO 和 .zsync 文件。如果你下载 .ISO 文件,则必须在 ISO 更新时下载完整的 ISO 文件。但是,如果你下载的是 .zsync 文件,那么 Zsync 将在未来仅下载新的更改。你不需要每次都下载整个 ISO 映像。 +你可能注意到,Ubuntu 18.04 LTS 每日构建版有直接的 ISO 和 .zsync 文件。如果你下载 .ISO 文件,则必须在 ISO 更新时下载完整的 ISO 文件。但是,如果你下载的是 .zsync 文件,那么 Zsync 以后仅会下载新的更改。你不需要每次都下载整个 ISO 映像。 .zsync 文件包含 zsync 程序所需的元数据。该文件包含 rsync 算法的预先计算的校验和。它在服务器上生成一次,然后由任意数量的下载器使用。要使用 Zsync 客户端程序下载 .zsync 文件,你只需执行以下操作: + ``` $ zsync <.zsync-file-URL> - ``` 例如: + ``` $ zsync http://cdimage.ubuntu.com/ubuntu/daily-live/current/bionic-desktop-amd64.iso.zsync - ``` 如果你的系统中已有以前的镜像文件,那么 Zsync 将计算远程服务器中旧文件和新文件之间的差异,并仅下载新的部分。你将在终端看见计算过程一系列的点或星星。 -如果你下载的文件的旧版本存在于当前工作目录,那么 Zsync 将只下载新的部分。下载完成后,你将看到两个镜像,一个你刚下载的镜像和以 **.iso.zs-old** 为扩展名的旧镜像。 +如果你下载的文件的旧版本存在于当前工作目录,那么 Zsync 将只下载新的部分。下载完成后,你将看到两个镜像,一个你刚下载的镜像和以 .iso.zs-old 为扩展名的旧镜像。 如果没有找到相关的本地数据,Zsync 会下载整个文件。 ![](http://www.ostechnix.com/wp-content/uploads/2018/02/Zsync-1.png) -你可以随时按 **CTRL-C** 取消下载过程。 +你可以随时按 `CTRL-C` 取消下载过程。 试想一下,如果你直接下载 .ISO 文件或使用 torrent,每当你下载新镜像时,你将损失约 1.4GB 流量。因此,Zsync 不会下载整个 Alpha、beta 和日常构建映像,而只是在你的系统上下载了 ISO 文件的新部分,并在系统中有一个旧版本的拷贝。 -今天就到这里。希望对你有帮助。我将很快另外写一篇有用的指南。在此之前,请继续关注 OSTechNix! - -干杯! - +今天就到这里。希望对你有帮助。我将很快另外写一篇有用的指南。在此之前,请保持关注! +干杯! -------------------------------------------------------------------------------- @@ -90,7 +85,7 @@ via: https://www.ostechnix.com/zsync-file-transfer-utility-download-new-parts-fi 作者:[SK][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 4bcc712074b1483e723c12d763e2527fef3c7d5d Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 24 Mar 2018 12:07:17 +0800 Subject: [PATCH 0098/1057] PUB:20180205 A File Transfer Utility To Download Only The New Parts Of A File.md @geekpi --- ...e Transfer Utility To Download Only The New Parts Of A File.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md (100%) diff --git a/translated/tech/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md b/published/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md similarity index 100% rename from translated/tech/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md rename to published/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md From 3bc757346b314f5a40ccce445f592bf4fc485c26 Mon Sep 17 00:00:00 2001 From: yizhuyan Date: Sat, 24 Mar 2018 13:20:24 +0800 Subject: [PATCH 0099/1057] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=AF=95?= =?UTF-8?q?=EF=BC=8C=E7=94=B3=E8=AF=B7=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...On Linux - Unix Web Server DocumentRoot.md | 154 ------------------ 1 file changed, 154 deletions(-) delete mode 100644 sources/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md diff --git a/sources/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md b/sources/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md deleted file mode 100644 index d5b31e5120..0000000000 --- a/sources/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md +++ /dev/null @@ -1,154 +0,0 @@ -translating by yizhuoyan - -How To Set Readonly File Permissions On Linux / Unix Web Server DocumentRoot -====== - -How do I set a read-only permission for all of my files stored in /var/www/html/ directory? - -You can use the chmod command to set read-only permission for all files on a Linux / Unix / macOS / Apple OS X / *BSD operating systems. This page explains how to setup read only file permission on Linux or Unix web server such as Nginx, Lighttpd, Apache and more. - -[![Proper read-only permissions for Linux/Unix Nginx/Apache web server's directory][1]][1] - -### How to set files in read-only mode - - -The syntax is: -``` -### use only for files ## -chmod 0444 /var/www/html/* -chmod 0444 /var/www/html/*.php -``` - -### How to to set directories in read-only mode - -TO set directories in read-only mode, enter: -``` -### use only for dirs ## -chmod 0444 /var/www/html/ -chmod 0444 /path/to/your/dir/ -# *************************************************************************** -# Say webserver user/group is www-data, and file-owned by ftp-data user/group -# *************************************************************************** -# All files/dirs are read-only -chmod -R 0444 /var/www/html/ -# All files/dir owned by ftp-data -chown -R ftp-data:ftp-data /var/www/html/ -# All directories and sub-dirs has 0445 permission (so that webserver user www-data can read our files) -find /var/www/html/ -type d -print0 | xargs -0 -I {} chmod 0445 "{}" -``` -To find all files (including sub-directories in /var/www/html) and set read-only permission, enter: -``` -### works on files only ## -find /var/www/html -type f -iname "*" -print0 | xargs -I {} -0 chmod 0444 {} -``` - -However, you need to set set read-only and execute permission on /var/www/html and all sub-directories so that web server can enter into your DocumentRoot, enter: -``` -### works on dirs only ## -find /var/www/html -type d -iname "*" -print0 | xargs -I {} -0 chmod 0544 {} -``` - -### A warning about write permission - -Please note that write access on a directory /var/www/html/ allows anyone to remove or add new files. In other words, you may need to set a read-only permission for /var/www/html/ directory itself: -``` -### read-only web-root but web server allowed to read files ## -chmod 0555 /var/www/html -``` - -In some cases you can change file owner and group to set tight permissions as per your setup: -``` -### Say /var/www/html is owned by normal user, you can set it to root:root or httpd:httpd (recommended) ### -chown -R root:root /var/www/html/ - -### Make sure apache user owns /var/www/html/ ## -chown -R apache:apache /var/www/html/ -``` - -### A note about NFS exported directories - -You can specify whether the directory should have [read-only or read/write permissions using /etc/exports][2] file. This file defines the various shares on the NFS server and their permissions. A few examples: -``` -# Read-only access to anyone -/var/www/html *(ro,sync) - -# Read-write access to a client on 192.168.1.10 (upload.example.com) -/var/www/html 192.168.1.10(rw,sync) -``` - -### A note about read-only Samba (CIFS) share for MS-Windows clients - -To share sales as read-only, update smb.conf as follows: -``` -[sales] -comment = Sales Data -path = /export/cifs/sales -read only = Yes -guest ok = Yes -``` - -### A note about file systems table - -You can use the /etc/fstab file on Unix or Linux to configure to mount certain files in read-only mode. You need to have a dedicated partition. Do not set / or other system partitions in read-only mode. In this example /srv/html is set to read-only mode using /etc/fstab file: -``` -/dev/sda6 /srv/html ext4 ro 1 1 -``` - -You can use the mount command to [remount partition in read-only mode][3] (run it as the root user): -``` -# mount -o remount,ro /dev/sda6 /srv/html -``` -OR -``` -# mount -o remount,ro /srv/html -``` -The above command will try to attempt to remount an already-mounted filesystem at /srv/html. This is commonly used to change the mount flags for a filesystem, especially to make a readonly filesystem writeable. It does not change device or mount point. To make file system writable again, enter: -``` -# mount -o remount,rw /dev/sda6 /srv/html -``` -OR -``` -# mount -o remount,rw /srv/html -``` - -### Linux: chattr Command - -You can change file [attributes on a Linux file system to read-only][4] using the chattr command: -``` -chattr +i /path/to/file.php -chattr +i /var/www/html/ - -# find everything in /var/www/html and set to read-only # -find /var/www/html -iname "*" -print0 | xargs -I {} -0 chattr +i {} -``` - -To remove read-only attribute pass the -i option: -``` -# chattr -i /path/to/file.php -``` -FreeBSD, Mac OS X and other BSD unix user can use the [chflags command][5]: -``` -### set read-only ## -chflags schg /path/to/file.php - -# remove read-only ## -chflags noschg /path/to/file.php -``` - - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/faq/howto-set-readonly-file-permission-in-linux-unix/ - -作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz -[1]:https://www.cyberciti.biz/media/new/faq/2012/04/linux-unix-set-read-only-file-system-permission-for-apache-nginx.jpg -[2]:https://www.cyberciti.biz//www.cyberciti.biz/faq/centos-fedora-rhel-nfs-v4-configuration/ -[3]:https://www.cyberciti.biz/faq/howto-freebsd-remount-partition/ -[4]:https://www.cyberciti.biz/tips/linux-password-trick.html -[5]:https://www.cyberciti.biz/tips/howto-write-protect-file-with-immutable-bit.html From fb6cbb154a00edbe2fa364b488f0b78653c26d2e Mon Sep 17 00:00:00 2001 From: yizhuyan Date: Sat, 24 Mar 2018 13:21:56 +0800 Subject: [PATCH 0100/1057] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md --- ...On Linux - Unix Web Server DocumentRoot.md | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 translated/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md diff --git a/translated/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md b/translated/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md new file mode 100644 index 0000000000..7793a7f2da --- /dev/null +++ b/translated/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md @@ -0,0 +1,167 @@ + +如何在Linux/Unix中的Web服务根文档目录(DocumentRoot)上设置只读文件权限 +====== +我是如何对存放在/var/www/html/目录中的所有我的文件设置只读权限的? + + +你可以使用`chmod`命令对Linux / Unix / macOS / Apple OS X / *BSD操作系统上的所有文件来设置只读权限。这篇文章介绍如何在Linux/Unix的web服务器(如 Nginx, Lighttpd, Apache等)上来设置只读文件权限。 +[![Proper read-only permissions for Linux/Unix Nginx/Apache web server's directory][1]][1] + +### 如何设置文件为只读模式 + + +语法为: + +``` +### 仅针对文件 ## +chmod 0444 /var/www/html/* +chmod 0444 /var/www/html/*.php +``` + +### 如何设置目录为只读模式 + +语法为: +``` +### 仅针对目录## +chmod 0444 /var/www/html/ +chmod 0444 /path/to/your/dir/ +# *************************************************************************** +# Say webserver user/group is www-data, and file-owned by ftp-data user/group +# 假如webserver用户/用户组是www-data ,文件拥有者是ftp-data用户/用户组 +# *************************************************************************** +# 设置目录所有文件为只读 +chmod -R 0444 /var/www/html/ +#设置文件/目录拥有者为ftp-data +chown -R ftp-data:ftp-data /var/www/html/ +# 所有目录和子目录的权限为0445 (这样webserver用户或用户组就可以读取我们的文件) +find /var/www/html/ -type d -print0 | xargs -0 -I {} chmod 0445 "{}" +``` +找到所有/var/www/html下的所有文件(包括子目录),键入: + +``` +### 仅对文件有效## +find /var/www/html -type f -iname "*" -print0 | xargs -I {} -0 chmod 0444 {} +``` +然而,你需要在/var/www/html目录及其子目录上设置只读和执行权限,如此才能让web server能够访问根目录,键入: + +``` +### 仅对目录有效 ## +find /var/www/html -type d -iname "*" -print0 | xargs -I {} -0 chmod 0544 {} +``` + +### 警惕写权限 + + +请注意在/var/www/html/目录上的写权限会允许任何人删除文件或添加新文件。也就是说,你可能需要设置一个只读权限给/var/www/html/目录本身。 +``` +### web根目录只读## +chmod 0555 /var/www/html +``` +在某些情况下,根据你的设置要求,你可以改变文件的属主和属组来设置严格的权限。 +``` +### 如果/var/www/html目录的拥有人是普通用户,你可以设置拥有人为: root:root 或 httpd:httpd (推荐) ### +chown -R root:root /var/www/html/ + +### 确保apache拥有/var/www/html/ ## +chown -R apache:apache /var/www/html/ +``` + +### 关于NFS导出目录 + +你可以在/etc/exports文件中指定哪个目录应该拥有[只读或者读写权限 ][2] . 这个文件定义各种各样的共享在NFS服务器和他们的权限。如: + +``` +# 对任何人只读权限 +/var/www/html *(ro,sync) + +# 对192.168.1.10(upload.example.com)客户端读写权限访问 +/var/www/html 192.168.1.10(rw,sync) +``` + + +### 关于Samba (CIFS)只读共享对MS-Windows客户端 + + +共享sales为只读,更新smb.conf,如下: +``` +[sales] +comment = Sales Data +path = /export/cifs/sales +read only = Yes +guest ok = Yes +``` + +### 关于文件系统表(file systems table) + +你可以在Unix/Linux上的/etc/fstab文件中配置挂载某些文件为只读模式。 +你需要有专用分区,不要设置其他系统分区为只读模式。 + +如下在/etc/fstab文件中设置/srv/html为只读模式。 +``` +/dev/sda6 /srv/html ext4 ro 1 1 +``` +你可以使用`mount`命令[重新挂载分区为只读模式][3](使用root用户) + +``` +# mount -o remount,ro /dev/sda6 /srv/html +``` +或者 +``` +# mount -o remount,ro /srv/html +``` + + +上面的命令会尝试重新挂载已挂载的文件系统在/srv/html上。这是改变文件系统挂载标志的常用方法,特别是让只读文件改为可写的。这种方式不会改变设备或者挂载点。让文件变得再次可写,键入: +``` +# mount -o remount,rw /dev/sda6 /srv/html +``` +或 +``` +# mount -o remount,rw /srv/html +``` + +### Linux: chattr 命令 + + +你可以在Linux文件系统上使用`chattr`命令[改变文件属性为只读][4],如: +``` +chattr +i /path/to/file.php +chattr +i /var/www/html/ + +# 查找任何在/var/www/html下的文件并设置为只读# +find /var/www/html -iname "*" -print0 | xargs -I {} -0 chattr +i {} +``` + + +通过提供`-i`选项可删除只读属性 +``` +chattr -i /path/to/file.php +``` + +FreeBSD, Mac OS X 和其他BSD Unix用户可使用[`chflags`命令][5]: + +``` +### 设置只读 ## +chflags schg /path/to/file.php + +### 删除只读 ## +chflags noschg /path/to/file.php +``` + + +-------------------------------------------------------------------------------- + +来源: https://www.cyberciti.biz/faq/howto-set-readonly-file-permission-in-linux-unix/ + +作者:[Vivek Gite][a] +译者:[yizhuoyan](https://github.com/yizhuoyan) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz +[1]:https://www.cyberciti.biz/media/new/faq/2012/04/linux-unix-set-read-only-file-system-permission-for-apache-nginx.jpg +[2]:https://www.cyberciti.biz//www.cyberciti.biz/faq/centos-fedora-rhel-nfs-v4-configuration/ +[3]:https://www.cyberciti.biz/faq/howto-freebsd-remount-partition/ +[4]:https://www.cyberciti.biz/tips/linux-password-trick.html +[5]:https://www.cyberciti.biz/tips/howto-write-protect-file-with-immutable-bit.html From 725a14b4f31973ce69db9cc40b61c86b0599ce7a Mon Sep 17 00:00:00 2001 From: leemeans <1808577072@qq.com> Date: Sat, 24 Mar 2018 13:41:22 +0800 Subject: [PATCH 0101/1057] last chapter left --- ... block local spoofed addresses using the Linux firewall.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md b/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md index cd3dddd934..a699744e75 100644 --- a/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md +++ b/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md @@ -24,10 +24,14 @@ With the iptables firewall, you can create policies, or ordered sets of rules, w 有了iptables防火墙,你可以创建策略或者有序的规则集,规则集可以告诉内核如何对待特定的数据包。在内核中的是Netfilter框架。Netfilter既是框架也是iptables防火墙的工程名。作为一个框架,Netfilter允许iptables勾取被设计来操作数据包的函数。概括地说,iptables依靠Netfilter框架构筑诸如过滤数据包数据的功能。 Each iptables rule is applied to a chain within a table. An iptables chain is a collection of rules that are compared against packets with similar characteristics, while a table (such as nat or mangle) describes diverse categories of functionality. For instance, a mangle table alters packet data. Thus, specialized rules that alter packet data are applied to it, and filtering rules are applied to the filter table because the filter table filters packet data. +每个iptables规则都被应用到一个含表的链中。一个iptables链就是一个比较包中相似字符的规则的集合。而表(例如nat或者mangle)则描述不同的功能目录。例如,一个mangle表转化包数据。因此,特定的改变包数据的规则被应用到这里,而过滤规则被应用到filter表,因为filter表过滤包数据。 Iptables rules have a set of matches, along with a target, such as `Drop` or `Deny`, that instructs iptables what to do with a packet that conforms to the rule. Thus, without a target and a set of matches, iptables can’t effectively process packets. A target simply refers to a specific action to be taken if a packet matches a rule. Matches, on the other hand, must be met by every packet in order for iptables to process them. +iptables规则有一系列匹配,伴随着一个诸如`Drop`或者`Deny`的目标,这可以告诉iptables对一个包做什么符合规则。因此,没有一个目标和一系列匹配,iptables就不能有效地处理包。如果一个包匹配一条规则,一个目标简单地指向一个将要采取的特定措施。另一方面,为了让iptables处理,匹配必须被每个包满足吗。 + Now that we understand how the iptables firewall operates, let's look at how to use iptables firewall to detect and reject or drop spoofed addresses. +现在我们已经知道iptables防火墙如何工作,开始着眼于如何使用iptables防火墙检测并拒绝或丢弃被欺骗的地址吧。 ### Turning on source address verification From dcdde642f32a24227a9e6c7f64dfa70c1c4f1aff Mon Sep 17 00:00:00 2001 From: yizhuyan Date: Sat, 24 Mar 2018 13:49:08 +0800 Subject: [PATCH 0102/1057] translating by yizhuoyan --- ...Folders From Accidental Deletion Or Modification In Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md b/sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md index f8071c02bc..e2c00cbb75 100644 --- a/sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md +++ b/sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md @@ -1,3 +1,5 @@ +translating by yizhuoyan + Prevent Files And Folders From Accidental Deletion Or Modification In Linux ====== From 61793798fba2e5ae0028e2ddde2bf22c6703fa5f Mon Sep 17 00:00:00 2001 From: amwps290 Date: Sat, 24 Mar 2018 14:03:08 +0800 Subject: [PATCH 0103/1057] Delete 20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md --- ...aging Systemd Units From Linux Terminal.md | 111 ------------------ 1 file changed, 111 deletions(-) delete mode 100644 sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md diff --git a/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md b/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md deleted file mode 100644 index 9c6933c18b..0000000000 --- a/sources/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md +++ /dev/null @@ -1,111 +0,0 @@ -translating by amwps290 -chkservice – A Tool For Managing Systemd Units From Linux Terminal -====== -systemd stand for system daemon is a new init system and system manager which is become very popular and widely adapted new standard init system by most of Linux distributions. - -Systemctl is a systemd utility which is help us to manage systemd daemons. It control system startup and services, uses parallelization, socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and automount points. - -Also it offers logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. - -### What Is chkservice - -[chkservice][1] is an ncurses-based tool for managing systemd units from the terminal. It provides the user with a comprehensive view of all systemd services and allows them to be changed easily. - -It requires super user privileges to make changes into unit states or sysv scripts. - -### How To Install chkservice In Linux - -We can install chkservice in two ways, either package or manual method. - -For **`Debian/Ubuntu`** , use [APT-GET Command][2] or [APT Command][3]to install chkservice. -``` -$ sudo add-apt-repository ppa:linuxenko/chkservice -$ sudo apt-get update -$ sudo apt-get install chkservice - -``` - -For **`Arch Linux`** based systems, use [Yaourt Command][4] or [Packer Command][5] to install chkservice from AUR repository. -``` -$ yaourt -S chkservice -or -$ packer -S chkservice - -``` - -For **`Fedora`** , use [DNF Command][6] to install chkservice. -``` -$ sudo dnf copr enable srakitnican/default -$ sudo dnf install chkservice - -``` - -For **`Debian Based Systems`** , use [DPKG Command][7] to install chkservice. -``` -$ wget https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.deb -$ sudo dpkg -i chkservice_0.1.0-amd64.deb - -``` - -For **`RPM Based Systems`** , use [DNF Command][8] to install chkservice. -``` -$ sudo yum install https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.rpm - -``` - -### How To Use chkservice - -Just fire the following command to launch the chkservice tool. The output is split to four parts. - - * **`First Part:`** This part shows about daemons status like, enabled [X] or disabled [] or static [s] or masked -m- - * **`Second Part:`** This part shows daemons status like, started [ >] or stopped [=] - * **`Third Part:`** This part shows the unit name - * **`Fourth Part:`** This part showing the unit short description - - -``` -$ sudo chkservice - -``` - -![][10] - -To view help page, hit `?` button. This will shows you available options to manage the systemd services. -![][11] - -Select the units, which you want to enable or disable then hit `Space Bar` button. -![][12] - -Select the units, which you want to start or stop then hit `s` button. -![][13] - -Select the units, which you want to reload then hit `r` button. After hit `r` key, you can see the `updated` message at the top. -![][14] - -Hit `q` button to quit the utility. - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/chkservice-a-tool-for-managing-systemd-units-from-linux-terminal/ - -作者:[Ramya Nuvvula][a] -译者:[译者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/ramya/ -[1]:https://github.com/linuxenko/chkservice -[2]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ -[3]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ -[4]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ -[5]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ -[6]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ -[7]:https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/ -[8]:https://www.2daygeek.com/rpm-command-examples/ -[9]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[10]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-1.png -[11]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-2.png -[12]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-3.png -[13]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-4.png -[14]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-5.png From 7d5f6fd603b952c7a4ec64362a369c1acbd9a6cc Mon Sep 17 00:00:00 2001 From: amwps290 Date: Sat, 24 Mar 2018 14:07:50 +0800 Subject: [PATCH 0104/1057] translated by amwps290 --- ...aging Systemd Units From Linux Terminal.md | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md diff --git a/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md b/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md new file mode 100644 index 0000000000..29300c3b02 --- /dev/null +++ b/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md @@ -0,0 +1,119 @@ +# chkservice -Linux终端管理系统单元的工具 + +systemd 即系统守护进程是一个新的初始化系统和系统管理工具,这个 systemd 非常流行,大部分的 Linux 发行版开始使用这种新的初始化系统。 + +Systemctl 是一个 systemd 的工具,它可以帮助我们管理 systemd 守护进程。 它控制系统启动和服务,使用并行化方式,套接字和 D-Bus 激活启动服务,提供按需启动守护进程,使用 Linux 控制组跟踪进程,维护挂载和自动挂载点。 + +此外,它还提供了守护进程日志、用于控制基本系统配置如主机名、日期、地区、维护登录用户列表和运行容器和虚拟机、系统帐户、运行时目录和设置,以及守护进程来管理简单的网络配置、网络时间同步、日志转发和名称解析。 + +### 什么是 chkservice + +[chkservice][1] 是一个基于 ncurses 的在终端中管理系统资源的工具。它提供了一个非常全面的系统资源视图,可以使它们非常容易修改。 + +只有拥有超级管理权限才能够改变系统资源状态和系统启动脚本。 + +### 在 Linux 安装 chkservice + +我们可以通过两种方式安装 chkservice,通过包安装或者手动安装。 + +对于 `Debian/Ubuntu`,使用 [APT-GET Command][2] 或 [APT Command][3] 安装 chkservice. + +``` +$ sudo add-apt-repository ppa:linuxenko/chkservice +$ sudo apt-get update +$ sudo apt-get install chkservice + +``` + +对于 `Arch Linux` 系的系统,使用 [Yaourt Command][4] 或 [Packer Command][5] 从 AUR 库安装 chkservice。 + +``` +$ yaourt -S chkservice +or +$ packer -S chkservice + +``` + +对于 **`Fedora`** , 使用 [DNF Command][6] 安装 chkservice。 + +``` +$ sudo dnf copr enable srakitnican/default +$ sudo dnf install chkservice + +``` + +对于 `Debian` 系系统,使用 [DPKG Command][7] 安装 chkservice。 + +``` +$ wget https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.deb +$ sudo dpkg -i chkservice_0.1.0-amd64.deb + +``` + +对于 `RPM` 系的系统,使用 [DNF Command][8] 安装 chkservice。 + +``` +$ sudo yum install https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.rpm + +``` + +### 如何使用 chkservice + +只需输入以下命令即可启动 chkservice 工具。 输出分为四部分。 + + * **`第一部分:`** 这一部分显示了守护进程的状态,比如可用的 [X] 或者不可用的 [] 或者静态的 [s] 或者被掩藏的 -m- + * **`第二部分:`** 这一部分显示守护进程的状态例如开始 [ >] 或者停止 [=] + * **`第三部分:`** 这一部分显示单元的名称 + * **`第四部分:`** 这一部分简短地显示了守护进程的一些信息 + + +``` +$ sudo chkservice + +``` + +![][10] + +要查看帮助页面,点击 `?` 按钮。 这将向您显示管理 systemd 服务的可用选项。 + +![][11] + +选择要启用或禁用的守护进程,然后点击`空格键`按钮。 + +![][12] + +选择你想开始或停止的守护进程,然后点击 `s` 按钮。 + +![][13] + +选择要重新启动的守护进程,然后按 `r` 按钮。 点击 `r` 键后,您可以在顶部看到更新的提示。 + +![][14] + +按 `q` 按钮退出。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/chkservice-a-tool-for-managing-systemd-units-from-linux-terminal/ + +作者:[Ramya Nuvvula][a] +译者:[amwps290](https://github.com/amwps290) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com/author/ramya/ +[1]:https://github.com/linuxenko/chkservice +[2]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[3]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[4]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ +[5]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ +[6]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[7]:https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/ +[8]:https://www.2daygeek.com/rpm-command-examples/ +[9]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[10]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-1.png +[11]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-2.png +[12]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-3.png +[13]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-4.png +[14]:https://www.2daygeek.com/wp-content/uploads/2018/03/chkservice-to-manage-systemd-units-5.png From df180d06ce50dce935135c40f52c01ab448aa297 Mon Sep 17 00:00:00 2001 From: Means Lee Date: Sat, 24 Mar 2018 15:25:27 +0800 Subject: [PATCH 0105/1057] leemeans translated --- ...ofed addresses using the Linux firewall.md | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md b/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md index a699744e75..6c54c36164 100644 --- a/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md +++ b/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md @@ -1,59 +1,49 @@ -leemeans translating -How to block local spoofed addresses using the Linux firewall 如何使用Linux防火墙隔离局域网受欺骗地址 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_UnspokenBlockers_1110_A.png?itok=x8A9mqVA) -Attackers are finding sophisticated ways to penetrate even remote networks that are protected by intrusion detection and prevention systems. No IDS/IPS can halt or minimize attacks by hackers who are determined to take over your network. Improper configuration allows attackers to bypass all implemented network security measures. + 即便是被入侵检测和隔离系统保护的远程网络,黑客们也在寻找精致的方法入侵。IDS/IPS是不能停止或者减少那些想要接管你的网络的黑客的攻击的。不恰当的配置允许攻击者绕过所有部署的安全措施。 -In this article, I will explain how security engineers or system administrators can prevent these attacks. 在这篇文章中,我将会解释安全工程师或者系统管理员怎样可以避免这些攻击。 -Almost all Linux distributions come with a built-in firewall to secure processes and applications running on the Linux host. Most firewalls are designed as IDS/IPS solutions, whose primary purpose is to detect and prevent malicious packets from gaining access to a network. 几乎所有的Linux发行版都带着一个内建的防火墙来保护运行在Linux宿主机上的进程和应用程序。大多数都按照IDS/IPS解决方案设计,这样的设计的主要目的是检测和避免恶意包获取网络的进入权。 -A Linux firewall usually comes with two interfaces: iptables and ipchains. Most people refer to these interfaces as the "iptables firewall" or the "ipchains firewall." Both interfaces are designed as packet filters. Iptables acts as a stateful firewall, making decisions based on previous packets. Ipchains does not make decisions based on previous packets; hence, it is designed as a stateless firewall. Linux防火墙通常带有两个接口:iptable和ipchain程序。大多数人将这些接口称作iptables防火墙或者ipchains防火墙。这两个接口都被设计成包过滤器。iptables是有状态防火墙,基于先前的包做出决定。 -In this article, we will focus on the iptables firewall, which comes with kernel version 2.4 and beyond. 在这篇文章中,我们将会专注于内核2.4之后出现的iptables防火墙。 -With the iptables firewall, you can create policies, or ordered sets of rules, which communicate to the kernel how it should treat specific classes of packets. Inside the kernel is the Netfilter framework. Netfilter is both a framework and the project name for the iptables firewall. As a framework, Netfilter allows iptables to hook functions designed to perform operations on packets. In a nutshell, iptables relies on the Netfilter framework to build firewall functionality such as filtering packet data. 有了iptables防火墙,你可以创建策略或者有序的规则集,规则集可以告诉内核如何对待特定的数据包。在内核中的是Netfilter框架。Netfilter既是框架也是iptables防火墙的工程名。作为一个框架,Netfilter允许iptables勾取被设计来操作数据包的函数。概括地说,iptables依靠Netfilter框架构筑诸如过滤数据包数据的功能。 -Each iptables rule is applied to a chain within a table. An iptables chain is a collection of rules that are compared against packets with similar characteristics, while a table (such as nat or mangle) describes diverse categories of functionality. For instance, a mangle table alters packet data. Thus, specialized rules that alter packet data are applied to it, and filtering rules are applied to the filter table because the filter table filters packet data. 每个iptables规则都被应用到一个含表的链中。一个iptables链就是一个比较包中相似字符的规则的集合。而表(例如nat或者mangle)则描述不同的功能目录。例如,一个mangle表转化包数据。因此,特定的改变包数据的规则被应用到这里,而过滤规则被应用到filter表,因为filter表过滤包数据。 -Iptables rules have a set of matches, along with a target, such as `Drop` or `Deny`, that instructs iptables what to do with a packet that conforms to the rule. Thus, without a target and a set of matches, iptables can’t effectively process packets. A target simply refers to a specific action to be taken if a packet matches a rule. Matches, on the other hand, must be met by every packet in order for iptables to process them. iptables规则有一系列匹配,伴随着一个诸如`Drop`或者`Deny`的目标,这可以告诉iptables对一个包做什么符合规则。因此,没有一个目标和一系列匹配,iptables就不能有效地处理包。如果一个包匹配一条规则,一个目标简单地指向一个将要采取的特定措施。另一方面,为了让iptables处理,匹配必须被每个包满足吗。 -Now that we understand how the iptables firewall operates, let's look at how to use iptables firewall to detect and reject or drop spoofed addresses. 现在我们已经知道iptables防火墙如何工作,开始着眼于如何使用iptables防火墙检测并拒绝或丢弃被欺骗的地址吧。 -### Turning on source address verification +### 打开源地址验证 -The first step I, as a security engineer, take when I deal with spoofed addresses from remote hosts is to turn on source address verification in the kernel. +作为一个安全工程师,在处理远程主机被欺骗地址的时候,我采取的第一步是在内核打开源地址验证。 -Source address verification is a kernel-level feature that drops packets pretending to come from your network. It uses the reverse path filter method to check whether the source of the received packet is reachable through the interface it came in. +源地址验证是一种内核层级的特性,这种特性丢弃那些伪装成来自你的网络的包。这种特性使用反向路径过滤器方法来检查收到的包的源地址是否可以通过包到达的接口可以到达。(译注:到达的包的源地址应该可以从它到达的网络接口反向到达,只需反转源地址和目的地址就可以达到这样的效果) -To turn source address verification, utilize the simple shell script below instead of doing it manually: +利用下面简单的脚本可以打开源地址验证而不用手工操作: ``` #!/bin/sh -#author’s name: Michael K Aboagye +#作者: Michael K Aboagye -#purpose of program: to enable reverse path filtering +#程序目标: 打开反向路径过滤 -#date: 7/02/18 +#日期: 7/02/18 -#displays “enabling source address verification” on the screen +#在屏幕上显示 “enabling source address verification” echo -n "Enabling source address verification…" -#Overwrites the value 0 to 1 to enable source address verification +#将值0覆盖为1来打开源地址验证 echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter @@ -61,29 +51,28 @@ echo "completed" ``` -The preceding script, when executed, displays the message `Enabling source address verification` without appending a new line. The default value of the reverse path filter is 0.0, which means no source validation. Thus, the second line simply overwrites the default value 0 to 1. 1 means that the kernel will validate the source by confirming the reverse path. +先前的脚本在执行的时候只显示了`Enabling source address verification`这条信息而没有添加新行。默认的反向路径过滤的值是0,0表示没有源验证。因此,第二行简单地将默认值0覆盖为1。1表示内核将会通过确认反向路径来验证源(地址)。 -Finally, you can use the following command to drop or reject spoofed addresses from remote hosts by choosing either one of these targets: `DROP` or `REJECT`. However, I recommend using `DROP` for security reasons. +最后,你可以使用下面的命令通过选择`DROP`或者`REJECT`目标中的一个来丢弃或者拒绝来自远端主机的被欺骗地址。但是,处于安全原因的考虑,我建议使用`DROP`目标。 -Replace the “IP-address” placeholder with your own IP address, as shown below. Also, you must choose to use either `REJECT` or `DROP`; the two targets don’t work together. +像下面这样,用你自己的IP地址代替“IP-address” 占位符。另外,你必须选择使用`REJECT`或者`DROP`中的一个,这两个目标不能同时使用。 ``` -   iptables -A INPUT -i internal_interface -s IP_address -j REJECT / DROP   + iptables -A INPUT -i internal_interface -s IP_address -j REJECT / DROP -    iptables -A INPUT -i internal_interface -s 192.168.0.0/16  -j REJECT/ DROP + iptables -A INPUT -i internal_interface -s 192.168.0.0/16 -j REJECT/ DROP ``` -This article provides only the basics of how to prevent spoofing attacks from remote hosts using the iptables firewall. - +这篇文章只提供了如何使用iptables防火墙来避免远端欺骗攻击的基础(知识)。 -------------------------------------------------------------------------------- via: https://opensource.com/article/18/2/block-local-spoofed-addresses-using-linux-firewall 作者:[Michael Kwaku Aboagye][a] -译者:[译者ID](https://github.com/译者ID) +译者:[leemeans](https://github.com/leemeans) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From bf33223acd7d9a224dd0de3ccc5f12b1d76752ef Mon Sep 17 00:00:00 2001 From: leemeans <1808577072@qq.com> Date: Sat, 24 Mar 2018 15:54:23 +0800 Subject: [PATCH 0106/1057] leemeans translating [leemeans translating]A Command Line Productivity Tool For Tracking Work Hours --- ...9 A Command Line Productivity Tool For Tracking Work Hours.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md b/sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md index b9fb95c8bd..24cbe8e1fa 100644 --- a/sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md +++ b/sources/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md @@ -1,3 +1,4 @@ +leemeans translating A Command Line Productivity Tool For Tracking Work Hours ====== From 82a073f9b74ee3d58a883d1e02d6a04cb6fc89ac Mon Sep 17 00:00:00 2001 From: HankChow Date: Sat, 24 Mar 2018 22:54:41 +0800 Subject: [PATCH 0107/1057] hankchow translating --- .../tech/20180215 Check Linux Distribution Name and Version.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180215 Check Linux Distribution Name and Version.md b/sources/tech/20180215 Check Linux Distribution Name and Version.md index 5336c31c4e..e1ab341eb2 100644 --- a/sources/tech/20180215 Check Linux Distribution Name and Version.md +++ b/sources/tech/20180215 Check Linux Distribution Name and Version.md @@ -1,3 +1,5 @@ +hankchow translating + Check Linux Distribution Name and Version ====== You have joined new company and want to install some software’s which is requested by DevApp team, also want to restart few of the service after installation. What to do? From 75940dfad3adbd122742d676319765c59682f340 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Sun, 25 Mar 2018 07:32:20 +0800 Subject: [PATCH 0108/1057] 2018-03-25 --- ...hy Linux is better than Windows or macOS for security.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index f55622720d..e81061627c 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -5,13 +5,13 @@ fuzheng1998 translating ![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg) -企业投入了大量时间、精力和金钱来保障系统的安全性。The most security-conscious might have a security operations center. They of course use firewalls and antivirus tools. They probably spend a lot of time monitoring their networks, looking for telltale anomalies that could indicate a breach. What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. +企业投入了大量时间、精力和金钱来保障系统的安全性。安全意识最强的可能就是有一个安全的运转中心。他们肯定用了防火墙以及反病毒软件。他们也可能花费大量时间监控网络,They probably spend a lot of time monitoring their networks, looking for telltale anomalies that could indicate a breach. What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. But how many have given much thought to one of the cornerstones of their digital operations: the operating systems deployed on the workforce’s PCs? Was security even a factor when the desktop OS was selected? 这就产生了一个 IT 人士都应该能回答的问题:哪种操作系统对于一般性使用最安全呢? -我们问了一些专家他们对于以下三种选项的看法:Windows, 最复杂的平台也是最易受欢迎的桌面操作系统;macOS X,基于 FreeBSD 的 Unix 操作系统,驱动着苹果的 Macintosh 系列机运行;还有 Linux,这里我们的意思是所有的 Linux 发行版以及与基于 Unix 的操作系统相关的系统。 +我们问了一些专家他们对于以下三种选项的看法:Windows, 最复杂的平台也是最易受欢迎的桌面操作系统;macOS X,基于 FreeBSD 的 Unix 操作系统,驱动着苹果的 Macintosh 系列机运行;还有 Linux,这里我们指的是所有的 Linux 发行版以及与基于 Unix 的操作系统相关的系统。 ### 我们怎么会这样How we got here @@ -19,7 +19,7 @@ One reason enterprises might not have evaluated the security of the OS they depl Still, would it be wise to reconsider? Are the three leading desktop OSes different enough in their approach to security to make a change worthwhile? -Certainly the threats confronting enterprise systems have changed in the last few years. Attacks have become far more sophisticated. The lone teen hacker that once dominated the public imagination has been supplanted by well-organized networks of criminals and shadowy, government-funded organizations with vast computing resources. +当然商业系统面临的威胁近几年已经改变了。攻击变得成熟多了。Certainly the threats confronting enterprise systems have changed in the last few years. Attacks have become far more sophisticated. The lone teen hacker that once dominated the public imagination has been supplanted by well-organized networks of criminals and shadowy, government-funded organizations with vast computing resources. Like many of you, I have firsthand experience of the threats that are out there: I have been infected by malware and viruses on numerous Windows computers, and I even had macro viruses that infected files on my Mac. More recently, a widespread automated hack circumvented the security on my website and infected it with malware. The effects of such malware were always initially subtle, something you wouldn’t even notice, until the malware ended up so deeply embedded in the system that performance started to suffer noticeably. One striking thing about the infestations was that I was never specifically targeted by the miscreants; nowadays, it’s as easy to attack 100,000 computers with a botnet as it is to attack a dozen. From 8d10b6fcf0aee7b3a3d53544bf62106b873c3de6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 25 Mar 2018 09:34:12 +0800 Subject: [PATCH 0109/1057] Rename translated/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md to translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md --- ...ly File Permissions On Linux - Unix Web Server DocumentRoot.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/{ => tech}/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md (100%) diff --git a/translated/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md b/translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md similarity index 100% rename from translated/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md rename to translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md From 2102a4dede86a037925044ab0b0bae81ffde5d94 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 25 Mar 2018 09:38:08 +0800 Subject: [PATCH 0110/1057] Rename sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md to translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md --- ...w to block local spoofed addresses using the Linux firewall.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20180227 How to block local spoofed addresses using the Linux firewall.md (100%) diff --git a/sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md b/translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md similarity index 100% rename from sources/tech/20180227 How to block local spoofed addresses using the Linux firewall.md rename to translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md From 6368f7488f276cc8290ea9f39bf5658646a792ab Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 10:34:01 +0800 Subject: [PATCH 0111/1057] PRF:20140225 How To Safely Generate A Random Number - Quarrelsome.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @kimii 翻译的很好! --- ... Generate A Random Number - Quarrelsome.md | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/translated/tech/20140225 How To Safely Generate A Random Number - Quarrelsome.md b/translated/tech/20140225 How To Safely Generate A Random Number - Quarrelsome.md index 23765b77ba..000b50f159 100644 --- a/translated/tech/20140225 How To Safely Generate A Random Number - Quarrelsome.md +++ b/translated/tech/20140225 How To Safely Generate A Random Number - Quarrelsome.md @@ -1,57 +1,55 @@ -如何安全地生成随机数 - 争论 +如何安全地生成随机数 ====== + ### 使用 urandom -使用 urandom。使用 urandom。使用 urandom。使用 urandom。使用 urandom。使用 urandom。 +使用 [urandom][1]!使用 [urandom][2]!使用 [urandom][3]! + +使用 [urandom][4]!使用 [urandom][5]!使用 [urandom][6]! ### 但对于密码学密钥呢? -仍然使用 urandom[6]。 +仍然使用 [urandom][6]。 -### 为什么不是 SecureRandom, OpenSSL, havaged 或者 c 语言实现呢? +### 为什么不是 SecureRandom、OpenSSL、havaged 或者 c 语言实现呢? -这些是用户空间的 CSPRNG(伪随机数生成器)。你应该想用内核的 CSPRNG,因为: +这些是用户空间的 CSPRNG(伪随机数生成器)。你应该用内核的 CSPRNG,因为: - * 内核可以访问原始设备熵。 - - * 它保证不在应用程序之间共享相同的状态。 - - * 一个好的内核 CSPRNG,像 FreeBSD 中的,也可以保证在提供种子之前不给你随机数据。 +* 内核可以访问原始设备熵。 +* 它可以确保不在应用程序之间共享相同的状态。 +* 一个好的内核 CSPRNG,像 FreeBSD 中的,也可以保证它播种之前不给你随机数据。 +研究过去十年中的随机失败案例,你会看到一连串的用户空间的随机失败案例。[Debian 的 OpenSSH 崩溃][7]?用户空间随机!安卓的比特币钱包[重复 ECDSA 随机 k 值][8]?用户空间随机!可预测洗牌的赌博网站?用户空间随机! +用户空间的生成器几乎总是依赖于内核的生成器。即使它们不这样做,整个系统的安全性也会确保如此。**但用户空间的 CSPRNG 不会增加防御深度;相反,它会产生两个单点故障。** +### 手册页不是说使用 /dev/random 嘛? -研究过去十年中的随机失败案例,你会看到一连串的用户空间随机失败。[Debian 的 OpenSSH 崩溃][7]?用户空间随机。安卓的比特币钱包[重复 ECDSA k's][8]?用户空间随机。可预测洗牌的赌博网站?用户空间随机。 - -用户空间生成器几乎总是依赖于内核的生成器。即使它们不这样做,整个系统的安全性也会确保如此。**用户空间的 CSPRNG 不会增加防御深度;相反,它会产生两个单点故障。** - -### 手册页不是说使用/dev/random嘛? - -这个稍后详述,保留你的想法。你应该忽略掉手册页。不要使用 /dev/random。/dev/random 和 /dev/urandom 之间的区别是 Unix 设计缺陷。手册页不想承认这一点,因此它产生了一个并不存在的安全问题。把 random(4) 上的密码学上的建议当作传奇,继续你的生活。 +这个稍后详述,保留你的意见。你应该忽略掉手册页。不要使用 `/dev/random`。`/dev/random` 和 `/dev/urandom` 之间的区别是 Unix 设计缺陷。手册页不想承认这一点,因此它产生了一个并不存在的安全顾虑。把 `random(4)` 中的密码学上的建议当作传说,继续你的生活吧。 ### 但是如果我需要的是真随机值,而非伪随机值呢? -Urandom 和 /dev/random 提供的是同一类型的随机。与流行的观念相反,/dev/random 不提供“真正的随机”。从密码学上来说,你通常不需要“真正的随机”。 +urandom 和 `/dev/random` 提供的是同一类型的随机。与流行的观念相反,`/dev/random` 不提供“真正的随机”。从密码学上来说,你通常不需要“真正的随机”。 -Urandom 和 /dev/random 都基于一个简单的想法。它们的设计与流密码的设计密切相关:一个小秘密被延伸到不可预测值的不确定流中。 这里的秘密是“熵”,而流是“输出”。 +urandom 和 `/dev/random` 都基于一个简单的想法。它们的设计与流密码的设计密切相关:一个小秘密被延伸到不可预测值的不确定流中。 这里的秘密是“熵”,而流是“输出”。 -只在 Linux 上 /dev/random 和 urandom 仍然有意义上的不同。Linux 内核的 CSPRNG 定期进行密钥更新(通过收集更多的熵)。但是 /dev/random 也试图跟踪内核池中剩余的熵,并且如果它没有足够的剩余熵时,偶尔也会罢工。这种设计和我所说的一样蠢;这与基于“密钥流”中剩下多少“密钥”的 AES-CTR 设计类似。 +只在 Linux 上 `/dev/random` 和 urandom 仍然有意义上的不同。Linux 内核的 CSPRNG 定期进行密钥更新(通过收集更多的熵)。但是 `/dev/random` 也试图跟踪内核池中剩余的熵,并且如果它没有足够的剩余熵时,偶尔也会罢工。这种设计和我所说的一样蠢;这与基于“密钥流”中剩下多少“密钥”的 AES-CTR 设计类似。 -如果你使用 /dev/random 而非 urandom,那么当 Linux 对自己的 RNG(随机数生成器)如何工作感到困惑时,你的程序将不可预测地(或者如果你是攻击者,非常可预测地)挂起。使用 /dev/random 会使你的程序不太稳定,但在密码学角度上它也不会让程序更加安全。 +如果你使用 `/dev/random` 而非 urandom,那么当 Linux 对自己的 RNG(随机数生成器)如何工作感到困惑时,你的程序将不可预测地(或者如果你是攻击者,非常可预测地)挂起。使用 `/dev/random` 会使你的程序不太稳定,但这不会让你在密码学上更安全。 -### 这里有个缺陷,不是吗? +### 这是个缺陷,对吗? -不是,但存在一个你可能想要了解的 Linux 内核 bug,即使这并不能改变你应该使用哪一个 RNG。 +不是,但存在一个你可能想要了解的 Linux 内核 bug,即使这并不能改变你应该使用哪一个 RNG。 -在 Linux 上,如果你的软件在引导时立即运行,并且/或者刚刚安装了操作系统,那么你的代码可能会与 RNG 发生竞争。这很糟糕,因为如果你赢了比赛,那么你可能会在一段时间内从 urandom 获得可预测的输出。这是 Linux 中的一个 bug,如果你正在为 Linux 嵌入式设备构建平台级代码,那你需要了解它。 +在 Linux 上,如果你的软件在引导时立即运行,或者这个操作系统你刚刚安装好,那么你的代码可能会与 RNG 发生竞争。这很糟糕,因为如果你赢了竞争,那么你可能会在一段时间内从 urandom 获得可预测的输出。这是 Linux 中的一个 bug,如果你正在为 Linux 嵌入式设备构建平台级代码,那你需要了解它。 -在 Linux 上,这确实是 urandom(而不是 /dev/random)的问题。这也是[Linux 内核中的错误][9]。 但它也容易在用户空间中修复:在引导时,明确地为 urandom 提供种子。长期以来,大多数 Linux 发行版都是这么做的。但不要切换到不同的 CSPRNG。 +在 Linux 上,这确实是 urandom(而不是 `/dev/random`)的问题。这也是 [Linux 内核中的错误][9]。 但它也容易在用户空间中修复:在引导时,明确地为 urandom 提供种子。长期以来,大多数 Linux 发行版都是这么做的。但**不要**切换到不同的 CSPRNG。 ### 在其它操作系统上呢? -FreeBSD 和 OS X 消除了 urandom 和 /dev/random 之间的区别; 这两个设备的行为是相同的。不幸的是,手册页在解释为什么这样做上干的很糟糕,并延续了 Linux 上 urandom 可怕的神话。 +FreeBSD 和 OS X 消除了 urandom 和 `/dev/random` 之间的区别;这两个设备的行为是相同的。不幸的是,手册页在解释为什么这样做上干的很糟糕,并延续了 Linux 上 urandom 可怕的神话。 -无论你使用 /dev/random 还是 urandom,FreeBSD 的内核加密 RNG 都不会阻塞。 除非它没有被提供种子,在这种情况下,这两者都会阻塞。与 Linux 不同,这种行为是有道理的。Linux 应该采用它。但是,如果你是一名应用程序开发人员,这对你几乎没有什么影响:Linux,FreeBSD,iOS,无论什么:使用 urandom 吧。 +无论你使用 `/dev/random` 还是 urandom,FreeBSD 的内核加密 RNG 都不会停摆。 除非它没有被提供种子,在这种情况下,这两者都会停摆。与 Linux 不同,这种行为是有道理的。Linux 应该采用它。但是,如果你是一名应用程序开发人员,这对你几乎没有什么影响:Linux、FreeBSD、iOS,无论什么:使用 urandom 吧。 ### 太长了,懒得看 @@ -61,23 +59,23 @@ FreeBSD 和 OS X 消除了 urandom 和 /dev/random 之间的区别; 这两个设 [ruby-trunk Feature #9569][10] -> 现在,在尝试检测 /dev/urandom 之前,SecureRandom.random_bytes 会尝试检测要使用的 OpenSSL。 我认为这应该反过来。在这两种情况下,你只需要将随机字节进行解压,所以 SecureRandom 可以跳过中间人(和第二个故障点),如果可用的话可以直接与 /dev/urandom 进行交互。 +> 现在,在尝试检测 `/dev/urandom` 之前,SecureRandom.random_bytes 会尝试检测要使用的 OpenSSL。 我认为这应该反过来。在这两种情况下,你只需要将随机字节进行解压,所以 SecureRandom 可以跳过中间人(和第二个故障点),如果可用的话可以直接与 `/dev/urandom` 进行交互。 -总结: +总结: -> /dev/urandom 不适合用来直接生成会话密钥和频繁生成其他应用程序级随机数据 +> `/dev/urandom` 不适合用来直接生成会话密钥和频繁生成其他应用程序级随机数据。 > > GNU/Linux 上的 random(4) 手册所述...... -感谢 Matthew Green, Nate Lawson, Sean Devlin, Coda Hale, and Alex Balducci 阅读了本文草稿。公正警告:Matthew 只是大多同意我的观点。 +感谢 Matthew Green、 Nate Lawson、 Sean Devlin、 Coda Hale 和 Alex Balducci 阅读了本文草稿。公正警告:Matthew 只是大多同意我的观点。 -------------------------------------------------------------------------------- via: https://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/ -作者:[Thomas;Erin;Matasano][a] +作者:[Thomas & Erin Ptacek][a] 译者:[kimii](https://github.com/kimii) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a36adb81f093348a23129904cc12a1d596f94b21 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 10:34:24 +0800 Subject: [PATCH 0112/1057] PUB:20140225 How To Safely Generate A Random Number - Quarrelsome.md @kimii https://linux.cn/article-9478-1.html --- ...140225 How To Safely Generate A Random Number - Quarrelsome.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20140225 How To Safely Generate A Random Number - Quarrelsome.md (100%) diff --git a/translated/tech/20140225 How To Safely Generate A Random Number - Quarrelsome.md b/published/20140225 How To Safely Generate A Random Number - Quarrelsome.md similarity index 100% rename from translated/tech/20140225 How To Safely Generate A Random Number - Quarrelsome.md rename to published/20140225 How To Safely Generate A Random Number - Quarrelsome.md From 6fca89fc1dad96fdbef3f86967a7637a998f6efe Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 11:00:05 +0800 Subject: [PATCH 0113/1057] PRF:20180125 Building a Linux-based HPC system on the Raspberry.md @qhwdw --- ...Linux-based HPC system on the Raspberry.md | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/translated/tech/20180125 Building a Linux-based HPC system on the Raspberry.md b/translated/tech/20180125 Building a Linux-based HPC system on the Raspberry.md index b201690a3f..f7f8dab1fd 100644 --- a/translated/tech/20180125 Building a Linux-based HPC system on the Raspberry.md +++ b/translated/tech/20180125 Building a Linux-based HPC system on the Raspberry.md @@ -1,15 +1,14 @@ 使用 Ansible 在树莓派上构建一个基于 Linux 的高性能计算系统 ============================================================ -### 使用低成本的硬件和开源软件设计一个高性能计算集群。 +> 使用低成本的硬件和开源软件设计一个高性能计算集群。 ![Building a Linux-based HPC system on the Raspberry Pi with Ansible](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82 "Building a Linux-based HPC system on the Raspberry Pi with Ansible") 图片来源:opensource.com -在我的 [Opensource.com 上前面的文章中][14],我介绍了 [OpenHPC][15] 项目,它的目标是致力于加速高性能计算(HPC)的创新。这篇文章将更深入来介绍使用 OpenHPC 的特性来构建一个小型的 HPC 系统。将它称为 _HPC 系统_  可能有点“扯虎皮拉大旗”的意思,因此,更确切的说法应该是,通过 OpenHPC 项目发布的 [方法构建集群][16] 系统。 - -这个集群由两台树莓派 3 系统作为活动计算节点,以及一台虚拟机作为主节点,结构示意如下: +在我的 [之前发表在 Opensource.com 上的文章中][14],我介绍了 [OpenHPC][15] 项目,它的目标是致力于加速高性能计算(HPC)的创新。这篇文章将更深入来介绍使用 OpenHPC 的特性来构建一个小型的 HPC 系统。将它称为 _HPC 系统_  可能有点“扯虎皮拉大旗”的意思,因此,更确切的说法应该是,它是一个基于 OpenHPC 项目发布的 [集群构建方法][16] 的系统。 +这个集群由两台树莓派 3 系统作为计算节点,以及一台虚拟机作为主节点,结构示意如下: ![Map of HPC cluster](https://opensource.com/sites/default/files/u128651/hpc_with_pi-1.png "Map of HPC cluster") @@ -17,13 +16,12 @@ 下图是真实的设备工作照: - ![HPC hardware setup](https://opensource.com/sites/default/files/u128651/hpc_with_pi-2.jpg "HPC hardware setup") -去配置一台像上图这样的 HPC 系统,我是按照 OpenHPC 集群构建方法 ——  [CentOS 7.4/aarch64 + Warewulf + Slurm 安装指南][17] (PDF) 的一些步骤来做的。这个方法包括 [Warewulf][18] 提供的使用说明;因为我的那三个系统是手动安装的,我跳过了 Warewulf 部分以及创建 [Ansible playbook][19] 的一些步骤。 +要把我的系统配置成像上图这样的 HPC 系统,我是按照 OpenHPC 的集群构建方法的 [CentOS 7.4/aarch64 + Warewulf + Slurm 安装指南][17] (PDF)的一些步骤来做的。这个方法包括了使用 [Warewulf][18] 的配置说明;因为我的那三个系统是手动安装的,我跳过了 Warewulf 部分以及创建 [Ansible 剧本][19] 的一些步骤。 +在 [Ansible][26] 剧本中设置完成我的集群之后,我就可以向资源管理器提交作业了。在我的这个案例中, [Slurm][27] 充当了资源管理器,它是集群中的一个实例,由它来决定我的作业什么时候在哪里运行。在集群上启动一个简单的作业的方式之一: -在 [Ansible][26] playbooks 中设置完成我的集群之后,我就可以向资源管理器提交作业了。在我的这个案例中, [Slurm][27] 充当了资源管理器,它是集群中的一个实例,由它来决定我的作业什么时候在哪里运行。其中一种可做的事情是,在集群上启动一个简单的作业: ``` [ohpc@centos01 ~]$ srun hostname calvin @@ -66,9 +64,9 @@ calvin Mon 11 Dec 16:42:41 UTC 2017 ``` -为示范资源管理器的基本功能、简单的和一系列的命令行工具,这个集群系统是挺合适的,但是,去配置一个类似HPC 系统去做各种工作就有点无聊了。 +为示范资源管理器的基本功能,简单的串行命令行工具就行,但是,做各种工作去配置一个类似 HPC 系统就有点无聊了。 -一个更有趣的应用是在这个集群的所有可用 CPU 上运行一个 [Open MPI][20] 并行作业。我使用了一个基于 [Game of Life][21] 的应用,它被用于一个名为“使用 Red Hat 企业版 Linux 跨多种架构运行 `Game of Life`“的 [视频][22]。除了以前实现的基于 MPI 的 `Game of Life` 之外,在我的集群中现在运行的这个版本对每个涉及的主机的单元格颜色都是不同的。下面的脚本以图形输出的方式来交互式启动应用: +一个更有趣的应用是在这个集群的所有可用 CPU 上运行一个 [Open MPI][20] 的并行作业。我使用了一个基于 [康威生命游戏][21] 的应用,它被用于一个名为“使用 Red Hat 企业版 Linux 跨多种架构运行康威生命游戏”的 [视频][22]。除了以前基于 MPI 的 `Game of Life` 版本之外,在我的集群中现在运行的这个版本对每个涉及的主机的单元格颜色都是不同的。下面的脚本以图形输出的方式来交互式启动应用: ``` $ cat life.mpi @@ -91,15 +89,13 @@ $ srun -n 8 --x11 life.mpi 为了演示,这个作业有一个图形界面,它展示了当前计算的结果: - ![](https://opensource.com/sites/default/files/u128651/hpc_with_pi-3.png) -红色单元格是由其中一个计算节点来计算的,而绿色单元格是由另外一个计算节点来计算的。我也可以让 `Game of Life` 程序为使用的每个 CPU 核心(这里的每个计算节点有四个核心)去生成不同的颜色,这样它的输出如下: - +红色单元格是由其中一个计算节点来计算的,而绿色单元格是由另外一个计算节点来计算的。我也可以让康威生命游戏程序为使用的每个 CPU 核心(这里的每个计算节点有四个核心)去生成不同的颜色,这样它的输出如下: ![](https://opensource.com/sites/default/files/u128651/hpc_with_pi-4.png) -感谢 OpenHPC 提供的软件包和安装方法,因为它们我可以去配置一个由两个计算节点和一个主节点的 HPC 式的系统。我可以在资源管理器上提交作业,然后使用 OpenHPC 提供的软件在我的树莓派的 CPU 上去启动 MPI 应用程序。 +感谢 OpenHPC 提供的软件包和安装方法,因为它们让我可以去配置一个由两个计算节点和一个主节点的 HPC 式的系统。我可以在资源管理器上提交作业,然后使用 OpenHPC 提供的软件在我的树莓派的 CPU 上去启动 MPI 应用程序。 * * * @@ -107,15 +103,15 @@ $ srun -n 8 --x11 life.mpi ### 关于作者 - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/gotchi-square.png?itok=PJKu7LHn)][23] Adrian Reber —— Adrian 是 Red Hat 的高级软件工程师,他早在 2010 年就开始了迁移的过程,迁移到高性能计算环境中,从那个时候起迁移了许多的程序,并因此获得了博士学位,然后加入了 Red Hat 公司并开始去迁移到容器。偶尔他仍然去迁移单个进程,并且它至今仍然对高性能计算非常感兴趣。[关于我的更多信息点这里][12] + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/gotchi-square.png?itok=PJKu7LHn)][23] Adrian Reber —— Adrian 是 Red Hat 的高级软件工程师,他早在 2010 年就开始了迁移处理过程到高性能计算环境,从那个时候起迁移了许多的处理过程,并因此获得了博士学位,然后加入了 Red Hat 公司并开始去迁移到容器。偶尔他仍然去迁移单个处理过程,并且它至今仍然对高性能计算非常感兴趣。[关于我的更多信息点这里][12] -------------------------------------------------------------------------------- via: https://opensource.com/article/18/1/how-build-hpc-system-raspberry-pi-and-openhpc -作者:[Adrian Reber ][a] +作者:[Adrian Reber][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 d6492063e1439f43a17b5c92cdef142349652f94 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 11:01:28 +0800 Subject: [PATCH 0114/1057] PUB:20180125 Building a Linux-based HPC system on the Raspberry.md @qhwdw https://linux.cn/article-9479-1.html --- ...20180125 Building a Linux-based HPC system on the Raspberry.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180125 Building a Linux-based HPC system on the Raspberry.md (100%) diff --git a/translated/tech/20180125 Building a Linux-based HPC system on the Raspberry.md b/published/20180125 Building a Linux-based HPC system on the Raspberry.md similarity index 100% rename from translated/tech/20180125 Building a Linux-based HPC system on the Raspberry.md rename to published/20180125 Building a Linux-based HPC system on the Raspberry.md From 225c7c0c73779933145635e22f0b42a688be565f Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 25 Mar 2018 16:54:27 +0800 Subject: [PATCH 0115/1057] pygmalion666 translating pygmalion666 translating --- ...0 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index d350bd07b8..138215d9ec 100644 --- a/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -1,3 +1,4 @@ +【Pgmalion666 Translating】 10 Tools To Add Some Spice To Your UNIX/Linux Shell Scripts ====== There are some misconceptions that shell scripts are only for a CLI environment. You can efficiently use various tools to write GUI and network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxes, progress bars, etc.). You can always control the final output, cursor position on the screen, various output effects, and more. With the following tools, you can build powerful, interactive, user-friendly UNIX / Linux bash shell scripts. From 74953e7e2b0d7cabdb1bbc028a4b0163c59d5971 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Sun, 25 Mar 2018 21:43:56 +0800 Subject: [PATCH 0116/1057] Translating by qhwdw --- sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md b/sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md index 50d4d454b6..c73e8fe80f 100644 --- a/sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md +++ b/sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md @@ -1,3 +1,4 @@ +Translating by qhwdw Caffeinated 6.828: Lab 1: Booting a PC ====== From 72d4294d5885f3de09a66a8d6de7750fd373aaa9 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 22:30:16 +0800 Subject: [PATCH 0117/1057] PRF:20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md @heart4lor --- ... a Minecraft Server - ThisHosting.Rocks.md | 95 ++++++++----------- 1 file changed, 42 insertions(+), 53 deletions(-) diff --git a/translated/tech/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md b/translated/tech/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md index 8296840a01..6825f8ccd2 100644 --- a/translated/tech/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md +++ b/translated/tech/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md @@ -1,64 +1,53 @@ 如何搭建“我的世界”服务器 ====== -我们将通过一个一步步的、新手友好的教程来向你展示如何搭建一个“我的世界”服务器。这将会是一个长期的多人游戏服务器,你可以与来自世界各地的朋友们一起玩,而不用在同一个局域网下。 + +![](https://thishosting.rocks/wp-content/uploads/2018/01/how-to-make-minecraft-server.jpg) + +我们将通过一个一步步的、新手友好的教程来向你展示如何搭建一个“我的世界(Minecraft)”服务器。这将会是一个长期的多人游戏服务器,你可以与来自世界各地的朋友们一起玩,而不用在同一个局域网下。 ### 如何搭建一个“我的世界”服务器 - 快速指南 如果你很急,想直达重点的话,这是我们的目录。我们推荐通读整篇文章。 * [学点东西][1] (可选) - * [再学点东西][2] (可选) - * [需求][3] (必读) - * [安装并运行“我的世界”服务器][4] (必读) - * [在你登出 VPS 后继续运行服务端][5] (可选) - * [让服务端随系统启动][6] (可选) - * [配置你的“我的世界”服务器][7] (必读) - * [常见问题][8] (可选) 在你开始行动之前,要先了解一些事情: -#### 为什么你不应该使用专门的“我的世界”服务器提供商 +#### 为什么你**不**应该使用专门的“我的世界”服务器提供商 既然你正在阅读这篇文章,你肯定对搭建自己的“我的世界”服务器感兴趣。不应该使用专门的“我的世界”服务器提供商的原因有很多,以下是其中一些: * 它们通常很慢。这是因为你是在和很多用户一起共享资源。这有的时候会超负荷,他们中很多都会超售。 - -* 你并不能完全控制”我的世界“服务端,或是真正的服务器。你没法按照你的意愿进行自定义。 - +* 你并不能完全控制“我的世界”服务端或真正的服务器。你没法按照你的意愿进行自定义。 * 你是受限制的。这种主机套餐或多或少都会有限制。 -当然,使用现成的提供商也是有优点的。最好的就是你不用做下面这些操作。但是那还有什么意思呢?![🙂](https://s.w.org/images/core/emoji/2.3/svg/1f642.svg) +当然,使用现成的提供商也是有优点的。最好的就是你不用做下面这些操作。但是那还有什么意思呢?! -#### 为什么不应该用你的个人电脑作为”我的世界“服务器 +#### 为什么不应该用你的个人电脑作为“我的世界”服务器 我们注意到很多教程都展示的是如何在你自己的电脑上搭建服务器。这样做有一些弊端,比如: * 你的家庭网络不够安全,无法抵挡 DDoS 攻击。游戏服务器通常容易被 DDoS 攻击,而你的家庭网络设置通常不够安全,来抵挡它们。很可能连小型攻击都无法阻挡。 - -* 你得处理端口转发。如果你试着在家庭网络中搭建”我的世界“服务器的话,你肯定会偶然发现端口转发的问题,并且处理时可能会有问题。 - +* 你得处理端口转发。如果你试着在家庭网络中搭建“我的世界”服务器的话,你肯定会偶然发现端口转发的问题,并且处理时可能会有问题。 * 你得保持你的电脑一直开着。你的电费将会突破天际,并且你会增加不必要的硬件负载。大部分服务器硬件都是企业级的,提升了稳定性和持久性,专门设计用来处理负载。 - * 你的家庭网络速度不够快。家庭网络并不是设计用来负载多人联机游戏的。即使你想搭建一个小型服务器,你也需要一个更好的网络套餐。幸运的是,数据中心有多个高速的、企业级的互联网连接,来保证他们达到(或尽量达到)100%在线。 - * 你的硬件很可能不够好。再说一次,服务器使用的都是企业级硬件,最新最快的处理器、固态硬盘,等等。你的个人电脑很可能不是的。 +* 你的个人电脑很可能是 Windows/MacOS。尽管这有所争议,但我们相信 Linux 更适合搭建游戏服务器。不用担心,搭建“我的世界”服务器不需要完全了解 Linux(尽管推荐这样)。我们会向你展示你需要了解的。 -* 你的个人电脑很可能是 Windows/MacOS。尽管这是有争议的,我们相信 Linux 更适合搭建游戏服务器。不用担心,搭建”我的世界“服务器不需要完全了解 Linux(尽管推荐这样)。我们会向你展示你需要了解的。 +我们的建议是不要使用个人电脑,即使从技术角度来说你能做到。买一个云服务器并不是很贵。下面我们会向你展示如何在云服务器上搭建“我的世界”服务端。小心地遵守以下步骤,就很简单。 -我们的建议是不要使用个人电脑,即使从技术角度来说你能做到。买一个云服务器并不是很贵。下面我们会向你展示如何在云服务器上搭建”我的世界“服务端。小心地遵守以下步骤,就很简单。 - -### 搭建一个”我的世界“服务器 - 需求 +### 搭建一个“我的世界”服务器 - 需求 这是一些需求,你在教程开始之前需要拥有并了解它们: -* 你需要一个 [Linux 云服务器][9]。我们推荐 [Vultr][10]。这家价格便宜,服务质量高,客户支持很好,并且所有的服务器硬件都很高端。检查[“我的世界”服务器需求][11]来选择你需要哪种类型的服务器(像内存和硬盘之类的资源)。我们推荐每月 20 美元的套餐。他们也支持按小时收费,所以如果你只是临时需要服务器和朋友们联机的话,你的花费会更少。注册时选择 Ubuntu 16.04 发行版。在注册时选择离你的朋友们最近的地域。这样的话你就需要保护并管理服务器。如果你不想这样的话,你可以选择[托管的服务器][],这样的话服务器提供商可能会给你搭建好一个“我的世界”服务器。 +* 你需要一个 [Linux 云服务器][9]。我们推荐 [Vultr][10]。这家价格便宜,服务质量高,客户支持很好,并且所有的服务器硬件都很高端。检查[“我的世界”服务器需求][11]来选择你需要哪种类型的服务器(像内存和硬盘之类的资源)。我们推荐每月 20 美元的套餐。他们也支持按小时收费,所以如果你只是临时需要服务器和朋友们联机的话,你的花费会更少。注册时选择 Ubuntu 16.04 发行版。在注册时选择离你的朋友们最近的地域。这样的话你就需要保护并管理服务器。如果你不想这样的话,你可以选择[托管的服务器][12],这样的话服务器提供商可能会给你搭建好一个“我的世界”服务器。 * 你需要一个 SSH 客户端来连接到你的 Linux 云服务器。新手通常建议使用 [PuTTy][13],但我们也推荐使用 [MobaXTerm][14]。也有很多 SSH 客户端,所以挑一个你喜欢的吧。 * 你需要设置你的服务器(至少做好基本的安全设置)。谷歌一下你会发现很多教程。你也可以按照 [Linode 的 安全指南][15],然后在你的 [Vultr][16] 服务器上一步步操作。 * 下面我们将会处理软件依赖,比如 Java。 @@ -67,17 +56,17 @@ ### 如何在 Ubuntu(Linux)上搭建一个“我的世界”服务器 -这篇教程是为 [Vultr][17] 上的 Ubuntu 16.04 撰写并测试可行的。但是这对 Ubuntu 14.04, [Ubuntu 18.04][18],以及其他基于 Ubuntu 的发行版,其他服务器提供商也是可行的。 +这篇教程是为 [Vultr][17] 上的 Ubuntu 16.04 撰写并测试可行的。但是这对 Ubuntu 14.04, [Ubuntu 18.04][18],以及其他基于 Ubuntu 的发行版、其他服务器提供商也是可行的。 -我们使用默认的 Vanilla 服务端。你也可以使用像 CraftBukkit 或 Spigot 这样的服务端,来支持更多的自定义和插件。虽然如果你使用过多插件的话会毁了服务端。这各有优缺点。不管怎么说,下面的教程使用默认的 Vanilla 服务端,来使事情变得简单和更新手友好。如果有兴趣的话我们可能会发表一篇 CraftBukkit 的教程。 +我们使用默认的 Vanilla 服务端。你也可以使用像 CraftBukkit 或 Spigot 这样的服务端,来支持更多的自定义和插件。虽然如果你使用过多插件的话会影响服务端。这各有优缺点。不管怎么说,下面的教程使用默认的 Vanilla 服务端,来使事情变得简单和更新手友好。如果有兴趣的话我们可能会发表一篇 CraftBukkit 的教程。 -#### 1. 登陆到你的服务器 +#### 1. 登录到你的服务器 -我们将使用 root 账户。如果你使用受限的账户的话,大部分命令都需要 ‘sudo’。做你没有权限的事情时会出现警告。 +我们将使用 root 账户。如果你使用受限的账户的话,大部分命令都需要 `sudo`。做你没有权限的事情时会出现警告。 -你可以通过 SSH 客户端来登陆你的服务器。使用你的 IP 和端口(大部分都是 22)。 +你可以通过 SSH 客户端来登录你的服务器。使用你的 IP 和端口(大部分都是 22)。 -在你登陆之后,确保你的[服务器安全][19]。 +在你登录之后,确保你的[服务器安全][19]。 #### 2. 更新 Ubuntu @@ -87,7 +76,7 @@ apt-get update && apt-get upgrade ``` -在提示时敲击“回车键” 和/或 “y”。 +在提示时敲击“回车键” 和/或 `y`。 #### 3. 安装必要的工具 @@ -113,37 +102,37 @@ mkdir /opt/minecraft cd /opt/minecraft ``` -现在你可以下载“我的世界“服务端文件了。去往[下载页面][20]获取下载链接。使用wget下载文件: +现在你可以下载“我的世界“服务端文件了。去往[下载页面][20]获取下载链接。使用 `wget` 下载文件: ``` wget https://s3.amazonaws.com/Minecraft.Download/versions/1.12.2/minecraft_server.1.12.2.jar ``` -#### 5. 安装”我的世界“服务端 +#### 5. 安装“我的世界”服务端 -下载好了服务端 .jar 文件之后,你就需要先运行一下,它会生成一些文件,包括一个 eula.txt 许可文件。第一次运行的时候,它会返回一个错误并退出。这是正常的。使用下面的命令运行它: +下载好了服务端的 .jar 文件之后,你就需要先运行一下,它会生成一些文件,包括一个 `eula.txt` 许可文件。第一次运行的时候,它会返回一个错误并退出。这是正常的。使用下面的命令运行它: ``` java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.2.jar nogui ``` -”-Xms2048M“是你的服务端能使用的最小的内存,”-Xmx3472M“是最大的。[调整][21]基于你服务器的硬件资源。如果你在 [Vultr][22] 服务器上有 4GB 内存,并且不用服务器来干其他事情的话可以就这样留着不动。 +`-Xms2048M` 是你的服务端能使用的最小的内存,`-Xmx3472M` 是最大的内存。[调整][21]基于你服务器的硬件资源。如果你在 [Vultr][22] 服务器上有 4GB 内存,并且不用服务器来干其他事情的话可以就这样留着不动。 -在这条命令结束并返回一个错误之后,将会生成一个新的 eula.txt 文件。你需要同意那个文件里的协议。你可以通过下面这条命令将”eula=true“添加到文件中: +在这条命令结束并返回一个错误之后,将会生成一个新的 `eula.txt` 文件。你需要同意那个文件里的协议。你可以通过下面这条命令将 `eula=true` 添加到文件中: ``` sed -i.orig 's/eula=false/eula=true/g' eula.txt ``` -你现在可以通过和上面一样的命令来开启服务端并进入”我的世界“服务端控制台了: +你现在可以通过和上面一样的命令来开启服务端并进入“我的世界”服务端控制台了: ``` java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.2.jar nogui ``` -确保你在 /opt/minecraft 目录,或者其他你安装你的 MC 服务端的目录下。 +确保你在 `/opt/minecraft` 目录,或者其他你安装你的 MC 服务端的目录下。 -如果你只是测试或暂时需要的话,到这里就可以停了。如果你在登陆服务器时有问题的话,你就需要[配置你的防火墙][23]。 +如果你只是测试或暂时需要的话,到这里就可以停了。如果你在登录服务器时有问题的话,你就需要[配置你的防火墙][23]。 第一次成功启动服务端时会花费一点时间来生成。 @@ -166,7 +155,7 @@ nano /opt/minecraft/startminecraft.sh cd /opt/minecraft/ && java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.2.jar nogui ``` -如果你不熟悉 nano 的话 - 你可以使用“CTRL + X”,再敲击“Y”,然后回车。这个脚本将进入你先前创建的“我的世界”服务端并运行 Java 命令来开启服务端。你需要执行下面的命令来使脚本可执行: +如果你不熟悉 nano 的话 - 你可以使用 `CTRL + X`,再敲击 `Y`,然后回车。这个脚本将进入你先前创建的“我的世界”服务端并运行 Java 命令来开启服务端。你需要执行下面的命令来使脚本可执行: ``` chmod +x startminecraft.sh @@ -178,7 +167,7 @@ chmod +x startminecraft.sh /opt/minecraft/startminecraft.sh ``` -但是,如果/当你登出 SSH 会话的话,服务端就会关闭。要想让服务端不登陆也持续运行的话,你可以使用 screen 会话。一个 screen 会话会一直运行,直到实际的服务器被关闭或重启。 +但是,如果/当你登出 SSH 会话的话,服务端就会关闭。要想让服务端不登录也持续运行的话,你可以使用 `screen` 会话。`screen` 会话会一直运行,直到实际的服务器被关闭或重启。 使用下面的命令开启一个 screen 会话: @@ -186,23 +175,23 @@ chmod +x startminecraft.sh screen -S minecraft ``` -一旦你进入了 screen 会话(看起来就像是你新建了一个 SSH 会话),你就可以使用先前创建的 bash 脚本来启动服务端: +一旦你进入了 `screen` 会话(看起来就像是你新建了一个 SSH 会话),你就可以使用先前创建的 bash 脚本来启动服务端: ``` /opt/minecraft/startminecraft.sh ``` -要退出 screen 会话的话,你应该按 CTRL +A-D。即使你离开 screen 会话(断开的),服务端也会继续运行。你现在可以安全的登出 Ubuntu 服务器了,你创建的“我的世界”服务端将会继续运行。 +要退出 `screen` 会话的话,你应该按 `CTRL+A-D`。即使你离开 `screen` 会话(断开的),服务端也会继续运行。你现在可以安全的登出 Ubuntu 服务器了,你创建的“我的世界”服务端将会继续运行。 -但是,如果 Ubuntu 服务器重启或关闭了的话,screen 会话将不再起作用。所以**为了让我们之前做的这些在启动时自动运行**,做下面这些: +但是,如果 Ubuntu 服务器重启或关闭了的话,`screen` 会话将不再起作用。所以**为了让我们之前做的这些在启动时自动运行**,做下面这些: -打开 /etc/rc.local 文件: +打开 `/etc/rc.local` 文件: ``` nano /etc/rc.local ``` -在“exit 0”语句前添加如下内容: +在 `exit 0` 语句前添加如下内容: ``` screen -dm -S minecraft /opt/minecraft/startminecraft.sh @@ -211,7 +200,7 @@ exit 0 保存并关闭文件。 -要访问“我的世界”服务端控制台,只需运行下面的命令来重新连接 screen 会话: +要访问“我的世界”服务端控制台,只需运行下面的命令来重新连接 `screen` 会话: ``` screen -r minecraft @@ -247,7 +236,7 @@ ufw allow 25565/tcp nano /opt/minecraft/server.properties ``` -并将“white-list”行改为“true”: +并将 `white-list` 行改为 `true`: ``` white-list=true @@ -279,7 +268,7 @@ whitelist add PlayerUsername whitelist remove PlayerUsername ``` -使用 CTRL + A-D 来退出 screen(服务器控制台)。值得注意的是,这会拒绝除白名单以外的所有人连接到服务端。 +使用 `CTRL+A-D` 来退出 `screen`(服务器控制台)。值得注意的是,这会拒绝除白名单以外的所有人连接到服务端。 [![how to create a minecraft server](https://thishosting.rocks/wp-content/uploads/2018/01/create-a-minecraft-server.jpg)][26] @@ -305,7 +294,7 @@ whitelist remove PlayerUsername screen -r minecraft ``` -在这里执行[命令][28]。像下面这些命令: +并执行[命令][28]。像下面这些命令: ``` difficulty hard @@ -321,7 +310,7 @@ gamemode survival @a 如果有新版本发布的话,你需要这样做: -进入”我的世界“目录: +进入“我的世界”目录: ``` cd /opt/minecraft @@ -356,7 +345,7 @@ cd /opt/minecraft/ && java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.3.jar #### 为什么你们的教程这么长,而其他的只有 2 行那么长?! -我们想让这个教程对新手来说更友好,并且尽可能详细。我们还向你展示了了如何让服务端长期运行并跟随系统启动,我们向你展示了如何配置你的服务端以及所有的东西。我是说,你当然可以用几行来启动“我的世界”服务器,但那样的话绝对很烂,从不仅一方面说。 +我们想让这个教程对新手来说更友好,并且尽可能详细。我们还向你展示了如何让服务端长期运行并跟随系统启动,我们向你展示了如何配置你的服务端以及所有的东西。我是说,你当然可以用几行来启动“我的世界”服务器,但那样的话绝对很烂,从不仅一方面说。 #### 我不知道 Linux 或者这里说的什么东西,我该如何搭建一个“我的世界”服务器呢? @@ -372,7 +361,7 @@ via: https://thishosting.rocks/how-to-make-a-minecraft-server/ 作者:[ThisHosting.Rocks][a] 译者:[heart4lor](https://github.com/heart4lor) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 23952b0d079c1e82aaf243ded95f6df7b14c7af7 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 22:30:57 +0800 Subject: [PATCH 0118/1057] PUB:20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md @heart4lor https://linux.cn/article-9480-1.html --- ...20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md (100%) diff --git a/translated/tech/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md b/published/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md similarity index 100% rename from translated/tech/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md rename to published/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md From 65eef8245d367d07b486b0cea5e90e2350e5de77 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 22:46:13 +0800 Subject: [PATCH 0119/1057] PRF:20180205 Block ads on your network with Raspberry Pi and pi-hole.md @qhwdw --- ...r network with Raspberry Pi and pi-hole.md | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/translated/tech/20180205 Block ads on your network with Raspberry Pi and pi-hole.md b/translated/tech/20180205 Block ads on your network with Raspberry Pi and pi-hole.md index a2dd85f4d5..41e8f0afe6 100644 --- a/translated/tech/20180205 Block ads on your network with Raspberry Pi and pi-hole.md +++ b/translated/tech/20180205 Block ads on your network with Raspberry Pi and pi-hole.md @@ -1,11 +1,13 @@ -使用树莓派和 pi-hole 拦截你的网络上的广告 +在你的网络中使用树莓派和 Pi-hole 拦截广告 ====== +> 痛恨上网时看到广告?学习这篇教程来设置 Pi-hole。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pi-hole-banner.png?itok=1TXcp3hm) 有一个闲置的树莓派?在浏览网页时讨厌广告?[Pi-hole][1] 是一个拦截广告的开源软件项目,它可以将你的家庭网络上的所有广告路由到一个不存在的地方,从而实现在你的设备上拦截广告的目的。这么好的方法只需要花几钟的时间来设置,你就可以使用它了。 -Pi-hole 拦截了超过 100,000 个提供广告的域名,它可以拦截任何设备(包括移动设备、平板电脑、以及个人电脑)上的广告,并且它是完整的拦截了广告,而不是仅将它们隐藏起来,它这样做可以提升总体的网络性能(因为广告不需要下载)。你可以在一个 web 界面上、或者也可以使用一个 API 来监视性能和统计数据。 +Pi-hole 拦截了超过 100,000 个提供广告的域名,它可以拦截任何设备(包括移动设备、平板电脑、以及个人电脑)上的广告,并且它是完整的拦截了广告,而不是仅将它们隐藏起来,这样做可以提升总体的网络性能(因为广告不需要下载)。你可以在一个 web 界面上、或者也可以使用一个 API 来监视性能和统计数据。 ### 你需要: @@ -19,7 +21,7 @@ Pi-hole 拦截了超过 100,000 个提供广告的域名,它可以拦截任何 ![](https://opensource.com/sites/default/files/u128651/power-supply.png) ![](https://opensource.com/sites/default/files/u128651/ethernet-cable.png) -你不需要使用一个最新型号的树莓派 — 一个老款足够完成这项工作,只要它的内存不小于 512MB 就可以 — 因此一个一代树莓派 Model B(rev 2)就足够,一个 Model B+、或者二代的或者三代的树莓派都可以。你可能需要一个 Pi Zero,也需要一个 USB micro 以太网适配器。你可以使用一个带 WiFi 的 Pi Zero W 而不是以太网。但是,作为你的网络基础设施的一部分,我建议你使用一个性能良好、稳定的有线连接来代替 WiFi 连接。 +你不需要使用一个最新型号的树莓派 — 一个老款足够完成这项工作,只要它的内存不小于 512MB 就可以 — 因此一个一代树莓派 Model B(rev 2)就足够,一个 Model B+、或者二代的或者三代的树莓派都可以。你可以使用 Pi Zero,但需要一个 USB micro 以太网适配器。你可以使用一个带 WiFi 的 Pi Zero W 而不是以太网。但是,作为你的网络基础设施的一部分,我建议你使用一个性能良好、稳定的有线连接来代替 WiFi 连接。 ### 准备 SD 卡 @@ -33,14 +35,14 @@ Pi-hole 拦截了超过 100,000 个提供广告的域名,它可以拦截任何 ![](https://opensource.com/sites/default/files/etcher-win-520px.png) -SD 卡准备完成之后,你可以将它插入到你的树莓派,连接上键盘、显示器、和以太网,然后为树莓派接上电源。在初始化设置之后,这个树莓派就不需要键盘或显示器了。如果你有使用”无头“树莓派工作的经验,你可以去 [启用 SSH][4] 然后去设置它 [启用远程连接][5]。 +SD 卡准备完成之后,你可以将它插入到你的树莓派,连接上键盘、显示器和以太网,然后为树莓派接上电源。在初始化设置之后,这个树莓派就不需要键盘或显示器了。如果你有使用“无末端headless”树莓派工作的经验,你可以 [启用 SSH][4] 然后去设置它 [启用远程连接][5]。 ### 安装 Pi-hole 在你的树莓派引导完成之后,用缺省用户名(`pi`)和密码(`raspberry`)登入。现在你就可以运行命令行了,可以去安装 Pi-hole 了。简单地输入下列命令并回车: + ``` curl -sSL https://install.pi-hole.net | bash - ``` 这个命令下载了 Pi-hole 安装脚本然后去运行它。你可以在你的电脑浏览器中输入 `https://install.pi-hole.net` 来查看它的内容,你将会看到这个脚本做了些什么。它为你生成了一个**管理员密码**,并和其它安装信息一起显示在你的屏幕上。 @@ -59,17 +61,17 @@ curl -sSL https://install.pi-hole.net | bash 关于这一步的更多信息,可以查看 [Pi-hole discourse][6]。 -你还需要确保你的 Pi-hole 始终保持相同的 IP 地址,因此,你需要去查看 DHCP,将你的树莓派的 IP 地址条目添加到保留地址中。 +你还需要确保你的 Pi-hole 始终保持相同的 IP 地址,因此,你需要去查看 DHCP 设置,将你的树莓派的 IP 地址条目添加到保留地址中。 ### 外部测试 现在,在命令行下输入 `sudo halt` 关闭运行的树莓派,并断开它的电源。你可以拔掉显示器连接线和键盘,然后将你的树莓派放置到一个合适的固定的地方 — 或许应该将它放在你的路由器附近。确保连接着以太网线,然后重新连接电源以启动它。 -在你的个人电脑上导航到一个网站(强烈建议访问 [Opensource.com][7] 网站),或者用你的 WiFi 中的一个设备去检查你的因特网访问是否正常(如果不能正常访问,可能是你的 DNS 配置错误)。如果在浏览器中看到了预期的结果,说明它的工作正常。现在,你浏览网站时,应该再也看不到广告了!甚至在你的 apps 中提供的广告也无法出现在你的移动设备中!祝你”冲浪“愉快! +在你的个人电脑上导航到一个网站(强烈建议访问 [Opensource.com][7] 网站),或者用你的 WiFi 中的一个设备去检查你的因特网访问是否正常(如果不能正常访问,可能是你的 DNS 配置错误)。如果在浏览器中看到了预期的结果,说明它的工作正常。现在,你浏览网站时,应该再也看不到广告了!甚至在你的 app 中提供的广告也无法出现在你的移动设备中!祝你“冲浪”愉快! 如果你想去测试一下你的广告拦截的新功能,你可以去这个 [测试页面][8] 尝试浏览一些内置广告的网站。 -现在你可以在你的电脑浏览器上输入 Pi-hole 的 IP 地址来访问它的 web 界面(比如, \- 或者 `http://pi.hole/admin` 也可能会工作)。你将看到 Pi-hole 管理面板和一些统计数据(在这时可能数字比较小)。在你输入密码(在安装时显示在屏幕上的)后,你将看到更漂亮的图形界面: +现在你可以在你的电脑浏览器上输入 Pi-hole 的 IP 地址来访问它的 web 界面(比如,`http://192.168.1.4/admin` 或者 `http://pi.hole/admin` 也可能会工作)。你将看到 Pi-hole 管理面板和一些统计数据(在这时可能数字比较小)。在你输入(在安装时显示在屏幕上的)密码后,你将看到更漂亮的图形界面: ![](https://opensource.com/sites/default/files/u128651/pi-hole-web.png) @@ -87,7 +89,7 @@ via: https://opensource.com/article/18/2/block-ads-raspberry-pi 作者:[Ben Nuttall][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 c005a3a25a0181d6c70d94e757529a1ac6cba2bc Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sun, 25 Mar 2018 22:46:37 +0800 Subject: [PATCH 0120/1057] Delete 20180111 How to install software applications on Linux.md --- ... install software applications on Linux.md | 263 ------------------ 1 file changed, 263 deletions(-) delete mode 100644 sources/tech/20180111 How to install software applications on Linux.md diff --git a/sources/tech/20180111 How to install software applications on Linux.md b/sources/tech/20180111 How to install software applications on Linux.md deleted file mode 100644 index 166293cb18..0000000000 --- a/sources/tech/20180111 How to install software applications on Linux.md +++ /dev/null @@ -1,263 +0,0 @@ -Translating By MjSeven - -How to install software applications on Linux -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_) - -Image by : Internet Archive Book Images. Modified by Opensource.com. CC BY-SA 4.0 - -How do you install an application on Linux? As with many operating systems, there isn't just one answer to that question. Applications can come from so many sources--it's nearly impossible to count--and each development team may deliver their software whatever way they feel is best. Knowing how to install what you're given is part of being a true power user of your OS. - -### Repositories - -For well over a decade, Linux has used software repositories to distribute software. A "repository" in this context is a public server hosting installable software packages. A Linux distribution provides a command, and usually a graphical interface to that command, that pulls the software from the server and installs it onto your computer. It's such a simple concept that it has served as the model for all major cellphone operating systems and, more recently, the "app stores" of the two major closed source computer operating systems. - - -![Linux repository][2] - -Not an app store - -Installing from a software repository is the primary method of installing apps on Linux. It should be the first place you look for any application you intend to install. - -To install from a software repository, there's usually a command: -``` - - -$ sudo dnf install inkscape -``` - -The actual command you use depends on what distribution of Linux you use. Fedora uses `dnf`, OpenSUSE uses `zypper`, Debian and Ubuntu use `apt`, Slackware uses `sbopkg`, FreeBSD uses `pkg_add`, and Illumos-based OpenIndiana uses `pkg`. Whatever you use, the incantation usually involves searching for the proper name of what you want to install, because sometimes what you call software is not its official or solitary designation: -``` - - -$ sudo dnf search pyqt - -PyQt.x86_64 : Python bindings for Qt3 - -PyQt4.x86_64 : Python bindings for Qt4 - -python-qt5.x86_64 : PyQt5 is Python bindings for Qt5 -``` - -Once you have located the name of the package you want to install, use the `install` subcommand to perform the actual download and automated install: -``` - - -$ sudo dnf install python-qt5 -``` - -For specifics on installing from a software repository, see your distribution's documentation. - -The same generally holds true with the graphical tools. Search for what you think you want, and then install it. - -![](https://opensource.com/sites/default/files/u128651/apper.png) - -Like the underlying command, the name of the graphical installer depends on what distribution you are running. The relevant application is usually tagged with the software or package keywords, so search your launcher or menu for those terms, and you'll find what you need. Since open source is all about user choice, if you don't like the graphical user interface (GUI) that your distribution provides, there may be an alternative that you can install. And now you know how to do that. - -#### Extra repositories - -Your distribution has its standard repository for software that it packages for you, and there are usually extra repositories common to your distribution. For example, [EPEL][3] serves Red Hat Enterprise Linux and CentOS, [RPMFusion][4] serves Fedora, Ubuntu has various levels of support as well as a Personal Package Archive (PPA) network, [Packman][5] provides extra software for OpenSUSE, and [SlackBuilds.org][6] provides community build scripts for Slackware. - -By default, your Linux OS is set to look at just its official repositories, so if you want to use additional software collections, you must add extra repositories yourself. You can usually install a repository as though it were a software package. In fact, when you install certain software, such as [GNU Ring][7] video chat, the [Vivaldi][8] web browser, Google Chrome, and many others, what you are actually installing is access to their private repositories, from which the latest version of their application is installed to your machine. - - -![Installing a repo][10] - -Installing a repo - -You can also add the repository manually by editing a text file and adding it to your package manager's configuration directory, or by running a command to install the repository. As usual, the exact command you use depends on the distribution you are running; for example, here is a `dnf` command that adds a repository to the system: -``` - - -$ sudo dnf config-manager --add-repo=http://example.com/pub/centos/7 -``` - -### Installing apps without repositories - -The repository model is so popular because it provides a link between the user (you) and the developer. When important updates are released, your system kindly prompts you to accept the updates, and you can accept them all from one centralized location. - -Sometimes, though, there are times when a package is made available with no repository attached. These installable packages come in several forms. - -#### Linux packages - -Sometimes, a developer distributes software in a common Linux packaging format, such as RPM, DEB, or the newer but very popular FlatPak or Snap formats. You make not get access to a repository with this download; you might just get the package. - -The video editor [Lightworks][11], for example, provides a `.deb` file for APT users and an `.rpm` file for RPM users. When you want to update, you return to the website and download the latest appropriate file. - -These one-off packages can be installed with all the same tools used when installing from a repository. If you double-click the package you download, a graphical installer launches and steps you through the install process. - -Alternately, you can install from a terminal. The difference here is that a lone package file you've downloaded from the internet isn't coming from a repository. It's a "local" install, meaning your package management software doesn't need to download it to install it. Most package managers handle this transparently: -``` - - -$ sudo dnf install ~/Downloads/lwks-14.0.0-amd64.rpm -``` - -In some cases, you need to take additional steps to get the application to run, so carefully read the documentation about the software you're installing. - -#### Generic install scripts - -Some developers release their packages in one of several generic formats. Common extensions include `.run` and `.sh`. NVIDIA graphic card drivers, Foundry visual FX packages like Nuke and Mari, and many DRM-free games from [GOG][12] use this style of installer. - -This model of installation relies on the developer to deliver an installation "wizard." Some of the installers are graphical, while others just run in a terminal. - -There are two ways to run these types of installers. - - 1. You can run the installer directly from a terminal: - - -``` - - -$ sh ./game/gog_warsow_x.y.z.sh -``` - - 2. Alternately, you can run it from your desktop by marking it as executable. To mark an installer executable, right-click on its icon and select **Properties**. - -![Giving an installer executable permission][14] - - -Giving an installer executable permission - -Once you've given permission for it to run, double-click the icon to start the install. - -![GOG installer][16] - -GOG installer - -For the rest of the install, just follow the instructions on the screen. - -#### AppImage portable apps - -The AppImage format is relatively new to Linux, although its concept is based on both NeXT and Rox. The idea is simple: everything required to run an application is placed into one directory, and then that directory is treated as an "app." To run the application, you just double-click the icon, and it runs. There's no need or expectation that the application is installed in the traditional sense; it just runs from wherever you have it lying around on your hard drive. - -Despite its ability to run as a self-contained app, an AppImage usually offers to do some soft system integration. - -![AppImage system integration][18] - -AppImage system integration - -If you accept this offer, a local `.desktop` file is installed to your home directory. A `.desktop` file is a small configuration file used by the Applications menu and mimetype system of a Linux desktop. Essentially, placing the desktop config file in your home directory's application list "installs" the application without actually installing it. You get all the benefits of having installed something, and the benefits of being able to run something locally, as a "portable app." - -#### Application directory - -Sometimes, a developer just compiles an application and posts the result as a download, with no install script and no packaging. Usually, this means that you download a TAR file, [extract it][19], and then double-click the executable file (it's usually the one with the name of the software you downloaded). - -![Twine downloaded for Linux][21] - - -Twine downloaded for Linux - -When presented with this style of software delivery, you can either leave it where you downloaded it and launch it manually when you need it, or you can do a quick and dirty install yourself. This involves two simple steps: - - 1. Save the directory to a standard location and launch it manually when you need it. - 2. Save the directory to a standard location and create a `.desktop` file to integrate it into your system. - - - -If you're just installing applications for yourself, it's traditional to keep a `bin` directory (short for "binary") in your home directory as a storage location for locally installed applications and scripts. If you have other users on your system who need access to the applications, it's traditional to place the binaries in `/opt`. Ultimately, it's up to you where you store the application. - -Downloads often come in directories with versioned names, such as `twine_2.13` or `pcgen-v6.07.04`. Since it's reasonable to assume you'll update the application at some point, it's a good idea to either remove the version number or to create a symlink to the directory. This way, the launcher that you create for the application can remain the same, even though you update the application itself. - -To create a `.desktop` launcher file, open a text editor and create a file called `twine.desktop`. The [Desktop Entry Specification][22] is defined by [FreeDesktop.org][23]. Here is a simple launcher for a game development IDE called Twine, installed to the system-wide `/opt` directory: -``` - - -[Desktop Entry] - -Encoding=UTF-8 - -Name=Twine - -GenericName=Twine - -Comment=Twine - -Exec=/opt/twine/Twine - -Icon=/usr/share/icons/oxygen/64x64/categories/applications-games.png - -Terminal=false - -Type=Application - -Categories=Development;IDE; -``` - -The tricky line is the `Exec` line. It must contain a valid command to start the application. Usually, it's just the full path to the thing you downloaded, but in some cases, it's something more complex. For example, a Java application might need to be launched as an argument to Java itself: -``` - - -Exec=java -jar /path/to/foo.jar -``` - -Sometimes, a project includes a wrapper script that you can run so you don't have to figure out the right command: -``` - - -Exec=/opt/foo/foo-launcher.sh -``` - -In the Twine example, there's no icon bundled with the download, so the example `.desktop` file assigns a generic gaming icon that shipped with the KDE desktop. You can use workarounds like that, but if you're more artistic, you can just create your own icon, or you can search the Internet for a good icon. As long as the `Icon` line points to a valid PNG or SVG file, your application will inherit the icon. - -The example script also sets the application category primarily to Development, so in KDE, GNOME, and most other Application menus, Twine appears under the Development category. - -To get this example to appear in an Application menu, place the `twine.desktop` file into one of two places: - - * Place it in `~/.local/share/applications` if you're storing the application in your own home directory. - * Place it in `/usr/share/applications` if you're storing the application in `/opt` or another system-wide location and want it to appear in all your users' Application menus. - - - -And now the application is installed as it needs to be and integrated with the rest of your system. - -### Compiling from source - -Finally, there's the truly universal install format: source code. Compiling an application from source code is a great way to learn how applications are structured, how they interact with your system, and how they can be customized. It's by no means a push-button process, though. It requires a build environment, it usually involves installing dependency libraries and header files, and sometimes a little bit of debugging. - -To learn more about compiling from source code, [read my article][24] on the topic. - -### Now you know - -Some people think installing software is a magical process that only developers understand, or they think it "activates" an application, as if the binary executable file isn't valid until it has been "installed." Hopefully, learning about the many different methods of installing has shown you that install is really just shorthand for "copying files from one place to the appropriate places on your system." There's nothing mysterious about it. As long as you approach each install without expectations of how it's supposed to happen, and instead look for what the developer has set up as the install process, it's generally easy, even if it is different from what you're used to. - -The important thing is that an installer is honest with you. If you come across an installer that attempts to install additional software without your consent (or maybe it asks for consent, but in a confusing or misleading way), or that attempts to run checks on your system for no apparent reason, then don't continue an install. - -Good software is flexible, honest, and open. And now you know how to get good software onto your computer. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/how-install-apps-linux - -作者:[Seth Kenlon][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/seth -[1]:/file/382591 -[2]:https://opensource.com/sites/default/files/u128651/repo.png (Linux repository) -[3]:https://fedoraproject.org/wiki/EPEL -[4]:http://rpmfusion.org -[5]:http://packman.links2linux.org/ -[6]:http://slackbuilds.org -[7]:https://ring.cx/en/download/gnu-linux -[8]:http://vivaldi.com -[9]:/file/382566 -[10]:https://opensource.com/sites/default/files/u128651/access.png (Installing a repo) -[11]:https://www.lwks.com/ -[12]:http://gog.com -[13]:/file/382581 -[14]:https://opensource.com/sites/default/files/u128651/exec.jpg (Giving an installer executable permission) -[15]:/file/382586 -[16]:https://opensource.com/sites/default/files/u128651/gog.jpg (GOG installer) -[17]:/file/382576 -[18]:https://opensource.com/sites/default/files/u128651/appimage.png (AppImage system integration) -[19]:https://opensource.com/article/17/7/how-unzip-targz-file -[20]:/file/382596 -[21]:https://opensource.com/sites/default/files/u128651/twine.jpg (Twine downloaded for Linux) -[22]:https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html -[23]:http://freedesktop.org -[24]:https://opensource.com/article/17/10/open-source-cats From 594e017e3925fde97fc21f4b302dd978cb992b5a Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 22:46:42 +0800 Subject: [PATCH 0121/1057] PUB:20180205 Block ads on your network with Raspberry Pi and pi-hole.md @qhwdw https://linux.cn/article-9481-1.html --- ...205 Block ads on your network with Raspberry Pi and pi-hole.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180205 Block ads on your network with Raspberry Pi and pi-hole.md (100%) diff --git a/translated/tech/20180205 Block ads on your network with Raspberry Pi and pi-hole.md b/published/20180205 Block ads on your network with Raspberry Pi and pi-hole.md similarity index 100% rename from translated/tech/20180205 Block ads on your network with Raspberry Pi and pi-hole.md rename to published/20180205 Block ads on your network with Raspberry Pi and pi-hole.md From 2b359b3d72dba0ce6fde3f42d094ab50e97bbe10 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sun, 25 Mar 2018 22:47:12 +0800 Subject: [PATCH 0122/1057] Create 20180111 How to install software applications on Linux.md --- ... install software applications on Linux.md | 235 ++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 translated/tech/20180111 How to install software applications on Linux.md diff --git a/translated/tech/20180111 How to install software applications on Linux.md b/translated/tech/20180111 How to install software applications on Linux.md new file mode 100644 index 0000000000..a2809f55c9 --- /dev/null +++ b/translated/tech/20180111 How to install software applications on Linux.md @@ -0,0 +1,235 @@ +如何在 Linux 上安装应用程序 +===== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_) + +图片提供:Internet Archive Book Images。由 Opensource.com 修改。CC BY-SA 4.0 + +如何在 Linux 上安装应用程序?与有许多操作系统一样,这个问题不止有一个答案。应用程序可以可以来自许多来源-几乎不可能数的清,并且每个开发团队都可以以他们认为最好的方式提供软件。知道如何安装你所得到的软件是成为操作系统强大用户的一部分。 + + +### 仓库 + +十多年来,Linux 已经使用软件库来分发软件。在这种情况下,“仓库”是一个托管可安装软件包的公共服务器。Linux 发行版提供了一条命令,通常是该命令的图形界面,用于从服务器获取软件并将其安装到你的计算机。这是一个非常简单的概念,它已经成为所有主流手机操作系统的模型,最近,它也成为了两大闭源计算机操作系统的“应用商店”。 + +![Linux repository][2] + +不是一个应用程序商店 + +从软件仓库安装是在 Linux 上安装应用程序的主要方法,它应该是你想要安装的任何应用程序的第一个地方。 + +从软件仓库安装,通常需要一个命令: +``` +$ sudo dnf install inkscape +``` + +实际使用的命令取决于你所使用的 Linux 发行版。Fedora 使用 `dnf`,OpenSUSE 使用 `zypper`,Debian 和 Ubuntu 使用 `apt`,Slackware 使用 `sbopkg`,FreeBSD 使用 `pkg_add`,而基于 lllumos 的 Openlndiana 使用 `pkg`。无论你使用什么,命令通常包括搜索你想要安装应用程序的正确名称,因为有时候你认为的软件名称不是它官方或单独的名称: +``` +$ sudo dnf search pyqt + +PyQt.x86_64 : Python bindings for Qt3 + +PyQt4.x86_64 : Python bindings for Qt4 + +python-qt5.x86_64 : PyQt5 is Python bindings for Qt5 +``` +一旦你找到要安装的软件包的名称后,使用 `install` 子命令执行实际的下载和自动安装: +``` +$ sudo dnf install python-qt5 +``` + +有关从软件仓库安装的具体信息,请参阅你的 Linux 发行版的文档。 + +图形工具通常也是如此。搜索你认为你想要的,然后安装它。 + +![](https://opensource.com/sites/default/files/u128651/apper.png) + +与底层命令一样,图形安装程序的名称取决于你正在运行的 Linux 发行版。相关应用程序通常使用软件或关键字进行标记,因此请在你的启动项或菜单中搜索这些条款,然后你将找到所需的内容。 由于开源是关于用户的选择,所以如果你不喜欢你的发行版提供的图形用户界面(GUI),那么你可以选择安装与否。 现在你知道如何做到这一点。 + +#### 额外仓库 +你的 Linux 发行版为其打包的软件提供了标准仓库,通常也有额外的仓库。例如,[EPEL][3] 服务于 Red Hat Enterprise Linux 和 CentOS,[RPMFusion][4] 服务于 Fedora,Ubuntu 有各种级别的支持以及个人包存档(PPA),[Packman][5] 为 OpenSUSE 提供额外的软件以及 [SlackBuilds.org][6] 为 Slackware 提供社区构建脚本。 + +默认情况下,你的 Linux 操作系统设置为只查看其官方仓库,因此如果你想使用其他软件集合,则必须自己添加额外库。你通常可以像安装软件包一样安装仓库。实际上,当你安装例如 [GNU Ring][7] 视频聊天,[Vivaldi][8] web 浏览器,谷歌浏览器等许多软件时,你实际安装的是访问他们的私人仓库,从中将最新版本的应用程序安装到你的机器上。 + +![Installing a repo][10] + +建立一个仓库 + +你还可以通过编辑文本文件将仓库手动添加到软件包管理器的配置目录,或者运行命令来添加添加仓库。像往常一样,你使用的确切命令取决于 Linux 发行版本。例如,这是一个 `dnf` 命令,它将一个仓库添加到系统中: +``` +$ sudo dnf config-manager --add-repo=http://example.com/pub/centos/7 +``` + +### 不使用仓库来安装应用程序 + +仓库模型非常流行,因为它提供了用户(你)和开发人员之间的链接。重要更新发布之后,系统会提示你接受更新,并且你可以从一个集中位置接受所有更新。 + +然而,有时候一个软件包没有附加的仓库可以使用。这些安装包有几种形式。 + +#### Linux 包 + +有时候,开发人员会以通用的 Linux 打包格式分发软件,例如 RPM,DEB 或较新但非常流行的 FlatPak 或 Snap 格式。你无法使用此下载访问仓库;你可能会得到这个包。 + +例如,视频编辑器 [Lightworks][11] 为 APT 用户提供了一个 `.deb` 文件,RPM 用户提供了 `.rpm` 文件。当你想要更新时,可以到网站下载最新的适合的文件。 + +这些一次性软件包可以使用从仓库进行安装时所用的所有工具进行安装。如果双击下载的软件包,图形安装程序将启动并逐步完成安装过程。 + +或者,你可以从终端进行安装。这里的区别在于你从互联网下载的独立包文件不是来自仓库。这是一个“本地”安装,这意味着你的软件安装包不需要下载来安装。大多数软件包管理器都是透明处理的: +``` +$ sudo dnf install ~/Downloads/lwks-14.0.0-amd64.rpm +``` + +在某些情况下,你需要采取额外的步骤才能使应用程序运行,因此请仔细阅读有关你正在安装软件的文档。 + +#### 通用安装 + +一些开发人员以几种通用格式发布他们的包。常见的扩展包括 `.run` 和 `.sh`。NVIDIA 显卡驱动程序,像 Nuke 和 Mari 这样的 Foundry visual FX 软件包以及来自 [GOG][12] 的许多无 DRM 游戏都是用这种安装程序。(译注:DRM 是数字版权管理。) + +这种安装模式依赖于开发人员提供安装“向导”。一些安装程序是图形化的,而另一些只是在终端中运行。 + +有两种方式来运行这些类型的安装程序。 + +1. 你可以直接从终端运行安装程序: + +``` + +$ sh ./game/gog_warsow_x.y.z.sh +``` +2. 另外,你可以通过标记其为可执行文件来运行它。要标记为安装程序可执行文件,右键单击它的图标并选择 **Properties**。 + +![Giving an installer executable permission][14] + +给安装程序可执行权限。 + +一旦你允许其运行,双击图标就可以安装了。 + +![GOG installer][16] + +GOG 安装程序 + +对于其余的安装程序,只需要按照屏幕上的说明进行操作。 + +#### AppImage 便携式应用程序 + +AppImage 格式对于 Linux 相对来说比较新,尽管它的概念是基于 NeXT 和 Rox 的。这个想法很简单:运行应用程序所需的一切都应该放在一个目录中,然后该目录被视为一个“应用程序”。要运行该应用程序,只需双击该图标即可运行。没有必要或期望应用程序安装在传统意义的地方;它只是从你在硬盘上的任何地方运行。 + +尽管它可以作为独立应用运行,但 AppImage 通常提供一些系统集成。 + +![AppImage system integration][18] + +AppImage 系统集成 + +如果你接受此条件,则将本地 `.desktop` 文件安装到你的主目录。`.desktop` 文件是 Linux 桌面的应用程序菜单和 mimetype 系统使用的一个小配置文件。实质上,将桌面配置文件放置在主目录的应用程序列表中“安装”应用程序,而不实际安装它。你获得了安装某些东西的所有好处,以及能够在本地运行某些东西的好处,例如“便携式应用程序”。 + +#### 应用程序目录 + +有时,开发人员只需要编译一个应用程序,然后将结果发布到下载中,没有安装脚本,也没有打包。通常,这意味着你下载了一个 TAR 文件,然后 [解压缩][19],然后双击可执行文件(通常是你下载软件的名称)。 + + +![Twine downloaded for Linux][21] + +下载 Twine + +当使用这种软件方式交付时,你可以将它放在你下载的地方,当你需要它时,你可以手动启动它,或者你可以自己进行快速但是麻烦的安装。这包括两个简单的步骤: + +1. 将目录保存到一个标准位置,并在需要时手动启动它。 +2. 将目录保存到一个标准位置,并创建一个 `.desktop` 文件,将其集成到你的系统中。 + +如果你只是为自己安装应用程序,那么在你的主目录中保留 `bin` 目录(简称“二进制文件”)作为本地安装的应用程序和脚本的存储位置是传统意义上的。如果你的系统上有其他用户需要访问这些应用程序,传统上将二进制文件放置在 `/opt` 中。最后,这取决于你存储应用程序的位置。 + +下载通常以带版本名称的目录进行,如 `twine_2.13` 或者 `pcgen-v6.07.04`。由于可以合理地假设你将在某个时候更新应用程序,因此将版本号删除或创建目录的符号链接是个不错的主意。这样,即使你更新应用程序本身,为应用程序创建的启动程序也可以保持不变。 + +要创建一个 `.desktop` 启动文件,打开一个文本编辑器并创建一个名为 `twine.desktop` 的文件。[桌面条目规范][22] 由 [FreeDesktop.org][23] 定义。这是一个简单的启动器,用于一个名为 Twine 的游戏开发 IDE,安装在系统范围的 `/opt` 目录中: + +``` +[Desktop Entry] + +Encoding=UTF-8 + +Name=Twine + +GenericName=Twine + +Comment=Twine + +Exec=/opt/twine/Twine + +Icon=/usr/share/icons/oxygen/64x64/categories/applications-games.png + +Terminal=false + +Type=Application + +Categories=Development;IDE; +``` + +棘手的一行是 `Exec` 行。它必须包含一个有效的命令来启动应用程序。通常,它只是你下载的东西的完整路径,但在某些情况下,它更复杂一些。例如,Java 应用程序可能需要作为 Java 自身的参数启动。 +``` +Exec=java -jar /path/to/foo.jar +``` + +有时,一个项目包含一个可以运行的包装脚本,这样你就不必找出正确的命令: +``` +Exec=/opt/foo/foo-launcher.sh +``` + +在这个 Twine 例子中,没有与下载捆绑的图标,因此示例 `.desktop` 文件指定了 KDE 桌面附带的通用游戏图标。你可以使用类似的解决方法,但如果你更具艺术性,这可以创建自己的图标,或者可以在 Internet 上搜索一个好的图标。只要 `Icon` 行指向一个有效的 PNG 或 SVG 文件,你的应用程序就会继承该图标。 + +示例脚本还将应用程序类别主要设置为 Development,因此在 KDE, GNOME 和大多数其他应用程序菜单中,Twine 出现在开发类别下。 + +为了让这个例子出现在应用程序菜单中,把 `twine.desktop` 文件放这到两个地方之一: + +* 如果你将应用程序存储在你自己的家目录下,那么请将其放在 `~/.local/share/applications`。 +* 如果你将应用程序存储在 `/opt` 目录或者其他系统范围的位置,并希望它出现在所有用户的应用程序菜单中,请将它放在 `/usr/share/applications` 目录中。 + +现在,该应用程序已安装,因为它需要与系统的其他部分集成。 + +### 从源代码编译 + +最后,还有真正的通用格式安装格式:源代码。从源代码编译应用程序是学习如何构建应用程序,如何与系统交互以及如何定制应用程序的好方法。尽管如此,它绝不是一个按按钮式过程。它需要一个构建环境,通常需要安装依赖库和头文件,有时还要进行一些调试。 + +要了解更多关于从源代码编译的内容,请阅读[我这篇文章][24]。 + +### 现在你明白了 + +有些人认为安装软件是一个神奇的过程,只有开发人员理解,或者他们认为它“激活”了应用程序,就好像二进制可执行文件在“安装”之前无效。学习许多不同的安装方法会告诉你安装实际上只是“将文件从一个地方复制到系统中适当位置”的简写。 没有什么神秘的。只要你去了解每次安装,不是期望应该如何发生,并且寻找开发者为安装过程设置了什么,那么通常很容易,即使它与你的习惯不同。 + +重要的是安装人员对你很诚实。 如果你遇到未经你的同意尝试安装其他软件的安装程序(或者它可能会以混淆或误导的方式请求同意),或者尝试在没有明显原因的情况下对系统执行检查,则不要继续安装。 + +好的软件是灵活的,诚实的,开放的。 现在你知道如何在你的计算机上获得好的软件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/how-install-apps-linux + +作者:[Seth Kenlon][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[1]:/file/382591 +[2]:https://opensource.com/sites/default/files/u128651/repo.png (Linux repository) +[3]:https://fedoraproject.org/wiki/EPEL +[4]:http://rpmfusion.org +[5]:http://packman.links2linux.org/ +[6]:http://slackbuilds.org +[7]:https://ring.cx/en/download/gnu-linux +[8]:http://vivaldi.com +[9]:/file/382566 +[10]:https://opensource.com/sites/default/files/u128651/access.png (Installing a repo) +[11]:https://www.lwks.com/ +[12]:http://gog.com +[13]:/file/382581 +[14]:https://opensource.com/sites/default/files/u128651/exec.jpg (Giving an installer executable permission) +[15]:/file/382586 +[16]:https://opensource.com/sites/default/files/u128651/gog.jpg (GOG installer) +[17]:/file/382576 +[18]:https://opensource.com/sites/default/files/u128651/appimage.png (AppImage system integration) +[19]:https://opensource.com/article/17/7/how-unzip-targz-file +[20]:/file/382596 +[21]:https://opensource.com/sites/default/files/u128651/twine.jpg (Twine downloaded for Linux) +[22]:https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html +[23]:http://freedesktop.org +[24]:https://opensource.com/article/17/10/open-source-cats From bd06407d676f40eaea18eb6acdbc539982e10f65 Mon Sep 17 00:00:00 2001 From: HankChow Date: Sun, 25 Mar 2018 23:18:34 +0800 Subject: [PATCH 0123/1057] translated --- ...eck Linux Distribution Name and Version.md | 82 ++++++++----------- 1 file changed, 35 insertions(+), 47 deletions(-) rename {sources => translated}/tech/20180215 Check Linux Distribution Name and Version.md (51%) diff --git a/sources/tech/20180215 Check Linux Distribution Name and Version.md b/translated/tech/20180215 Check Linux Distribution Name and Version.md similarity index 51% rename from sources/tech/20180215 Check Linux Distribution Name and Version.md rename to translated/tech/20180215 Check Linux Distribution Name and Version.md index e1ab341eb2..9a3b99eda5 100644 --- a/sources/tech/20180215 Check Linux Distribution Name and Version.md +++ b/translated/tech/20180215 Check Linux Distribution Name and Version.md @@ -1,26 +1,14 @@ -hankchow translating - -Check Linux Distribution Name and Version +查看 Linux 发行版名称和版本号的8种方法 ====== -You have joined new company and want to install some software’s which is requested by DevApp team, also want to restart few of the service after installation. What to do? +如果你加入了一家新公司,要为开发团队安装所需的软件并重启服务,这个时候首先要弄清楚它们运行在什么发行版以及哪个版本的系统上,你才能正确完成后续的工作。作为系统管理员,充分了解系统信息是首要的任务。 -In this situation at least you should know what Distribution & Version is running on it. It will help you perform the activity without any issue. +查看 Linux 发行版名称和版本号有很多种方法。你可能会问,为什么要去了解这些基本信息呢? -Administrator should gather some of the information about the system before doing any activity, which is first task for him. +因为对于诸如 RHEL、Debian、openSUSE、Arch Linux 这几种主流发行版来说,它们各自拥有不同的包管理器来管理系统上的软件包,如果不知道所使用的是哪一个发行版的系统,在包安装的时候就会无从下手,而且由于大多数发行版都是用 systemd 命令而不是 SysVinit 脚本,在重启服务的时候也难以执行正确的命令。 -There are many ways to find the Linux distribution name and version. You might ask, why i want to know this basic things? +下面来看看可以使用那些基本命令来查看 Linux 发行版名称和版本号。 -We have four major distributions such as RHEL, Debian, openSUSE & Arch Linux. Each distribution comes with their own package manager which help us to install packages on the system. - -If you don’t know the distribution name then you wont be able to perform the package installation. - -Also you won’t able to run the proper command for service bounces because most of the distributions implemented systemd command instead of SysVinit script. - -It’s good to have the basic commands which will helps you in many ways. - -Use the following Methods to Check Your Linux Distribution Name and Version. - -### List of methods +### 方法总览 * lsb_release command * /etc/*-release file @@ -33,9 +21,10 @@ Use the following Methods to Check Your Linux Distribution Name and Version. -### Method-1: lsb_release Command +### 方法1: lsb_release 命令 + +LSB(Linux Standard Base,Linux 标准库)能够打印发行版的具体信息,包括发行版名称、版本号、代号等。 -LSB stands for Linux Standard Base that prints distribution-specific information such as Distribution name, Release version and codename. ``` # lsb_release -a No LSB modules are available. @@ -46,11 +35,10 @@ Codename: xenial ``` -### Method-2: /etc/arch-release /etc/os-release File +### 方法2: /etc/arch-release /etc/os-release File -release file typically known as Operating system identification. The `/etc` directory contains many files that contains various information about the distribution. Each distribution has their own set of files, which display this information. +版本文件通常被视为操作系统的标识。在 `/etc` 目录下放置了很多记录着发行版各种信息的文件,每个发行版都各自有一套这样记录着相关信息的文件。下面是一组在 Ubuntu/Debian 系统上显示出来的文件内容。 -The below set of files are present on Ubuntu/Debian system. ``` # cat /etc/issue Ubuntu 16.04.3 LTS \n \l @@ -82,7 +70,7 @@ UBUNTU_CODENAME=xenial ``` -The below set of files are present on RHEL/CentOS/Fedora system. The `/etc/redhat-release` & `/etc/system-release` files symlinks with `/etc/[distro]-release` file. +下面这一组是在 RHEL/CentOS/Fedora 系统上显示出来的文件内容。其中 `/etc/redhat-release` 和 `/etc/system-release` 文件是指向 `/etc/[发行版名称]-release` 文件的一个连接。 ``` # cat /etc/centos-release CentOS release 6.9 (Final) @@ -115,34 +103,34 @@ Fedora release 27 (Twenty Seven) ``` -### Method-3: uname Command +### 方法3: uname 命令 -uname (stands for unix name) is an utility that prints the system information like kernel name, version and other details about the system and the operating system running on it. +uname(unix name) 是一个打印系统信息的工具,包括内核名称、版本号、系统详细信息以及所运行的操作系统等等。 -**Suggested Read :** [6 Methods To Check The Running Linux Kernel Version On System][1] +**建议阅读:** [6种查看系统 Linux 内核的方法][1] ``` # uname -a Linux localhost.localdomain 4.12.14-300.fc26.x86_64 #1 SMP Wed Sep 20 16:28:07 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux ``` -The above colored words describe the version of operating system as Fedora Core 26. +以上运行结果说明使用的操作系统版本是 Fedora 26。 -### Method-4: /proc/version File +### 方法4: /proc/version File -This file specifies the version of the Linux kernel, the version of gcc used to compile the kernel, and the time of kernel compilation. It also contains the kernel compiler’s user name (in parentheses). +这个文件记录了 Linux 内核的版本、用于编译内核的 gcc 的版本、内核编译的时间,以及内核编译者的用户名。 ``` # cat /proc/version -Linux version 4.12.14-300.fc26.x86_64 ([email protected]) (gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) ) #1 SMP Wed Sep 20 16:28:07 UTC 2017 +Linux version 4.12.14-300.fc26.x86_64 ([email protected]) (gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) ) #1 SMP Wed Sep 20 16:28:07 UTC 2017 ``` -### Method-5: dmesg Command +### Method-5: dmesg 命令 -dmesg (stands for display message or driver message) is a command on most Unix-like operating systems that prints the message buffer of the kernel. +dmesg(display message/driver message,展示信息/驱动程序信息)是大多数类 Unix 操作系统上的一个命令,用于打印内核上消息缓冲区的信息。 ``` # dmesg | grep "Linux" -[ 0.000000] Linux version 4.12.14-300.fc26.x86_64 ([email protected]) (gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) ) #1 SMP Wed Sep 20 16:28:07 UTC 2017 +[ 0.000000] Linux version 4.12.14-300.fc26.x86_64 ([email protected]) (gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) ) #1 SMP Wed Sep 20 16:28:07 UTC 2017 [ 0.001000] SELinux: Initializing. [ 0.001000] SELinux: Starting in permissive mode [ 0.470288] SELinux: Registering netfilter hooks @@ -154,11 +142,11 @@ dmesg (stands for display message or driver message) is a command on most Unix-l ``` -### Method-6: Yum/Dnf Command +### Method-6: Yum/Dnf 命令 -Yum (Yellowdog Updater Modified) is one of the package manager utility in Linux operating system. Yum command is used to install, update, search & remove packages on some Linux distributions based on RedHat. +Yum(Yellowdog Updater Modified)是 Linux 操作系统上的一个包管理工具,而 `yum` 命令则是一些基于 RedHat 的 Linux 发行版上用于安装、更新、查找、删除软件包的命令。 -**Suggested Read :** [YUM Command To Manage Packages on RHEL/CentOS Systems][2] +**建议阅读:** [在 RHEL/CentOS 系统上使用 yum 命令管理软件包][2] ``` # yum info nano Loaded plugins: fastestmirror, ovl @@ -180,7 +168,7 @@ Description : GNU nano is a small and friendly text editor. ``` -The below yum repolist command shows that Base, Extras, and Updates repositories are coming from CentOS 7 repository. +下面的 `yum repolist` 命令执行后显示了 yum 的基础源仓库、额外源仓库、更新源仓库都来自 CentOS 7 仓库。 ``` # yum repolist Loaded plugins: fastestmirror, ovl @@ -196,9 +184,9 @@ repolist: 11908 ``` -We can also use Dnf command to check distribution name and version. +使用 `dnf` 命令也同样可以查看发行版名称和版本号。 -**Suggested Read :** [DNF (Fork of YUM) Command To Manage Packages on Fedora System][3] +**建议阅读:** [在 Fedora 系统上使用 DNF(YUM 的一个分支)命令管理软件包][3] ``` # dnf info nano Last metadata expiration check: 0:01:25 ago on Thu Feb 15 01:59:31 2018. @@ -218,22 +206,22 @@ Description : GNU nano is a small and friendly text editor. ``` -### Method-7: RPM Command +### Method-7: RPM 命令 -RPM stands for RedHat Package Manager is a powerful, command line Package Management utility for Red Hat based system such as CentOS, Oracle Linux & Fedora. This help us to identify the running system version. +RPM(RedHat Package Manager, RedHat 包管理器)是在 CentOS、Oracle Linux、Fedora 这些基于 RedHat 的操作系统上的一个强大的命令行包管理工具,同样也可以帮助我们查看系统的版本信息。 -**Suggested Read :** [RPM commands to manage packages on RHEL based systems][4] +**建议阅读:** [在基于 RHEL 的系统上使用 RPM 命令管理软件包][4] ``` # rpm -q nano nano-2.8.7-1.fc27.x86_64 ``` -### Method-8: APT-GET Command +### Method-8: APT-GET 命令 -Apt-Get stands for Advanced Packaging Tool (APT). apg-get is a powerful command-line tool which is used to automatically download and install new software packages, upgrade existing software packages, update the package list index, and to upgrade the entire Debian based systems. +Apt-Get(Advanced Packaging Tool)是一个强大的命令行工具,可以自动下载安装新软件包、更新已有的软件包、更新软件包列表索引,甚至更新整个 Debian 系统。 -**Suggested Read :** [Apt-Get & Apt-Cache commands to manage packages on Debian Based Systems][5] +**建议阅读:** [在基于 Debian 的系统上使用 Apt-Get 和 Apt-Cache 命令管理软件包][5] ``` # apt-cache policy nano nano: @@ -253,7 +241,7 @@ nano: via: https://www.2daygeek.com/check-find-linux-distribution-name-and-version/ 作者:[Magesh Maruthamuthu][a] -译者:[译者ID](https://github.com/译者ID) +译者:[HankChow](https://github.com/HankChow) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 64e0a8551794ca7ab4d3c942395537475f3bce05 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 25 Mar 2018 23:27:26 +0800 Subject: [PATCH 0124/1057] pygmalion666 translating Translating 15% of the article "20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts" --- ... Spice To Your UNIX-Linux Shell Scripts.md | 392 ++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md new file mode 100644 index 0000000000..3735494dee --- /dev/null +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -0,0 +1,392 @@ +# 10 个给 UNIX-Linux Shell 脚本增加趣味的工具 + +====== + +There are some misconceptions that shell scripts are only for a CLI environment. You can efficiently use various tools to write GUI and network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxes, progress bars, etc.). You can always control the final output, cursor position on the screen, various output effects, and more. With the following tools, you can build powerful, interactive, user-friendly UNIX / Linux bash shell scripts. + +有些误解认为 shell 脚本仅适用于命令行环境。你可以在 KDE 或者 Gnome 桌面下有效的使用各种工具编写 GUI 或者网络(socket)脚本。shell 脚本可以利用一些 GUI 的组件(菜单、警告框、状态栏等等)。你可以一直控制屏幕最终输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户有好的 UNIX / Linux bash 脚本。 + +Creating GUI application is not an expensive task but a task that takes time and patience. Luckily, both UNIX and Linux ships with plenty of tools to write beautiful GUI scripts. The following tools are tested on FreeBSD and Linux operating systems but should work under other UNIX like operating systems. + +制作 GUI 应用不是一个昂贵任务,但是需要时间和耐心。幸运的是,UNIX 和 Linux 都附带有大量写漂亮 GUI 脚本的工具。以下工具在 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 + +## 1. notify-send 命令 + +The notify-send command allows you to send desktop notifications to the user via a notification daemon from the command line. This is useful to inform the desktop user about an event or display some form of information without getting in the user's way. You need to install the following package on a Debian/Ubuntu Linux using [apt command][1]/[apt-get command][2]: + +notify-send 命令允许你通过通知守护进程发送桌面通知给用户。这种通知桌面用户一个事件或者显示一些信息,而避免侵入用户的方式是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt][1] 或 [apt-get][2] 命令安装下面的包: + +`$ sudo apt-get install libnotify-bin` +CentOS/RHEL user try the following [yum command][3]: +`$ sudo yum install libnotify` +Fedora Linux user type the following dnf command: +`$ sudo dnf install libnotify` +In this example, send simple desktop notification from the command line, enter: +``` +### send some notification ## +notify-send "rsnapshot done :)" +``` + +Sample outputs: +![Fig:01: notify-send in action ][4] +Here is another code with additional options: +``` +.... +alert=18000 +live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g') +[ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i "BSE Sensex touched 18k"; notify_counter=1; } +... +``` + +Sample outputs: +![Fig.02: notify-send with timeouts and other options][5] +Where, + + * -t 5000: Specifies the timeout in milliseconds ( 5000 milliseconds = 5 seconds) + * -u low : Set the urgency level (i.e. low, normal, or critical). + * -i gtk-dialog-info : Set an icon filename or stock icon to display (you can set path as -i /path/to/your-icon.png). + + + +For more information on use of the notify-send utility, please refer to the notify-send man page, viewable by typing man notify-send from the command line: +``` +man notify-send +``` + +### #2: tput Command + +The tput command is used to set terminal features. With tput you can set: + + * Move the cursor around the screen. + * Get information about terminal. + * Set colors (background and foreground). + * Set bold mode. + * Set reverse mode and much more. + + + +Here is a sample code: +``` +#!/bin/bash + +# clear the screen +tput clear + +# Move cursor to screen location X,Y (top left is 0,0) +tput cup 3 15 + +# Set a foreground colour using ANSI escape +tput setaf 3 +echo "XYX Corp LTD." +tput sgr0 + +tput cup 5 17 +# Set reverse video mode +tput rev +echo "M A I N - M E N U" +tput sgr0 + +tput cup 7 15 +echo "1. User Management" + +tput cup 8 15 +echo "2. Service Management" + +tput cup 9 15 +echo "3. Process Management" + +tput cup 10 15 +echo "4. Backup" + +# Set bold mode +tput bold +tput cup 12 15 +read -p "Enter your choice [1-4] " choice + +tput clear +tput sgr0 +tput rc +``` + + +Sample outputs: +![Fig.03: tput in action][6] +For more detail concerning the tput command, see the following man page: +``` +man 5 terminfo +man tput +``` + +### #3: setleds Command + +The setleds command allows you to set the keyboard leds. In this example, set NumLock on: +``` +setleds -D +num +``` + +To turn it off NumLock, enter: +``` +setleds -D -num +``` + + * -caps : Clear CapsLock. + * +caps : Set CapsLock. + * -scroll : Clear ScrollLock. + * +scroll : Set ScrollLock. + + + +See setleds command man page for more information and options: +`man setleds` + +### #4: zenity Command + +The [zenity commadn will display GTK+ dialogs box][7], and return the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts. Here is a sample GUI client for the whois directory service for given domain name: + +```shell +#!/bin/bash +# Get domain name +_zenity="/usr/bin/zenity" +_out="/tmp/whois.output.$$" +domain=$(${_zenity} --title "Enter domain" \ + --entry --text "Enter the domain you would like to see whois info" ) + +if [ $? -eq 0 ] +then + # Display a progress dialog while searching whois database + whois $domain | tee >(${_zenity} --width=200 --height=100 \ + --title="whois" --progress \ + --pulsate --text="Searching domain info..." \ + --auto-kill --auto-close \ + --percentage=10) >${_out} + + # Display back output + ${_zenity} --width=800 --height=600 \ + --title "Whois info for $domain" \ + --text-info --filename="${_out}" +else + ${_zenity} --error \ + --text="No input provided" +fi +``` + +Sample outputs: +![Fig.04: zenity in Action][8] +See the zenity man page for more information and all other supports GTK+ widgets: +``` +zenity --help +man zenity +``` + +### #5: kdialog Command + +kdialog is just like zenity but it is designed for KDE desktop / qt apps. You can display dialogs using kdialog. The following will display message on screen: +``` +kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not found." +``` + +Sample outputs: +![Fig.05: Suppressing the display of a dialog ][9] + +See [shell scripting with KDE Dialogs][10] tutorial for more information. + +### #6: Dialog + +[Dialog is an application used in shell scripts][11] which displays text user interface widgets. It uses the curses or ncurses library. Here is a sample code: +``` +#!/bin/bash +dialog --title "Delete file" \ +--backtitle "Linux Shell Script Tutorial Example" \ +--yesno "Are you sure you want to permanently delete \"/tmp/foo.txt\"?" 7 60 + +# Get exit status +# 0 means user hit [yes] button. +# 1 means user hit [no] button. +# 255 means user hit [Esc] key. +response=$? +case $response in + 0) echo "File deleted.";; + 1) echo "File not deleted.";; + 255) echo "[ESC] key pressed.";; +esac +``` + +See the dialog man page for details: +`man dialog` + +#### A Note About Other User Interface Widgets Tools + +UNIX and Linux comes with lots of other tools to display and control apps from the command line, and shell scripts can make use of some of the KDE / Gnome / X widget set: + + * **gmessage** - a GTK-based xmessage clone. + * **xmessage** - display a message or query in a window (X-based /bin/echo) + * **whiptail** - display dialog boxes from shell scripts + * **python-dialog** - Python module for making simple Text/Console-mode user interfaces + + + +### #7: logger command + +The logger command writes entries in the system log file such as /var/log/messages. It provides a shell command interface to the syslog system log module: +``` +logger "MySQL database backup failed." +tail -f /var/log/messages +logger -t mysqld -p daemon.error "Database Server failed" +tail -f /var/log/syslog +``` + +Sample outputs: +``` +Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature/speed normal +Apr 20 00:12:20 vivek-desktop mysqld: Database Server failed +``` + +See howto [write message to a syslog / log file][12] for more information. Alternatively, you can see the logger man page for details: +`man logger` + +### #8: setterm Command + +The setterm command can set various terminal attributes. In this example, force screen to turn black in 15 minutes. Monitor standby will occur at 60 minutes: +``` +setterm -blank 15 -powersave powerdown -powerdown 60 +``` + +In this example show underlined text for xterm window: +``` +setterm -underline on; +echo "Add Your Important Message Here" +setterm -underline off +``` + +Another useful option is to turn on or off cursor: +``` +setterm -cursor off +``` + +Turn it on: +``` +setterm -cursor on +``` + +See the setterm command man page for details: +`man setterm` + +### #9: smbclient: Sending Messages To MS-Windows Workstations + +The smbclient command can talk to an SMB/CIFS server. It can send a message to selected users or all users on MS-Windows systems: +``` +smbclient -M WinXPPro </dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 open" || echo "TCP port 25 close" +``` + +You can use [bash loop and find out open ports][14] with the snippets: +``` +echo "Scanning TCP ports..." +for p in {1..1023} +do + (echo >/dev/tcp/localhost/$p) >/dev/null 2>&1 && echo "$p open" +done +``` + + +Sample outputs: +``` +Scanning TCP ports... +22 open +53 open +80 open +139 open +445 open +631 open +``` + +In this example, your bash script act as an HTTP client: +``` +#!/bin/bash +exec 3<> /dev/tcp/${1:-www.cyberciti.biz}/80 + +printf "GET / HTTP/1.0\r\n" >&3 +printf "Accept: text/html, text/plain\r\n" >&3 +printf "Accept-Language: en\r\n" >&3 +printf "User-Agent: nixCraft_BashScript v.%s\r\n" "${BASH_VERSION}" >&3 +printf "\r\n" >&3 + +while read LINE <&3 +do + # do something on $LINE + # or send $LINE to grep or awk for grabbing data + # or simply display back data with echo command + echo $LINE +done +``` + +See the bash man page for more information: +`man bash` + +### A Note About GUI Tools and Cronjob + +You need to request local display/input service using export DISPLAY=[user's machine]:0 command if you are [using cronjob][15] to call your scripts. For example, call /home/vivek/scripts/monitor.stock.sh as follows which uses zenity tool: +`@hourly DISPLAY=:0.0 /home/vivek/scripts/monitor.stock.sh` + +Have a favorite UNIX tool to spice up shell script? Share it in the comments below. + +### about the author + +The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][16], [Facebook][17], [Google+][18]. + +-------------------------------------------------------------------------------- + +via: https://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html + +作者:[Vivek Gite][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz +[1]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) +[2]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) +[3]:https://www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/ (See Linux/Unix yum command examples for more info) +[4]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send.png (notify-send: Shell Script Get Or Send Desktop Notifications ) +[5]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send-with-icons-timeout.png (Linux / UNIX: Display Notifications From Your Shell Scripts With notify-send) +[6]:https://www.cyberciti.biz/media/new/tips/2010/04/tput-options.png (Linux / UNIX Script Colours and Cursor Movement With tput) +[7]:https://bash.cyberciti.biz/guide/Zenity:_Shell_Scripting_with_Gnome +[8]:https://www.cyberciti.biz/media/new/tips/2010/04/zenity-outputs.png (zenity: Linux / UNIX display Dialogs Boxes From The Shell Scripts) +[9]:https://www.cyberciti.biz/media/new/tips/2010/04/KDialog.png (Kdialog: Suppressing the display of a dialog ) +[10]:http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs +[11]:https://bash.cyberciti.biz/guide/Bash_display_dialog_boxes +[12]:https://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html +[13]:https://www.cyberciti.biz/tips/freebsd-sending-a-message-to-windows-workstation.html +[14]:https://www.cyberciti.biz/faq/bash-for-loop/ +[15]:https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/ +[16]:https://twitter.com/nixcraft +[17]:https://facebook.com/nixcraft +[18]:https://plus.google.com/+CybercitiBiz \ No newline at end of file From 1527597cdb6ce4bda92ea55a814a45be6f346529 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 23:54:22 +0800 Subject: [PATCH 0125/1057] PRF:20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md @yizhuoyan --- ...On Linux - Unix Web Server DocumentRoot.md | 83 +++++++++++-------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md b/translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md index 7793a7f2da..2aad1679ba 100644 --- a/translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md +++ b/translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md @@ -1,19 +1,18 @@ - -如何在Linux/Unix中的Web服务根文档目录(DocumentRoot)上设置只读文件权限 +如何在 Web 服务器文档根目录上设置只读文件权限 ====== -我是如何对存放在/var/www/html/目录中的所有我的文件设置只读权限的? +**Q:如何对我存放在 `/var/www/html/` 目录中的所有文件设置只读权限?** + +你可以使用 `chmod` 命令对 Linux/Unix/macOS/OS X/*BSD 操作系统上的所有文件来设置只读权限。这篇文章介绍如何在 Linux/Unix 的 web 服务器(如 Nginx、 Lighttpd、 Apache 等)上来设置只读文件权限。 -你可以使用`chmod`命令对Linux / Unix / macOS / Apple OS X / *BSD操作系统上的所有文件来设置只读权限。这篇文章介绍如何在Linux/Unix的web服务器(如 Nginx, Lighttpd, Apache等)上来设置只读文件权限。 [![Proper read-only permissions for Linux/Unix Nginx/Apache web server's directory][1]][1] ### 如何设置文件为只读模式 - 语法为: ``` -### 仅针对文件 ## +### 仅针对文件 ### chmod 0444 /var/www/html/* chmod 0444 /var/www/html/*.php ``` @@ -21,54 +20,59 @@ chmod 0444 /var/www/html/*.php ### 如何设置目录为只读模式 语法为: + ``` -### 仅针对目录## +### 仅针对目录 ### chmod 0444 /var/www/html/ chmod 0444 /path/to/your/dir/ # *************************************************************************** -# Say webserver user/group is www-data, and file-owned by ftp-data user/group -# 假如webserver用户/用户组是www-data ,文件拥有者是ftp-data用户/用户组 +# 假如 web 服务器的用户/用户组是 www-data,文件拥有者是 ftp-data 用户/用户组 # *************************************************************************** # 设置目录所有文件为只读 chmod -R 0444 /var/www/html/ -#设置文件/目录拥有者为ftp-data +# 设置文件/目录拥有者为 ftp-data chown -R ftp-data:ftp-data /var/www/html/ -# 所有目录和子目录的权限为0445 (这样webserver用户或用户组就可以读取我们的文件) +# 所有目录和子目录的权限为 0445 (这样 web 服务器的用户或用户组就可以读取我们的文件) find /var/www/html/ -type d -print0 | xargs -0 -I {} chmod 0445 "{}" ``` -找到所有/var/www/html下的所有文件(包括子目录),键入: + +找到所有 `/var/www/html` 下的所有文件(包括子目录),键入: ``` -### 仅对文件有效## +### 仅对文件有效 ### find /var/www/html -type f -iname "*" -print0 | xargs -I {} -0 chmod 0444 {} ``` -然而,你需要在/var/www/html目录及其子目录上设置只读和执行权限,如此才能让web server能够访问根目录,键入: + +然而,你需要在 `/var/www/html` 目录及其子目录上设置只读和执行权限,如此才能让 web 服务器能够访问根目录,键入: ``` -### 仅对目录有效 ## +### 仅对目录有效 ### find /var/www/html -type d -iname "*" -print0 | xargs -I {} -0 chmod 0544 {} ``` ### 警惕写权限 +请注意在 `/var/www/html/` 目录上的写权限会允许任何人删除文件或添加新文件。也就是说,你可能需要设置一个只读权限给 `/var/www/html/` 目录本身。 -请注意在/var/www/html/目录上的写权限会允许任何人删除文件或添加新文件。也就是说,你可能需要设置一个只读权限给/var/www/html/目录本身。 ``` -### web根目录只读## +### web根目录只读 ### chmod 0555 /var/www/html ``` + 在某些情况下,根据你的设置要求,你可以改变文件的属主和属组来设置严格的权限。 + ``` -### 如果/var/www/html目录的拥有人是普通用户,你可以设置拥有人为: root:root 或 httpd:httpd (推荐) ### +### 如果 /var/www/html 目录的拥有人是普通用户,你可以设置拥有人为:root:root 或 httpd:httpd (推荐) ### chown -R root:root /var/www/html/ -### 确保apache拥有/var/www/html/ ## +### 确保 apache 拥有 /var/www/html/ ### chown -R apache:apache /var/www/html/ ``` -### 关于NFS导出目录 +### 关于 NFS 导出目录 + +你可以在 `/etc/exports` 文件中指定哪个目录应该拥有[只读或者读写权限 ][2]。这个文件定义各种各样的共享在 NFS 服务器和他们的权限。如: -你可以在/etc/exports文件中指定哪个目录应该拥有[只读或者读写权限 ][2] . 这个文件定义各种各样的共享在NFS服务器和他们的权限。如: ``` # 对任何人只读权限 @@ -78,11 +82,11 @@ chown -R apache:apache /var/www/html/ /var/www/html 192.168.1.10(rw,sync) ``` - -### 关于Samba (CIFS)只读共享对MS-Windows客户端 +### 关于用于 MS-Windows客户端的 Samba(CIFS)只读共享 -共享sales为只读,更新smb.conf,如下: +要以只读共享 `sales`,更新 `smb.conf`,如下: + ``` [sales] comment = Sales Data @@ -91,39 +95,47 @@ read only = Yes guest ok = Yes ``` -### 关于文件系统表(file systems table) +### 关于文件系统表(fstab) + +你可以在 Unix/Linux 上的 `/etc/fstab` 文件中配置挂载某些文件为只读模式。 -你可以在Unix/Linux上的/etc/fstab文件中配置挂载某些文件为只读模式。 你需要有专用分区,不要设置其他系统分区为只读模式。 -如下在/etc/fstab文件中设置/srv/html为只读模式。 +如下在 `/etc/fstab` 文件中设置 `/srv/html` 为只读模式。 + ``` /dev/sda6 /srv/html ext4 ro 1 1 ``` -你可以使用`mount`命令[重新挂载分区为只读模式][3](使用root用户) + +你可以使用 `mount` 命令[重新挂载分区为只读模式][3](使用 root 用户) ``` # mount -o remount,ro /dev/sda6 /srv/html ``` + 或者 + ``` # mount -o remount,ro /srv/html ``` +上面的命令会尝试重新挂载已挂载的文件系统到 `/srv/html`上。这是改变文件系统挂载标志的常用方法,特别是让只读文件改为可写的。这种方式不会改变设备或者挂载点。让文件变得再次可写,键入: -上面的命令会尝试重新挂载已挂载的文件系统在/srv/html上。这是改变文件系统挂载标志的常用方法,特别是让只读文件改为可写的。这种方式不会改变设备或者挂载点。让文件变得再次可写,键入: ``` # mount -o remount,rw /dev/sda6 /srv/html ``` + 或 + ``` # mount -o remount,rw /srv/html ``` -### Linux: chattr 命令 +### Linux:chattr 命令 -你可以在Linux文件系统上使用`chattr`命令[改变文件属性为只读][4],如: +你可以在 Linux 文件系统上使用 `chattr` 命令[改变文件属性为只读][4],如: + ``` chattr +i /path/to/file.php chattr +i /var/www/html/ @@ -132,13 +144,13 @@ chattr +i /var/www/html/ find /var/www/html -iname "*" -print0 | xargs -I {} -0 chattr +i {} ``` +通过提供 `-i` 选项可删除只读属性: -通过提供`-i`选项可删除只读属性 ``` chattr -i /path/to/file.php ``` -FreeBSD, Mac OS X 和其他BSD Unix用户可使用[`chflags`命令][5]: +FreeBSD、Mac OS X 和其他 BSD Unix 用户可使用[`chflags`命令][5]: ``` ### 设置只读 ## @@ -148,14 +160,13 @@ chflags schg /path/to/file.php chflags noschg /path/to/file.php ``` - -------------------------------------------------------------------------------- -来源: https://www.cyberciti.biz/faq/howto-set-readonly-file-permission-in-linux-unix/ +via: https://www.cyberciti.biz/faq/howto-set-readonly-file-permission-in-linux-unix/ 作者:[Vivek Gite][a] 译者:[yizhuoyan](https://github.com/yizhuoyan) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 23c990ff5c4c7e5dab9f5d6d0a33e49bfbca95a7 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 25 Mar 2018 23:54:48 +0800 Subject: [PATCH 0126/1057] PUB:20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md @yizhuoyan https://linux.cn/article-9482-1.html --- ...ly File Permissions On Linux - Unix Web Server DocumentRoot.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md (100%) diff --git a/translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md b/published/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md similarity index 100% rename from translated/tech/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md rename to published/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md From 67f30755dd90daf86d7a32078c9e4b15d5d82ba6 Mon Sep 17 00:00:00 2001 From: amwps290 Date: Mon, 26 Mar 2018 08:07:13 +0800 Subject: [PATCH 0127/1057] translating by amwps290 --- sources/tech/20180322 Simple Load Balancing with DNS on Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180322 Simple Load Balancing with DNS on Linux.md b/sources/tech/20180322 Simple Load Balancing with DNS on Linux.md index f57eea67b5..e0c5da2901 100644 --- a/sources/tech/20180322 Simple Load Balancing with DNS on Linux.md +++ b/sources/tech/20180322 Simple Load Balancing with DNS on Linux.md @@ -1,3 +1,4 @@ +translating by amwps290 Simple Load Balancing with DNS on Linux ====== From ca12cc589b998eff2d9524286a9fe4500ef1c9e6 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Mon, 26 Mar 2018 08:20:16 +0800 Subject: [PATCH 0128/1057] 2018-03-26 --- ...06 Why Linux is better than Windows or macOS for security.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index e81061627c..a36dd6f190 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -5,7 +5,7 @@ fuzheng1998 translating ![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg) -企业投入了大量时间、精力和金钱来保障系统的安全性。安全意识最强的可能就是有一个安全的运转中心。他们肯定用了防火墙以及反病毒软件。他们也可能花费大量时间监控网络,They probably spend a lot of time monitoring their networks, looking for telltale anomalies that could indicate a breach. What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. +企业投入了大量时间、精力和金钱来保障系统的安全性。安全意识最强的可能就是有一个安全的运转中心。他们肯定用了防火墙以及反病毒软件。他们也可能花费大量时间监控网络,寻找可能违约的泄密异常。 What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. But how many have given much thought to one of the cornerstones of their digital operations: the operating systems deployed on the workforce’s PCs? Was security even a factor when the desktop OS was selected? From cd87db277a1b414e1343d78c9467e12f848e3609 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 26 Mar 2018 09:12:31 +0800 Subject: [PATCH 0129/1057] translated --- ...ased Indie Linux Distribution- MagpieOS.md | 80 ------------------- ...ased Indie Linux Distribution- MagpieOS.md | 78 ++++++++++++++++++ 2 files changed, 78 insertions(+), 80 deletions(-) delete mode 100644 sources/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md create mode 100644 translated/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md diff --git a/sources/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md b/sources/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md deleted file mode 100644 index 8a1d32c586..0000000000 --- a/sources/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md +++ /dev/null @@ -1,80 +0,0 @@ -translating---geekpi - -Quick Look at the Arch Based Indie Linux Distribution: MagpieOS -====== -Most of the Linux distros that are in use today are either created and developed in the US or Europe. A young developer from Bangladesh wants to change all that. - -### Who is Rizwan? - -[Rizwan][1] is a computer science student from Bangladesh. He is currently studying to become a profession Python programmer. He started using Linux back in 2015. Working with Linux inspired him to create this own Linux distribution. He also wants to let the rest of the world know that Bangladesh is upgrading to Linux. - -He has also worked on creating a [live version of Linux From Scratch][2]. - -## ![MagpieOS Linux][3] - -### What is MagpieOS? - -Rizwan's new distro is named MagpieOS. [MagpieOS][4] is very simple. It is basically Arch with the GNOME3 desktop environment. MagpieOS also includes a custom repo with icons and themes (claimed to be) not available on other Arch-based distros or AUR. - -Here is a list of the software included with MagpieOS: Firefox, LibreOffice, Uget, Bleachbit, Notepadqq, SUSE Studio Image Writer, Pamac Package Manager, Gparted, Gimp, Rhythmbox, Simple Screen Recorder, all default GNOME software including Totem Video Player, and a new set of custom wallpaper. - -Currently, MagpieOS only supported the GNOME desktop environment. Rizwan picked it because it is his favorite. However, he plans to add more desktop environments in the future. - -Unfortunately, MagpieOS does not support the Bangla language or any other local languages. It supports GNOME's default language like English, Hindi etc. - -Rizwan named his distro MagpieOS because the [magpie][5] is the official bird of Bangladesh. - -## ![MagpieOS Linux][6] - -### Why Arch? - -Like most people, Rizwan started his Linux journey by using [Ubuntu][7]. In the beginning, he was happy with it. However, sometimes the software he wanted to install was not available in the repos and he had to hunt through Google looking for the correct PPA. He decided to switch to [Arch][8] because Arch has many packages that were not available on Ubuntu. Rizwan also liked the fact that Arch is a rolling release and would always be up-to-date. - -The problem with Arch is that it is complicated and time-consuming to install. So, Rizwan tried out several Arch-based distros and was not happy with any of them. He didn't like [Manjaro][9] because they did not have permission to use Arch's repos. Also, Arch repo mirrors are faster than Manjaro's and have more software. He liked [Antergos][10], but to install you need a constant internet connection. If your connection fails during installation, you have to start over. - -Because of these issues, Rizwan decided to create a simple distro that would give him and others an Arch install without all the hassle. He also hopes to get developers from his home country to switch from Ubuntu to Arch by using his distro. - -### How to Help Rizwan with MagpieOS - -If you are interested in helping Rizwan develop MagpieOS, you can contact him via the [MagpieOS website][4]. You can also check out the project's [GitHub page][11]. Rizwan said that he is not looking for financial support at the moment. - -## ![MagpieOS Linux][12] - -### Final Thoughts - -I installed MagpieOS to give it a quick once-over. It uses the [Calamares installer][13], which means installing it was relatively quick and painless. After I rebooted, I was greeted by an audio message welcoming me to MagpieOS. - -To be honest, it was the first time I have heard a post-install greeting. (Windows 10 might have one, but I'm not sure.) There was also a Mac OS-esque application dock at the bottom of the screen. Other than that, it felt like any other GNOME 3 desktop I have used. - -Considering that it's an indie project at the nascent stage, I won't recommend it using as your main OS. But if you are a distrohopper, you can surely give it a try. - -That being said, this is a good first try for a student seeking to put his country on the technological map. All the best, Rizwan. - -Have you already heard of MagpieOS? What is your favorite region or locally made Linux distro? Please let us know in the comments below. - -If you found this article interesting, please take a minute to share it on social media. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/magpieos/ - -作者:[John Paul][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/john/ -[1]:https://twitter.com/Linux_Saikat -[2]:https://itsfoss.com/linux-from-scratch-live-cd/ -[3]:https://itsfoss.com/wp-content/uploads/2018/01/magpieos1.jpg -[4]:http://www.magpieos.net -[5]:https://en.wikipedia.org/wiki/Magpie -[6]:https://itsfoss.com/wp-content/uploads/2018/01/magpieos2.jpg -[7]:https://www.ubuntu.com -[8]:https://www.archlinux.org -[9]:http://manjaro.org -[10]:https://antergos.com -[11]:https://github.com/Rizwan-Hasan/MagpieOS -[12]:https://itsfoss.com/wp-content/uploads/2018/01/magpieos3.png -[13]:https://calamares.io diff --git a/translated/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md b/translated/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md new file mode 100644 index 0000000000..178b242760 --- /dev/null +++ b/translated/tech/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md @@ -0,0 +1,78 @@ +快速了解基于 Arch 的独立 Linux 发行版:MagpieOS +====== +目前使用的大多数 Linux 发行版都是在美国或欧洲创建和开发的。来自孟加拉国的年轻开发人员想要改变这一切。 + +### 谁是 Rizwan? + +[Rizwan][1] 是来自孟加拉国的计算机科学专业的学生。他目前正在学习成为一名专业的 Python 程序员。他在 2015 年开始使用 Linux。使用 Linux 启发他创建了自己的 Linux 发行版。他还希望让世界其他地方知道孟加拉国正在升级到 Linux。 + +他还致力于从头创建[ Linux live 版本][2]。 + +## ![MagpieOS Linux][3] + +### 什么是 MagpieOS? + +Rizwan 的新发行版被命名为 MagpieOS。 [MagpieOS][4]非常简单。它基本上是 GNOME3 桌面环境的 Arch。 MagpieOS 还包括一个自定义的仓库,其中包含图标和主题(据称是),这在其他基于 Arch 的发行版或 AUR上 不可用。 + +下面是 MagpieOS 包含的软件列表:Firefox、LibreOffice、Uget、Bleachbit、Notepadqq、SUSE Studio Image Writer、Pamac 软件包管理器、Gparted、Gimp、Rhythmbox、简单屏幕录像机、包括 Totem 视频播放器在内的所有默认 GNOME 软件,以及一套新的定制壁纸。 + +目前,MagpieOS 仅支持 GNOME 桌面环境。Rizwan 选择它是因为这是他的最爱。但是,他计划在未来添加更多的桌面环境。 + +不幸的是,MagpieOS 不支持孟加拉语或任何其他当地语言。它支持 GNOME 的默认语言,如英语、印地语等。 + +Rizwan 命名他的发行为 MagpieOS,因为[喜鹊][5] (magpie) 是孟加拉国的官方鸟。 + +## ![MagpieOS Linux][6] + +### 为什么选择 Arch? + +和大多数人一样,Rizwan 通过使用 [Ubuntu][7] 开始了他的 Linux 旅程。一开始,他对此感到满意。但是,有时他想安装的软件在仓库中没有,他不得不通过 Google 寻找正确的 PPA。他决定切换到 [Arch][8],因为 Arch 有许多在 Ubuntu 上没有的软件包。Rizwan 也喜欢 Arch 是一个滚动版本,并且始终是最新的。 + +Arch 的问题在于它的安装非常复杂和耗时。所以,Rizwan 尝试了几个基于 Arch 的发行版,并且对任何一个都不满意。他不喜欢 [Manjaro][9],因为他们没有权限使用 Arch 的仓库。此外,Arch 仓库镜像比 Manjaro 更快并且拥有更多软件。他喜欢 [Antergos][10],但要安装需要一个持续的互联网连接。如果在安装过程中连接失败,则必须重新开始。 + +由于这些问题,Rizwan 决定创建一个简单的发行版,让他和其他人无需麻烦地安装 Arch。他还希望通过使用他的发行版让他的祖国的开发人员从 Ubuntu 切换到 Arch。 + +### 如何通过 MagpieOS 帮助 Rizwan + +如果你有兴趣帮助 Rizwan 开发 MagpieOS,你可以通过[ MagpieOS 网站][4]与他联系。你也可以查看该项目的[ GitHub 页面][11]。Rizwan 表示,他目前不寻求财政支持。 + +## ![MagpieOS Linux][12] + +### 最后的想法 + +我快速地一次安装完成 MagpieOS。它使用[ Calamares 安装程序][13],这意味着安装它相对快速和无痛。重新启动后,我听到一封欢迎我来到 MagpieOS 的音频消息。 + +说实话,这是我第一次听到安装后的问候。(Windows 10 可能也有,但我不确定。)屏幕底部还有一个 Mac OS 风格的应用程序停靠栏。除此之外,它感觉像我用过的其他任何 GNOME 3 桌面。 + +考虑到这是一个刚刚起步的独立项目,我不会推荐它作为你的主要操作系统。但是,如果你是一个发行版尝试者,你一定会试试看。 + +话虽如此,对于一个想把自己的国家放在技术地图上的学生来说,这是一个不错的尝试。做得很好,Rizwan。 + +你有没有听说过 MagpieOS?你最喜欢的地区或本地制作的 Linux 发行版是什么?请在下面的评论中告诉我们。 + +如果你发现这篇文章有趣,请花点时间在社交媒体上分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/magpieos/ + +作者:[John Paul][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[1]:https://twitter.com/Linux_Saikat +[2]:https://itsfoss.com/linux-from-scratch-live-cd/ +[3]:https://itsfoss.com/wp-content/uploads/2018/01/magpieos1.jpg +[4]:http://www.magpieos.net +[5]:https://en.wikipedia.org/wiki/Magpie +[6]:https://itsfoss.com/wp-content/uploads/2018/01/magpieos2.jpg +[7]:https://www.ubuntu.com +[8]:https://www.archlinux.org +[9]:http://manjaro.org +[10]:https://antergos.com +[11]:https://github.com/Rizwan-Hasan/MagpieOS +[12]:https://itsfoss.com/wp-content/uploads/2018/01/magpieos3.png +[13]:https://calamares.io From 2ab8eb4c8f03dee97e27b284eebed8aaa36a2211 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 26 Mar 2018 09:15:33 +0800 Subject: [PATCH 0130/1057] translating --- sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md b/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md index 8134eeea3d..2eb36f7e81 100644 --- a/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md +++ b/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md @@ -1,3 +1,5 @@ +translating---geekpi + Caffeinated 6.828: Exercise: Shell ====== From 52b235f3b4b4ecbc8e799a7a676f29d9d8970b97 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 26 Mar 2018 10:30:44 +0800 Subject: [PATCH 0131/1057] PRF:20180306 Most Useful Linux Commands You Can Run in Windows 10.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @CYLeft 有些地方不够细心,还需翻译后自行审读一下为好。 --- ...inux Commands You Can Run in Windows 10.md | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/translated/tech/20180306 Most Useful Linux Commands You Can Run in Windows 10.md b/translated/tech/20180306 Most Useful Linux Commands You Can Run in Windows 10.md index f0dc91b294..6fec18c739 100644 --- a/translated/tech/20180306 Most Useful Linux Commands You Can Run in Windows 10.md +++ b/translated/tech/20180306 Most Useful Linux Commands You Can Run in Windows 10.md @@ -1,128 +1,126 @@ - -运行在 Windows 10 系统中绝对实用的 Linux 命令 +可以运行在 Windows 10 中的最实用的 Linux 命令 ====== ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/wsl-commands.png?itok=91oEXdO8) 在本系列早先的文章中,我们讨论了关于如何在 [Windows 10 上开启 WSL 之旅][1] 的内容。作为本系列的最后一篇文章,我们准备探讨一些能在 Windows 10 上广泛使用的 Linux 命令。 -话题深入之前,请先让我们明确本教程所适用的人群。本文适用于使用 Windows 10 系统的初级开发者,帮助其了解学习关于 Azure、AWS 或是私有云的 Linux 平台。换句话说,就是为了帮助初次接触 Linux 系统的 Windows 10 用户。 +话题深入之前,请先让我们明确本教程所适用的人群。本文适用于使用 Windows 10 系统,但是又想在 Azure、AWS 或是私有云平台上学习 Linux 的初级开发者。换句话说,就是为了帮助初次接触 Linux 系统的 Windows 10 用户。 -您的工作量决定了您所需要的命令,而我的需求可能和您的不一样。本文旨在帮助您在 Windwos 10 上舒服的使用 Linux。不过请牢记,WSL 并不提供硬件访问的功能,比如声卡、GPU,至少官方是这么描述的。但是这可能并不能阻止 Linux 用户的折腾精神。很多用户不仅完成了硬件访问,甚至已经在 Windows 10 上安装上了 Linux 桌面程序。但是本文并不会涉及这些内容,我们可能会讨论这些,但不是现在。 +您的工作任务决定了您所需要的命令,而我的需求可能和您的不一样。本文旨在帮助您在 Windwos 10 上舒服的使用 Linux。不过请牢记,WSL 并不提供硬件访问的功能,比如声卡、GPU,至少官方是这么描述的。但是这可能并不能阻止 Linux 用户的折腾精神。很多用户不仅完成了硬件访问,甚至已经在 Windows 10 上安装上了 Linux 桌面程序。但是本文并不会涉及这些内容,我们可能会讨论这些,但不是现在。 下面是我们需要着手的任务。 ### 如何让您的 Linux 系统保持到最新的版本 -因为 Linux 运行在了 Windows 系统中,所以您将被剥夺 Linux 系统所提供的所有安全服务。另外,如果不及时给 Linux 系统打补丁,Windows 设备将被迫暴露在外界威胁中,所以还请保持您的 Linux 设备到最新版本。 +因为 Linux 运行在了 Windows 系统中,所以您将被剥夺 Linux 系统所提供的所有安全特性。另外,如果不及时给 Linux 系统打补丁,你的 Windows 设备将被迫暴露在外界威胁中,所以还请保持您的 Linux 为最新版本。 -WSL 官方支持 openSUSE、SUSE Linux Enterprise 和 Ubuntu。您也可以安装其他发行版,但是我只需要它们当中的两个就可以完成我的所有工作,毕竟,我只需要访问一些 Linux 基础程序。 +WSL 官方支持 openSUSE/SUSE Linux Enterprise 和 Ubuntu。您也可以安装其他发行版,但是我只需要它们当中的二者之一就可以完成我的所有工作,毕竟,我只需要访问一些 Linux 基础程序。 **更新 openSUSE Leap:** + ``` sudo zypper up - ``` 如果您想升级系统,您可以运行下面的命令: + ``` sudo zypper dup - ``` **更新 Ubuntu:** + ``` sudo apt-get update - sudo apt-get dist-upgrade - ``` -由于 Linux 系统的更新是渐进式的,所以更新系统成为了我的日常。Windows 10 的更新通常需要重启系统,而 Linux 不同,一般只有 KB 或是 MB 级的更新,无需重启。 +这样你就安全了,由于 Linux 系统的更新是渐进式的,所以更新系统成为了我的日常。不像 Windows 10 的更新通常需要重启系统,而 Linux 不同,一般只有 KB 或是 MB 级的更新,无需重启。 ### 管理文件目录 -系统更新之后,我们还剩余一些非必要或是不那么重要的任务。 +系统更新之后,我们来看看一些或普通或不太普通的任务。 -系统更新之外的第二重要的任务是使用 Linux 管理本地和远程文件。我承认我更青睐图形界面程序,但是终端能提供更可靠、更有价值的服务。使用 Explorer 程序,尝试移动 1 TB 的文件,祝你好运。数据量大的话,我通常使用 rsync 命令来移动它们。如果中断任务,rsync 可以在上次停止的节点继续工作。 +系统更新之外的第二重要的任务是使用 Linux 管理本地和远程文件。我承认我更青睐图形界面程序,但是终端能提供更可靠、更有价值的服务。要不你使用资源管理器移动 1 TB 的文件试试?我通常使用 `rsync` 命令来移动大量文件。如果中断任务,`rsync` 可以在上次停止的位置继续工作。 -虽然您可能更习惯使用 cp 或是 mv 命令复制、移动文件,但是我还是喜欢灵活的 rsync 命令,了解 rsync 对远程文件传输也有帮助。使用 rsync 大半为了完成下面三个任务: +虽然您可能更习惯使用 `cp` 或是 `mv` 命令复制、移动文件,但是我还是喜欢灵活的 `rsync` 命令,了解 `rsync` 对远程文件传输也有帮助。使用 `rsync` 大半为了完成下面三个任务: **使用 rsync 复制整个目录:** + ``` rsync -avzP /source-directory /destination directory - ``` **使用 rsync 移动文件:** + ``` rsync --remove-source-files -avzP /source-directory /destination-directory - ``` 在成功复制目标目录之后,此命令将删除源文件。 **使用 rsync 同步文件:** -我的文件可能在多处存储。但是,我只会在主要位置中增加或是删除。如果不使用专业的软件,同步文件可能会给用户带来挑战,而 rsync 刚好可以简化这个过程。这个命令可以让两个目录文件内容同步,留个印象,也许用得上。 +我的文件可能在多处存储。但是,我只会在主要位置中增加或是删除。如果不使用专业的软件,同步文件可能会给用户带来挑战,而 `rsync` 刚好可以简化这个过程。这个命令可以让两个目录文件内容同步。不过要注意,这是一个单向同步,即从源位置同步到目标位置。 + ``` rsync --delete -avzP /source-directory /destination-directory - ``` -如果原目录中没有找到文件,上述命令将删除目标目录中的文件,并通过另一种方式创建源目录的镜像复制。 +如果源目录中没有找到文件,上述命令将删除目标目录中的文件。换言之,它创建了源目录的一个镜像。 ### 文件自动备份 -保持文件备份是一项普通的工作。为了保持我的设备的完全同步,我运行了一个 cron 作业在夜间持续同步我的所有目录。保持一个外部驱动,每周我都会手动同步。由于可能删掉我不想删除的文件,所以我并没有使用 --delete 选项。 +保持文件备份是一项乏味的工作。为了保持我的设备的完全同步,我运行了一个 cron 作业在夜间保持我的所有目录同步。不过我会留一个外部驱动器,基本上每周我都会手动同步一次。由于可能删掉我不想删除的文件,所以我并没有使用 `--delete` 选项。我会根据情况手动决定是否使用这个选项。 + +**创建 cron 作业,打开 crontab:** -**创建 cron 作业, 打开 crontab:** ``` crontab -e - ``` 移动大文件时,我会选择在系统空闲的深夜执行该命令。此命令将在每天早上 1 点运行,您大概可以这样修改它: + ``` # 0 1 * * * rsync -avzP /source-directory /destination-directory - ``` 这是使用 crontab 的定时作业的命令结构: + ``` # m h dom mon dow command - ``` -在此,m = 分钟, h = 小时, dom= 本月的某天, mon= 月; dow= 本周的某天。 +在此,`m` = 分钟,`h` = 小时,`dom` = 本月的某天,`mon` = 月,`dow` = 本周的某天。 -我们将在每天早上 1 点运行这条命令。您可以选择 dow 或是 dom(比如,每月 5 号)等。您可以在 [这里][2] 阅读更多相关内容。 +我们将在每天早上 1 点运行这条命令。您可以选择 `dow` 或是 `dom`(比如,每月 5 号)等。您可以在 [这里][2] 阅读更多相关内容。 ### 管理远程服务器 -在 Windows 系统上使用 WSL 的优势之一就是能方便管理远程 Linux 服务器,WSL 能提供原生的 Linux 工具给您。首先,您需要使用 ssh 命令登陆远程 Linux 服务器。 +在 Windows 系统上使用 WSL 的优势之一就是能方便管理云上的 Linux 服务器,WSL 能提供原生的 Linux 工具给您。首先,您需要使用 `ssh` 命令登录远程 Linux 服务器。 + +比如,我的服务器 ip 是 192.168.0.112;端口为 2018(不是默认的 22 端口);Linux 用户名是 swapnil,密码是 “就不告诉你”。 -比如,我的服务器 ip 是 192.168.0.112;端口为 2018(不是默认的 22 端口);Linux 用户名是 swapnil,密码是 `就不告诉你`。 ``` ssh -p2018 swapnil@192.168.0.112 - ``` -它会向您请求用户密码,然后您就可以登陆到 Linux 服务器了。现在您可以执行任意您想执行的所有操作,且不需使用额外的 puTTY 程序。 +它会向您询问用户密码,然后您就可以登录到 Linux 服务器了。现在您可以在 Linux 服务器上执行任意您想执行的所有操作了。不需使用 PuTTY 程序了。 -使用 rsync ,您可以很轻易的将本地文件传输到远程设备。源文件还是目标目录取决于您是上传文件到服务器,还是下载文件到本地目录,您可以使用 [username@IP][3]。 +使用 `rsync` ,您可以很轻易的在本地机器和远程机器之间传输文件。源目录还是目标目录取决于您是上传文件到服务器,还是下载文件到本地目录,您可以使用 `username@IP-address-of-server:/path-of-directory` 来指定目录。 + +如果我想复制一些文本内容到服务器的 home 目录,命令如下: -如果我想在服务器中复制一些文本内容到 home 目录,参照这里的目录: ``` rsync -avzP /source-directory-on-local-machine ‘ssh -p2018’ swapnil@192.168.0.112:/home/swapnil/Documents/ - ``` -这将会在远程服务器中复制文件到 `Documents` 目录。 +这将会复制这些文件到远程服务器中 `Documents` 目录。 ### 总结 -本教程主要是为了证明您可以通过 Windows 10 系统的 WSL 完成 Linux 系的很大一部分的任务。通常来说,它提高了生产效率。现在,Linux 的世界已经向 Windwos 10 系统打开怀抱了,尽情探索吧。如果您有任何疑问,或是想了解 WSL 涉及到的其他层面,欢迎在下方的评论区分享您的想法。 +本教程主要是为了证明您可以在 Windows 10 系统上通过 WSL 完成 Linux 方面的很大一部分的任务。通常来说,它提高了生产效率。现在,Linux 的世界已经向 Windwos 10 系统张开怀抱了,尽情探索吧。如果您有任何疑问,或是想了解 WSL 涉及到的其他层面,欢迎在下方的评论区分享您的想法。 在 [Administering Linux on Azure (LFS205)][4] 课程中了解更多,可以在 [这里][5] 注册。 @@ -132,7 +130,7 @@ via: https://www.linux.com/blog/learn/2018/3/most-useful-linux-commands-you-can- 作者:[SAPNIL BHARTIYA][a] 译者:[CYLeft](https://github.com/CYLeft) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 224225298dd50c0ca8a94e97eb0701ca3ed0499d Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 26 Mar 2018 10:31:16 +0800 Subject: [PATCH 0132/1057] PUB:20180306 Most Useful Linux Commands You Can Run in Windows 10.md @CYLeft https://linux.cn/article-9483-1.html --- ...180306 Most Useful Linux Commands You Can Run in Windows 10.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180306 Most Useful Linux Commands You Can Run in Windows 10.md (100%) diff --git a/translated/tech/20180306 Most Useful Linux Commands You Can Run in Windows 10.md b/published/20180306 Most Useful Linux Commands You Can Run in Windows 10.md similarity index 100% rename from translated/tech/20180306 Most Useful Linux Commands You Can Run in Windows 10.md rename to published/20180306 Most Useful Linux Commands You Can Run in Windows 10.md From 3e41808e46c3e358f7224b5dcf03267d21dbdbc1 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 26 Mar 2018 10:57:01 +0800 Subject: [PATCH 0133/1057] Update 20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md --- ...1009 10 Free Linux Productivity Apps You Haven-t Heard Of.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md b/sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md index ed77417a7c..940b438c8a 100644 --- a/sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md +++ b/sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md @@ -1,3 +1,5 @@ +Translating by MjSeven + 10 Free Linux Productivity Apps You Haven’t Heard Of ====== From a214135b88778bc0e9f02bd4cff2cbd42220111e Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 26 Mar 2018 14:31:43 +0800 Subject: [PATCH 0134/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Top=20Linux=20t?= =?UTF-8?q?ools=20for=20writers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180323 Top Linux tools for writers.md | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 sources/talk/20180323 Top Linux tools for writers.md diff --git a/sources/talk/20180323 Top Linux tools for writers.md b/sources/talk/20180323 Top Linux tools for writers.md new file mode 100644 index 0000000000..befca52ffb --- /dev/null +++ b/sources/talk/20180323 Top Linux tools for writers.md @@ -0,0 +1,78 @@ +Top Linux tools for writers +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_pencils.png?itok=U2FwL2LA) +If you've read [my article about how I switched to Linux][1], then you know that I’m a superuser. I also stated that I’m not an “expert” on anything. That’s still fair to say. But I have learned many helpful things over the last several years, and I'd like to pass these tips along to other new Linux users. + +Today, I’m going to discuss the tools I use when I write. I based my choices on three criteria: + + 1. My main writing tool must be compatible for any publisher when I submit stories or articles. + 2. The software must be quick and simple to use. + 3. Free is good. + + + +There are some wonderful all-in-one free solutions, such as: + +However, I tend to get lost and lose my train of thought when I'm trying to find information, so I opted to go with multiple applications that suit my needs. Also, I don’t want to be reliant on the internet in case service goes down. I set these programs up on my monitor so I can see them all at once. + +Consider the following tools suggestions—everyone works differently, and you might find some other app that better fits the way you work. These tools are current to this writing: + +### Word processor + +[LibreOffice 6.0.1][2]. Until recently, I used [WPS][3], but font-rendering problems (Times New Roman was always in bold format) nixed it. The newest version of LibreOffice adapts to Microsoft Office very nicely, and the fact that it's open source ticks the box for me. + +### Thesaurus + +[Artha][4] gives you synonyms, antonyms, derivatives, and more. It’s clean-looking and fast. Type the word "fast," for example, and you'll get the dictionary definition as well as the other options listed above. Artha is a huge gift to the open source community, and more people should try it as it seems to be one of those obscure little programs. If you’re using Linux, install this application now. You won’t regret it. + +### Note-taking + +[Zim][5] touts itself as a desktop wiki, but it’s also the easiest multi-level note-taking app you’ll find anywhere. There are other, prettier note-taking programs available, but Zim is exactly what I need to manage my characters, locations, plots, and sub-plots. + +### Submission tracking + +I once used a proprietary piece of software called [FileMaker Pro][6], and it spoiled me. There are plenty of database applications out there, but in my opinion the easiest one to use is [Glom][7]. It suits my needs graphically, letting me enter information in a form rather than a table. In Glom, you create the form you need so you can see relevant information instantly (for me, digging through a spreadsheet table to find information is like dragging my eyeballs over shards of glass). Although Glom no longer appears to be in development, it remains relevant. + +### Research + +I’ve begun using [StartPage.com][8] as my default search engine. Sure, [Google][9] can be one of your best friends when you're writing. But I don't like how Google tracks me every time I want to learn about a specific person/place/thing. So I use StartPage.com instead; it's fast and does not track your searches. I also use [DuckDuckGo.com][10] as an alternative to Google. + +### Other tools + +[Chromium Browser][11] is an open source version of [Google Chrome][12], with privacy plugins. + +Though [Thunderbird][13], from [Mozilla][14], is a great program, I find [Geary][15] a much quicker and lighter email app. For more on open source email apps, read [Jason Baker][16]'s excellent article, [Top 6 open source desktop email clients][17]. + +As you might have noticed, my taste in apps tends to merge the best of Windows, MacOS, and the open source Linux alternatives mentioned here. I hope these suggestions help you discover helpful new ways to compose (thank you, Artha!) and track your written works. + +Happy writing! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/top-Linux-tools-for-writers + +作者:[Adam Worth][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/adamworth +[1]:https://opensource.com/article/18/2/my-linux-story-Antergos +[2]:https://www.libreoffice.org/ +[3]:http://wps-community.org/ +[4]:https://sourceforge.net/projects/artha/ +[5]:http://zim-wiki.org/ +[6]:http://www.filemaker.com/ +[7]:https://www.glom.org/ +[8]:https://www.startpage.com/ +[9]:https://www.google.com/ +[10]:https://duckduckgo.com/ +[11]:https://www.chromium.org/ +[12]:https://www.google.com/chrome/ +[13]:https://www.mozilla.org/en-US/thunderbird/ +[14]:https://www.mozilla.org/en-US/ +[15]:https://wiki.gnome.org/Apps/Geary +[16]:https://opensource.com/users/jason-baker +[17]:https://opensource.com/business/18/1/desktop-email-clients From 9477b015dac6c7081a5b100b7fba9aa35e7f5f2e Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 26 Mar 2018 14:33:34 +0800 Subject: [PATCH 0135/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20tell?= =?UTF-8?q?=20when=20moving=20to=20blockchain=20is=20a=20bad=20idea?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...when moving to blockchain is a bad idea.md | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md diff --git a/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md new file mode 100644 index 0000000000..9f5fe6c01d --- /dev/null +++ b/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -0,0 +1,82 @@ +How to tell when moving to blockchain is a bad idea +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/blocks_building.png?itok=eMOT-ire) +So, there's this thing called "blockchain" that is quite popular… + +You know that already, of course. I keep wondering whether we've hit "peak hype" for blockchain and related technologies yet, but so far there's no sign of it. When I'm talking about blockchain here, I'm including distributed ledger technologies (DLTs), which are, by some tight definitions of the term, not really blockchains at all. I'm particularly interested, from a professional point of view, in permissioned blockchains. You can read more about how that's defined in my article [Is blockchain a security topic?][1] The key point here is that I'm interested in business applications of blockchain beyond cryptocurrency.1 + +And, if the hype is to be believed—and some of it probably should be2—then there is an almost infinite set of applications for blockchain. That's probably correct, but it doesn't mean all of them are good applications for blockchain. Some, in fact, are likely to be very bad applications for blockchain. + +The hype associated with blockchain, however, means that businesses are rushing to embrace this new technology3 without really understanding what they're doing. The drivers towards this are arguably three-fold: + + 1. You can, if you try, make almost any application with multiple users that stores data into a blockchain-enabled application. + 2. There are lots of conferences and "gurus" telling people that if they don't embrace blockchain now, they'll go out of business within six months4. + 3. It's not easy technology to understand fully, and lots of its proponents "on-the-ground" in organisations are techies. + + + +I want to unpack that last statement before I get a hail of trolls flaming me.5 I have nothing against techies—I'm one myself—but one of our characteristics tends to be enormous enthusiasm about new things ("shinies") that we understand, but whose impact on the business we don't always fully grok.6 That's not always a positive for business leaders. + +The danger, then, is that the confluence of those three drivers may lead to businesses moving to blockchain applications without fully understanding whether it's a good idea. I wrote in another post ([Blockchain: should we all play?][2]) about some tests to decide when a process is a good fit for blockchain and when it's not. They were useful, but the more I think about it, the more I'm convinced that we need some simple tests to tell us when we should definitely not move a process or an application to a blockchain. I present my three tests. If your answer to any of these questions is "yes," then you almost certainly don't need a blockchain. + +### Test 1: Does it have a centralised controller or authority? + +If the answer is "yes," then you don't need a blockchain. + +If, for instance, you're selling, I don't know, futons, and you have a single ordering system, then you have a single authority for deciding when to send out a futon. You almost certainly don't need to make this a blockchain. If you are a purveyor of content that has to pass through a single editorial and publishing process, you almost certainly don't need to make this a blockchain. + +The lesson is: Blockchains really don't make sense unless the tasks required in the process execution—and the trust associated with those tasks—is distributed among multiple entities. + +### Test 2: Could it work fine with a standard database? + +If the answer to this question is "yes," then you don't need a blockchain. + +This and the previous question are somewhat intertwined but don't need to be. There are applications where you have distributed processes but need to store information centrally, or you have centralised authorities but distributed data, where one answer may be "yes" and the other is "no." But if your answer to this question is "yes," use a standard database. + +Databases are good at what they do, they are cheaper in terms of design and operations than running a blockchain or distributed ledger, and we know how to make them work. Blockchains are about letting everybody8 see and hold data, but the overheads can be high and the implications costly. + +### Test 3: Is adoption going to be costly or annoying to some stakeholders? + +If the answer to this question is "yes," then you don't need a blockchain. + +I've heard assertions that blockchains always benefit all users. This is patently false. If you are creating an application for a process and changing the way your stakeholders interact with you and it, you need to consider whether that change is in their best interests. It's very easy to create and introduce an application, blockchain or not, that reduces business friction for the owner of the process but increases it for other stakeholders. + +If I make engine parts for the automotive industry, it may benefit me immensely to be able to track and manage the parts on a blockchain. I may be able to see at a glance who supplied what, when, and the quality of the steel used in the (for example) ball bearings I buy. On the other hand, if I'm a ball-bearing producer with an established process that works for the 40 other companies to whom I sell ball bearings, adopting a new process for one company—with associated changes to my method of work, systems, storage, and security requirements—is unlikely to be in my best interests. It's going to be both costly and annoying. + +### In summary + +Tests are guidelines; they're not fixed in stone. One of these tests looks like a technical test (the database one), but it's really as much about business roles and responsibilities as the other two. All of them, hopefully, can be used as a counterbalance to the three drivers of blockchain adoption I mentioned. + +1\. Which, don't get me wrong, is definitely interesting and a business application—it's just not what I'm going to talk about in this post. + +2\. The trick is knowing which bits. Let me know if you work out how, OK? + +3\. It's actually quite a large set of technologies, to be honest. + +4\. Which is patently untrue, unless the word "they" refers to the conferences and gurus, in which case it's probably correct. + +5\. Which may happen anyway due to my egregious mixing of metaphors. + +6\. There's a word to love. I've put it in to exhibit my techie credentials.7 + +7\. And before you doubt them, yes, I've read the book, in both cut and uncut versions. + +8\. Within reason. + +This article originally appeared on [Alice, Eve, and Bob – a security blog][3] and is republished with permission. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/3-tests-not-moving-blockchain + +作者:[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/12/blockchain-security-topic +[2]:https://aliceevebob.com/2017/09/12/blockchain-should-we-all-play/ +[3]:https://aliceevebob.com/2018/02/13/3-tests-for-not-moving-to-blockchain/ From 954583a1b241a08308ff0547d18d90d6ee79646b Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 26 Mar 2018 14:43:54 +0800 Subject: [PATCH 0136/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=207=20steps=20to?= =?UTF-8?q?=20DevOps=20hiring=20success?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...180323 7 steps to DevOps hiring success.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 sources/talk/20180323 7 steps to DevOps hiring success.md diff --git a/sources/talk/20180323 7 steps to DevOps hiring success.md b/sources/talk/20180323 7 steps to DevOps hiring success.md new file mode 100644 index 0000000000..cdea0c65ac --- /dev/null +++ b/sources/talk/20180323 7 steps to DevOps hiring success.md @@ -0,0 +1,56 @@ +7 steps to DevOps hiring success +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) +As many of us in the DevOps scene know, most companies are hiring, or, at least, trying to do so. The required skills and job descriptions can change entirely from company to company. As a broad overview, most teams are looking for a candidate from either an operations and infrastructure background or someone from a software engineering and development background, then combined with key skills relating to continuous integration, configuration management, continuous delivery/deployment, and cloud infrastructure. Currently in high-demand is knowledge of container orchestration. + +In the ideal world, the two backgrounds will meet somewhere in the middle to form Dev and Ops, but in most cases, there is a lean toward one side or the other while maintaining sufficient skills to understand the needs and demands of their counterparts to work collaboratively and achieve the end goal of continuous delivery/deployment. Every company is different and there isn’t necessarily a right or wrong here. It all depends on your infrastructure, tech stack, other team members’ skills, and the individual goals you hope to achieve by hiring this individual. + +### Focus your hiring + +Now, given the various routes to becoming a DevOps practitioner, how do hiring managers focus their search and selection process to ensure that they’re hitting the mark? + +#### Decide on the background + +Assess the strengths of your existing team. Do you already have some amazing software engineers but you’re lacking the infrastructure knowledge? Aim to close these gaps in skills. You may have been given the budget to hire for DevOps, but you don’t have to spend weeks/months searching for the best software engineer who happens to use Docker and Kubernetes because they are the current hot trends in this space. Find the person who will provide the most value in your environment and go from there. + +#### Contractor or permanent employee? + +Many hiring managers will automatically start searching for a full-time permanent employee when their needs may suggest that they have other options. Sometimes a contractor is your best bet or maybe contract-hire. If you’re aiming to design, implement and build a new DevOps environment, why not find a senior person who has done this a number of times already? Try hiring a senior contractor and bring on a junior full-time hire in parallel; this way, you’ll be able to retain the external contractor knowledge by having them work alongside the junior hire. Contractors can be expensive, but the knowledge they bring can be invaluable, especially if the work can be completed over a shorter time frame. Again, this is just another point of view and you might be best off with a full-time hire to grow the team. + +#### CTRL F is not the solution + +Focus on their understanding of DevOps and CI/CD-related processes over specific tools. I believe the best approach is to focus on finding someone who understands the methodologies over the tools. Does your candidate understand the concept of continuous integration or the concept of continuous delivery? That’s more important than asking whether your candidate uses Jenkins versus Bamboo versus TeamCity and so on. Try not to get caught up in the exact tool chain. The focus should be on the candidates’ ability to solve problems. Are they obsessed with increasing efficiency, saving time, automating manual processes and constantly searching for flaws in the system? They might be the person you were looking for, but you missed them because you didn’t see the word "Puppet" on the resume. + +#### Work closely with your internal talent acquisition team and/or an external recruiter + +Be clear and precise with what you’re looking for and have an ongoing, open communication with recruiters. They can and will help you if used effectively. The job of these recruiters is to save you time by sourcing candidates while you’re focusing on your day-to-day role. Work closely with them and deliver in the same way that you would expect them to deliver for you. If you say you will review a candidate by X time, do it. If they say they’ll have a candidate in your inbox by Y time, make sure they do it, too. Start by setting up an initial call to talk through your requirement, lay out a timeline in which you expect candidates by a specific time, and explain your process in terms of when you will interview, how many interview rounds, and how soon after you will be able to make a final decision on whether to offer or reject the candidates. If you can get this relationship working well, you’ll save lots of time. And make sure your internal teams are focused on supporting your process, not blocking it. + +#### $$$ + +Decide how much you want to pay. It’s not all about the money, but you can waste a lot of your and other people’s time if you don’t lock down the ballpark salary or hourly rate that you can afford. If your budget doesn’t stretch as far as your competitors’, you need to consider what else can help sell the opportunity. Flexible working hours and remote working options are some great ways to do this. Most companies have snacks, beer, and cool offices nowadays, so focus on the real value such as the innovative work your team is doing and how awesome your game-changing product might be. + +#### Drop the ego + +You may have an amazing company and/or product, but you also have some hot competition. Everyone is hiring in this space and candidates have a lot of the buying power. It is no longer as simple as saying, "We are hiring" and the awesome candidates come flowing in. You need to sell your opportunities. Maintaining a reputation as a great place to work is also important. A poor hiring process, such as interviewing without giving feedback, can contribute to bad rumors being spread across the industry. It only takes a few minutes to leave a sour review on Glassdoor. + +#### A smooth process is a successful One + +"Let’s get every single person within the company to do a one-hour interview with the new DevOps person we are hiring!" No, let’s not do that. Two or three stages should be sufficient. You have managers and directors for a reason. Trust your instinct and use your experience to make decisions on who will fit into your organization. Some of the most successful companies can do one phone screen followed by an in-person meeting. During the in-person interview, spend a morning or afternoon allowing the candidate to meet the relevant leaders and senior members of their direct team, then take them for lunch, dinner, or drinks where you can see how they are on a social level. If you can’t have a simple conversation with them, then you probably won’t enjoy working with them. If the thumbs are up, make the hire and don’t wait around. A good candidate will usually have numerous offers on the table at the same time. + +If all goes well, you should be inviting your shiny new employee or contractor into the office in the next few weeks and hopefully many more throughout the year. + +This article was originally published on [DevOps.com][1] and republished with author permission. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/7-steps-devops-hiring-success + +作者:[Conor Delanbanque][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/cdelanbanque +[1]:https://devops.com/7-steps-devops-hiring-success/ From 572f6af4e3521210f08afea06d7229eb44d1ccea Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 26 Mar 2018 14:46:08 +0800 Subject: [PATCH 0137/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Find?= =?UTF-8?q?=20If=20A=20CPU=20Supports=20Virtualization=20Technology=20(VT)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Supports Virtualization Technology (VT).md | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md diff --git a/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md b/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md new file mode 100644 index 0000000000..6648f29b85 --- /dev/null +++ b/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md @@ -0,0 +1,176 @@ +How To Find If A CPU Supports Virtualization Technology (VT) +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Virtualization-Technology-720x340.png) +We already knew how to [**check if your Linux OS is 32 bit or 64 bit**][1] and how to [**find if your Linux system is physical or virtual machine**][2]. Today, we are going to learn yet another useful topic – how to find if a CPU supports virtualization technology (VT) or not? This should be first thing you might want to verify before installing virtualization applications such as VirtualBox or VMWare workstation to run virtual machines on your Linux system. Now let us go and find out if your computer supports VT or not. Trust me, it is really easy! + +### Find If A CPU Supports Virtualization Technology (VT) + +We can check if the CPU supports VT in several methods. Here I present you four methods. + +#### Method 1: Using “egrep” command + +**Egrep** is one of the variant of [**Grep**][3] command which is used to search text files with regular expressions. For the purpose of this guide, we are going to grep **/cpu/procinfo/** file to find out if the CPU supports VT or not. + +To find out if your CPU supports VT using egrep command, run: +``` +$ egrep "(svm|vmx)" /proc/cpuinfo + +``` + +**Sample output:** + +You will get either **“vmx”** (Intel-VT technology) or **“svm”** (AMD-V support) in the output. +``` +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx lahf_lm epb pti tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts +[...] + +``` + +Since the output is very long, you may find it hard to find the words “vmx” or “svm” in the output. No worries! You can distinguish those terms with colors like below. +``` +$ egrep --color -i "svm|vmx" /proc/cpuinfo + +``` + +![][5] + +If you don’t get any output, it means that your system doesn’t support virtualization. + +Please note that these CPU flags (vmx or svm) in the cpuinfo means that your system will support VT. In some CPU models, the VT support might be disabled in the BIOS, by default. In such cases, you should check your BIOS settings to enable VT support. + +For more details about grep/egrep command, refer the man pages. +``` +$ man grep + +``` + +#### Method 2 – Using “lscpu” command + +The “lscpu” command is used to display the information about your CPU architecture. It gathers information from sysfs, /proc/cpuinfo file and displays the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes of your host system. + +To find out if the VT support is enabled or not, simply run: +``` +$ lscpu + +``` + +![][6] + +For more details, check the man pages. +``` +$ man lscpu + +``` + +#### Method 3 – Using “Cpu-checker” utility + +**Cpu-checker** is yet another useful utility to test your CPU for virtualization support. As far as I searched on the web, this utility is available for only Ubuntu-based systems. To install it, run: +``` +$ sudo apt-get install cpu-checker + +``` + +Once cpu-checker package is installed, run the following command to check whether VT support is enable or not: +``` +$ sudo kvm-ok + +``` + +If your CPU supports VT, you will get the following output: +``` +INFO: /dev/kvm exists +KVM acceleration can be used + +``` + +If your CPU doesn’t support VT, you will see an output something like below. +``` +INFO: Your CPU does not support KVM extensions +KVM acceleration can NOT be used + +``` + +#### Method 4 – Using “virt-host-validate ” tool + +This tool is specifically for RHEL based distros like CentOS and Scientific Linux. The **libvirt-client** package provides **virt-host-validate** binary. So you need to install “libvert-client” package to use this tool. +``` +$ sudo yum install libvirt-client + +``` + +Now, run “virt-host-validate” command to find if VT is enabled or not in your RHEL-based systems. +``` +$ sudo virt-host-validate + +``` + +If you get **pass** for all results, your system supports VT. +``` + QEMU: Checking for hardware virtualization : PASS + QEMU: Checking if device /dev/vhost-net exists : PASS + QEMU: Checking if device /dev/net/tun exists : PASS + QEMU: Checking for cgroup 'memory' controller support : PASS + QEMU: Checking for cgroup 'memory' controller mount-point : PASS + QEMU: Checking for cgroup 'cpu' controller support : PASS + QEMU: Checking for cgroup 'cpu' controller mount-point : PASS + QEMU: Checking for cgroup 'cpuacct' controller support : PASS + QEMU: Checking for cgroup 'cpuacct' controller mount-point : PASS + QEMU: Checking for cgroup 'cpuset' controller support : PASS + QEMU: Checking for cgroup 'cpuset' controller mount-point : PASS + QEMU: Checking for cgroup 'devices' controller support : PASS + QEMU: Checking for cgroup 'devices' controller mount-point : PASS + QEMU: Checking for cgroup 'blkio' controller support : PASS + QEMU: Checking for cgroup 'blkio' controller mount-point : PASS + QEMU: Checking for device assignment IOMMU support : PASS + LXC: Checking for Linux >= 2.6.26 : PASS + LXC: Checking for namespace ipc : PASS + LXC: Checking for namespace mnt : PASS + LXC: Checking for namespace pid : PASS + LXC: Checking for namespace uts : PASS + LXC: Checking for namespace net : PASS + LXC: Checking for namespace user : PASS + LXC: Checking for cgroup 'memory' controller support : PASS + LXC: Checking for cgroup 'memory' controller mount-point : PASS + LXC: Checking for cgroup 'cpu' controller support : PASS + LXC: Checking for cgroup 'cpu' controller mount-point : PASS + LXC: Checking for cgroup 'cpuacct' controller support : PASS + LXC: Checking for cgroup 'cpuacct' controller mount-point : PASS + LXC: Checking for cgroup 'cpuset' controller support : PASS + LXC: Checking for cgroup 'cpuset' controller mount-point : PASS + LXC: Checking for cgroup 'devices' controller support : PASS + LXC: Checking for cgroup 'devices' controller mount-point : PASS + LXC: Checking for cgroup 'blkio' controller support : PASS + LXC: Checking for cgroup 'blkio' controller mount-point : PASS + +``` + +If your system doesn’t support VT, you will see an output like below. +``` +QEMU: Checking for hardware virtualization : FAIL (Only emulated CPUs are available, performance will be significantly limited) +[...] + +``` + +And, that’s all for now folks. In this guide, we have discussed various methods to find if a CPU supports VT or not. As you can see, it was very easy. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-find-if-a-cpu-supports-virtualization-technology-vt/ + +作者:[SK][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/author/sk/ +[1]:https://www.ostechnix.com/check-linux-system-32-bit-64-bit/ +[2]:https://www.ostechnix.com/check-linux-system-physical-virtual-machine/ +[3]:https://www.ostechnix.com/the-grep-command-tutorial-with-examples-for-beginners/ +[4]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/cpuinfo.png +[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/cpuinfo-1-2.png From 108c6ab50ee2ffaaddc111afec3694009c1c9b4e Mon Sep 17 00:00:00 2001 From: pinewall Date: Mon, 26 Mar 2018 18:24:37 +0800 Subject: [PATCH 0138/1057] pinewall Translating --- ...180323 How to tell when moving to blockchain is a bad idea.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md index 9f5fe6c01d..8e0fa91821 100644 --- a/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -1,3 +1,4 @@ +pinewall Translating How to tell when moving to blockchain is a bad idea ====== From e814e88831d47901ee94721d1fba1e760b53b1a6 Mon Sep 17 00:00:00 2001 From: HankChow Date: Mon, 26 Mar 2018 21:40:42 +0800 Subject: [PATCH 0139/1057] hankchow translating --- .../20180215 Build a bikesharing app with Redis and Python.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180215 Build a bikesharing app with Redis and Python.md b/sources/tech/20180215 Build a bikesharing app with Redis and Python.md index 06e4c6949a..67ddd07730 100644 --- a/sources/tech/20180215 Build a bikesharing app with Redis and Python.md +++ b/sources/tech/20180215 Build a bikesharing app with Redis and Python.md @@ -1,3 +1,5 @@ +hankchow translating + Build a bikesharing app with Redis and Python ====== From ee18ca560947aaa889ad12d5174769f0aede775c Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 26 Mar 2018 22:29:57 +0800 Subject: [PATCH 0140/1057] Delete 20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md --- ... Productivity Apps You Haven-t Heard Of.md | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md diff --git a/sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md b/sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md deleted file mode 100644 index 940b438c8a..0000000000 --- a/sources/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md +++ /dev/null @@ -1,103 +0,0 @@ -Translating by MjSeven - -10 Free Linux Productivity Apps You Haven’t Heard Of -====== - -![](https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-00-Featured.jpg) - -Productivity apps can really make your work easier. If you are a Linux user, these 10 lesser-known free productivity apps for the Linux desktop can help you.. As a matter of fact, it's possible keen Linux users have heard of all the apps on the list, but for somebody who hasn't gone beyond the main apps, these should be unknown. - -### 1. Tomboy/Gnote - -![linux-productivity-apps-01-tomboy][1] - -[Tomboy][2] is a simple note-taking app. It's not for Linux only - you can get it for Unix, Windows, and macOS, too. Tomboy is pretty straightforward to use - you write a note, choose whether to make it sticky on your desktop, and delete it when you are done with it. - -### 2. MyNotex - -![linux-productivity-apps-02-mynotex][3] - -If you want a note-taker with more features but still prefer a small and simple app rather than a huge suite, check [MyNotex][4]. In addition to simple note taking and retrieval, it comes with some nice perks, such as formatting abilities, keyboard shortcuts, and attachments, to name a few. You can also use it as a picture manager. - -### 3. Trojitá - -![linux-productivity-apps-03-trojita][5] - -Though you can live without a desktop email client, if you are used to having one, out of the dozens that are available, try [Trojita][6]. It's good for productivity because it is a fast and lightweight email client, yet it offers all the basics (and more) a good email client must have. - -### 4. Kontact - -![linux-productivity-apps-04-kontact][7] - -A Personal Information Manager (PIM) is a great productivity tool. My personal preferences go to [Kontact][8]. Even though it hasn't been updated in years, it's still a very useful PIM tool to manage emails, address books, calendars, tasks, news feeds, etc. Kontact is a KDE native, but you can use it with other desktops as well. - -### 5. Osmo - -![linux-productivity-apps-05-osmo][9] - -[Osmo][10] is a much more up-to-date app with calendar, tasks, contacts, and notes functionality. It comes with some perks, such as encrypted private data backup and address locations on the map, as well as great search capabilities for notes, tasks, contacts, etc. - -### 6. Catfish - -![linux-productivity-apps-06-catfish][11] - -You can't be productive without a good searching tool. [Catfish][12] is one of the must-try search tools. It's a GTK+ tool and is very fast and lightweight. Catfish uses autocompletion from Zeitgeist, and you can also filter results by date and type. - -### 7. KOrganizer - -![linux-productivity-apps-07-korganizer][13] - -[KOrganizer][14] is the calendar and scheduling component of the Kontact app I mentioned above. If you don't need a full-fledged PIM app but only calendar and scheduling, you can go with KOrganizer instead. KOrganizer offers quick ToDo and quick event entry, as well as attachments for events and todos. - -### 8. Evolution - -![linux-productivity-apps-08-evolution][15] - -If you are not a fan of KDE apps but still you need a good PIM, try GNOME's [Evolution][16]. Evolution is not exactly a less popular app you haven't heard of, but since it's useful, it made the list. Maybe you've heard about Evolution as an email client ,but it's much more than this - you can use it to manage calendars, mail, address books and tasks. - -### 9. Freeplane - -![linux-productivity-apps-09-freeplane][17] - -I don't know if many of you use mind-mapping software on a daily basis, but if you do, check [Freeplane][18]. This is a free mind mapping and knowledge management software you can use for business or fun. You create notes, arrange them in clouds or charts, set tasks with calendars and reminders, etc. - -### 10. Calligra Flow - -![linux-productivity-apps-10-calligra-flow][19] - -Finally, if you need a flowchart and diagramming tool, try [Calligra Flow][20]. Think of it as the open source [alternative of Microsoft Visio][21], though Calligra Flow doesn't offer all the perks Visio offers. Still, you can use it to create network diagrams, organization charts, flowcharts and more. - -Productivity tools not only speed up work, but they also make you more organized. I bet there is hardly a person who doesn't use productivity tools in some form. Trying the apps listed here could make you more productive and could make your life at least a bit easier - --------------------------------------------------------------------------------- - -via: https://www.maketecheasier.com/free-linux-productivity-apps-you-havent-heard-of/ - -作者:[Ada Ivanova][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.maketecheasier.com/author/adaivanoff/ -[1]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-01-Tomboy.png (linux-productivity-apps-01-tomboy) -[2]:https://wiki.gnome.org/Apps/Tomboy -[3]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-02-MyNotex.jpg (linux-productivity-apps-02-mynotex) -[4]:https://sites.google.com/site/mynotex/ -[5]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-03-Trojita.jpg (linux-productivity-apps-03-trojita) -[6]:http://trojita.flaska.net/ -[7]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-04-Kontact.jpg (linux-productivity-apps-04-kontact) -[8]:https://userbase.kde.org/Kontact -[9]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-05-Osmo.jpg (linux-productivity-apps-05-osmo) -[10]:http://clayo.org/osmo/ -[11]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-06-Catfish.png (linux-productivity-apps-06-catfish) -[12]:http://www.twotoasts.de/index.php/catfish/ -[13]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-07-KOrganizer.jpg (linux-productivity-apps-07-korganizer) -[14]:https://userbase.kde.org/KOrganizer -[15]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-08-Evolution.jpg (linux-productivity-apps-08-evolution) -[16]:https://help.gnome.org/users/evolution/3.22/intro-main-window.html.en -[17]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-09-Freeplane.jpg (linux-productivity-apps-09-freeplane) -[18]:https://www.freeplane.org/wiki/index.php/Home -[19]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-10-Calligra-Flow.jpg (linux-productivity-apps-10-calligra-flow) -[20]:https://www.calligra.org/flow/ -[21]:https://www.maketecheasier.com/5-best-free-alternatives-to-microsoft-visio/ From 2fcbf39a2918063db067870d869340a5ba151478 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 26 Mar 2018 22:30:43 +0800 Subject: [PATCH 0141/1057] Create 20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md --- ... Productivity Apps You Haven-t Heard Of.md | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md diff --git a/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md b/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md new file mode 100644 index 0000000000..18aca169bf --- /dev/null +++ b/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md @@ -0,0 +1,101 @@ +你从没听过的 10 个免费的 Linux 高效率应用程序 +===== + +![](https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-00-Featured.jpg) + +高效率的应用程序确实可以让你工作变得更轻松。如果你是一位 Linux 用户,这 10 个不太知名的 Linux 桌面应用程序可以帮助到你。事实上,Linux 用户可能已经听说过列表上的所有应用,但对于那些没有超越主流应用的人来说,这些应用是未知的。 + +### 1. Tomboy/Gnote + +![linux-productivity-apps-01-tomboy][1] + +[Tomboy][2] 是一个简单的便签应用。它不仅仅适用于 Linux,你也可以在 Unix,Windows 和 macOS 上获得它。Tomboy 很容易使用-你写一个便条,选择是否让它粘贴在你的桌面上,当你完成它时删除它。 + +### 2. MyNotex + +![linux-productivity-apps-02-mynotex][3] + +如果你想要一个更多功能的便签,但是仍喜欢一个小而简单的应用程序,而不是一个巨大的套件,请查看 [MyNotex][4]。除了简单的笔记和检索之外,它还带有一些不错的功能,例如格式化,键盘快捷键和附件等等。你也可以将其用作图片管理器。 + +### 3. Trojitá + +![linux-productivity-apps-03-trojita][5] + +尽管你可以没有桌面电子右键客户端,但如果你已经习惯了有几十个可用的桌面电子右键客户端,请尝试 [Trojita][6]。这有利于生产力,因为它是一个快速轻量级的电子邮件客户端,但它提供了一个好的电子邮件客户端必须具备的所有功能(以及更多)。 + +### 4. Kontact + +![linux-productivity-apps-04-kontact][7] + +个人信息管理器 (PIM) 是一款出色的生产力工具。我的个人喜好是 [Kontact][8]。尽管它已经有几年没有更新,但它仍然是一个非常有用的 PIM 工具,用于管理电子邮件,地址簿,日历,任务,新闻源等。Kontact 是一个本地 KDE,但你也可以在其他桌面上使用它。 + +### 5. Osmo + +![linux-productivity-apps-05-osmo][9] + +[Osmo][10] 是以一款更先进的应用,包括日历,任务,联系人和 notes 功能。它还附带一些额外的功能,比如加密的私有数据备份和地图上的地理位置,以及对 notes 、任务、、联系人登录强大搜索功能。 + +### 6. Catfish + +![linux-productivity-apps-06-catfish][11] + +一个好的搜索工具是高生产力的表现。[Catfish][12] 是一个必须尝试的搜索工具。它是一个 GTK+ 工具,非常快速,轻量级。Catfish 会利用 Zeitgeist 的自动完成功能,你还可以按日期和类型过滤搜索结果。 + +### 7. KOrganizer + +![linux-productivity-apps-07-korganizer][13] + +[KOrganizer][14] 是我上面提到的 Kontact 应用程序的日历和调度组件。如果你不需要完整的 PIM 应用程序,只需要日历和日程安排,则可以使用 KOrganizer。KOrganizer 提供快速的待办事项和快速事件条目,以及事件和待办事项的附件。 + +### 8. Evolution + +![linux-productivity-apps-08-evolution][15] + +如果你不是 KDE 应用程序的粉丝,但你仍然需要一个好的 PIM,那么试试 GNOME 的 [Evolution][16]。Evolution 并不是一个你从没听过的不太受欢迎的应用程序,但因为它有用,所以它出现在这个列表中。也许你已经听说过 Evolution 是一个电子邮件客户端,但它远不止于此-你可以用它来管理日历,邮件,地址簿和任务。 + +### 9. Freeplane + +![linux-productivity-apps-09-freeplane][17] + +我不知道你们中的大多数是否每天都使用思维导图软件,但是如果你使用,请选择 [Freeplane][18]。这是一款免费的思维导图和知识管理软件,可用于商业或娱乐。你可以创建笔记,将其排列在云或图表中,使用日历和提醒设置任务等。 + +### 10. Calligra Flow + +![linux-productivity-apps-10-calligra-flow][19] + +最后,如果你需要流程图和图标工具,请尝试 [Calligra Flow][20]。你可以将其视为开放源代码 [Microsoft Visio][21] 的替代品,但 Calligra Flow 不提供 Viso 提供的所有特权。不过,你可以使用它来创建网络图,组织结构图,流程图等等。 + +生产力工具不仅可以加快工作速度,还可以让你更有条理。我敢打赌,在某些方面几乎没有人不使用生产力工具。尝试这里列出的应用程序可以使你的工作效率更高,还能让你的生活至少轻松一些。 + +-------------------------------------------------------------------------------- + +via: https://www.maketecheasier.com/free-linux-productivity-apps-you-havent-heard-of/ + +作者:[Ada Ivanova][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.maketecheasier.com/author/adaivanoff/ +[1]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-01-Tomboy.png (linux-productivity-apps-01-tomboy) +[2]:https://wiki.gnome.org/Apps/Tomboy +[3]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-02-MyNotex.jpg (linux-productivity-apps-02-mynotex) +[4]:https://sites.google.com/site/mynotex/ +[5]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-03-Trojita.jpg (linux-productivity-apps-03-trojita) +[6]:http://trojita.flaska.net/ +[7]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-04-Kontact.jpg (linux-productivity-apps-04-kontact) +[8]:https://userbase.kde.org/Kontact +[9]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-05-Osmo.jpg (linux-productivity-apps-05-osmo) +[10]:http://clayo.org/osmo/ +[11]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-06-Catfish.png (linux-productivity-apps-06-catfish) +[12]:http://www.twotoasts.de/index.php/catfish/ +[13]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-07-KOrganizer.jpg (linux-productivity-apps-07-korganizer) +[14]:https://userbase.kde.org/KOrganizer +[15]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-08-Evolution.jpg (linux-productivity-apps-08-evolution) +[16]:https://help.gnome.org/users/evolution/3.22/intro-main-window.html.en +[17]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-09-Freeplane.jpg (linux-productivity-apps-09-freeplane) +[18]:https://www.freeplane.org/wiki/index.php/Home +[19]:https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-10-Calligra-Flow.jpg (linux-productivity-apps-10-calligra-flow) +[20]:https://www.calligra.org/flow/ +[21]:https://www.maketecheasier.com/5-best-free-alternatives-to-microsoft-visio/ From 76fd1d189d3a0c08e16fd1513eae5e6b027ac809 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 26 Mar 2018 22:31:26 +0800 Subject: [PATCH 0142/1057] Update 20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md --- ...1009 10 Free Linux Productivity Apps You Haven-t Heard Of.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md b/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md index 18aca169bf..904bfb5eb0 100644 --- a/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md +++ b/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md @@ -72,7 +72,7 @@ via: https://www.maketecheasier.com/free-linux-productivity-apps-you-havent-heard-of/ 作者:[Ada Ivanova][a] -译者:[译者ID](https://github.com/译者ID) +译者:[MjSeven](https://github.com/MjSeven) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b43742414e65101e2ad34844f74088f36bce814d Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 26 Mar 2018 22:32:45 +0800 Subject: [PATCH 0143/1057] Update 20180129 How to Use DockerHub.md --- sources/tech/20180129 How to Use DockerHub.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180129 How to Use DockerHub.md b/sources/tech/20180129 How to Use DockerHub.md index 3793a6b718..10dc39e63b 100644 --- a/sources/tech/20180129 How to Use DockerHub.md +++ b/sources/tech/20180129 How to Use DockerHub.md @@ -1,3 +1,5 @@ +Translating By MjSeven + How to Use DockerHub ====== From 3a00bba8063559ef8cf777177126c501982178fd Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 27 Mar 2018 08:46:04 +0800 Subject: [PATCH 0144/1057] translated --- ...180312 Continuous integration in Fedora.md | 60 ------------------- ...180312 Continuous integration in Fedora.md | 53 ++++++++++++++++ 2 files changed, 53 insertions(+), 60 deletions(-) delete mode 100644 sources/tech/20180312 Continuous integration in Fedora.md create mode 100644 translated/tech/20180312 Continuous integration in Fedora.md diff --git a/sources/tech/20180312 Continuous integration in Fedora.md b/sources/tech/20180312 Continuous integration in Fedora.md deleted file mode 100644 index 64d87baf81..0000000000 --- a/sources/tech/20180312 Continuous integration in Fedora.md +++ /dev/null @@ -1,60 +0,0 @@ -translating---geekpi - -Continuous integration in Fedora -====== - -![](https://fedoramagazine.org/wp-content/uploads/2017/07/ci-mar2018-945x400.jpg) -Continuous Integration (CI) is the process of running tests for every change made to a project, integrated as if this were the new deliverable. If done consistently, it means that software is always ready to be released. CI is a very well established process across the entire IT industry as well as free and open source projects. Fedora has been a little behind on this, but we’re catching up. Read below to find out how. - -### Why do we need this? - -CI will improve Fedora all around. It provides a more stable and consistent operating system by revealing bugs as early as possible. It lets you add tests when you encounter an issue so it doesn’t happen again (avoid regressions). CI can run tests from the upstream project as well as Fedora-specific ones that test the integration of the application in the distribution. - -Above all, consistent CI allows automation and reduced manual labor. It frees up our valuable volunteers and contributors to spend more time on new things for Fedora. - -### How will it look? - -For starters, we’ll run tests for every commit to git repositories of Fedora’s packages (dist-git). These tests are independent of the tests each of these packages run when built. However, they test the functionality of the package in an environment as close as possible to what Fedora’s users run. In addition to package-specific tests, Fedora also runs some distribution-wide tests, such as upgrade testing from F27 to F28 or rawhide. - -Packages are “gated” based on test results: test failures prevent an update being pushed to users. However, sometimes tests fail for various reasons. Perhaps the tests themselves are wrong, or not up to date with the software. Or perhaps an infrastructure issue occurred and prevented the tests from running correctly. Maintainers will be able to re-trigger the tests or waive their results until the tests are updated. - -Eventually, Fedora’s CI will run tests when a new pull-request is opened or updated on . This will give maintainers information about the impact of the proposed change on the stability of the package, and help them decide how to proceed. - -### What do we have today? - -Currently, a CI pipeline runs tests on packages that are part of Fedora Atomic Host. Other packages can have tests in dist-git, but they won’t be run automatically yet. Distribution specific tests already run on all of our packages. These test results are used to gate packages with failures. - -### How do I get involved? - -The best way to get started is to read the documentation about [Continuous Integration in Fedora][1]. You should get familiar with the [Standard Test Interface][2], which describes a lot of the terminology as well as how to write tests and use existing ones. - -With this knowledge, if you’re a package maintainer you can start adding tests to your packages. You can run them on your local machine or in a virtual machine. (This latter is advisable for destructive tests!) - -The Standard Test Interface makes testing consistent. As a result, you can easily add any tests to a package you like, and submit them to the maintainers in a pull-request on its [repository][3]. - -Reach out on #fedora-ci on irc.freenode.net with feedback, questions or for a general discussion on CI. - -Photo by [Samuel Zeller][4] on [Unsplash][5] - -#### Like this: - -Like - -Loading... - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/continuous-integration-fedora/ - -作者:[Pierre-Yves Chibon;Dominik Perpeet][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://fedoramagazine.org -[1]:http://fedoraproject.org/wiki/CI -[2]:http://fedoraproject.org/wiki/CI/Standard_Test_Interface -[3]:https://src.fedoraproject.org -[4]:https://unsplash.com/photos/77oXlGwwOw0?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[5]:https://unsplash.com/search/photos/factory-line?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/translated/tech/20180312 Continuous integration in Fedora.md b/translated/tech/20180312 Continuous integration in Fedora.md new file mode 100644 index 0000000000..5575e1fc3a --- /dev/null +++ b/translated/tech/20180312 Continuous integration in Fedora.md @@ -0,0 +1,53 @@ +在 Fedora 中持续集成 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2017/07/ci-mar2018-945x400.jpg) +持续集成 (CI) 是为项目的每一项变更运行测试的过程,如同这是新的交付项目一样。如果持续执行,这意味着软件随时可以发布。 CI 是整个 IT 行业以及免费和开源项目非常成熟的流程。Fedora 在这方面有点落后,但我们正在赶上。阅读以下内容了解进展。 + +### 我们为什么需要这个? + +CI 将全面改善 Fedora。它通过尽早揭示 bug 提供更稳定和一致的操作系统。它让你在遇到问题时添加测试,以免再次发生(避免回归)。CI 可以运行来自上游的项目测试,还有测试集成在发行版中 Fedora 特定的测试。 + +最重要的是,一致的 CI 能自动化并减少手工劳动。它释放了我们宝贵的志愿者和贡献者,让他们将更多时间花在 Fedora 的新事物上。 + +### 它看起来如何? + +对于初学者,我们将对在 Fedora 包 (dist-git) 仓库的每个提交运行测试。这些测试独立于构建时运行的每个软件包的测试。但是,他们在尽可能接近 Fedora 用户运行环境的环境中测试软件包的功能。除了特定的软件包测试外,Fedora 还运行一些发行测试,例如从 F27 升级到 F28 或者全新安装。 + +软件包根据测试结果进行“控制”:测试失败会阻止将更新推送给用户。但是,有时由于各种原因,测试会失败。也许测试本身是错误的,或者不是最新的软件。或者可能发生基础架构问题,并阻止测试正常运行。维护人员能够重新触发测试或放弃测试结果,直到测试更新。 + +最终,当在 上有合并请求或者更新时,Fedora 的 CI 将运行测试。这将使维护者了解建议的更改对包稳定性的影响,并帮助他们决定如何进行。 + +### 我们如今有什么? + +目前,CI 管道在 Fedora Atomic Host 一部分软件包上运行测试。其他软件包可以在 dist-git 中进行测试,但它们不会自动运行。分发特定的测试已经在我们所有的软件包上运行。这些测试结果被用于过滤测试失败的软件包。 + +### 我该如何参与? + +最好的入门方法是阅读关于[ Fedora 持续集成][1]的文档。你应该熟悉[标准测试接口][2],它描述了很多术语以及如何编写测试和使用现有的测试。 + +有了这些知识,如果你是一个软件包维护者,你可以开始添加测试到你的软件包。你可以在本地或虚拟机上运行它们。 (后者对于破坏性测试是明治的!) + +标准测试接口使测试保持一致。因此,你可以轻松地将任何测试添加到你喜欢的包中,并在 [仓库]​​[3] 提交合并请求给维护人员。 + +Reach out on #fedora-ci on irc.freenode.net with feedback, questions or for a general discussion on CI. +在 irc.freenode.net 上与 #fedora-ci 联系,提供反馈,问题或关于 CI 的一般性讨论。 + +[Samuel Zeller][4] 在 [Unsplash][5] 上提供的照片 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/continuous-integration-fedora/ + +作者:[Pierre-Yves Chibon;Dominik Perpeet][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org +[1]:http://fedoraproject.org/wiki/CI +[2]:http://fedoraproject.org/wiki/CI/Standard_Test_Interface +[3]:https://src.fedoraproject.org +[4]:https://unsplash.com/photos/77oXlGwwOw0?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[5]:https://unsplash.com/search/photos/factory-line?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText From b1b27a5b3c77fe9aea747d805e8175edb5232faf Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 27 Mar 2018 08:53:02 +0800 Subject: [PATCH 0145/1057] translating --- ... To Find If A CPU Supports Virtualization Technology (VT).md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md b/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md index 6648f29b85..bf313627df 100644 --- a/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md +++ b/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md @@ -1,3 +1,5 @@ +translating---geekpi + How To Find If A CPU Supports Virtualization Technology (VT) ====== From 808573e7d150841e66f8343399a0ea8bd7bdb7a1 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Tue, 27 Mar 2018 10:30:07 +0800 Subject: [PATCH 0146/1057] 2018-03-27 --- ...06 Why Linux is better than Windows or macOS for security.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index a36dd6f190..4660ffddd7 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -7,7 +7,7 @@ fuzheng1998 translating 企业投入了大量时间、精力和金钱来保障系统的安全性。安全意识最强的可能就是有一个安全的运转中心。他们肯定用了防火墙以及反病毒软件。他们也可能花费大量时间监控网络,寻找可能违约的泄密异常。 What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. -But how many have given much thought to one of the cornerstones of their digital operations: the operating systems deployed on the workforce’s PCs? Was security even a factor when the desktop OS was selected? +然而又有多少人想过数字化操作的基石之一:就是部署在员工的个人电脑上的操作系统?选择桌面操作系统时安全性是一个考虑因素吗? 这就产生了一个 IT 人士都应该能回答的问题:哪种操作系统对于一般性使用最安全呢? From f111ee296b9e1384630600b86babecda0132a6bb Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 27 Mar 2018 10:42:35 +0800 Subject: [PATCH 0147/1057] PRF:20180203 3 Ways to Extend the Power of Kubernetes.md @geekpi --- ...203 3 Ways to Extend the Power of Kubernetes.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/translated/tech/20180203 3 Ways to Extend the Power of Kubernetes.md b/translated/tech/20180203 3 Ways to Extend the Power of Kubernetes.md index ceee299984..963c441dee 100644 --- a/translated/tech/20180203 3 Ways to Extend the Power of Kubernetes.md +++ b/translated/tech/20180203 3 Ways to Extend the Power of Kubernetes.md @@ -1,19 +1,19 @@ -3种扩展 Kubernetes 能力的方式 +3 种扩展 Kubernetes 能力的方式 ====== ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/chen-goldberg-kubecon.png?itok=WR_4i31u) -Google 的工程总监 Chen Goldberg 在奥斯汀最近的[KubeCon 和 CloudNativeCon][1]上说,Kubernetes 的扩展能力是它的秘密武器。 +Google 的工程总监 Chen Goldberg 在最近的奥斯汀 [KubeCon 和 CloudNativeCon][1]上说,Kubernetes 的扩展能力是它的秘密武器。 在建立帮助工程师提高工作效率的工具的竞赛中,Goldberg 谈到他曾经领导过一个开发这样一个平台的团队。尽管平台最初有用,但它无法扩展,并且修改也很困难。 -幸运的是,Goldberg 说,Kubernetes 没有这些问题。首先,Kubernetes 是一个自我修复系统,因为它使用的控制器实现了“_协调环_”(Reconciliation Loop)。在协调环中,控制器观察系统的当前状态并将其与所需状态进行比较。一旦它确定了这两个状态之间的差异,它就会努力实现所需的状态。这使得 Kubernetes 非常适合动态环境。 +幸运的是,Goldberg 说,Kubernetes 没有这些问题。首先,Kubernetes 是一个自我修复系统,因为它使用的控制器实现了“协调环Reconciliation Loop”。在协调环中,控制器观察系统的当前状态并将其与所需状态进行比较。一旦它确定了这两个状态之间的差异,它就会努力实现所需的状态。这使得 Kubernetes 非常适合动态环境。 -### 3种扩展 Kubernetes 的方式 +### 3 种扩展 Kubernetes 的方式 -Goldberg 然后解释说,要建立控制器,你需要资源,也就是说,你需要扩展 Kubernetes。有三种方法可以做到这一点,从最灵活(但也更困难)到最简单的是:使用 Kube 聚合器,使用 API​​ 服务器构建器或创建自定义资源定义(或 CRD)。 +Goldberg 然后解释说,要建立控制器,你需要资源,也就是说,你需要扩展 Kubernetes。有三种方法可以做到这一点,从最灵活(但也更困难)到最简单的依次是:使用 Kube 聚合器、使用 API​​ 服务器构建器或创建自定义资源定义Custom Resource Definition(CRD)。 -后者允许即使使用最少的编码来扩展 Kubernetes 的功能。为了演示它是如何完成的,Goggle 软件工程师 Anthony Yeh 出席并展示了为 Kubernetes 添加一个状态集。 (状态集对象用于管理有状态应用,即需要存储应用状态的程序,跟踪例如用户身份及其个人设置。)使用 _catset_,在一个 100 行 JavaScript 的文件中实现的 CRD,Yeh 展示了如何将状态集添加到 Kubernetes 部署中。之前的扩展不是 CRD,需要 24 个文件和 3000 多行代码。 +后者甚至可以使用极少的代码来扩展 Kubernetes 的功能。为了演示它是如何完成的,Goggle 软件工程师 Anthony Yeh 上台展示了为 Kubernetes 添加一个状态集。 (状态集对象用于管理有状态应用,即需要存储应用状态的程序,跟踪例如用户身份及其个人设置。)使用 _catset_,在一个 100 行 JavaScript 的文件中实现的 CRD,Yeh 展示了如何将状态集添加到 Kubernetes 部署中。之前的扩展不是 CRD,需要 24 个文件和 3000 多行代码。 为解决 CRD 可靠性问题,Goldberg 表示,Kubernetes 已经启动了一项认证计划,允许公司在 Kubernetes 社区注册和认证其扩展。在一个月内,已有 30 多家公司报名参加该计划。 @@ -31,7 +31,7 @@ via: https://www.linux.com/blog/event/kubecon/2018/2/3-ways-extend-power-kuberne 作者:[PAUL BROWN][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 663521abe602b24d6fea79d5a37c7713f3692217 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 27 Mar 2018 10:43:49 +0800 Subject: [PATCH 0148/1057] PUB:20180203 3 Ways to Extend the Power of Kubernetes.md @geekpi --- .../20180203 3 Ways to Extend the Power of Kubernetes.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180203 3 Ways to Extend the Power of Kubernetes.md (100%) diff --git a/translated/tech/20180203 3 Ways to Extend the Power of Kubernetes.md b/published/20180203 3 Ways to Extend the Power of Kubernetes.md similarity index 100% rename from translated/tech/20180203 3 Ways to Extend the Power of Kubernetes.md rename to published/20180203 3 Ways to Extend the Power of Kubernetes.md From 1a67c18aa6ef3a8b565c92cc2f0969faf1406bc3 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 27 Mar 2018 11:19:37 +0800 Subject: [PATCH 0149/1057] PRF:20180129 Parsing HTML with Python.md @Flowsnow --- .../tech/20180129 Parsing HTML with Python.md | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/translated/tech/20180129 Parsing HTML with Python.md b/translated/tech/20180129 Parsing HTML with Python.md index 5701b92aee..9159672395 100644 --- a/translated/tech/20180129 Parsing HTML with Python.md +++ b/translated/tech/20180129 Parsing HTML with Python.md @@ -1,20 +1,22 @@ -用Python解析HTML +如何用 Python 解析 HTML ====== +用一些简单的脚本,可以很容易地清理文档和其它大量的 HTML 文件。但是首先你需要解析它们。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_html_code.png?itok=VjUmGsnl) -图片由Jason Baker为Opensource.com所作。 +图片由 Jason Baker 为 Opensource.com 所作。 -作为Scribus文档团队的长期成员,我随时了解最新的源代码更新,以便对文档进行更新和补充。 我最近在刚升级到Fedora 27系统的计算机上使用Subversion进行“checkout”操作时,对于文档下载所需要的时间我感到很惊讶,文档由HTML页面和相关图像组成。 我担心该项目的文档看起来比项目本身大得多,并且怀疑其中的一些内容是“僵尸”文档——不会再使用的HTML文件以及HTML中无法访问到的图像。 +作为 Scribus 文档团队的长期成员,我要随时了解最新的源代码更新,以便对文档进行更新和补充。 我最近在刚升级到 Fedora 27 系统的计算机上使用 Subversion 进行检出操作时,对于下载该文档所需要的时间我感到很惊讶,文档由 HTML 页面和相关图像组成。 我恐怕该项目的文档看起来比项目本身大得多,并且怀疑其中的一些内容是“僵尸”文档——不再使用的 HTML 文件以及 HTML 中无法访问到的图像。 -我决定为自己创建一个项目来解决这个问题。 一种方法是搜索未使用的现有图像文件。 如果我可以扫描所有HTML文件中的图像引用,然后将该列表与实际图像文件进行比较,那么我可能会看到不匹配的文件。 +我决定为自己创建一个项目来解决这个问题。 一种方法是搜索未使用的现有图像文件。 如果我可以扫描所有 HTML 文件中的图像引用,然后将该列表与实际图像文件进行比较,那么我可能会看到不匹配的文件。 这是一个典型的图像标签: + ``` Edit examples ``` -我对第一组引号之间的部分很感兴趣,在src =之后。 寻找解决方案后,我找到一个名为[BeautifulSoup][1]的Python模块。 脚本的核心部分如下所示: +我对 `src=` 之后的第一组引号之间的部分很感兴趣。 在寻找了一些解决方案后,我找到一个名为 [BeautifulSoup][1] 的 Python 模块。 脚本的核心部分如下所示: ``` soup = BeautifulSoup(all_text, 'html.parser') @@ -24,15 +26,15 @@ if len(match) > 0: imagelist.append(str(m)) ``` -我们可以使用这个`findAll` 方法来挖出图片标签。 这是一小部分输出: +我们可以使用这个 `findAll` 方法来挖出图片标签。 这是一小部分输出: ``` GSview - Advanced Options PanelScribus External Tools Preferences ``` -到现在为止还挺好。我原以为下一步就可以搞定了,但是当我在脚本中尝试了一些字符串方法时,它返回了有关标记的错误而不是字符串的错误。 我将输出保存到一个文件中,并在[KWrite][2]中进行编辑。 KWrite的一个好处是你可以使用正则表达式(regex)来做“查找和替换”操作,所以我可以用`\n', all_text) @@ -42,27 +44,28 @@ if len(match)>0: ``` 它的一小部分输出如下所示: + ``` images/cmcanvas.png" title="Context Menu for the document canvas" alt="Context Menu for the document canvas" />
``` -我决定回到`src=`这一块。 一种方法是等待`s`出现,然后看下一个字符是否是`r`,下一个是`c`,下一个是否`=`。 如果是这样,那就匹配上了! 那么两个双引号之间的内容就是我所需要的。 这种方法的问题在于需要连续识别上面这样的结构。 一种查看代表一行HTML文本的字符串的方法是: +我决定回到 `src=` 这一块。 一种方法是等待 `s` 出现,然后看下一个字符是否是 `r`,下一个是 `c`,下一个是否 `=`。 如果是这样,那就匹配上了! 那么两个双引号之间的内容就是我所需要的。 这种方法的问题在于需要连续识别上面这样的结构。 一种查看代表一行 HTML 文本的字符串的方法是: ``` for c in all_text: ``` -但是这个逻辑太乱了,以至于不能持续匹配到前面的`c`,还有之前的字符,更之前的字符,更更之前的字符。 +但是这个逻辑太乱了,以至于不能持续匹配到前面的 `c`,还有之前的字符,更之前的字符,更更之前的字符。 -最后,我决定专注于`=`并使用索引方法,以便我可以轻松地引用字符串中的任何先前或将来的字符。 这里是搜索部分: +最后,我决定专注于 `=` 并使用索引方法,以便我可以轻松地引用字符串中的任何先前或将来的字符。 这里是搜索部分: ``` index = 3 @@ -77,7 +80,7 @@ for c in all_text: index += 1 ``` -我用第四个字符开始搜索(索引从0开始),所以我在下面没有出现索引错误,并且实际上,在每一行的第四个字符之前不会有等号。 第一个测试是看字符串中是否出现了`=`,如果没有,我们就会前进。 如果我们确实看到一个等号,那么我们会看前三个字符是否是`s`,`r`和`c`。 如果全都匹配了,就调用函数`imagefound`: +我用第四个字符开始搜索(索引从 0 开始),所以我在下面没有出现索引错误,并且实际上,在每一行的第四个字符之前不会有等号。 第一个测试是看字符串中是否出现了 `=`,如果没有,我们就会前进。 如果我们确实看到一个等号,那么我们会看前三个字符是否是 `s`、`r` 和 `c`。 如果全都匹配了,就调用函数 `imagefound`: ``` def imagefound(all_text, imagelist, index): @@ -95,9 +98,10 @@ def imagefound(all_text, imagelist, index): return ``` -我们正在给函数发送当前索引,它代表着`=`。 我们知道下一个字符将会是`"`,所以我们跳过两个字符,并开始向名为`newimage`的控制字符串添加字符,直到我们发现下一个`"`,此时我们完成了一次匹配。 我们将字符串加一个`换行`符添加到列表`imagelist`中并`返回`,请记住,在剩余的这个HTML字符串中可能会有更多图片标签,所以我们马上回到搜索循环的中间。 +我们给函数发送当前索引,它代表着 `=`。 我们知道下一个字符将会是 `"`,所以我们跳过两个字符,并开始向名为 `newimage` 的控制字符串添加字符,直到我们发现下一个 `"`,此时我们完成了一次匹配。 我们将字符串加一个换行符(`\n`)添加到列表 `imagelist` 中并返回(`return`),请记住,在剩余的这个 HTML 字符串中可能会有更多图片标签,所以我们马上回到搜索循环中。 以下是我们的输出现在的样子: + ``` images/text-frame-link.png images/text-frame-unlink.png @@ -111,7 +115,7 @@ images/fontpref1.png images/dtp-studio.png ``` -啊,干净多了,而这只花费几秒钟的时间。 我本可以将索引前移7步来剪切`images/`部分,但我更愿意把这个部分保存下来,确保我没有切片掉图像文件名的第一个字母,这很容易用KWrite编辑成功- - 你甚至不需要正则表达式。 做完这些并保存文件后,下一步就是运行我编写的另一个脚本`sortlist.py`: +啊,干净多了,而这只花费几秒钟的时间。 我本可以将索引前移 7 步来剪切 `images/` 部分,但我更愿意把这个部分保存下来,以确保我没有剪切掉图像文件名的第一个字母,这很容易用 KWrite 编辑成功 —— 你甚至不需要正则表达式。 做完这些并保存文件后,下一步就是运行我编写的另一个脚本 `sortlist.py`: ``` #!/usr/bin/env python @@ -137,9 +141,10 @@ outfile.close() ls /home/gregp/development/Scribus15x/doc/en/images/*.png > '/tmp/actual_images.txt' ``` -然后我需要在该文件上运行`sortlist.py`,因为`ls`方法的排序与Python不同。 我原本可以在这些文件上运行比较脚本,但我更愿意以可视方式进行操作。 最后,我成功找到了42个图像,这些图像没有来自文档的HTML引用。 +然后我需要在该文件上运行 `sortlist.py`,因为 `ls` 方法的排序与 Python 不同。 我原本可以在这些文件上运行比较脚本,但我更愿意以可视方式进行操作。 最后,我成功找到了 42 个图像,这些图像没有来自文档的 HTML 引用。 这是我的完整解析脚本: + ``` #!/usr/bin/env python # -*- coding: utf-8 -*- @@ -191,16 +196,17 @@ imageno = len(imagelist) print str(imageno) + " images were found and saved" ``` -脚本名称为`parseimg4.py`,这并不能真实反映我陆续编写的脚本数量,包括微调的和大改的以及丢弃并重新开始写的。 请注意,我已经对这些目录和文件名进行了硬编码,但是总结起来很容易,要求用户输入这些信息。 同样,因为它们是工作脚本,所以我将输出发送到 `/tmp`目录,所以一旦重新启动系统,它们就会消失。 +脚本名称为 `parseimg4.py`,这并不能真实反映我陆续编写的脚本数量(包括微调的和大改的以及丢弃并重新开始写的)。 请注意,我已经对这些目录和文件名进行了硬编码,但是很容易变得通用化,让用户输入这些信息。 同样,因为它们是工作脚本,所以我将输出发送到 `/tmp` 目录,所以一旦重新启动系统,它们就会消失。 -这不是故事的结尾,因为下一个问题是:僵尸HTML文件怎么办? 任何未使用的文件都可能会引用到前面比对方法没有提取到的图像。 我们有一个`menu.xml`文件作为联机手册的目录,但我还需要考虑TOC(译者注:TOC是table of contents的缩写)中列出的某些文件可能引用了不在TOC中的文件,是的,我确实找到了一些这样的文件。 +这不是故事的结尾,因为下一个问题是:僵尸 HTML 文件怎么办? 任何未使用的文件都可能会引用图像,不能被前面的方法所找出。 我们有一个 `menu.xml` 文件作为联机手册的目录,但我还需要考虑 TOC(LCTT 译注:TOC 是 table of contents 的缩写)中列出的某些文件可能引用了不在 TOC 中的文件,是的,我确实找到了一些这样的文件。 最后我可以说,这是一个比图像搜索更简单的任务,而且开发的过程对我有很大的帮助。 +### 关于作者 -### About the author - - [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/20150529_gregp.jpg?itok=nv02g6PV)][7] Greg Pittman - Greg是Kentucky州Louisville市的一名退休的神经学家,从二十世纪六十年代的Fortran IV语言开始长期以来对计算机和编程有着浓厚的兴趣。 当Linux和开源软件出现的时候,Greg深受启发,去学习更多只是,并实现最终贡献的承诺。 他是Scribus团队的成员。[更多关于我][8] + [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/20150529_gregp.jpg?itok=nv02g6PV)][7] + +Greg Pittman 是 Kentucky 州 Louisville 市的一名退休的神经学家,从二十世纪六十年代的 Fortran IV 语言开始长期以来对计算机和编程有着浓厚的兴趣。 当 Linux 和开源软件出现的时候,Greg 深受启发,去学习更多知识,并实现最终贡献的承诺。 他是 Scribus 团队的成员。[更多关于我][8] -------------------------------------------------------------------------------- @@ -208,7 +214,7 @@ via: https://opensource.com/article/18/1/parsing-html-python 作者:[Greg Pittman][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 aaa7184adf1e1b884a0f798e6a285086b4a836a1 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 27 Mar 2018 11:20:01 +0800 Subject: [PATCH 0150/1057] PUB:20180129 Parsing HTML with Python.md @Flowsnow https://linux.cn/article-9485-1.html --- .../tech => published}/20180129 Parsing HTML with Python.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180129 Parsing HTML with Python.md (100%) diff --git a/translated/tech/20180129 Parsing HTML with Python.md b/published/20180129 Parsing HTML with Python.md similarity index 100% rename from translated/tech/20180129 Parsing HTML with Python.md rename to published/20180129 Parsing HTML with Python.md From 7b20f0689a34dd81c9fb6dbb352a8737b320d25f Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 27 Mar 2018 13:00:05 +0800 Subject: [PATCH 0151/1057] PRF:20180111 How to install software applications on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @MjSeven 很好 --- ... install software applications on Linux.md | 93 +++++++++---------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/translated/tech/20180111 How to install software applications on Linux.md b/translated/tech/20180111 How to install software applications on Linux.md index a2809f55c9..9116e438be 100644 --- a/translated/tech/20180111 How to install software applications on Linux.md +++ b/translated/tech/20180111 How to install software applications on Linux.md @@ -1,39 +1,41 @@ 如何在 Linux 上安装应用程序 ===== +> 学习在你的 Linux 计算机上摆弄那些软件。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_) 图片提供:Internet Archive Book Images。由 Opensource.com 修改。CC BY-SA 4.0 -如何在 Linux 上安装应用程序?与有许多操作系统一样,这个问题不止有一个答案。应用程序可以可以来自许多来源-几乎不可能数的清,并且每个开发团队都可以以他们认为最好的方式提供软件。知道如何安装你所得到的软件是成为操作系统强大用户的一部分。 - +如何在 Linux 上安装应用程序?因为有许多操作系统,这个问题不止有一个答案。应用程序可以可以来自许多来源 —— 几乎不可能数的清,并且每个开发团队都可以以他们认为最好的方式提供软件。知道如何安装你所得到的软件是成为操作系统高级用户的一部分。 ### 仓库 -十多年来,Linux 已经使用软件库来分发软件。在这种情况下,“仓库”是一个托管可安装软件包的公共服务器。Linux 发行版提供了一条命令,通常是该命令的图形界面,用于从服务器获取软件并将其安装到你的计算机。这是一个非常简单的概念,它已经成为所有主流手机操作系统的模型,最近,它也成为了两大闭源计算机操作系统的“应用商店”。 +十多年来,Linux 已经在使用软件库来分发软件。在这种情况下,“仓库”是一个托管可安装软件包的公共服务器。Linux 发行版提供了一条命令,以及该命令的图形界面,用于从服务器获取软件并将其安装到你的计算机。这是一个非常简单的概念,它已经成为所有主流手机操作系统的模式,最近,该模式也成为了两大闭源计算机操作系统的“应用商店”。 ![Linux repository][2] -不是一个应用程序商店 +*不是应用程序商店* -从软件仓库安装是在 Linux 上安装应用程序的主要方法,它应该是你想要安装的任何应用程序的第一个地方。 +从软件仓库安装是在 Linux 上安装应用程序的主要方法,它应该是你寻找想要安装的任何应用程序的首选地方。 + +从软件仓库安装,通常需要一个命令,如: -从软件仓库安装,通常需要一个命令: ``` $ sudo dnf install inkscape ``` -实际使用的命令取决于你所使用的 Linux 发行版。Fedora 使用 `dnf`,OpenSUSE 使用 `zypper`,Debian 和 Ubuntu 使用 `apt`,Slackware 使用 `sbopkg`,FreeBSD 使用 `pkg_add`,而基于 lllumos 的 Openlndiana 使用 `pkg`。无论你使用什么,命令通常包括搜索你想要安装应用程序的正确名称,因为有时候你认为的软件名称不是它官方或单独的名称: +实际使用的命令取决于你所使用的 Linux 发行版。Fedora 使用 `dnf`,OpenSUSE 使用 `zypper`,Debian 和 Ubuntu 使用 `apt`,Slackware 使用 `sbopkg`,FreeBSD 使用 `pkg_add`,而基于 lllumos 的 Openlndiana 使用 `pkg`。无论你使用什么,该命令通常要搜索你想要安装应用程序的正确名称,因为有时候你认为的软件名称不是它官方或独有的名称: + ``` $ sudo dnf search pyqt - PyQt.x86_64 : Python bindings for Qt3 - PyQt4.x86_64 : Python bindings for Qt4 - python-qt5.x86_64 : PyQt5 is Python bindings for Qt5 ``` + 一旦你找到要安装的软件包的名称后,使用 `install` 子命令执行实际的下载和自动安装: + ``` $ sudo dnf install python-qt5 ``` @@ -44,18 +46,20 @@ $ sudo dnf install python-qt5 ![](https://opensource.com/sites/default/files/u128651/apper.png) -与底层命令一样,图形安装程序的名称取决于你正在运行的 Linux 发行版。相关应用程序通常使用软件或关键字进行标记,因此请在你的启动项或菜单中搜索这些条款,然后你将找到所需的内容。 由于开源是关于用户的选择,所以如果你不喜欢你的发行版提供的图形用户界面(GUI),那么你可以选择安装与否。 现在你知道如何做到这一点。 +与底层命令一样,图形安装程序的名称取决于你正在运行的 Linux 发行版。相关的应用程序通常使用“软件(software)”或“包(package)”等关键字进行标记,因此请在你的启动项或菜单中搜索这些词汇,然后你将找到所需的内容。 由于开源全由用户来选择,所以如果你不喜欢你的发行版提供的图形用户界面(GUI),那么你可以选择安装替代品。 你知道该如何做到这一点。 #### 额外仓库 + 你的 Linux 发行版为其打包的软件提供了标准仓库,通常也有额外的仓库。例如,[EPEL][3] 服务于 Red Hat Enterprise Linux 和 CentOS,[RPMFusion][4] 服务于 Fedora,Ubuntu 有各种级别的支持以及个人包存档(PPA),[Packman][5] 为 OpenSUSE 提供额外的软件以及 [SlackBuilds.org][6] 为 Slackware 提供社区构建脚本。 -默认情况下,你的 Linux 操作系统设置为只查看其官方仓库,因此如果你想使用其他软件集合,则必须自己添加额外库。你通常可以像安装软件包一样安装仓库。实际上,当你安装例如 [GNU Ring][7] 视频聊天,[Vivaldi][8] web 浏览器,谷歌浏览器等许多软件时,你实际安装的是访问他们的私人仓库,从中将最新版本的应用程序安装到你的机器上。 +默认情况下,你的 Linux 操作系统设置为只查看其官方仓库,因此如果你想使用其他软件集合,则必须自己添加额外库。你通常可以像安装软件包一样安装仓库。实际上,当你安装例如 [GNU Ring][7] 视频聊天,[Vivaldi][8] web 浏览器,谷歌浏览器等许多软件时,你的实际安装是访问他们的私有仓库,从中将最新版本的应用程序安装到你的机器上。 ![Installing a repo][10] -建立一个仓库 +*安装仓库* + +你还可以通过编辑文本文件将仓库手动添加到你的软件包管理器的配置目录,或者运行命令来添加添加仓库。像往常一样,你使用的确切命令取决于 Linux 发行版本。例如,这是一个 `dnf` 命令,它将一个仓库添加到系统中: -你还可以通过编辑文本文件将仓库手动添加到软件包管理器的配置目录,或者运行命令来添加添加仓库。像往常一样,你使用的确切命令取决于 Linux 发行版本。例如,这是一个 `dnf` 命令,它将一个仓库添加到系统中: ``` $ sudo dnf config-manager --add-repo=http://example.com/pub/centos/7 ``` @@ -64,118 +68,111 @@ $ sudo dnf config-manager --add-repo=http://example.com/pub/centos/7 仓库模型非常流行,因为它提供了用户(你)和开发人员之间的链接。重要更新发布之后,系统会提示你接受更新,并且你可以从一个集中位置接受所有更新。 -然而,有时候一个软件包没有附加的仓库可以使用。这些安装包有几种形式。 +然而,有时候一个软件包还没有放到仓库中时。这些安装包有几种形式。 #### Linux 包 -有时候,开发人员会以通用的 Linux 打包格式分发软件,例如 RPM,DEB 或较新但非常流行的 FlatPak 或 Snap 格式。你无法使用此下载访问仓库;你可能会得到这个包。 +有时候,开发人员会以通用的 Linux 打包格式分发软件,例如 RPM、DEB 或较新但非常流行的 FlatPak 或 Snap 格式。你不是访问仓库下载的,你只是得到了这个包。 例如,视频编辑器 [Lightworks][11] 为 APT 用户提供了一个 `.deb` 文件,RPM 用户提供了 `.rpm` 文件。当你想要更新时,可以到网站下载最新的适合的文件。 -这些一次性软件包可以使用从仓库进行安装时所用的所有工具进行安装。如果双击下载的软件包,图形安装程序将启动并逐步完成安装过程。 +这些一次性软件包可以使用从仓库进行安装时所用的一样的工具进行安装。如果双击下载的软件包,图形安装程序将启动并逐步完成安装过程。 或者,你可以从终端进行安装。这里的区别在于你从互联网下载的独立包文件不是来自仓库。这是一个“本地”安装,这意味着你的软件安装包不需要下载来安装。大多数软件包管理器都是透明处理的: + ``` $ sudo dnf install ~/Downloads/lwks-14.0.0-amd64.rpm ``` 在某些情况下,你需要采取额外的步骤才能使应用程序运行,因此请仔细阅读有关你正在安装软件的文档。 -#### 通用安装 +#### 通用安装脚本 -一些开发人员以几种通用格式发布他们的包。常见的扩展包括 `.run` 和 `.sh`。NVIDIA 显卡驱动程序,像 Nuke 和 Mari 这样的 Foundry visual FX 软件包以及来自 [GOG][12] 的许多无 DRM 游戏都是用这种安装程序。(译注:DRM 是数字版权管理。) +一些开发人员以几种通用格式发布他们的包。常见的扩展名包括 `.run` 和 `.sh`。NVIDIA 显卡驱动程序、像 Nuke 和 Mari 这样的 Foundry visual FX 软件包以及来自 [GOG][12] 的许多非 DRM 游戏都是用这种安装程序。(LCTT 译注:DRM 是数字版权管理。) 这种安装模式依赖于开发人员提供安装“向导”。一些安装程序是图形化的,而另一些只是在终端中运行。 有两种方式来运行这些类型的安装程序。 -1. 你可以直接从终端运行安装程序: +1、 你可以直接从终端运行安装程序: ``` - $ sh ./game/gog_warsow_x.y.z.sh ``` -2. 另外,你可以通过标记其为可执行文件来运行它。要标记为安装程序可执行文件,右键单击它的图标并选择 **Properties**。 + +2、 另外,你可以通过标记其为可执行文件来运行它。要标记为安装程序可执行文件,右键单击它的图标并选择其属性。 ![Giving an installer executable permission][14] -给安装程序可执行权限。 +*给安装程序可执行权限。* 一旦你允许其运行,双击图标就可以安装了。 ![GOG installer][16] -GOG 安装程序 +*GOG 安装程序* 对于其余的安装程序,只需要按照屏幕上的说明进行操作。 #### AppImage 便携式应用程序 -AppImage 格式对于 Linux 相对来说比较新,尽管它的概念是基于 NeXT 和 Rox 的。这个想法很简单:运行应用程序所需的一切都应该放在一个目录中,然后该目录被视为一个“应用程序”。要运行该应用程序,只需双击该图标即可运行。没有必要或期望应用程序安装在传统意义的地方;它只是从你在硬盘上的任何地方运行。 +AppImage 格式对于 Linux 相对来说比较新,尽管它的概念是基于 NeXT 和 Rox 的。这个想法很简单:运行应用程序所需的一切都应该放在一个目录中,然后该目录被视为一个“应用程序”。要运行该应用程序,只需双击该图标即可运行。不需要也要不应该把应用程序安装在传统意义的地方;它从你在硬盘上的任何地方运行都行。 尽管它可以作为独立应用运行,但 AppImage 通常提供一些系统集成。 ![AppImage system integration][18] -AppImage 系统集成 +*AppImage 系统集成* -如果你接受此条件,则将本地 `.desktop` 文件安装到你的主目录。`.desktop` 文件是 Linux 桌面的应用程序菜单和 mimetype 系统使用的一个小配置文件。实质上,将桌面配置文件放置在主目录的应用程序列表中“安装”应用程序,而不实际安装它。你获得了安装某些东西的所有好处,以及能够在本地运行某些东西的好处,例如“便携式应用程序”。 +如果你接受此条件,则将一个本地的 `.desktop` 文件安装到你的主目录。`.desktop` 文件是 Linux 桌面的应用程序菜单和 mimetype 系统使用的一个小配置文件。实质上,只是将桌面配置文件放置在主目录的应用程序列表中“安装”应用程序,而不实际安装它。你获得了安装某些东西的所有好处,以及能够在本地运行某些东西的好处,即“便携式应用程序”。 #### 应用程序目录 -有时,开发人员只需要编译一个应用程序,然后将结果发布到下载中,没有安装脚本,也没有打包。通常,这意味着你下载了一个 TAR 文件,然后 [解压缩][19],然后双击可执行文件(通常是你下载软件的名称)。 - +有时,开发人员只是编译一个应用程序,然后将结果发布到下载中,没有安装脚本,也没有打包。通常,这意味着你下载了一个 TAR 文件,然后 [解压缩][19],然后双击可执行文件(通常是你下载软件的名称)。 ![Twine downloaded for Linux][21] -下载 Twine +*下载 Twine* 当使用这种软件方式交付时,你可以将它放在你下载的地方,当你需要它时,你可以手动启动它,或者你可以自己进行快速但是麻烦的安装。这包括两个简单的步骤: 1. 将目录保存到一个标准位置,并在需要时手动启动它。 2. 将目录保存到一个标准位置,并创建一个 `.desktop` 文件,将其集成到你的系统中。 -如果你只是为自己安装应用程序,那么在你的主目录中保留 `bin` 目录(简称“二进制文件”)作为本地安装的应用程序和脚本的存储位置是传统意义上的。如果你的系统上有其他用户需要访问这些应用程序,传统上将二进制文件放置在 `/opt` 中。最后,这取决于你存储应用程序的位置。 +如果你只是为自己安装应用程序,那么传统上会在你的主目录中放个 `bin` (“二进制文件binary” 的简称)目录作为本地安装的应用程序和脚本的存储位置。如果你的系统上有其他用户需要访问这些应用程序,传统上将二进制文件放置在 `/opt` 中。最后,这取决于你存储应用程序的位置。 -下载通常以带版本名称的目录进行,如 `twine_2.13` 或者 `pcgen-v6.07.04`。由于可以合理地假设你将在某个时候更新应用程序,因此将版本号删除或创建目录的符号链接是个不错的主意。这样,即使你更新应用程序本身,为应用程序创建的启动程序也可以保持不变。 +下载通常以带版本名称的目录进行,如 `twine_2.13` 或者 `pcgen-v6.07.04`。由于假设你将在某个时候更新应用程序,因此将版本号删除或创建目录的符号链接是个不错的主意。这样,即使你更新应用程序本身,为应用程序创建的启动程序也可以保持不变。 -要创建一个 `.desktop` 启动文件,打开一个文本编辑器并创建一个名为 `twine.desktop` 的文件。[桌面条目规范][22] 由 [FreeDesktop.org][23] 定义。这是一个简单的启动器,用于一个名为 Twine 的游戏开发 IDE,安装在系统范围的 `/opt` 目录中: +要创建一个 `.desktop` 启动文件,打开一个文本编辑器并创建一个名为 `twine.desktop` 的文件。[桌面条目规范][22] 由 [FreeDesktop.org][23] 定义。下面是一个简单的启动器,用于一个名为 Twine 的游戏开发 IDE,安装在系统范围的 `/opt` 目录中: ``` [Desktop Entry] - Encoding=UTF-8 - Name=Twine - GenericName=Twine - Comment=Twine - Exec=/opt/twine/Twine - Icon=/usr/share/icons/oxygen/64x64/categories/applications-games.png - Terminal=false - Type=Application - Categories=Development;IDE; ``` 棘手的一行是 `Exec` 行。它必须包含一个有效的命令来启动应用程序。通常,它只是你下载的东西的完整路径,但在某些情况下,它更复杂一些。例如,Java 应用程序可能需要作为 Java 自身的参数启动。 + ``` Exec=java -jar /path/to/foo.jar ``` 有时,一个项目包含一个可以运行的包装脚本,这样你就不必找出正确的命令: + ``` Exec=/opt/foo/foo-launcher.sh ``` -在这个 Twine 例子中,没有与下载捆绑的图标,因此示例 `.desktop` 文件指定了 KDE 桌面附带的通用游戏图标。你可以使用类似的解决方法,但如果你更具艺术性,这可以创建自己的图标,或者可以在 Internet 上搜索一个好的图标。只要 `Icon` 行指向一个有效的 PNG 或 SVG 文件,你的应用程序就会继承该图标。 +在这个 Twine 例子中,没有与该下载的软件捆绑的图标,因此示例 `.desktop` 文件指定了 KDE 桌面附带的通用游戏图标。你可以使用类似的解决方法,但如果你更具艺术性,可以创建自己的图标,或者可以在 Internet 上搜索一个好的图标。只要 `Icon` 行指向一个有效的 PNG 或 SVG 文件,你的应用程序就会以该图标为代表。 -示例脚本还将应用程序类别主要设置为 Development,因此在 KDE, GNOME 和大多数其他应用程序菜单中,Twine 出现在开发类别下。 +示例脚本还将应用程序类别主要设置为 Development,因此在 KDE、GNOME 和大多数其他应用程序菜单中,Twine 出现在开发类别下。 为了让这个例子出现在应用程序菜单中,把 `twine.desktop` 文件放这到两个地方之一: @@ -186,7 +183,7 @@ Exec=/opt/foo/foo-launcher.sh ### 从源代码编译 -最后,还有真正的通用格式安装格式:源代码。从源代码编译应用程序是学习如何构建应用程序,如何与系统交互以及如何定制应用程序的好方法。尽管如此,它绝不是一个按按钮式过程。它需要一个构建环境,通常需要安装依赖库和头文件,有时还要进行一些调试。 +最后,还有真正的通用格式安装格式:源代码。从源代码编译应用程序是学习如何构建应用程序,如何与系统交互以及如何定制应用程序的好方法。尽管如此,它绝不是一个点击按钮式过程。它需要一个构建环境,通常需要安装依赖库和头文件,有时还要进行一些调试。 要了解更多关于从源代码编译的内容,请阅读[我这篇文章][24]。 @@ -194,9 +191,9 @@ Exec=/opt/foo/foo-launcher.sh 有些人认为安装软件是一个神奇的过程,只有开发人员理解,或者他们认为它“激活”了应用程序,就好像二进制可执行文件在“安装”之前无效。学习许多不同的安装方法会告诉你安装实际上只是“将文件从一个地方复制到系统中适当位置”的简写。 没有什么神秘的。只要你去了解每次安装,不是期望应该如何发生,并且寻找开发者为安装过程设置了什么,那么通常很容易,即使它与你的习惯不同。 -重要的是安装人员对你很诚实。 如果你遇到未经你的同意尝试安装其他软件的安装程序(或者它可能会以混淆或误导的方式请求同意),或者尝试在没有明显原因的情况下对系统执行检查,则不要继续安装。 +重要的是安装器要诚实于你。 如果你遇到未经你的同意尝试安装其他软件的安装程序(或者它可能会以混淆或误导的方式请求同意),或者尝试在没有明显原因的情况下对系统执行检查,则不要继续安装。 -好的软件是灵活的,诚实的,开放的。 现在你知道如何在你的计算机上获得好的软件。 +好的软件是灵活的、诚实的、开放的。 现在你知道如何在你的计算机上获得好软件了。 -------------------------------------------------------------------------------- @@ -204,7 +201,7 @@ via: https://opensource.com/article/18/1/how-install-apps-linux 作者:[Seth Kenlon][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 da581fbbfb1205c810e1e3415d17ef0b61069502 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 27 Mar 2018 13:00:43 +0800 Subject: [PATCH 0152/1057] PUB:20180111 How to install software applications on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @MjSeven https://linux.cn/article-9486-1.html 很好 --- .../20180111 How to install software applications on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180111 How to install software applications on Linux.md (100%) diff --git a/translated/tech/20180111 How to install software applications on Linux.md b/published/20180111 How to install software applications on Linux.md similarity index 100% rename from translated/tech/20180111 How to install software applications on Linux.md rename to published/20180111 How to install software applications on Linux.md From dd13f5006634dff5ab7ef935f7be6543335efb00 Mon Sep 17 00:00:00 2001 From: yizhuyan Date: Tue, 27 Mar 2018 16:42:44 +0800 Subject: [PATCH 0153/1057] translating by yizhuoyan --- sources/tech/20171024 Learn Blockchains by Building One.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171024 Learn Blockchains by Building One.md b/sources/tech/20171024 Learn Blockchains by Building One.md index d8a2069b0b..6edffe0179 100644 --- a/sources/tech/20171024 Learn Blockchains by Building One.md +++ b/sources/tech/20171024 Learn Blockchains by Building One.md @@ -1,3 +1,5 @@ +translating by yizhuoyan + Learn Blockchains by Building One ====== From 73824f026a6cb8faf1b2eb5ebe66bae43b657d63 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 27 Mar 2018 19:30:23 +0800 Subject: [PATCH 0154/1057] Delete 20180129 How to Use DockerHub.md --- sources/tech/20180129 How to Use DockerHub.md | 137 ------------------ 1 file changed, 137 deletions(-) delete mode 100644 sources/tech/20180129 How to Use DockerHub.md diff --git a/sources/tech/20180129 How to Use DockerHub.md b/sources/tech/20180129 How to Use DockerHub.md deleted file mode 100644 index 10dc39e63b..0000000000 --- a/sources/tech/20180129 How to Use DockerHub.md +++ /dev/null @@ -1,137 +0,0 @@ -Translating By MjSeven - -How to Use DockerHub -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dockerhub-container.jpg?itok=tvraxGzh) - -In the previous articles, we learned the basics of [Docker terminology][1], [how to install Docker][2] on desktop Linux, macOS, and Windows, and [how to create container images][3] and run them on your system. In this last article in the series, we will talk about using images from DockerHub and publishing your own images to DockerHub. - -First things first: what is DockerHub and why is it important? DockerHub is a cloud-based repository run and managed by Docker Inc. It's an online repository where Docker images can be published and used by other users. There are both public and private repositories. If you are a company, you can have a private repository for use within your own organization, whereas public images can be used by anyone. - -You can also use official Docker images that are published publicly. I use many such images, including for my test WordPress installations, KDE plasma apps, and more. Although we learned last time how to create your own Docker images, you don't have to. There are thousands of images published on DockerHub for you to use. DockerHub is hardcoded into Docker as the default registry, so when you run the docker pull command against any image, it will be downloaded from DockerHub. - -### Download images from Docker Hub and run locally - -Please check out the previous articles in the series to get started. Then, once you have Docker running on your system, you can open the terminal and run: -``` -$ docker images -``` - -This command will show all the docker images currently on your system. Let's say you want to deploy Ubuntu on your local machine; you would do: -``` -$ docker pull ubuntu -``` - -If you already have Ubuntu image on your system, the command will automatically update that image to the latest version. So, if you want to update the existing images, just run the docker pull command, easy peasy. It's like apt-get upgrade without any muss and fuss. - -You already know how to run an image: -``` -$ docker run -it - -$ docker run -it ubuntu -``` - -The command prompt should change to something like this: -``` -root@1b3ec4621737:/# -``` - -Now you can run any command and utility that you use on Ubuntu. It's all safe and contained. You can run all the experiments and tests you want on that Ubuntu. Once you are done testing, you can nuke the image and download a new one. There is no system overhead that you would get with a virtual machine. - -You can exit that container by running the exit command: -``` -$ exit -``` - -Now let's say you want to install Nginx on your system. Run search to find the desired image: -``` -$ docker search nginx - -aizMFFysICAEsgDDYrsrlqwoCgGbWVHtcOzgV9mA -``` - -As you can see, there are many images of Nginx on DockerHub. Why? Because anyone can publish an image. Various images are optimized for different projects, so you can choose the appropriate image. You just need to install the appropriate image for your use-case. - -Let's say you want to pull Bitnami's Nginx container: -``` -$ docker pull bitnami/nginx -``` - -Now run it with: -``` -$ docker run -it bitnami/nginx -``` - -### How to publish images to Docker Hub? - -Previously, [we learned how to create a Docker image][3], and we can easily publish that image to DockerHub. First, you need to log into DockerHub. If you don't already have an account, please [create one][5]. Then, you can open terminal app and log in: -``` -$ docker login --username= -``` - -Replace with the name of your username for Docker Hub. In my case it's arnieswap: -``` -$ docker login --username=arnieswap> -``` - -Enter the password, and you are logged in. Now run the docker images command to get the ID of the image that you created last time. -``` -$ docker images - -tW1jDOugkX7J2FfyFyToM6B8m5OYFwMba-Ag5aez -``` - -Now, suppose you want to push the ng image to DockerHub. First, we need to tag that image ([learn more about tags][1]): -``` -$ docker tag e7083fd898c7 arnieswap/my_repo:testing -``` - -Now push that image: -``` -$ docker push arnieswap/my_repo -``` - -The push refers to repository [docker.io/arnieswap/my_repo] -``` -12628b20827e: Pushed - -8600ee70176b: Mounted from library/ubuntu - -2bbb3cec611d: Mounted from library/ubuntu - -d2bb1fc88136: Mounted from library/ubuntu - -a6a01ad8b53f: Mounted from library/ubuntu - -833649a3e04c: Mounted from library/ubuntu - -testing: digest: sha256:286cb866f34a2aa85c9fd810ac2cedd87699c02731db1b8ca1cfad16ef17c146 size: 1569 - -``` - -Eureka! Your image is being uploaded. Once finished, open DockerHub, log into your account, and you can see your very first Docker image. Now anyone can deploy your image. It's the easiest and fastest way to develop and distribute software. Whenever you update the image, users can simply run: -``` -$ docker run arnieswap/my_repo -``` - -Now you know why people love Docker containers. They solve many problems that traditional workloads face and allow you develop, test, and deploy applications in no time. And, by following the steps in this series, you can try them out for yourself. - - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/intro-to-linux/2018/1/how-use-dockerhub - -作者:[Swapnil Bhartiya][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/arnieswap -[1]:https://www.linux.com/blog/intro-to-linux/2017/12/container-basics-terms-you-need-know -[2]:https://www.linux.com/blog/learn/intro-to-linux/how-install-docker-ce-your-desktop -[3]:https://www.linux.com/blog/learn/intro-to-linux/2018/1/how-create-docker-image -[4]:https://lh3.googleusercontent.com/aizMFFysICAEsgDDYrsrlqwoCgGbWVHtcOzgV9mAtV8IdBZgHPJTdHIZhWBNCRvOyJb108ZBajJ_Nz10yCxGSvk-AF-yvFxpojLdVu3Jjihcwaup6CQLc67A5nglBuGDaOZWcrbV -[5]:https://hub.docker.com/ -[6]:https://lh6.googleusercontent.com/tW1jDOugkX7J2FfyFyToM6B8m5OYFwMba-Ag5aezVGf2A5gsKJ47QrCh_TOKWgIKfE824Uc2Cwwwj9jWps1yJlUZqDyIceVQs-nEbKavFDxuUxLyd4thBA4_rsXrQH4r7hrG8FnD From de8799894b7cc855958a46e52ad0de2dfece71a1 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 27 Mar 2018 19:34:44 +0800 Subject: [PATCH 0155/1057] Create 20180129 How to Use DockerHub.md --- .../tech/20180129 How to Use DockerHub.md | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 translated/tech/20180129 How to Use DockerHub.md diff --git a/translated/tech/20180129 How to Use DockerHub.md b/translated/tech/20180129 How to Use DockerHub.md new file mode 100644 index 0000000000..300d7b3c9c --- /dev/null +++ b/translated/tech/20180129 How to Use DockerHub.md @@ -0,0 +1,134 @@ +如何使用 DockerHub +===== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dockerhub-container.jpg?itok=tvraxGzh) + +在前面的文章中,我们了解到了 [Docker terminology][1] 的基础,在Linux 桌面,MacOS 和 Windows上 [如何安装 Docker][2],[如何创建容器镜像][3] 并且在系统上运行它们。在本系列的最后一篇文章中,我们将讨论如何使用 DockerHub 中的镜像以及将自己的镜像发布到 DockerHub。 + +首先要做的是:什么是 DockerHub 以及为什么它很重要?DockerHub 是一个由 Docker Inc 运行和管理的基于云的存储库。它是一个在线存储库,Docker 镜像可以由其他用户发布和使用。它有公共和私人存储库。如果你是一家公司,你可以在你自己的组织内拥有一个私人存储库,这里的公共镜像可以被任何人使用。 + +你也可以使用公开发布的官方 Docker 镜像。我使用了很多这样的镜像,包括我的试验 WordPress 安装,KDE plasma 应用程序等等。虽然我们上次学习了如何创建自己的 Docker 镜像,但你不必这样做。DockerHub 上发布了数千镜像供你使用。DockerHub 作为默认注册表硬编码到 Docker 中,所以当你对任何镜像运行 docker pull 命令时,它将从 DockerHub 下载。 + +### 从 Docker Hub 下载镜像并在本地运行 + +请查看本系列的前几篇文章,以便开始阅读。然后,一旦 Docker 在你的系统上运行,你就可以打开终端并运行: +``` +$ docker images +``` + +该命令将显示当前系统上所有的 docker 镜像。假设你想在本地机器上部署 Ubuntu;你可能会: +``` +$ docker pull ubuntu +``` + +如果你的系统上已经存在 Ubuntu 镜像,那么该命令会自动将该系统更新到最新版本。因此,如果你想要更新现有的镜像,只需运行 docker pull 命令,易如反掌。这就像 apt-get update 一样,没有任何的混乱和麻烦。 + +你已经知道了如何运行镜像: +``` +$ docker run -it + +$ docker run -it ubuntu +``` + +命令提示符应该变为如下内容: +``` +root@1b3ec4621737:/# +``` + +现在你可以运行任何属于 Ubuntu 的命令和实用程序,这些都被包含在内而且安全。你可以在 Ubuntu 上运行你想要的所有实验和测试。一旦你完成了测试,你就可以核对镜像并下载一个新的。在虚拟机中不存在系统开销。 + +你可以通过运行 exit 命令退出该容器: +``` +$ exit +``` + +现在假设你想在系统上安装 Nginx,运行 search 命令来找到需要的镜像: +``` +$ docker search nginx + +aizMFFysICAEsgDDYrsrlqwoCgGbWVHtcOzgV9mA +``` + +正如你所看到的,DockerHub 上有很多 Nginx 镜像。为什么?因为任何人都可以发布镜像,各种镜像针对不同的项目进行了优化,因此你可以选择合适的镜像。你只需要为你的需求安装合适的镜像。 + +假设你想要拉取 Bitnami's Nginx 镜像: +``` +$ docker pull bitnami/nginx +``` + +现在运行: +``` +$ docker run -it bitnami/nginx +``` + +### 如何发布镜像到 Docker Hub? + +在此之前,[我们学习了如何创建 Docker 镜像][3],我们可以轻松地将该镜像发布到 DockerHub 中。首先,你需要登录 DockerHub,如果没有账户,请 [创建账户][5]。然后,你可以打开终端应用,登录: +``` +$ docker login --username= +``` + +将 <USERNAME> 替换为你自己的 Docker Hub 用户名。我这里是 arnieswap: +``` +$ docker login --username=arnieswap +``` + +输入密码,你就登录了。现在运行 docker 镜像命令来获取你上次创建的镜像的 ID。 +``` +$ docker images + +tW1jDOugkX7J2FfyFyToM6B8m5OYFwMba-Ag5aez +``` + +现在,假设你希望将 ng 镜像推送到 DockerHub,首先,我们需要标记该镜像([了解更多关于标记的信息][1]): +``` +$ docker tag e7083fd898c7 arnieswap/my_repo:testing +``` + +现在推送镜像: +``` +$ docker push arnieswap/my_repo +``` + +推送指向的是 [docker.io/arnieswap/my_repo] 仓库 +``` +12628b20827e: Pushed + +8600ee70176b: Mounted from library/ubuntu + +2bbb3cec611d: Mounted from library/ubuntu + +d2bb1fc88136: Mounted from library/ubuntu + +a6a01ad8b53f: Mounted from library/ubuntu + +833649a3e04c: Mounted from library/ubuntu + +testing: digest: sha256:286cb866f34a2aa85c9fd810ac2cedd87699c02731db1b8ca1cfad16ef17c146 size: 1569 + +``` + +哦耶!你的镜像正在上传。一旦完成,打开 DockerHub,登录到你的账户,你就能看到你的第一个 Docker 镜像。现在任何人都可以部署你的镜像。这是开发软件和发布软件最简单,最快速的方式。无论你何时更新镜像,用户都可以简单地运行: +``` +$ docker run arnieswap/my_repo +``` + +现在你知道为什么人们喜欢 Docker 容器了。它解决了传统工作负载所面临的许多问题,并允许你在任何时候开发、测试和部署应用程序。通过遵循本系列中的步骤,你自己可以尝试以下。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/intro-to-linux/2018/1/how-use-dockerhub + +作者:[Swapnil Bhartiya][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/arnieswap +[1]:https://www.linux.com/blog/intro-to-linux/2017/12/container-basics-terms-you-need-know +[2]:https://www.linux.com/blog/learn/intro-to-linux/how-install-docker-ce-your-desktop +[3]:https://www.linux.com/blog/learn/intro-to-linux/2018/1/how-create-docker-image +[4]:https://lh3.googleusercontent.com/aizMFFysICAEsgDDYrsrlqwoCgGbWVHtcOzgV9mAtV8IdBZgHPJTdHIZhWBNCRvOyJb108ZBajJ_Nz10yCxGSvk-AF-yvFxpojLdVu3Jjihcwaup6CQLc67A5nglBuGDaOZWcrbV +[5]:https://hub.docker.com/ +[6]:https://lh6.googleusercontent.com/tW1jDOugkX7J2FfyFyToM6B8m5OYFwMba-Ag5aezVGf2A5gsKJ47QrCh_TOKWgIKfE824Uc2Cwwwj9jWps1yJlUZqDyIceVQs-nEbKavFDxuUxLyd4thBA4_rsXrQH4r7hrG8FnD From 4d6a769f5c211978850899690f9f4e2aa0e22b42 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 27 Mar 2018 19:45:44 +0800 Subject: [PATCH 0156/1057] Update 20171101 Linux command line tools for working with non-Linux users.md --- ...inux command line tools for working with non-Linux users.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171101 Linux command line tools for working with non-Linux users.md b/sources/tech/20171101 Linux command line tools for working with non-Linux users.md index 23d87f6231..d2e69452a9 100644 --- a/sources/tech/20171101 Linux command line tools for working with non-Linux users.md +++ b/sources/tech/20171101 Linux command line tools for working with non-Linux users.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + Linux command line tools for working with non-Linux users ====== ![](https://images.techhive.com/images/article/2016/06/linux-shell-100666628-large.jpg) From a0622ccece83ed6949488d42e697c790cde74072 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 27 Mar 2018 19:46:01 +0800 Subject: [PATCH 0157/1057] Update 20171101 Linux command line tools for working with non-Linux users.md --- ...inux command line tools for working with non-Linux users.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/sources/tech/20171101 Linux command line tools for working with non-Linux users.md b/sources/tech/20171101 Linux command line tools for working with non-Linux users.md index d2e69452a9..23d87f6231 100644 --- a/sources/tech/20171101 Linux command line tools for working with non-Linux users.md +++ b/sources/tech/20171101 Linux command line tools for working with non-Linux users.md @@ -1,6 +1,3 @@ -Translating by MjSeven - - Linux command line tools for working with non-Linux users ====== ![](https://images.techhive.com/images/article/2016/06/linux-shell-100666628-large.jpg) From 017618a3ce715daf0c62b57b54dd4e9bb5ff0a83 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 27 Mar 2018 19:46:41 +0800 Subject: [PATCH 0158/1057] Update 20171101 Linux command line tools for working with non-Linux users.md --- ...Linux command line tools for working with non-Linux users.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171101 Linux command line tools for working with non-Linux users.md b/sources/tech/20171101 Linux command line tools for working with non-Linux users.md index 23d87f6231..c2583dd7e1 100644 --- a/sources/tech/20171101 Linux command line tools for working with non-Linux users.md +++ b/sources/tech/20171101 Linux command line tools for working with non-Linux users.md @@ -1,3 +1,5 @@ +Translating by MjSeven + Linux command line tools for working with non-Linux users ====== ![](https://images.techhive.com/images/article/2016/06/linux-shell-100666628-large.jpg) From c323437488bab082cd53ef5827fd04d88f87f1f6 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Wed, 28 Mar 2018 07:17:20 +0800 Subject: [PATCH 0159/1057] 2018-03-28 --- ... Why Linux is better than Windows or macOS for security.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index 4660ffddd7..df0557339d 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -19,9 +19,9 @@ One reason enterprises might not have evaluated the security of the OS they depl Still, would it be wise to reconsider? Are the three leading desktop OSes different enough in their approach to security to make a change worthwhile? -当然商业系统面临的威胁近几年已经改变了。攻击变得成熟多了。Certainly the threats confronting enterprise systems have changed in the last few years. Attacks have become far more sophisticated. The lone teen hacker that once dominated the public imagination has been supplanted by well-organized networks of criminals and shadowy, government-funded organizations with vast computing resources. +当然商业系统面临的威胁近几年已经改变了。攻击变得成熟多了。The lone teen hacker that once dominated the public imagination has been supplanted by well-organized networks of criminals and shadowy, government-funded organizations with vast computing resources. -Like many of you, I have firsthand experience of the threats that are out there: I have been infected by malware and viruses on numerous Windows computers, and I even had macro viruses that infected files on my Mac. More recently, a widespread automated hack circumvented the security on my website and infected it with malware. The effects of such malware were always initially subtle, something you wouldn’t even notice, until the malware ended up so deeply embedded in the system that performance started to suffer noticeably. One striking thing about the infestations was that I was never specifically targeted by the miscreants; nowadays, it’s as easy to attack 100,000 computers with a botnet as it is to attack a dozen. +想你们许多人一样,我已经有了很多那儿的亲身经历:我曾经在许多 Windows 电脑上被恶意软件和病毒感染,我甚至被 Mac 文件的宏病毒感染了。 More recently, a widespread automated hack circumvented the security on my website and infected it with malware. The effects of such malware were always initially subtle, something you wouldn’t even notice, until the malware ended up so deeply embedded in the system that performance started to suffer noticeably. One striking thing about the infestations was that I was never specifically targeted by the miscreants; nowadays, it’s as easy to attack 100,000 computers with a botnet as it is to attack a dozen. ### 操作系统真的重要吗?Does the OS really matter? From 92885091663cf0bbbf141a20a0cdf7a97266e827 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 28 Mar 2018 08:32:34 +0800 Subject: [PATCH 0160/1057] translated --- sources/tech/20180314 Playing with water.md | 42 ------------------- .../tech/20180314 Playing with water.md | 40 ++++++++++++++++++ 2 files changed, 40 insertions(+), 42 deletions(-) delete mode 100644 sources/tech/20180314 Playing with water.md create mode 100644 translated/tech/20180314 Playing with water.md diff --git a/sources/tech/20180314 Playing with water.md b/sources/tech/20180314 Playing with water.md deleted file mode 100644 index 7c354e7975..0000000000 --- a/sources/tech/20180314 Playing with water.md +++ /dev/null @@ -1,42 +0,0 @@ -translating---geekpi - -Playing with water -====== -![H2o Flow gradient boosting job][1] - -I'm currently taking a machine learning class and although it is an insane amount of work, I like it a lot. I initially had planned to use [R][2] to play around with the database I have, but the teacher recommended I use [H2o][3], a FOSS machine learning framework. - -I was a bit sceptical at first since I'm already pretty good with R, but then I found out you could simply import H2o as an R library. H2o replaces most R functions by its own parallelized ones to cut down on processing time (no more `doParallel` calls) and uses an "external" server you have to run on the side instead of running R calls directly. - -![H2o Flow gradient boosting model][4] - -I was pretty happy with this situation, that is until I actually started using H2o in R. With the huge database I'm playing with, the library felt clunky and I had a hard time doing anything useful. Most of the time, I just ended up with long Java traceback calls. Much love. - -I'm sure in the right hands using H2o as a library could have been incredibly powerful, but sadly it seems I haven't earned my black belt in R-fu yet. - -![H2o Flow variable importance weights][5] - -I was pissed for at least a whole day - not being able to achieve what I wanted to do - until I realised H2o comes with a WebUI called Flow. I'm normally not very fond of using web thingies to do important work like writing code, but Flow is simply incredible. - -Automated graphing functions, integrated ETA when running resource intensive models, descriptions for each and every model parameters (the parameters are even divided in sections based on your familiarly with the statistical models in question), Flow seemingly has it all. In no time I was able to run 3 basic machine learning models and get actual interpretable results. - -So yeah, if you've been itching to analyse very large databases using state of the art machine learning models, I would recommend using H2o. Try Flow at first instead of the Python or R hooks to see what it's capable of doing. - -The only downside to all of this is that H2o is written in Java and depends on Java 1.7 to run... That, and be warned: it requires a metric fuckton of processing power and RAM. My poor server struggled quite a bit even with 10 available cores and 10Gb of RAM... - --------------------------------------------------------------------------------- - -via: https://veronneau.org/playing-with-water.html - -作者:[Louis-Philippe Véronneau][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://veronneau.org/ -[1]:https://veronneau.org/media/blog/2018-03-14/h2o_job.png (H2o Flow gradient boosting job) -[2]:https://en.wikipedia.org/wiki/R_(programming_language) -[3]:https://www.h2o.ai -[4]:https://veronneau.org/media/blog/2018-03-14/h2o_model.png (H2o Flow gradient boosting model) -[5]:https://veronneau.org/media/blog/2018-03-14/h2o_var_importance.png (H2o Flow variable importance weights) diff --git a/translated/tech/20180314 Playing with water.md b/translated/tech/20180314 Playing with water.md new file mode 100644 index 0000000000..88adcebd32 --- /dev/null +++ b/translated/tech/20180314 Playing with water.md @@ -0,0 +1,40 @@ +尝试 H2o +====== +![H2o Flow gradient boosting job][1] + +我目前正在参加一个机器学习班,虽然有疯狂的工作量,但我非常喜欢。我最初计划使用 [R][2] 来训练我的数据库,但老师建议我使用一个 FOSS 机器学习框架 [H2o][3]。 + +起初我有点怀疑,因为我已经对 R 掌握得不错了,但后来我发现你可以简单地将 H2o 作为 R 库导入。H2o 将大多数 R 函数替换为其自己的并行化函数,以减少处理时间(不再需要 `doParallel` 调用),并且使用“外部”服务端来运行,而不是直接调用 R。 + +![H2o Flow gradient boosting model][4] + +直到我真正在实际中开始在 H2o 中使用 R 时,我对这种情况都非常满意。我在使用非常大得数据库时,库变得笨重,我几乎不能做任何有用得事情。大多数时候,我最后只是得到一个很长的 Java 回溯调用。 + +我相信正确地将 H2o 作为一个库使用将非常强大,但可惜的是,它似乎在我的 R-fu 中无效。 + +![H2o Flow variable importance weights][5] + +我至少有一整天都很生气 - 无法实现我想做的事 - 直到我意识到 H2o 有一个名为 Flow 的 WebUI。我通常不喜欢使用 web 来完成重要的工作,比如编写代码,但是 Flow 简直太不可思议了。 + +自动绘图功能,运行资源密集模型时集成 ETA(预计剩余时间),每个模型参数的描述(这些参数甚至会根据您熟悉的统计模型分成不同部分),Flow 似乎拥有所有功能。我很快就能够运行 3 种基本的机器学习模型并获得实际可解释的结果。 + +所以,如果你一直渴望使用最先进的机器学习模型分析非常大的数据库,我会推荐使用 H2o。首先尝试使用 Flow,而不是 Python 或 R 的钩子,来看看它能做什么。 + +唯一缺点是,H2o 是用 Java 编写的,并依赖 Java 1.7 来运行。并且需要警告:它需要非常强大的处理器和大量的内存。即使有 10 个可用的内核和 10Gb 的 RAM,我可怜的服务器也苦苦挣扎了一段时间。 + +-------------------------------------------------------------------------------- + +via: https://veronneau.org/playing-with-water.html + +作者:[Louis-Philippe Véronneau][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://veronneau.org/ +[1]:https://veronneau.org/media/blog/2018-03-14/h2o_job.png (H2o Flow gradient boosting job) +[2]:https://en.wikipedia.org/wiki/R_(programming_language) +[3]:https://www.h2o.ai +[4]:https://veronneau.org/media/blog/2018-03-14/h2o_model.png (H2o Flow gradient boosting model) +[5]:https://veronneau.org/media/blog/2018-03-14/h2o_var_importance.png (H2o Flow variable importance weights) From 86395cb7d1e818bad532c6b27280c3e93355134c Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 28 Mar 2018 08:39:15 +0800 Subject: [PATCH 0161/1057] translating --- ...180116 Why building a community is worth the extra effort.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180116 Why building a community is worth the extra effort.md b/sources/tech/20180116 Why building a community is worth the extra effort.md index ec971e84eb..68467a96cf 100644 --- a/sources/tech/20180116 Why building a community is worth the extra effort.md +++ b/sources/tech/20180116 Why building a community is worth the extra effort.md @@ -1,3 +1,5 @@ +translating---geekpi + Why building a community is worth the extra effort ====== From 66ec9cf2ddc2492fbe9073e5ad8ddbbe9164e28a Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 17:41:51 +0800 Subject: [PATCH 0162/1057] PRF:20180203 How to print filename with awk on Linux - Unix.md @amwps290 --- ...print filename with awk on Linux - Unix.md | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/translated/tech/20180203 How to print filename with awk on Linux - Unix.md b/translated/tech/20180203 How to print filename with awk on Linux - Unix.md index 58307d1e5c..34fc95c484 100644 --- a/translated/tech/20180203 How to print filename with awk on Linux - Unix.md +++ b/translated/tech/20180203 How to print filename with awk on Linux - Unix.md @@ -1,8 +1,9 @@ -# 如何在 Linux / Unix 上使用 awk 打印文件名 +如何在 Linux / Unix 上使用 awk 打印文件名 +================= -我想在 Linux / 类Unix 系统上使用 awk 打印文件名。 如何使用 awk 的 BEGIN 特殊模式打印文件名? 我可以使用 gawk/awk 打印当前输入文件的名称吗?( LCTT 注:读者最好能有一些 awk 的背景知识,否则阅读本文的时候会有一些困惑) +Q:我想在 Linux / 类Unix 系统上使用 awk 打印文件名。 如何使用 awk 的 `BEGIN` 特殊模式打印文件名? 我可以使用 gawk/awk 打印当前输入文件的名称吗?(LCTT 译注:读者最好能有一些 awk 的背景知识,否则阅读本文的时候会有一些困惑) -在 FILENAME 变量中存放着当前输入文件的名称。 您可以使用 FILENAME 显示或打印当前输入文件名,如果在命令行中未指定文件,则FILENAME的值为“ - ”(标准输入)( LCTT 注:多次按下回车键即可看到效果)。 但是,除非由 getline 设置,否则 FILENAME 在 BEGIN 特殊模式中未定义。 +在 `FILENAME` 变量中存放着当前输入文件的名称。 您可以使用 `FILENAME` 显示或打印当前输入文件名,如果在命令行中未指定文件,则 `FILENAME` 的值为 `-` (标准输入)(LCTT 译注:多次按下回车键即可看到效果)。 但是,除非由 `getline` 设置,否则 `FILENAME` 在 `BEGIN` 特殊模式中未定义。 ### 使用 awk 打印文件名 @@ -12,43 +13,48 @@ awk '{ print FILENAME }' fileNameHere awk '{ print FILENAME }' /etc/hosts ``` -因 awk 逐行读取文件,因此,你可能看到多个文件名,为了避免这个情况,你可以使用如下的命令:( LCTT注:FNR 表示当前记录数,只在文件中有效) + +因 awk 逐行读取文件,因此,你可能看到多个文件名,为了避免这个情况,你可以使用如下的命令:(LCTT 译注:`FNR` 表示当前记录数,只在文件中有效) ``` awk 'FNR == 1{ print FILENAME } ' /etc/passwd awk 'FNR == 1{ print FILENAME } ' /etc/hosts ``` + ![](https://www.cyberciti.biz/media/new/faq/2018/02/How-to-print-filename-using-awk-on-Linux-or-Unix.jpg) ### 使用 awk 的 BEGIN 特殊规则打印文件名 -使用下面的语法:( LCTT 注:ARGV[I] 表示输入的第 i 个参数) +使用下面的语法:(LCTT 译注:`ARGV[I]` 表示输入的第 i 个参数) ``` awk 'BEGIN{print ARGV[1]}' fileNameHere awk 'BEGIN{print ARGV[1]}{ print "someting or do something on data" }END{}' fileNameHere awk 'BEGIN{print ARGV[1]}' /etc/hosts ``` + 示例输出: ``` /etc/hosts - ``` -然而,ARGV\[1\] 并不是每一次都能奏效,例如: +然而,`ARGV[1]` 并不是每一次都能奏效,例如: -`ls -l /etc/hosts | awk 'BEGIN{print ARGV[1]} { print }'` +``` +ls -l /etc/hosts | awk 'BEGIN{print ARGV[1]} { print }' +``` -你需要将它修改如下(假设 ls -l 只产生一行输出): +你需要将它修改如下(假设 `ls -l` 只产生一行输出): -`ls -l /etc/hosts | awk '{ print "File: " $9 ", Owner:" $3 ", Group: " $4 }'` +``` +ls -l /etc/hosts | awk '{ print "File: " $9 ", Owner:" $3 ", Group: " $4 }' +``` 示例输出: ``` File: /etc/hosts, Owner:root, Group: root - ``` ### 处理由通配符指定的多个文件名 @@ -59,6 +65,7 @@ File: /etc/hosts, Owner:root, Group: root awk '{ print FILENAME; nextfile } ' *.c awk 'BEGIN{ print "Starting..."} { print FILENAME; nextfile }END{ print "....DONE"} ' *.conf ``` + 示例输出: ``` @@ -101,10 +108,9 @@ xattr.conf xinetd.conf yp.conf ....DONE - ``` -nextfile 告诉 awk 停止处理当前的输入文件。 下一个输入记录读取来自下一个输入文件。 更多信息,请参见 awk/[gawk][1] 命令手册页: +`nextfile` 告诉 awk 停止处理当前的输入文件。 下一个输入记录读取来自下一个输入文件。 更多信息,请参见 awk/[gawk][1] 命令手册页: ``` man awk @@ -115,11 +121,13 @@ man gawk 作者是 nixCraft 的创立者,也是经验丰富的系统管理员和 Linux/Unix shell 脚本的培训师。 他曾与全球各行各业的客户合作,涉及 IT,教育,国防和空间研究以及非营利部门等多个行业。 您可以在 [Twitter][2],[Facebook][3] 和 [Google+][4]上关注他。 可以通过订阅我的 [RSS][5] 来获取更多的关于**系统管理,Linux/Unix ,和开源主题**的相关资料。 +------------- + via: https://www.cyberciti.biz/faq/how-to-print-filename-with-awk-on-linux-unix/ -作者:Vivek GIte[][a] +作者:[Vivek Gite][a] 译者:[amwps290](https://github.com/amwps290) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 4baea3477e503ede86e968b38d202c706f42ea25 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 17:42:44 +0800 Subject: [PATCH 0163/1057] PUB:20180203 How to print filename with awk on Linux - Unix.md @amwps290 https://linux.cn/article-9487-1.html --- .../20180203 How to print filename with awk on Linux - Unix.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180203 How to print filename with awk on Linux - Unix.md (100%) diff --git a/translated/tech/20180203 How to print filename with awk on Linux - Unix.md b/published/20180203 How to print filename with awk on Linux - Unix.md similarity index 100% rename from translated/tech/20180203 How to print filename with awk on Linux - Unix.md rename to published/20180203 How to print filename with awk on Linux - Unix.md From 80cb298871cd00ab6b047019b8f57b104c4afe89 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 17:59:44 +0800 Subject: [PATCH 0164/1057] PRF:20171108 How to Use GNOME Shell Extensions [Complete Guide].md @MjSeven --- ...GNOME Shell Extensions [Complete Guide].md | 96 +++++++++++-------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/translated/tech/20171108 How to Use GNOME Shell Extensions [Complete Guide].md b/translated/tech/20171108 How to Use GNOME Shell Extensions [Complete Guide].md index 8f3c10cfa7..47cb18df76 100644 --- a/translated/tech/20171108 How to Use GNOME Shell Extensions [Complete Guide].md +++ b/translated/tech/20171108 How to Use GNOME Shell Extensions [Complete Guide].md @@ -1,7 +1,7 @@ -如何使用 GNOME Shell 扩展[完整指南] +如何使用 GNOME Shell 扩展 ===== -**简介:这是一份详细指南,我将会向你展示如何手动或通过浏览器轻松安装 GNOME Shell 扩展。** +> 简介:这是一份详细指南,我将会向你展示如何手动或通过浏览器轻松安装 GNOME Shell 扩展Extension。 在讨论 [如何在 Ubuntu 17.10 上安装主题][1] 一文时,我简要地提到了 GNOME Shell 扩展,它用来安装用户主题。今天,我们将详细介绍 Ubuntu 17.10 中的 GNOME Shell 扩展。 @@ -11,94 +11,103 @@ 在此之前,如果你喜欢视频,我已经在 [FOSS 的 YouTube 频道][2] 上展示了所有的这些操作。我强烈建议你订阅它来获得更多有关 Linux 的视频。 -## 什么是 GNOME Shell 扩展? +### 什么是 GNOME Shell 扩展? [GNOME Shell 扩展][3] 根本上来说是增强 GNOME 桌面功能的一小段代码。 -把它看作是你浏览器的一个附加组件。例如,你可以在浏览器中安装附加组件来禁用广告。这个附加组件是由第三方开发者开发的。虽然你的 Web 浏览器默认不提供此项功能,但安装此附加组件可增强你 Web 浏览器的功能。 +把它看作是你的浏览器的一个附加组件。例如,你可以在浏览器中安装附加组件来禁用广告。这个附加组件是由第三方开发者开发的。虽然你的 Web 浏览器默认不提供此项功能,但安装此附加组件可增强你 Web 浏览器的功能。 -同样, GNOME Shell 扩展就像那些可以安装在 GNOME 之上的第三方附加组件和插件。这些扩展程序是为执行特定任务而创建的,例如显示天气状况,网速等。大多数情况下,你可以在顶部面板中访问它们。 +同样, GNOME Shell 扩展就像那些可以安装在 GNOME 之上的第三方附加组件和插件。这些扩展程序是为执行特定任务而创建的,例如显示天气状况、网速等。大多数情况下,你可以在顶部面板中访问它们。 -![GNOME Shell 扩展 in action][5] +![GNOME Shell 扩展显示天气信息][5] -还有一些 GNOME 扩展在顶部面板上不可见,但它们仍然可以调整 GNOME 的行为。例如,鼠标中轴可以使用扩展来关闭一个应用程序。 +也有一些 GNOME 扩展在顶部面板上不可见,但它们仍然可以调整 GNOME 的行为。例如,有一个这样的扩展可以让鼠标中键来关闭应用程序。 -## 安装 GNOME Shell 扩展 +### 安装 GNOME Shell 扩展 现在你知道了什么是 GNOME Shell 扩展,那么让我们来看看如何安装它吧。有三种方式可以使用 GNOME 扩展: -* 使用来自 Ubuntu 的最小扩展集(或你的 Linux 发行版) -* 在 Web 浏览器种查找并安装扩展程序 +* 使用来自 Ubuntu (或你的 Linux 发行版)的最小扩展集 +* 在 Web 浏览器中查找并安装扩展程序 * 下载并手动安装扩展 在你学习如何使用 GNOME Shell 扩展之前,你应该安装 GNOME Tweak Tool。你可以在软件中心找到它,或者你可以使用以下命令: + ``` sudo apt install gnome-tweak-tool ``` 有时候,你需要知道你正在使用的 GNOME Shell 的版本,这有助于你确定扩展是否与系统兼容。你可以使用下面的命令来找到它: + ``` gnome-shell --version ``` -### 1. 使用 gnome-shell-extensions 包 [最简单最安全的方式] +#### 1. 使用 gnome-shell-extensions 包 [最简单最安全的方式] -Ubuntu (以及其他几个 Linux 发行版,如 Fedora )提供了一个包,这个包有最小的 GNOME 扩展。由于 Linux 发行版经过测试,所以你不必担心兼容性问题。 +Ubuntu(以及其他几个 Linux 发行版,如 Fedora )提供了一个包,这个包有最小集合的 GNOME 扩展。由于 Linux 发行版经过测试,所以你不必担心兼容性问题。 + +如果你不想费神,你只需获得这个包,你就可以安装 8-10 个 GNOME 扩展。 -如果你想要一个简单易懂的程序,你只需获得这个包,你就可以安装 8-10 个 GNOME 扩展。 ``` sudo apt install gnome-shell-extensions ``` -你将不得不重新启动系统(或者重新启动 GNOME Shell,我具体忘了是哪个)。之后,启动 GNOME Tweaks,你会发现一些扩展自动安装了,你只需切换按钮即可开始使用已安装的扩展程序。 +你将需要重新启动系统(或者重新启动 GNOME Shell,我具体忘了是哪个)。之后,启动 GNOME Tweaks,你会发现一些扩展自动安装了,你只需切换按钮即可开始使用已安装的扩展程序。 ![Change GNOME Shell theme in Ubuntu 17.1][6] -### 2. 从 Web 浏览器安装 GNOME Shell 扩展 +#### 2. 从 Web 浏览器安装 GNOME Shell 扩展 -GNOME 项目有一个专门用于扩展的网站。不是这个,你可以找到并安装它,从而管理你的扩展程序,甚至不需要 GNOME Tweaks Tool。 +GNOME 项目有一个专门用于扩展的网站,不干别的,你可以在这里找到并安装扩展,并管理它们,甚至不需要 GNOME Tweaks Tool。 -[GNOME Shell Extensions Website][3] +- [GNOME Shell Extensions Website][3] 但是为了安装 Web 浏览器扩展,你需要两件东西:浏览器附加组件和本地主机连接器。 -#### 步骤 1: 安装 浏览器附加组件 +**步骤 1: 安装 浏览器附加组件** 当你访问 GNOME Shell 扩展网站时,你会看到如下消息: -> "要使用此站点控制 GNOME Shell 扩展,你必须安装由两部分组成的 GNOME Shell 集成:浏览器扩展和本地主机消息应用。" + +> “要使用此站点控制 GNOME Shell 扩展,你必须安装由两部分组成的 GNOME Shell 集成:浏览器扩展和本地主机消息应用。” ![Installing GNOME Shell Extensions][7] -你只需在你的 Web 浏览器上点击建议的附加组件即可。你也可以从下面的链接安装它们: +你只需在你的 Web 浏览器上点击建议的附加组件链接即可。你也可以从下面的链接安装它们: -#### 步骤 2: 安装本地连接器 +- 对于 Google Chrome、Chromium 和 Vivaldi: [Chrome Web 商店][21] +- 对于 Firefox: [Mozilla Addons][22] +- 对于 Opera: [Opera Addons][23] + +**步骤 2: 安装本地连接器** 仅仅安装浏览器附加组件并没有帮助。你仍然会看到如下错误: -> "尽管 GNOME Shell 集成扩展正在运行,但未检测到本地主机连接器。请参阅文档以获取有关安装连接器的信息。" +> “尽管 GNOME Shell 集成扩展正在运行,但未检测到本地主机连接器。请参阅文档以获取有关安装连接器的信息。” ![How to install GNOME Shell Extensions][8] 这是因为你尚未安装主机连接器。要做到这一点,请使用以下命令: + ``` sudo apt install chrome-gnome-shell ``` -不要担心包名中的 'chrome' 前缀,它与 Chrome 无关,你无需再次安装 Firefox 或 Opera 的单独软件包。 +不要担心包名中的 “chrome” 前缀,它与 Chrome 无关,你无需再次安装 Firefox 或 Opera 的单独软件包。 -#### 步骤 3: 在 Web 浏览器中安装 GNOME Shell 扩展 +**步骤 3: 在 Web 浏览器中安装 GNOME Shell 扩展** 一旦你完成了这两个要求,你就可以开始了。现在,你将看不到任何错误消息。 ![GNOME Shell Extension][9] -一件好事情是它会按照 GNOME Shell 版本对扩展进行排序,但这不是强制性的。这里发生的事情是开发人员为当前的 GNOME 版本创建扩展。在一年之内,还会有两个 GNOME 发行版本。但开发人员没有时间测试或更新他/她的扩展。 +一件好的做法是按照 GNOME Shell 版本对扩展进行排序,但这不是强制性的。这是因为开发人员是为其当前的 GNOME 版本创建的扩展。而在一年之内,会发布两个或更多 GNOME 发行版本,但开发人员没有时间(在新的 GNOME 版本上)测试或更新他/她的扩展。 因此,你不知道该扩展是否与你的系统兼容。尽管扩展已经存在很长一段时间了,但是有可能在最新的 GNOME Shell 版本中,它也能正常工作。同样它也有可能不工作。 你也可以去搜索扩展程序。假设你想要安装有关天气的扩展,只要搜索它并选择一个搜索结果即可。 -当你访问扩展页面是,你会看到一个切换按钮。 +当你访问扩展页面时,你会看到一个切换按钮。 ![Installing GNOME Shell Extension ][10] @@ -106,21 +115,21 @@ sudo apt install chrome-gnome-shell ![Install GNOME Shell Extensions via web browser][11] -很明显,直接安装。安装完成后,你会看到切换按钮已打开,旁边有一个设置选项。你也可以使用设置选项配置扩展,也可以禁用扩展。 +显然,直接安装就好。安装完成后,你会看到切换按钮已打开,旁边有一个设置选项。你也可以使用设置选项配置扩展,也可以禁用扩展。 ![Configuring installed GNOME Shell Extensions][12] -你还可以在 GNOME Tweaks Tool 中配置 Web 浏览器中安装的扩展: +你也可以在 GNOME Tweaks Tool 中配置通过 Web 浏览器安装的扩展: ![GNOME Tweaks to handle GNOME Shell Extensions][13] -你可以在 GNOME 网站中 [安装的扩展部分][14] 下查看所有已安装的扩展。 +你可以在 GNOME 网站中 [已安装的扩展部分][14] 下查看所有已安装的扩展。 ![Manage your installed GNOME Shell Extensions][15] -使用 GNOME 扩展网站的一个主要优点是你可以查看是否有可用于扩展的更新,你不会在 GNOME Tweaks 或系统更新中获得它。 +使用 GNOME 扩展网站的一个主要优点是你可以查看扩展是否有可用的更新,你不会在 GNOME Tweaks 或系统更新中得到更新(和提示)。 -### 3. 手动安装 GNOME Shell 扩展 +#### 3. 手动安装 GNOME Shell 扩展 你不需要始终在线才能安装 GNOME Shell 扩展,你可以下载文件并稍后安装,这样就不必使用互联网了。 @@ -128,41 +137,41 @@ sudo apt install chrome-gnome-shell ![Download GNOME Shell Extension][16] -解压下载的文件,将该文件夹复制到 **~/.local/share/gnome-shell/extensions** 目录。到主目录下并按 Crl+H 显示隐藏的文件夹,在这里找到 .local 文件夹,你可以找到你的路径,直至扩展目录。 +解压下载的文件,将该文件夹复制到 `~/.local/share/gnome-shell/extensions` 目录。到主目录下并按 `Ctrl+H` 显示隐藏的文件夹,在这里找到 `.local` 文件夹,你可以找到你的路径,直至 `extensions` 目录。 -一旦你将文件复制到正确的目录后,进入它并打开 metadata.json 文件,寻找 uuid 的值。 +一旦你将文件复制到正确的目录后,进入它并打开 `metadata.json` 文件,寻找 `uuid` 的值。 -确保扩展文件夹名称与 metadata.json 中的 uuid 值相同。如果不相同,请将目录重命名为 uuid 的值。 +确保该扩展的文件夹名称与 `metadata.json` 中的 `uuid` 值相同。如果不相同,请将目录重命名为 `uuid` 的值。 ![Manually install GNOME Shell extension][17] -差不多了!现在重新启动 GNOME Shell。 按 Alt+F2 并输入 r 重新启动 GNOME Shell。 +差不多了!现在重新启动 GNOME Shell。 按 `Alt+F2` 并输入 `r` 重新启动 GNOME Shell。 ![Restart GNOME Shell][18] -同样重新启动 GNOME Tweaks Tool。你现在应该可以在 Tweaks Tool 中看到手动安装 GNOME 扩展,你可以在此处配置或启用新安装的扩展。 +同样重新启动 GNOME Tweaks Tool。你现在应该可以在 Tweaks Tool 中看到手动安装的 GNOME 扩展,你可以在此处配置或启用新安装的扩展。 这就是安装 GNOME Shell 扩展你需要知道的所有内容。 -## 移除 GNOME Shell 扩展 +### 移除 GNOME Shell 扩展 你可能想要删除一个已安装的 GNOME Shell 扩展,这是完全可以理解的。 如果你是通过 Web 浏览器安装的,你可以到 [GNOME 网站的以安装的扩展部分][14] 那移除它(如前面的图片所示)。 -如果你是手动安装的,可以从 ~/.local/share/gnome-shell/extensions 目录中删除扩展文件来删除它。 +如果你是手动安装的,可以从 `~/.local/share/gnome-shell/extensions` 目录中删除扩展文件来删除它。 -## 特别提示:获得 GNOME Shell 扩展更新的通知 +### 特别提示:获得 GNOME Shell 扩展更新的通知 到目前为止,你已经意识到除了访问 GNOME 扩展网站之外,无法知道更新是否可用于 GNOME Shell 扩展。 幸运的是,有一个 GNOME Shell 扩展可以通知你是否有可用于已安装扩展的更新。你可以从下面的链接中获得它: -[Extension Update Notifier][19] +- [Extension Update Notifier][19] ### 你如何管理 GNOME Shell 扩展? -我觉得很奇怪你不能通过系统更新来更新扩展,就好像 GNOME Shell 扩展不是系统的一部分。 +我觉得很奇怪不能通过系统更新来更新扩展,就好像 GNOME Shell 扩展不是系统的一部分。 如果你正在寻找一些建议,请阅读这篇文章: [关于最佳 GNOME 扩展][20]。同时,你可以分享有关 GNOME Shell 扩展的经验。你经常使用它们吗?如果是,哪些是你最喜欢的? @@ -172,7 +181,7 @@ via: [https://itsfoss.com/gnome-shell-extensions/](https://itsfoss.com/gnome-she 作者:[Abhishek Prakash][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/) 荣誉推出 @@ -196,3 +205,6 @@ via: [https://itsfoss.com/gnome-shell-extensions/](https://itsfoss.com/gnome-she [18]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2017/11/restart-gnome-shell-800x299.jpeg [19]:https://extensions.gnome.org/extension/1166/extension-update-notifier/ [20]:https://itsfoss.com/best-gnome-extensions/ +[21]:https://chrome.google.com/webstore/detail/gnome-shell-integration/gphhapmejobijbbhgpjhcjognlahblep +[22]:https://addons.mozilla.org/en/firefox/addon/gnome-shell-integration/ +[23]:https://addons.opera.com/en/extensions/details/gnome-shell-integration/ \ No newline at end of file From b9c5e5a60d13deaf3caf62112b87f71ab02a3484 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 18:00:45 +0800 Subject: [PATCH 0165/1057] PUB:20171108 How to Use GNOME Shell Extensions [Complete Guide].md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @MjSeven 不知道为什么上次发布这篇文章的PR居然没合并。。 --- ...20171108 How to Use GNOME Shell Extensions [Complete Guide].md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171108 How to Use GNOME Shell Extensions [Complete Guide].md (100%) diff --git a/translated/tech/20171108 How to Use GNOME Shell Extensions [Complete Guide].md b/published/20171108 How to Use GNOME Shell Extensions [Complete Guide].md similarity index 100% rename from translated/tech/20171108 How to Use GNOME Shell Extensions [Complete Guide].md rename to published/20171108 How to Use GNOME Shell Extensions [Complete Guide].md From 8708245d0da6c704bafabc74204d9a2f3fc5cffe Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 18:11:05 +0800 Subject: [PATCH 0166/1057] PRF:20180124 4 cool new projects to try in COPR for January.md @geekpi --- ...cool new projects to try in COPR for January.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/translated/tech/20180124 4 cool new projects to try in COPR for January.md b/translated/tech/20180124 4 cool new projects to try in COPR for January.md index 68b131967f..a52feb9270 100644 --- a/translated/tech/20180124 4 cool new projects to try in COPR for January.md +++ b/translated/tech/20180124 4 cool new projects to try in COPR for January.md @@ -1,21 +1,22 @@ -一月 COPR 中 4 个新的很酷的项目 +COPR 仓库中 4 个很酷的新软件 ====== ![](https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg) -COPR 是一个个人软件仓库[集合][1],它们不存在于 Fedora 中。有些软件不符合标准而不容易打包。或者它可能不符合其他的 Fedora 标准,尽管它是免费和开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 支持或者由项目自己签名。但是,它是尝试新的或实验性软件的一种很好的方法。 +COPR 是一个个人软件仓库[集合][1],它们不存在于 Fedora 中。有些软件不符合标准而不容易打包。或者它可能不符合其他的 Fedora 标准,尽管它是自由和开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 基础设施的支持,或者是由项目自己签名的。但是,它是尝试新的或实验性软件的一种很好的方法。 这是 COPR 中一系列新的和有趣的项目。 ### Elisa -[Elisa][2] 是一个最小的音乐播放器。它可以让你通过专辑、艺术家或曲目浏览音乐。它会自动检测你的 ~/Music 目录中的所有可播放音乐,因此它根本不需要设置 - 它也不提供任何音乐。目前,Elisa 专注于做一个简单的音乐播放器,所以它不提供管理音乐收藏的工具。 +[Elisa][2] 是一个极小的音乐播放器。它可以让你通过专辑、艺术家或曲目浏览音乐。它会自动检测你的 `~/Music` 目录中的所有可播放音乐,因此它根本不需要设置 - 它也不提供任何音乐。目前,Elisa 专注于做一个简单的音乐播放器,所以它不提供管理音乐收藏的工具。 ![][3] #### 安装说明 仓库目前为 Fedora 26、27 和 Rawhide 提供 Elisa。要安装 Elisa,请使用以下命令: + ``` sudo dnf copr enable eclipseo/elisa sudo dnf install elisa @@ -28,6 +29,7 @@ sudo dnf install elisa #### 安装说明 仓库目前为 Fedora 25、26、27 和 Rawhide 提供必应壁纸。要安装必应壁纸,请使用以下命令: + ``` sudo dnf copr enable julekgwa/Bingwallpapers sudo dnf install bingwallpapers @@ -35,11 +37,12 @@ sudo dnf install bingwallpapers ### Polybar -[Polybar][5] 是一个创建状态栏的工具。它有很多自定义选项以及内置的功能来显示常用服务的信息,例如 [bspwm][6]、[i3][7] 的系统托盘图标、窗口标题、工作区和桌面面板等。你也可以为你的状态栏配置你自己的模块。有关使用和配置的更多信息,请参考[ Polybar 的 wiki][8]。 +[Polybar][5] 是一个创建状态栏的工具。它有很多自定义选项以及显示常用服务的信息的内置功能,例如 [bspwm][6]、[i3][7] 的系统托盘图标、窗口标题、工作区和桌面面板等。你也可以为你的状态栏配置你自己的模块。有关使用和配置的更多信息,请参考[ Polybar 的 wiki][8]。 #### 安装说明 仓库目前为 Fedora 27 提供 Polybar。要安装 Polybar,请使用以下命令: + ``` sudo dnf copr enable tomwishaupt/polybar sudo dnf install polybar @@ -59,14 +62,13 @@ sudo dnf copr enable recteurlp/netdata sudo dnf install netdata ``` - -------------------------------------------------------------------------------- via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-january/ 作者:[Dominik Turecek][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 99685c43f27c2bab979a70ff5d9f254b37579873 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 18:11:23 +0800 Subject: [PATCH 0167/1057] PUB:20180124 4 cool new projects to try in COPR for January.md @geekpi --- .../20180124 4 cool new projects to try in COPR for January.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180124 4 cool new projects to try in COPR for January.md (100%) diff --git a/translated/tech/20180124 4 cool new projects to try in COPR for January.md b/published/20180124 4 cool new projects to try in COPR for January.md similarity index 100% rename from translated/tech/20180124 4 cool new projects to try in COPR for January.md rename to published/20180124 4 cool new projects to try in COPR for January.md From 176e86eaf3973896cfb6d39c4b888e967e5ff9ef Mon Sep 17 00:00:00 2001 From: yizhuyan Date: Wed, 28 Mar 2018 18:24:46 +0800 Subject: [PATCH 0168/1057] Delete 20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完毕 --- ...ental Deletion Or Modification In Linux.md | 297 ------------------ 1 file changed, 297 deletions(-) delete mode 100644 sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md diff --git a/sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md b/sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md deleted file mode 100644 index e2c00cbb75..0000000000 --- a/sources/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md +++ /dev/null @@ -1,297 +0,0 @@ -translating by yizhuoyan - -Prevent Files And Folders From Accidental Deletion Or Modification In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2017/02/Prevent-Files-And-Folders-From-Accidental-Deletion-Or-Modification-In-Linux-720x340.jpg) - -Some times, I accidentally “SHIFT+DELETE” my data. Yes, I am an idiot who don’t double check what I am exactly going to delete. And, I am too dumb or lazy to backup the data. Result? Data loss! They are gone in a fraction of second. I do it every now and then. If you’re anything like me, I’ve got a good news. There is a simple, yet useful commandline utility called **“chattr”** (abbreviation of **Ch** ange **Attr** ibute) which can be used to prevent files and folders from accidental deletion or modification in Unix-like distributions. It applies/removes certain attributes to a file or folder in your Linux system. So the users can’t delete or modify the files and folders either accidentally or intentionally, even as root user. Sounds useful, isn’t it? - -In this brief tutorial, we are going to see how to use chattr in real time in-order to prevent files and folders from accidental deletion in Linux. - -### Prevent Files And Folders From Accidental Deletion Or Modification In Linux - -By default, Chattr is available in most modern Linux operating systems. Let us see some examples. - -The default syntax of chattr command is: -``` -chattr [operator] [switch] [filename] - -``` - -chattr has the following operators. - - * The operator **‘+’** causes the selected attributes to be added to the existing attributes of the files; - * The operator **‘-‘** causes them to be removed; - * The operator **‘=’** causes them to be the only attributes that the files have. - - - -Chattr has different attributes namely – **aAcCdDeijsStTu**. Each letter applies a particular attributes to a file. - - * **a** – append only, - * **A** – no atime updates, - * **c** – compressed, - * **C** – no copy on write, - * **d** – no dump, - * **D** – synchronous directory updates, - * **e** – extent format, - * **i** – immutable, - * **j** – data journalling, - * **P** – project hierarchy, - * **s** – secure deletion, - * **S** – synchronous updates, - * **t** – no tail-merging, - * **T** – top of directory hierarchy, - * **u** – undeletable. - - - -In this tutorial, we are going to discuss the usage of two attributes, namely **a** , **i** which are used to prevent the deletion of files and folders. That’s what our topic today, isn’t? Indeed! - -### Prevent files from accidental deletion - -Let me create a file called **file.txt** in my current directory. -``` -$ touch file.txt - -``` - -Now, I am going to apply **“i”** attribute which makes the file immutable. It means you can’t delete, modify the file, even if you’re the file owner and the root user. -``` -$ sudo chattr +i file.txt - -``` - -You can check the file attributes using command: -``` -$ lsattr file.txt - -``` - -**Sample output:** -``` -----i---------e---- file.txt - -``` - -Now, try to remove the file either as a normal user or with sudo privileges. -``` -$ rm file.txt - -``` - -**Sample output:** -``` -rm: cannot remove 'file.txt': Operation not permitted - -``` - -Let me try with sudo command: -``` -$ sudo rm file.txt - -``` - -**Sample output:** -``` -rm: cannot remove 'file.txt': Operation not permitted - -``` - -Let us try to append some contents in the text file. -``` -$ echo 'Hello World!' >> file.txt - -``` - -**Sample output:** -``` -bash: file.txt: Operation not permitted - -``` - -Try with **sudo** privilege: -``` -$ sudo echo 'Hello World!' >> file.txt - -``` - -**Sample output:** -``` -bash: file.txt: Operation not permitted - -``` - -As you noticed in the above outputs, We can’t delete or modify the file even as root user or the file owner. - -To revoke attributes, just use **“-i”** switch as shown below. -``` -$ sudo chattr -i file.txt - -``` - -Now, the immutable attribute has been removed. You can now delete or modify the file. -``` -$ rm file.txt - -``` - -Similarly, you can restrict the directories from accidental deletion or modification as described in the next section. - -### Prevent folders from accidental deletion and modification - -Create a directory called dir1 and a file called file.txt inside this directory. -``` -$ mkdir dir1 && touch dir1/file.txt - -``` - -Now, make this directory and its contents (file.txt) immutable using command: -``` -$ sudo chattr -R +i dir1 - -``` - -Where, - - * **-R** – will make the dir1 and its contents immutable recursively. - * **+i** – makes the directory immutable. - - - -Now, try to delete the directory either as normal user or using sudo user. -``` -$ rm -fr dir1 - -$ sudo rm -fr dir1 - -``` - -You will get the following output: -``` -rm: cannot remove 'dir1/file.txt': Operation not permitted - -``` - -Try to append some contents in the file using “echo” command. Did you make it? Of course, you couldn’t! - -To revoke the attributes back, run: -``` -$ sudo chattr -R -i dir1 - -``` - -Now, you can delete or modify the contents of this directory as usual. - -### Prevent files and folders from accidental deletion, but allow append operation - -We know now how to prevent files and folders from accidental deletion and modification. Next, we are going to prevent files and folders from deletion, but allow the file for writing in append mode only. That means you can’t edit, modify the existing data in the file, rename the file, and delete the file. You can only open the file for writing in append mode. - -To set append mode attribution to a file/directory, we do the following. - -**For files:** -``` -$ sudo chattr +a file.txt - -``` - -**For directories: ** -``` -$ sudo chattr -R +a dir1 - -``` - -A file/folder with the ‘a’ attribute set can only be open in append mode for writing. - -Add some contents to the file(s) to check whether it works or not. -``` -$ echo 'Hello World!' >> file.txt - -$ echo 'Hello World!' >> dir1/file.txt - -``` - -Check the file contents using cat command: -``` -$ cat file.txt - -$ cat dir1/file.txt - -``` - -**Sample output:** -``` -Hello World! - -``` - -You will see that you can now be able to append the contents. It means we can modify the files and folders. - -Let us try to delete the file or folder now. -``` -$ rm file.txt - -``` - -**Output:** -``` -rm: cannot remove 'file.txt': Operation not permitted - -``` - -Let us try to delete the folder: -``` -$ rm -fr dir1/ - -``` - -**Sample output:** -``` -rm: cannot remove 'dir1/file.txt': Operation not permitted - -``` - -To remove the attributes, run the following commands: - -**For files:** -``` -$ sudo chattr -R -a file.txt - -``` - -**For directories: ** -``` -$ sudo chattr -R -a dir1/ - -``` - -Now, you can delete or modify the files and folders as usual. - -For more details, refer the man pages. -``` -man chattr - -``` - -### Wrapping up - -Data protection is one of the main job of a System administrator. There are numerous free and commercial data protection software are available on the market. Luckily, we’ve got this built-in tool that helps us to protect the data from accidental deletion or modification. Chattr can be used as additional tool to protect the important system files and data in your Linux system. - -And, that’s all for today. Hope this helps. I will be soon here with another useful article. Until then, stay tuned with OSTechNix! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/prevent-files-folders-accidental-deletion-modification-linux/ - -作者:[SK][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/author/sk/ From b52dec2ebb1ff4ea4055f7a016442531044cbcae Mon Sep 17 00:00:00 2001 From: yizhuyan Date: Wed, 28 Mar 2018 18:25:40 +0800 Subject: [PATCH 0169/1057] Create 20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完毕 --- ...ental Deletion Or Modification In Linux.md | 300 ++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 translated/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md diff --git a/translated/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md b/translated/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md new file mode 100644 index 0000000000..f3d8facea3 --- /dev/null +++ b/translated/tech/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md @@ -0,0 +1,300 @@ + +Linux系统中防止文件和目录被意外的删除或修改 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2017/02/Prevent-Files-And-Folders-From-Accidental-Deletion-Or-Modification-In-Linux-720x340.jpg) + +有时,我会不小心的按下`SHIFT+DELETE`来删除我的文件数据。是的,我是个笨蛋,不会再次确认下我实际准备要删除的东西。而且我太笨或者说太懒,没有备份我的文件数据。结果呢?数据丢失了!在一瞬间就丢失了。 + +这种事时不时就会发生在我身上。如果你和我一样,有个好消息告诉你。有个简单又有用的命令行工具叫**“chattr”**(**Ch** ange **Attr** ibute的缩写 ),在类Unix等发行版中,能够用来防止文件和目录被意外的删除或修改。 + +通过给文件或目录添加或删除某些属性,来保证用户不能删除或修改这些文件和目录,不管是有意的还是无意的,甚至root用户也不行。听起来很有用,是不是? + + +在这篇简短的教程中,我们一起来看看怎么在实际应用中使用chattr命令,来防止文件和目录被意外删除。 + + +### Linux中防止文件和目录被意外删除和修改 + +默认,Chattr命令在大多数现代Linux操作系统中是可用的。 + +默认语法是: + +``` +chattr [operator] [switch] [file] + +``` + + +chattr 具有如下操作符: + + + * 操作符**‘+’**追加指定属性到文件已存在属性中 + * 操作符**‘-‘**删除指定属性 + * 操作符**‘=’**直接设置文件属性为指定属性 + +Chattr 提供不同的属性,也就是-**aAcCdDeijsStTu**。每个字符代表一个特定文件属性。 + * **a** – 只能向文件中添加数据,而不能删除(appened only), + * **A** – 不更新文件或目录的最后存取时间(no atime updates), + * **c** – 将文件或目录压缩后存放(compressed), + * **C** – 不适用写入时复制机制(no copy on write), + * **d** – 设定文件不能成为dump程序的备份目标(no dump), + * **D** – 同步目录更新(synchronous directory updates), + * **e** – extend格式存储(extent format), + * **i** – 文件或目录不可改变(immutable), + * **j** – 设定此参数使得当通过mount参数:data=ordered 或者 data=writeback挂载的文件系统,文件在写入时会先被记录在journal中。(data journalling), + * **P** – project层次结构(project hierarchy), + * **s** – 保密性删除文件或目录(secure deletion), + * **S** – 即时更新文件或目录(synchronous updates), + * **t** – 不进行尾部合并(no tail-merging), + * **T** – 顶层目录层次结构(top of directory hierarchy), + * **u** – 不可删除(undeletable). + +在本教程中,我们将讨论两个属性的使用,即**a** , **i** ,这个两个属性可以用于防止文件和目录的被删除。这是我们今天的主题,对吧?来开始吧! + +### 防止文件被意外删除和修改 + +我先在我的当前目录创建一个**file.txt**文件。 +``` +$ touch file.txt + +``` +现在,我将给文件应用**“i”**属性,让文件不可改变。就是说你不能删除或修改这个文件,就算你是文件的拥有者和root用户也不行。 +``` +$ sudo chattr +i file.txt +``` + +使用`lsattr`命令检查文件已有属性 +``` +$ lsattr file.txt +``` + +**输出:** +``` +----i---------e---- file.txt +``` + +现在,试着用普通用户去删除文件 +``` +$ rm file.txt + +``` + +**输出:** +``` +#不能删除文件,非法操作 +rm: cannot remove 'file.txt': Operation not permitted +``` + +我来试试sudo特权: +``` +$ sudo rm file.txt +``` + +**输出:** +``` +#不能删除文件,非法操作 +rm: cannot remove 'file.txt': Operation not permitted +``` + +我们试试追加写内容到这个文本文件 +``` +$ echo 'Hello World!' >> file.txt + +``` + +**输出:** +``` +#非法操作 +bash: file.txt: Operation not permitted +``` + +试试 **sudo** 特权: +``` +$ sudo echo 'Hello World!' >> file.txt + +``` + +**输出:** +``` +#非法操作 +bash: file.txt: Operation not permitted + +``` +你应该注意到了,我们不能删除或修改这个文件,甚至root用户或者文件所有者也不行。 + +要撤销属性,使用**“-i”**即可。 +``` +$ sudo chattr -i file.txt + +``` + +现在,这不可改变属性已经被删除掉了。你现在可以删除或修改这个文件了。 +``` +$ rm file.txt + +``` + +类似的,你能够限制目录被意外删除或修改,如下一节所述。 + +### 防止目录被意外删除和修改 + +创建一个dir1目录,放入文件file.txt。 +``` +$ mkdir dir1 && touch dir1/file.txt + +``` + +现在,让目录及其内容(file.txt文件)不可改变: +``` +$ sudo chattr -R +i dir1 + +``` + +命令中, + + * **-R** – 递归使dir目录及其内容不可修改 + * **+i** – 使目录不可修改 + + + +现在,来试试删除这个目录,要么用普通用户,要么用sudo特权。 +``` +$ rm -fr dir1 + +$ sudo rm -fr dir1 + +``` + +你会看到如下输出: +``` +#不可删除'dir1/file.txt':非法操作 +rm: cannot remove 'dir1/file.txt': Operation not permitted + +``` +尝试用“echo”命令追加内容到文件,你成功了吗?当然,你做不到。 +撤销此属性,输入: +``` +$ sudo chattr -R -i dir1 + +``` + +现在你就能想平常一样删除或修改这个目录内容了。 + +### 防止文件和目录被意外删除,但允许追加操作 + +我们现已知道如何防止文件和目录被意外删除和修改了。接下来,我们将防止文件被删除但仅仅允许文件被追加内容。意思是你不可以编辑修改文件已存在的数据,或者重命名这个文件或者删除这个文件,你仅可以使用追加模式打开这个文件。 + + +为了设置追加属性到文件或目录,我们像下面这么操作: +**针对文件:** +``` +$ sudo chattr +a file.txt + +``` + +**针对目录: ** +``` +$ sudo chattr -R +a dir1 + +``` + +一个文件或目录被设置了‘a’这个属性就仅仅能够被追加模式打开进行写入。 +添加些内容到这个文件以测试是否有效果。 +``` +$ echo 'Hello World!' >> file.txt + +$ echo 'Hello World!' >> dir1/file.txt + +``` + + +查看文件内容使用cat命令 +``` +$ cat file.txt + +$ cat dir1/file.txt + +``` + +**输出:** +``` +Hello World! + +``` + + +你将看到你现在可以追加内容。就表示我们可以修改这个文件或目录。 + +现在让我们试试删除这个文件或目录。 +``` +$ rm file.txt + +``` + +**输出:** +``` +#不能删除文件'file.txt':非法操作 +rm: cannot remove 'file.txt': Operation not permitted + +``` + + +让我们试试删除这个目录: +``` +$ rm -fr dir1/ + +``` + +**输出:** +``` +#不能删除文件'dir1/file.txt':非法操作 +rm: cannot remove 'dir1/file.txt': Operation not permitted + +``` + + +删除这个属性,执行下面这个命令: +**针对文件:** +``` +$ sudo chattr -R -a file.txt + +``` + +**针对目录:** +``` +$ sudo chattr -R -a dir1/ + +``` + + +现在,你可以想平常一样删除或修改这个文件和目录了。 + +更多详情,查看man页面。 +``` +man chattr + +``` + +### 总结 + + +保护数据是系统管理人员的主要工作之一。市场上有众多可用的免费和收费的数据保护软件。幸好,我们已经拥有这个内置命令可以帮助我们去保护数据被意外的删除和修改。在你的Linux系统中,Chattr可作为保护重要系统文件和数据的附加工具。 + +然后,这就是今天所有内容了。希望对大家有所帮助。接下来我将会在这提供其他有用的文章。在那之前,敬请期待OSTechNix。 +再见! + + + + +-------------------------------------------------------------------------------- + +来源: https://www.ostechnix.com/prevent-files-folders-accidental-deletion-modification-linux/ + +作者:[SK][a] +译者:[yizhuoyan](https://github.com/yizhuoyan) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ From 6c24343596adfda09ec34e60dd5e4f58b8f37e8a Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 18:56:27 +0800 Subject: [PATCH 0170/1057] PRF:20171221 Mail transfer agent (MTA) basics.md @qhwdw --- ...171221 Mail transfer agent (MTA) basics.md | 128 ++++++++++-------- 1 file changed, 69 insertions(+), 59 deletions(-) diff --git a/translated/tech/20171221 Mail transfer agent (MTA) basics.md b/translated/tech/20171221 Mail transfer agent (MTA) basics.md index 2ebc2ee277..dc0c2bba91 100644 --- a/translated/tech/20171221 Mail transfer agent (MTA) basics.md +++ b/translated/tech/20171221 Mail transfer agent (MTA) basics.md @@ -1,7 +1,7 @@ 邮件传输代理(MTA)基础 ====== -## 概述 +### 概述 本教程中,你将学习: @@ -10,29 +10,28 @@ * 配置电子邮件转发。 * 了解常见邮件传输代理(MTA),比如,postfix、sendmail、qmail、以及 exim。 +### 控制邮件去向 +Linux 系统上的电子邮件是使用 MTA 投递的。你的 MTA 投递邮件到你的系统上的其他用户,并且 MTA 彼此通讯跨越系统投递到全世界。 -## 控制邮件去向 +Sendmail 是最古老的 Linux MTA。它最初起源于 1979 年用于阿帕网(ARPANET)的 delivermail 程序。如今它有几个替代品,在本教程中,我也会介绍它们。 -Linux 系统上的电子邮件是使用 MTAs 投递的。你的 MTA 投递邮件到你的系统上的其他用户,以及系统上的其它系统组或者与全世界的其它 MTAs 通讯以投递邮件。 - -### 前提条件 +#### 前提条件 为完成本系列教程的大部分内容,你需要具备 Linux 的基础知识,你需要拥有一个 Linux 系统来实践本教程中的命令。你应该熟悉 GNU 以及 UNIX 命令。有时候不同版本的程序的输出格式可能不同,因此,在你的系统中输出的结果可能与我在下面列出的稍有不同。 在本教程中,我使用的是 Ubuntu 14.04 LTS 和 sendmail 8.14.4 来做的演示。 -## 邮件传输 +### 邮件传输 -邮件传输代理(比如 sendmail)在用户和系统之间投递邮件。大量的因特网邮件使用简单邮件传输协议(SMTP),但是本地邮件可能是通过文件或者套接字等其它可能的方式来传输的。邮件是一种存储和转发的操作,因此,在用户接收邮件或者接收系统或者通讯联系可用之前,邮件一直是存储在某种文件或者数据库中。配置和确保 MTA 的安全是非常复杂的任务,它们中的大部分内容都已经超出了本教程的范围。 +邮件传输代理(比如 sendmail)在用户之间和系统之间投递邮件。大量的因特网邮件使用简单邮件传输协议(SMTP),但是本地邮件可能是通过文件或者套接字等其它可能的方式来传输的。邮件是一种存储和转发的操作,因此,在用户接收邮件或者接收系统和通讯联系可用之前,邮件一直是存储在某种文件或者数据库中。配置和确保 MTA 的安全是非常复杂的任务,它们中的大部分内容都已经超出了本教程的范围。 -## mail 命令 +### mail 命令 -如果你使用 SMTP 协议传输电子邮件,你或许知道你可以使用的许多邮件客户端,包括 `mail`、`mutt`、`alpine`、`notmuch`、以及其它基于主机控制台或者图形界面的邮件客户端。`mail` 命令是最老的、可用于脚本中的、发送和接收以及管理收到的邮件的备用命令。 +如果你使用 SMTP 协议传输电子邮件,你或许知道你可以使用许多邮件客户端,包括 `mail`、`mutt`、`alpine`、`notmuch`、以及其它基于主机控制台或者图形界面的邮件客户端。`mail` 命令是最老的、可用于脚本中的、发送和接收以及管理收到的邮件的备用命令。 -你可以使用 `mail` 命令交互式的向列表中的收件人发送信息,或者不使用参数去查看你收到的邮件。Listing 1 展示了如何在你的系统上去发送信息到用户 steve 和 pat,同时抄送拷贝给用户 bob。当提示 cc:和 subject:时,输入相应的抄送用户以及邮件主题,接着输入邮件正文,输入完成后按下 **Ctrl+D** (按下 Ctrl 键并保持再按下 D 之后全部松开)。 +你可以使用 `mail` 命令交互式的向列表中的收件人发送信息,或者不使用参数去查看你收到的邮件。清单 1 展示了如何在你的系统上去发送信息到用户 steve 和 pat,同时抄送拷贝给用户 bob。当提示 `Cc:` 和 `subject:` 时,输入相应的抄送用户以及邮件主题,接着输入邮件正文,输入完成后按下 `Ctrl+D` (按下 `Ctrl` 键并保持再按下 `D` 之后全部松开)。 -##### Listing 1. 使用 `mail` 交互式发送邮件 ``` ian@attic4-u14:~$ mail steve,pat Cc: bob @@ -42,18 +41,20 @@ This is a test message Ian ``` +*清单 1. 使用 `mail` 交互式发送邮件* + 如果一切顺利,你的邮件已经发出。如果在这里发生错误,你将看到错误信息。例如,如果你在接收者列表中输入一个无效的用户名,邮件将无法发送。注意在本示例中,所有的用户都在本地系统上存在,因此他们都是有效用户。 -你也可以使用命令行以非交互式发送邮件。Listing 2 展示了如何给用户 steve 和 pat 发送一封邮件。这种方式可以用在脚本中。在不同的包中 `mail` 命令的版本不同。对于抄送(cc:)有些支持一个 `-c` 选项,但是我使用的这个版本不支持这个选项,因此,我仅将邮件发送到收件人。 +你也可以使用命令行以非交互式发送邮件。清单 2 展示了如何给用户 steve 和 pat 发送一封邮件。这种方式可以用在脚本中。在不同的软件包中 `mail` 命令的版本不同。对于抄送(`Cc:`)有些支持一个 `-c` 选项,但是我使用的这个版本不支持这个选项,因此,我仅将邮件发送到收件人。 -Listing 2. 使用 `mail` 命令非交互式发送邮件 ``` ian@attic4-u14:~$ mail -t steve,pat -s "Test message 2" <<< "Another test.\n\nIan" ``` -如果你使用没有选项的 `mail` 命令,你将看到一个如 Listing 3 中所展示的那样一个收到的邮件的列表。你将看到用户 steve 有我上面发送的两个信息,再加上我以前发送的一个信息和后来用户 bob 发送的信息。所有的邮件都用 'N' 标记为新邮件。 +*清单 2. 使用 `mail` 命令非交互式发送邮件* + +如果你使用没有选项的 `mail` 命令,你将看到一个如清单 3 中所展示的那样一个收到信息的列表。你将看到用户 steve 有我上面发送的两个信息,再加上我以前发送的一个信息和后来用户 bob 发送的信息。所有的邮件都用 'N' 标记为新邮件。 -Listing 3. 使用 `mail` 查看收到的邮件 ``` steve@attic4-u14:~$ mail "/var/mail/steve": 4 messages 4 new @@ -64,9 +65,10 @@ steve@attic4-u14:~$ mail ? ``` -当前选中的信息使用一个 '>' 来标识,它是 Listing 3 中的第一封邮件。如果你按下 **回车键(Enter)**,将显示下一封未读邮件的第一页。按下 **空格楗(Space bar)** 将显示这个信息的下一页。当你读完这个信息并想返回到 '?' 提示时,按下 **回车键** 再次查看下一封邮件,依次类推。在任何 '?' 提示符下,你可以输入 'h' 再次去查看邮件头。你看过的邮件前面将显示一个 'R' 状态,如 Listing 4 所示。 +*清单 3. 使用 `mail` 查看收到的邮件* + +当前选中的信息使用一个 `>` 来标识,它是清单 3 中的第一封邮件。如果你按下回车键(`Enter`),将显示下一封未读邮件的第一页。按下空格楗将显示这个邮件的下一页。当你读完这个邮件并想返回到 `?` 提示符时,按下回车键再次查看下一封邮件,依次类推。在 `?` 提示符下,你可以输入 `h` 再次去查看邮件头。你看过的邮件前面将显示一个 `R` 状态,如清单 4 所示。 -Listing 4. 使用 'h' 去显示邮件头 ``` ? h R 1 Ian Shields Tue Dec 12 21:03 16/704 test message @@ -76,9 +78,10 @@ Listing 4. 使用 'h' 去显示邮件头 ? ``` -在这个图中,Steve 已经读了三个信息,但是没有读来自 bob 的信息。你可以通过数字来选择单个的信息,你也可以通过输入 ‘d' 删除你不想要的信息,或者输入 '3d' 去删除三封信息。如果你输入 'q' 你将退出 `mail` 命令。已读的信息将被转移到你的 home 目录下的 mbox 文件中,而未读的信息仍然保留在你的收件箱中,默认在 /var/mail/$(id -un)。如 Listing 5 所示。 +*清单 4. 使用 `h` 去显示邮件头* + +在这个图中,Steve 已经读了三个邮件,但是没有读来自 bob 的邮件。你可以通过数字来选择单个的信息,你也可以通过输入 `d` 删除你不想要的信息,或者输入 `3d` 去删除第三个信息。如果你输入 `q` 你将退出 `mail` 命令。已读的信息将被转移到你的家目录下的 `mbox` 文件中,而未读的信息仍然保留在你的收件箱中,默认在 `/var/mail/$(id -un)`。如清单 5 所示。 -Listing 5. 使用 'q' 退出 `mail` ``` ? h R 1 Ian Shields Tue Dec 12 21:03 16/704 test message @@ -91,31 +94,33 @@ Held 1 message in /var/mail/steve You have mail in /var/mail/steve ``` -如果你输入 'x' 而不是使用 'q' 去退出,你的邮箱在退出后将不保留你做的改变。因为这在 /var 文件系统中,你的系统管理员可能仅允许邮件在一个有限的时间范围内去保留三封邮件。去重读或者以其它方式再次处理保存在你的本地邮箱中的邮件,你可以使用 `-f` 选项去指定想要去读的文件。比如,`mail -f mbox`。 +*清单 5. 使用 `q` 退出 `mail`* -## 邮件别名 +如果你输入 `x` 而不是使用 `q` 去退出,你的邮箱在退出后将不保留你做的改变。因为这在 `/var` 文件系统中,你的系统管理员可能仅允许邮件在一个有限的时间范围内保留。要重新读取或者以其它方式再次处理保存在你的本地邮箱中的邮件,你可以使用 `-f` 选项去指定想要去读的文件。比如,`mail -f mbox`。 + +### 邮件别名 在前面的节中,看了如何在系统上给许多用户发送邮件。你可以使用一个全限定名字(比如 ian@myexampledomain.com)给其它系统上的用户发送邮件。 -有时候你可能希望用户的所有邮件都可以发送到其它地方。比如,你有一个服务器群,你希望所有的 root 用户的邮件都发给核心系统管理员。或者你可能希望去创建一个邮件列表,将邮件发送给一些人。为实现上述目标,你可以使用别名,别名允许你为一个给定的用户名定义一个或者多个目的地。这个目的地或者是其它用户的邮箱、文件、管道、或者是某个进一步处理的命令。你可以在 /etc/mail/aliases 或者 /etc/aliases 中创建别名来实现上述目的。根据你的系统的不同,你可以找到上述其中一个,符号链接到它们、或者其中之一。改变别名文件你需要有 root 权限。 +有时候你可能希望用户的所有邮件都可以发送到其它地方。比如,你有一个服务器群,你希望所有的 root 用户的邮件都发给中心的系统管理员。或者你可能希望去创建一个邮件列表,将邮件发送给一些人。为实现上述目标,你可以使用别名,别名允许你为一个给定的用户名定义一个或者多个目的地。这个目的地或者是其它用户的邮箱、文件、管道、或者是某个进一步处理的命令。你可以在 `/etc/mail/aliases` 或者 `/etc/aliases` 中创建别名来实现上述目的。根据你的系统的不同,你可以找到上述其中一个,符号链接到它们、或者其中之一。改变别名文件你需要有 root 权限。 别名的格式一般是: + +``` name: addr_1, addr_2, addr_3, ... -name 的位置是一个本地用户名字到别名,或者一个别名和 addr_1,addr_2,... 一个或多个别名。别名可以是一个本地用户,一个本地文件名,另一个别名,一个命令,一个包含文件,或者一个外部地址。 +``` -因此,发送邮件时如何区分别名呢(addr-N 值)? +这里 `name` 是一个要别名的本地用户名字(即别名),而 `addr_1`,`addr_2`,... 可以是一个或多个别名。别名可以是一个本地用户、一个本地文件名、另一个别名、一个命令、一个包含文件,或者一个外部地址。 - * 一个本地用户名是你机器上系统中的一个用户名字。从技术角度来说,它可以通过调用 `getpwnam` 命令找到它。 - * 一个本地文件名是以 '/' 开始的完全路径和文件名。它必须通过 `sendmail` 来写。信息是追加到这个文件上的。 - * 一个命令是以一个管道符号开始的(|)。信息是通过标准输入的方式发送到命令的。 - * 一个包含文件别名是以 `:include:` 和指定的一个路径和文件名开始的。文件中的别名被添加到别名中。 - * 一个外部地址是一个电子邮件地址,比如 john@somewhere.com。 +因此,发送邮件时如何区分别名呢(addr-N)? + * 本地用户名是你机器上系统中的一个用户名字。从技术角度来说,它可以通过调用 `getpwnam` 命令找到它。 + * 本地文件名是以 `/` 开始的完全路径和文件名。它必须是 `sendmail` 可写的。信息会追加到这个文件上。 + * 命令是以一个管道符号开始的(`|`)。信息是通过标准输入的方式发送到命令的。 + * 包含文件别名是以 `:include:` 和指定的路径和文件名开始的。在该文件中的别名被添加到该名字所代表的别名中。 + * 外部地址是一个电子邮件地址,比如 john@somewhere.com。 - -你可以在你的系统中找到一个示例文件,它是与你的 sendmail 包一起安装的,它的位置在 /usr/share/sendmail/examples/db/aliases。它包含一些给 postmaster、MAILER-DAEMON、abuse、和 spam的建议别名。在 Listing 6,我把我的 Ubuntu 14.04 LTS 系统上的一些示例文件,和人为的示例结合起来说明一些可能的情况。 - -Listing 6. 人为的 /etc/mail/aliases 示例 +你可以在你的系统中找到一个示例文件,它是与你的 sendmail 包一起安装的,它的位置在 `/usr/share/sendmail/examples/db/aliases`。它包含一些给 `postmaster`、`MAILER-DAEMON`、`abuse` 和 `spam 的别名建议。在清单 6,我把我的 Ubuntu 14.04 LTS 系统上的一些示例文件,和人工修改的示例结合起来说明一些可能的情况。 ``` ian@attic4-u14:~$ cat /etc/mail/aliases @@ -151,13 +156,14 @@ pat: /home/pat/accumulated-mail, sysadmins: :include: /etc/aliases-sysadmins ``` -注意那个 pat 既是一个别名也是一个系统中的用户。别名是以递归的方式展开的,因此,如果一个别名也是一个名字,那么它将被展开。Sendmail 并不会给同一个用户发送相同的邮件两遍,因此,如果你正好将 'pat' 作为 'pat' 的别名,那么 sendmail 在已经找到并处理完用户 ’pat‘ 之后,将忽略别名 'pat’。为避免这种问题,你可以在别名前使用一个'\' 做为前缀去指示它是一个不要进一步引起混淆的名字。在这种情况下,pat 的邮件除了文件和命令之外,其余的可能会被发送到他的正常的邮箱中。 +*清单 6. 人工修改的 /etc/mail/aliases 示例* -在 aliases 中以 '$' 开始的行是注释,它会被忽略。以空白开始的行会以延续行来处理。 +注意那个 pat 既是一个别名也是一个系统中的用户。别名是以递归的方式展开的,因此,如果一个别名也是一个名字,那么它将被展开。Sendmail 并不会给同一个用户发送相同的邮件两遍,因此,如果你正好将 pat 作为 pat 的别名,那么 sendmail 在已经找到并处理完用户 pat 之后,将忽略别名 pat。为避免这种问题,你可以在别名前使用一个 `\` 做为前缀去指示它是一个不要进一步引起混淆的名字。在这种情况下,pat 的邮件除了文件和命令之外,其余的可能会被发送到他的正常的邮箱中。 -Listing 7 展示了包含文件 /etc/aliases-sysadmins。 +在 `aliases` 文件中以 `#` 开始的行是注释,它会被忽略。以空白开始的行会以延续行来处理。 + +清单 7 展示了包含文件 `/etc/aliases-sysadmins`。 -Listing 7 包含文件 /etc/aliases-sysadmins ``` ian@attic4-u14:~$ cat /etc/aliases-sysadmins @@ -165,11 +171,12 @@ ian@attic4-u14:~$ cat /etc/aliases-sysadmins bob,pat ``` -## newaliases 命令 +*清单 7 包含文件 /etc/aliases-sysadmins* -sendmail 使用的主要配置文件被编译成数据库文件。邮件别名也是如此。你可以使用 `newaliases` 命令去编译你的 /etc/mail/aliases 和任何包含文件到 /etc/mail/aliases.db 中。注意,那个 `newaliases` 命令等价于 `sendmail -bi`。Listing 8 展示了一个示例。 +### newaliases 命令 + +sendmail 使用的主要配置文件会被编译成数据库文件。邮件别名也是如此。你可以使用 `newaliases` 命令去编译你的 `/etc/mail/aliases` 和任何包含文件到 `/etc/mail/aliases.db` 中。注意,`newaliases` 命令等价于 `sendmail -bi`。清单 8 展示了一个示例。 -Listing 8. 为邮件别名重建数据库 ``` ian@attic4-u14:~$ sudo newaliases /etc/mail/aliases: 7 aliases, longest 62 bytes, 184 bytes total @@ -178,11 +185,12 @@ lrwxrwxrwx 1 root smmsp 10 Dec 8 15:48 /etc/mail/aliases -> ../aliases -rw-r----- 1 smmta smmsp 12288 Dec 13 23:18 /etc/mail/aliases.db ``` -## 使用别名的示例 +*清单 8. 为邮件别名重建数据库* -Listing 9 展示了一个简单的 shell 脚本,它在我的别名示例中以一个命令的方式来使用。 +### 使用别名的示例 + +清单 9 展示了一个简单的 shell 脚本,它在我的别名示例中以一个命令的方式来使用。 -Listing 9. makemailcopy.sh 脚本 ``` ian@attic4-u14:~$ cat ~pat/makemailcopy.sh #!/bin/bash @@ -191,9 +199,10 @@ ian@attic4-u14:~$ cat ~pat/makemailcopy.sh cat >> ~pat/mail-copy ``` -Listing 10 展示了用于测试时更新的文件。 +*清单 9. makemailcopy.sh 脚本* + +清单 10 展示了用于测试时更新的文件。 -Listing 10. /etc/aliases-sysadmins 包含文件 ``` ian@attic4-u14:~$ date Wed Dec 13 22:54:22 EST 2017 @@ -205,23 +214,22 @@ ian@attic4-u14:~$ ls -lrt $(find /var/mail ~pat -type f -mmin -3 2>/dev/null ) -rw-rw---- 1 bob mail 12522 Dec 13 22:54 /var/mail/bob ``` +*清单 10. /etc/aliases-sysadmins 包含文件* + 需要注意的几点: - * 有一个用户 'mail' 与 sendmail 使用的组名字 'mail' 是一样的。 - * sendmail 在 /var/mail 保存用户邮件,它也在用户 ‘mail' 的 home 目录下。用户 'ian' 的默认收件箱在 /var/mail/ian 中。 - * 如果你希望 sendmail 在用户目录下写入文件,这个文件必须允许 sendmail 可写入。与其让任何人都可以写入,还不如定义一个组可写入,组名称为 'mail'。这需要系统管理员来帮你完成。 + * sendmail 使用的用户和组的名字是 mail。 + * sendmail 在 `/var/mail` 保存用户邮件,它也是用户 mail 的家目录。用户 ian 的默认收件箱在 `/var/mail/ian` 中。 + * 如果你希望 sendmail 在用户目录下写入文件,这个文件必须允许 sendmail 可写入。与其让任何人都可以写入,还不如定义一个组可写入,组名称为 mail。这需要系统管理员来帮你完成。 +### 使用一个 `.forward` 文件去转发邮件 +别名文件是由系统管理员来管理的。个人用户可以使用它们自己的家目录下的 `.forward` 文件去转发他们自己的邮件。你可以在你的 `.forward` 文件中放任何可以出现在别名文件的右侧的东西。这个文件的内容是明文的,不需要编译。当你收到邮件时,sendmail 将检查你的家目录中的 `.forward` 文件,然后就像处理别名一样处理它。 -## 使用一个 `.forward` 文件去转发邮件 +### 邮件队列和 mailq 命令 -别名文件是由系统管理员来管理的。个人用户可以使用它们自己的 home 目录下的 `.forward` 文件去转发他们自己的邮件。你可以在你的 `.forward` 文件中放任何东西,它可以放在别名文件的右侧。这个文件的内容是明文的,不需要编译。当你收到邮件时,sendmail 将检查你的 home 目录中的 `.forward` 文件,然后就像处理别名一样处理它。 +Linux 邮件使用存储-转发的处理模式。你已经看到的已接收邮件,在你读它之前一直保存在文件 `/var/mail` 中。你发出的邮件在接收服务器连接可用之前也会被保存。你可以使用 `mailq` 命令去查看邮件队列。清单 11 展示了一个发送给外部用户 ian@attic4-c6 的一个邮件示例,以及运行 `mailq` 命令的结果。在这个案例中,当前服务器没有连接到 attic4-c6,因此邮件在与对方服务器连接可用之前一直保存在队列中。 -## 邮件队列和 mailq 命令 - -Linux 邮件使用存储-转发的处理模式。你已经看到的已接收邮件,在你读它之前一直保存在文件 /var/mail 中。你发出的邮件在接收服务器连接可用之前也会被保存。你可以使用 `mailq` 命令去查看邮件队列。Listing 11 展示了一个发送给外部用户 ian@attic4-c6 的一个邮件示例,以及运行 `mailq` 命令的结果。在这个案例中,当前服务器没有连接到 attic4-c6,因此邮件在与对方服务器连接可用之前一直保存在队列中。 - -Listing 11. 使用 `mailq` 命令 ``` ian@attic4-u14:~$ mail -t ian@attic4-c6 -s "External mail" <<< "Testing external mail queues" ian@attic4-u14:~$ mailq @@ -236,9 +244,11 @@ vBE4mdE7025908* 29 Wed Dec 13 23:48 Total requests: 1 ``` -## 其它邮件传输代理 +*清单 11. 使用 `mailq` 命令* -为解决使用 sendmail 时安全方面的问题,在 上世纪九十年代开发了几个其它的邮件传输代理。Postfix 或许是最流行的一个,但是 qmail 和 exim 也大量使用。 +### 其它邮件传输代理 + +为解决使用 sendmail 时安全方面的问题,在上世纪九十年代开发了几个其它的邮件传输代理。Postfix 或许是最流行的一个,但是 qmail 和 exim 也大量使用。 Postfix 是 IBM 为代替 sendmail 而研发的。它更快、也易于管理、安全性更好一些。从外表看它非常像 sendmail,但是它的内部完全与 sendmail 不同。 @@ -246,7 +256,7 @@ Qmail 是一个安全、可靠、高效、简单的邮件传输代理,它由 D Exim 是另外一个 MTA,它由 University of Cambridge 开发。最初,它的名字是 `EXperimental Internet Mailer`。 -所有的这些 MTAs 都是为代替 sendmail 而设计的,因此,它们它们都兼容 sendmail 的一些格式。它们都能够处理别名和 `.forward` 文件。有些规定了一个 `sendmail` 命令作为一个前端到特定的 MTA 的自有命令。尽管一些选项可能会被静默忽略,但是大多数都允许使用常见的 sendmail 选项。`mailq` 命令是被直接支持的,或者使用一个类似功能的命令来代替。比如,你可以使用 `mailq` 或者 `exim -bp` 去显示 exim 邮件队列。当然,输出可以看到与 sendmail 的 `mailq` 命令的不同之外。 +所有的这些 MTA 都是为代替 sendmail 而设计的,因此,它们它们都兼容 sendmail 的一些格式。它们都能够处理别名和 `.forward` 文件。有些封装了一个 `sendmail` 命令作为一个到特定的 MTA 自有命令的前端。尽管一些选项可能会被静默忽略,但是大多数都允许使用常见的 sendmail 选项。`mailq` 命令是被直接支持的,或者使用一个类似功能的命令来代替。比如,你可以使用 `mailq` 或者 `exim -bp` 去显示 exim 邮件队列。当然,输出可以看到与 sendmail 的 `mailq` 命令的不同之外。 查看相关的主题,你可以找到更多的关于这些 MTA 的更多信息。 @@ -258,7 +268,7 @@ via: https://www.ibm.com/developerworks/library/l-lpic1-108-3/index.html 作者:[Ian Shields][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 0439e7977f1c5788740ca0c63f13ac6444792bf0 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 18:56:53 +0800 Subject: [PATCH 0171/1057] PUB:20171221 Mail transfer agent (MTA) basics.md @qhwdw https://linux.cn/article-9489-1.html --- .../20171221 Mail transfer agent (MTA) basics.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171221 Mail transfer agent (MTA) basics.md (100%) diff --git a/translated/tech/20171221 Mail transfer agent (MTA) basics.md b/published/20171221 Mail transfer agent (MTA) basics.md similarity index 100% rename from translated/tech/20171221 Mail transfer agent (MTA) basics.md rename to published/20171221 Mail transfer agent (MTA) basics.md From a331e563225b78fd6f05230f82cb7278c1f4fdc9 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 19:17:50 +0800 Subject: [PATCH 0172/1057] PRF:20180308 Test Your BASH Skills By Playing Command Line Games.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @MjSeven 如果遇到原文选题有缺漏的地方,请参照原文 URL 补充即可。 --- ...SH Skills By Playing Command Line Games.md | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md b/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md index 08836db9a0..9ed72f5616 100644 --- a/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md +++ b/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md @@ -1,24 +1,23 @@ 通过玩命令行游戏来测试你的 BASH 技能 ===== - ![](https://www.ostechnix.com/wp-content/uploads/2018/03/Test-your-bash-skills-1-720x340.png) -如果我们经常在实际场景中使用 Linux 命令,我们倾向于更有效的学习和记忆它们。除非你经常使用 Linux 命令,否则你可能会在一段时间内忘记它们。无论你是新手还是中级用户,总会有一些令人兴奋的方法来测试你的 BASH 技能。在本教程中,我将解释如何通过玩命令行游戏来测试你的 BASH 技能。其实从技术上讲,这些并不是真正的游戏,如 Super TuxKart,NFS 或 Counterstrike 等等。这些只是 Linux 命令培训课程的游戏化版本。你将根据游戏本身的某些指示来完成一个任务。 +如果我们经常在实际场景中使用 Linux 命令,我们就会更有效的学习和记忆它们。除非你经常使用 Linux 命令,否则你可能会在一段时间内忘记它们。无论你是新手还是老手,总会有一些趣味的方法来测试你的 BASH 技能。在本教程中,我将解释如何通过玩命令行游戏来测试你的 BASH 技能。其实从技术上讲,这些并不是像 Super TuxKart、极品飞车或 CS 等真正的游戏。这些只是 Linux 命令培训课程的游戏化版本。你将需要根据游戏本身的某些指示来完成一个任务。 -现在,我们将看到几款能帮助你实时学习和练习 Linux 命令的游戏。这些游戏不是消磨时间或者令人惊诧的,这些游戏将帮助你获得终端命令的真实体验。请继续阅读: +现在,我们来看看几款能帮助你实时学习和练习 Linux 命令的游戏。这些游戏不是消磨时间或者令人惊诧的,这些游戏将帮助你获得终端命令的真实体验。请继续阅读: ### 使用 “Wargames” 来测试 BASH 技能 -这是一个在线游戏,所以你必须和互联网保持连接。这些游戏可以帮助你以充满乐趣的游戏形式学习和练习 Linux 命令。Wargames 是 shell 游戏的集合,每款游戏有很多关卡。只有通过解决先前的关卡才能访问下一个关卡。不要担心!每个游戏都提供了有关如何进入下一关的清晰简洁说明。 +这是一个在线游戏,所以你必须联网。这些游戏可以帮助你以充满乐趣的游戏形式学习和练习 Linux 命令。Wargames 是一个 shell 游戏的集合,每款游戏有很多关卡。只有通过解决先前的关卡才能访问下一个关卡。不要担心!每个游戏都提供了有关如何进入下一关的清晰简洁说明。 -要玩 Wargames,请点击以下链接: +要玩 Wargames,请点击以下链接:[Wargames][1] 。 ![][2] 如你所见,左边列出了许多 shell 游戏。每个 shell 游戏都有自己的 SSH 端口。所以,你必须通过本地系统配置 SSH 连接到游戏,你可以在 Wargames 网站的左上角找到关于如何使用 SSH 连接到每个游戏的信息。 -例如,让我们来玩 **Bandit** 游戏吧。为此,单击 Wargames 主页上的 Bandit 链接。在左上角,你会看到 Bandit 游戏的 SSH 信息。 +例如,让我们来玩 Bandit 游戏吧。为此,单击 Wargames 主页上的 Bandit 链接。在左上角,你会看到 Bandit 游戏的 SSH 信息。 ![][3] @@ -28,27 +27,31 @@ ![][4] -正如你在上面的屏幕截图中看到的,你需要配置 SSH 端口 2220 连接 **bandit.labs.overthewire.org**,用户名是 **bandit0**,密码是 **bandit0**。 +正如你在上面的屏幕截图中看到的,你需要配置 SSH 端口 2220 连接 `bandit.labs.overthewire.org`,用户名是 `bandit0`,密码是 `bandit0`。 让我们连接到 Bandit 游戏关卡 0。 -输入密码 **bandit0** +``` +$ ssh bandit0@bandit.labs.overthewire.org -p 2220 +``` + +输入密码 `bandit0`。 示例输出将是: ![][5] -登录后,输入 **ls** 命令查看内容或者进入 **关卡 1 页面**,了解如何通过关卡 1 等等。建议的命令列表已在每个关卡提供。所以,你可以选择和使用任何合适的命令来解决每个关卡。 +登录后,输入 `ls` 命令查看内容或者进入关卡 1 页面,了解如何通过关卡 1 等等。建议的命令列表已在每个关卡提供。所以,你可以选择和使用任何合适的命令来解决每个关卡。 我必须承认,Wargames 是令人上瘾的,并且解决每个关卡是非常有趣的。 尽管有些关卡确实很具挑战性,你可能需要谷歌才能知道如何解决问题。 试一试,你会很喜欢它。 ### 使用 “Terminus” 来测试 BASH 技能 -这是另一个基于浏览器的在线 CLI 游戏(译注:CLI 命令行界面),可用于改进或测试你的 Linux 命令技能。要玩这个游戏,请打开你的 web 浏览器并导航到以下 URL。 +这是另一个基于浏览器的在线 CLI 游戏,可用于改进或测试你的 Linux 命令技能。要玩这个游戏,请打开你的 web 浏览器并导航到以下 URL:[Play Terminus Game][9] 一旦你进入游戏,你会看到有关如何玩游戏的说明。与 Wargames 不同,你不需要连接到它们的游戏服务器来玩游戏。Terminus 有一个内置的 CLI,你可以在其中找到有关如何使用它的说明。 -你可以使用命令 **“ls”** 查看周围的环境,使用命令 **“cd LOCATION”** 移动到新的位置,返回使用命令 **“cd ..”**,与这个世界进行交互使用命令 **“less ITEM”** 等等。要知道你当前的位置,只需输入 **“pwd”**。 +你可以使用命令 `ls` 查看周围的环境,使用命令 `cd 位置` 移动到新的位置,返回使用命令 `cd ..`,与这个世界进行交互使用命令 `less 项目` 等等。要知道你当前的位置,只需输入 `pwd`。 ![][6] @@ -56,48 +59,47 @@ 与上述游戏不同,你可以在本地玩这款游戏。你不需要连接任何远程系统,这是完全离线的游戏。 -相信我,这是一个有趣的游戏人。按照给定的说明,你将扮演一个侦探角色来解决一个神秘案件。 +相信我,这家伙是一个有趣的游戏。按照给定的说明,你将扮演一个侦探角色来解决一个神秘案件。 首先,克隆仓库: + ``` $ git clone https://github.com/veltman/clmystery.git - ``` -或者,从 [这里][7] 将其作为 zip 文件下载。解压缩并切换到下载文件的地方。左后,通过阅读 “instructions” 文件来解决神秘案例。 +或者,从 [这里][7] 将其作为 zip 文件下载。解压缩并切换到下载文件的地方。最后,通过阅读 `instructions` 文件来开启宝箱。 + ``` [sk@sk]: clmystery-master>$ ls cheatsheet.md cheatsheet.pdf encoded hint1 hint2 hint3 hint4 hint5 hint6 hint7 hint8 instructions LICENSE.md mystery README.md solution - ``` 这里是玩这个游戏的说明: 终端城发生了一起谋杀案,TCPD 需要你的帮助。你需要帮助它们弄清楚是谁犯罪了。 -为了查明是谁干的,你需要到 **‘mystery’** 子目录并从那里开始工作。你可能需要查看犯罪现场的所有线索( **‘crimescene’** 文件)。现场的警官相当谨慎,所以他们在警官报告中写下了一切。幸运的是,警官在所有的帽子里都用了 “CLUE” 一词,并把真正的线索标记了出来。 +为了查明是谁干的,你需要到 `mystery` 子目录并从那里开始工作。你可能需要查看犯罪现场的所有线索( `crimescene` 文件)。现场的警官相当谨慎,所以他们在警官报告中写下了一切。幸运的是,警官以全部大写的 “CLUE” 一词把真正的线索标记了出来。 + +如果里遇到任何问题,请打开其中一个提示文件,例如 “hint1”,“hint2” 等。你可以使用下面的 `cat` 命令打开提示文件。 -如果里遇到任何问题,请打开其中一个提示文件,例如 hint1,hint2 等。你可以使用下面的 cat 命令打开提示文件。 ``` $ cat hint1 - $ cat hint2 - ``` -要检查你的答案或找出解决方案,请在 clmystery 目录中打开文件 “solution”。 +要检查你的答案或找出解决方案,请在 `clmystery` 目录中打开文件 `solution`。 + ``` $ cat solution - ``` -要开始如何使用命令行,请参阅 **cheatsheet.md** 或 **cheatsheet.pdf** (在命令行中,你可以输入 ‘nano cheatsheet.md’)。请勿使用文本编辑器查看除说明,备忘录和提示以外的任何文件。 +要了解如何使用命令行,请参阅 `cheatsheet.md` 或 `cheatsheet.pdf` (在命令行中,你可以输入 ‘nano cheatsheet.md’)。请勿使用文本编辑器查看除 `instructions`、`cheatsheet` 和 `hint` 以外的任何文件。 -有关更多详细信息,请参阅 [**clmystery GitHub**][8] 页面。 +有关更多详细信息,请参阅 [clmystery GitHub][8] 页面。 -**推荐阅读:** +推荐阅读: -而这就是我现在所能记得的。如果将来遇到任何问题,我会继续添加更多游戏。将此链接加入书签并不时访问。如果你知道其他类似的游戏,请在下面的评论部分告诉我,我将测试和更新本指南。 +而这就是我现在所知道的。如果将来遇到任何问题,我会继续添加更多游戏。将此链接加入书签并不时访问。如果你知道其他类似的游戏,请在下面的评论部分告诉我,我将测试和更新本指南。 还有更多好东西,敬请关注! @@ -109,12 +111,12 @@ via: https://www.ostechnix.com/test-your-bash-skills-by-playing-command-line-gam 作者:[SK][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/) 荣誉推出 [a]:https://www.ostechnix.com/author/sk/ -[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[1]:http://overthewire.org/wargames/ [2]:http://www.ostechnix.com/wp-content/uploads/2018/03/Wargames-1.png [3]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-game.png [4]:http://www.ostechnix.com/wp-content/uploads/2018/03/Bandit-level-0.png @@ -122,3 +124,4 @@ via: https://www.ostechnix.com/test-your-bash-skills-by-playing-command-line-gam [6]:http://www.ostechnix.com/wp-content/uploads/2018/03/Terminus.png [7]:https://github.com/veltman/clmystery/archive/master.zip [8]:https://github.com/veltman/clmystery +[9]:http://web.mit.edu/mprat/Public/web/Terminus/Web/main.html From 207caa9845437454edb2ff8c53e87675e3b596cf Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 28 Mar 2018 19:18:20 +0800 Subject: [PATCH 0173/1057] PUB:20180308 Test Your BASH Skills By Playing Command Line Games.md @MjSeven https://linux.cn/article-9490-1.html --- ...0180308 Test Your BASH Skills By Playing Command Line Games.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180308 Test Your BASH Skills By Playing Command Line Games.md (100%) diff --git a/translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md b/published/20180308 Test Your BASH Skills By Playing Command Line Games.md similarity index 100% rename from translated/tech/20180308 Test Your BASH Skills By Playing Command Line Games.md rename to published/20180308 Test Your BASH Skills By Playing Command Line Games.md From 6c8e37e0634adda42b1af727395100ec90272358 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 28 Mar 2018 21:49:26 +0800 Subject: [PATCH 0174/1057] Update 20171212 Oh My Fish- Make Your Shell Beautiful.md --- sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md b/sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md index 2bc4fe93e4..99fea8b744 100644 --- a/sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md +++ b/sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md @@ -1,3 +1,5 @@ +Translating by MjSeven + Oh My Fish! Make Your Shell Beautiful ====== ![](https://www.ostechnix.com/wp-content/uploads/2017/12/oh-my-fish-720x340.jpg) From 96f91dc2848794504b360ea1ae1770172a4023a0 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Thu, 29 Mar 2018 07:19:36 +0800 Subject: [PATCH 0175/1057] 2018-3-29 --- ...06 Why Linux is better than Windows or macOS for security.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index df0557339d..0b09b13c86 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -25,7 +25,7 @@ Still, would it be wise to reconsider? Are the three leading desktop OSes differ ### 操作系统真的重要吗?Does the OS really matter? -The OS you deploy to your users does make a difference for your security stance, but it isn’t a sure safeguard. For one thing, a breach these days is more likely to come about because an attacker probed your users, not your systems. A [survey][1] of hackers who attended a recent DEFCON conference revealed that “84 percent use social engineering as part of their attack strategy.” Deploying a secure operating system is an important starting point, but without user education, strong firewalls and constant vigilance, even the most secure networks can be invaded. And of course there’s always the risk of user-downloaded software, extensions, utilities, plug-ins and other software that appears benign but becomes a path for malware to appear on the system. +给你的用户部署的那个操作系统确实对你的安全态度产生了影响,但那并不是一个可靠的安全措施For one thing, a breach these days is more likely to come about because an attacker probed your users, not your systems. A [survey][1] of hackers who attended a recent DEFCON conference revealed that “84 percent use social engineering as part of their attack strategy.” Deploying a secure operating system is an important starting point, but without user education, strong firewalls and constant vigilance, even the most secure networks can be invaded. And of course there’s always the risk of user-downloaded software, extensions, utilities, plug-ins and other software that appears benign but becomes a path for malware to appear on the system. And no matter which platform you choose, one of the best ways to keep your system secure is to ensure that you apply software updates promptly. Once a patch is in the wild, after all, the hackers can reverse engineer it and find a new exploit they can use in their next wave of attacks. From e7148f1ed22264439e517838629a85356de25056 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 29 Mar 2018 08:54:17 +0800 Subject: [PATCH 0176/1057] translated --- ...nd Tutorial With Examples For Beginners.md | 82 ------------------- ...nd Tutorial With Examples For Beginners.md | 81 ++++++++++++++++++ 2 files changed, 81 insertions(+), 82 deletions(-) delete mode 100644 sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md create mode 100644 translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md diff --git a/sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md b/sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md deleted file mode 100644 index 688322322f..0000000000 --- a/sources/tech/20180313 The Type Command Tutorial With Examples For Beginners.md +++ /dev/null @@ -1,82 +0,0 @@ -translating---geekpi - -The Type Command Tutorial With Examples For Beginners -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/03/Type-command-720x340.png) - -The **Type** command is used to find out the information about a Linux command. As the name implies, you can easily find whether the given command is an alias, shell built-in, file, function, or keyword using “type” command. Additionally, you can find the actual path of the command too. Why would anyone need to find the command type? For instance, if you happen to work on a shared computer often, some guys may intentionally or accidentally create an alias to a particular Linux command to perform an unwanted operation, for example **“alias ls = rm -rf /”**. So, it is always good idea to inspect them before something worse happen. This is where the type command comes in help. - -Let me show you some examples. - -Run the Type command without any flags. -``` -$ type ls -ls is aliased to `ls --color=auto' - -``` - -As you can see in the above output, the “ls” command has been aliased to “ls –color-auto”. It is, however, harmless. But just think of if the **ls** command is aliased to something dangerous. You don’t want that, do you? - -You can use **-t** flag to find only the type of a Linux command. For example: -``` -$ type -t ls -alias - -$ type -t mkdir -file - -$ type -t pwd -builtin - -$ type -t if -keyword - -$ type -t rvm -function - -``` - -This command just displays the type of the command, i.e alias. It doesn’t display what is aliased to the given command. If a command is not found, you will see nothing in the terminal. - -The another useful advantage of type command is we can easily find out the absolute path of a given Linux command. To do so, use **-p** flag as shown below. -``` -$ type -p cal -/usr/bin/cal - -``` - -This is similar to ‘which ls’ command. If the given command is aliased, nothing will be printed. - -To display all information of a command, use **-a** flag. -``` -$ type -a ls -ls is aliased to `ls --color=auto' -ls is /usr/bin/ls -ls is /bin/ls - -``` - -As you see, -a flag displays the type of the given command and its absolute path. For more details, refer man pages. -``` -$ man type - -``` - -Hope this helps. More good stuffs to come. Keep visiting! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/the-type-command-tutorial-with-examples-for-beginners/ - -作者:[SK][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/author/sk/ diff --git a/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md b/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md new file mode 100644 index 0000000000..29b87c6858 --- /dev/null +++ b/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md @@ -0,0 +1,81 @@ +给初学者的 Type 命令教程 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Type-command-720x340.png) + +** Type ** 命令用于查找 Linux 命令的信息。顾名思义,你可以使用 “type” 命令轻松找出给定的命令是否是别名、shell 内置命令、文件、函数或关键字。另外,你也可以找到命令的实际路径。为什么有人需要找到命令类型?例如,如果你经常在共享计算机上工作,则某些人可能会故意或意外地为特定的 Linux 命令创建别名来执行不需要的操作,例如 **“alias ls = rm -rf /”**。因此,在发生更糟糕的事情之前检查它们总是一个好主意。这是 type 命令有用的地方。 + +让我给你看一些例子。 + +不带任何选项运行 Type 命令。 +``` +$ type ls +ls is aliased to `ls --color=auto' + +``` + +正如你在上面的输出中看到的那样,“ls” 命令已被别名为 “ls -color-auto”。但是,它是无害的。但只要想想 **ls** 如果被别名为了其他一些危险的命令。你不想那样,是吗? + +你可以使用 **-t** 选项仅找出 Linux 命令的类型。例如: +``` +$ type -t ls +alias + +$ type -t mkdir +file + +$ type -t pwd +builtin + +$ type -t if +keyword + +$ type -t rvm +function + +``` + +该命令仅显示命令的类型,即 alias。它不显示被别名的命令。如果找不到命令,你将在终端中看不到任何内容。 + +type 命令的另一个有用的地方是我们可以很容易地找出给定 Linux 命令的绝对路径。为此,请使用 **- p** 选项,如下所示。 + +``` +$ type -p cal +/usr/bin/cal + +``` + +这与 “which ls” 命令类似。如果给定的命令是别名,则不会打印任何内容。 + +要显示命令的所有信息,请使用 **-a** 选项。 +``` +$ type -a ls +ls is aliased to `ls --color=auto' +ls is /usr/bin/ls +ls is /bin/ls + +``` + +如你所见,-a 标志显示给定命令的类型及其绝对路径。有关更多详细信息,请参阅手册页。 +``` +$ man type + +``` + +希望这有帮助。会有更多的好东西。请继续访问! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/the-type-command-tutorial-with-examples-for-beginners/ + +作者:[SK][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/author/sk/ From 8b9988086adcea41ba3bb9976b01bcc1aac181a6 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 29 Mar 2018 09:04:58 +0800 Subject: [PATCH 0177/1057] translating --- .../20180118 Securing the Linux filesystem with Tripwire.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180118 Securing the Linux filesystem with Tripwire.md b/sources/tech/20180118 Securing the Linux filesystem with Tripwire.md index a359e3a422..7afb8a5183 100644 --- a/sources/tech/20180118 Securing the Linux filesystem with Tripwire.md +++ b/sources/tech/20180118 Securing the Linux filesystem with Tripwire.md @@ -1,3 +1,5 @@ +translating----geekpi + Securing the Linux filesystem with Tripwire ====== From 0e85379330c07263c38218abd586c0dd6b7667b5 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 09:40:09 +0800 Subject: [PATCH 0178/1057] PRF:20160810 How does gdb work.md @ucasFL --- translated/tech/20160810 How does gdb work.md | 63 ++++++++----------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/translated/tech/20160810 How does gdb work.md b/translated/tech/20160810 How does gdb work.md index e45b988d3d..58fb60873e 100644 --- a/translated/tech/20160810 How does gdb work.md +++ b/translated/tech/20160810 How does gdb work.md @@ -1,9 +1,9 @@ gdb 如何工作? ============================================================ -大家好!今天,我开始进行我的 [ruby 堆栈跟踪项目][1],我意识到,我现在了解了一些关于 gdb 内部如何工作的内容。 +大家好!今天,我开始进行我的 [ruby 堆栈跟踪项目][1],我发觉我现在了解了一些关于 `gdb` 内部如何工作的内容。 -最近,我使用 gdb 来查看我的 Ruby 程序,所以,我们将对一个 Ruby 程序运行 gdb 。它实际上就是一个 Ruby 解释器。首先,我们需要打印出一个全局变量的地址:`ruby_current_thread`。 +最近,我使用 `gdb` 来查看我的 Ruby 程序,所以,我们将对一个 Ruby 程序运行 `gdb` 。它实际上就是一个 Ruby 解释器。首先,我们需要打印出一个全局变量的地址:`ruby_current_thread`。 ### 获取全局变量 @@ -13,10 +13,9 @@ gdb 如何工作? $ sudo gdb -p 2983 (gdb) p & ruby_current_thread $2 = (rb_thread_t **) 0x5598a9a8f7f0 - ``` -变量能够位于的地方有堆、栈或者程序的文本段。全局变量也是程序的一部分。某种程度上,你可以把它们想象成是在编译的时候分配的。因此,我们可以很容易的找出全局变量的地址。让我们来看看,gdb 是如何找出 `0x5598a9a87f0` 这个地址的。 +变量能够位于的地方有heapstack或者程序的文本段text。全局变量是程序的一部分。某种程度上,你可以把它们想象成是在编译的时候分配的。因此,我们可以很容易的找出全局变量的地址。让我们来看看,`gdb` 是如何找出 `0x5598a9a87f0` 这个地址的。 我们可以通过查看位于 `/proc` 目录下一个叫做 `/proc/$pid/maps` 的文件,来找到这个变量所位于的大致区域。 @@ -42,35 +41,33 @@ $4 = 0x48a7f0 ``` sudo nm /proc/2983/exe | grep ruby_current_thread 000000000048a7f0 b ruby_current_thread - ``` 我们看到了什么?能够看到 `0x48a7f0` 吗?是的,没错。所以,如果我们想找到程序中一个全局变量的地址,那么只需在符号表中查找变量的名字,然后再加上在 `/proc/whatever/maps` 中的起始地址,就得到了。 -所以现在,我们知道 gdb 做了什么。但是,gdb 实际做的事情更多,让我们跳过直接转到… +所以现在,我们知道 `gdb` 做了什么。但是,`gdb` 实际做的事情更多,让我们跳过直接转到… ### 解引用指针 ``` (gdb) p ruby_current_thread $1 = (rb_thread_t *) 0x5598ab3235b0 - ``` -我们要做的下一件事就是解引用 `ruby_current_thread` 这一指针。我们想看一下它所指向的地址。为了完成这件事,gdb 会运行大量系统调用比如: +我们要做的下一件事就是解引用 `ruby_current_thread` 这一指针。我们想看一下它所指向的地址。为了完成这件事,`gdb` 会运行大量系统调用比如: ``` ptrace(PTRACE_PEEKTEXT, 2983, 0x5598a9a8f7f0, [0x5598ab3235b0]) = 0 ``` -你是否还记得 `0x5598a9a8f7f0` 这个地址?gdb 会问:“嘿,在这个地址中的实际内容是什么?”。`2983` 是我们运行 gdb 这个进程的 ID。gdb 使用 `ptrace` 这一系统调用来完成这一件事。 +你是否还记得 `0x5598a9a8f7f0` 这个地址?`gdb` 会问:“嘿,在这个地址中的实际内容是什么?”。`2983` 是我们运行 gdb 这个进程的 ID。gdb 使用 `ptrace` 这一系统调用来完成这一件事。 -好极了!因此,我们可以解引用内存并找出内存地址中存储的内容。一些有用的 gdb 命令能够分别知道 `x/40w` 和 `x/40b` 这两个变量哪一个会在给定地址展示 40 个字/字节。 +好极了!因此,我们可以解引用内存并找出内存地址中存储的内容。有一些有用的 `gdb` 命令,比如 `x/40w 变量` 和 `x/40b 变量` 分别会显示给定地址的 40 个字/字节。 ### 描述结构 -一个内存地址中的内容可能看起来像下面这样。大量的字节! +一个内存地址中的内容可能看起来像下面这样。可以看到很多字节! ``` (gdb) x/40b ruby_current_thread @@ -79,7 +76,6 @@ ptrace(PTRACE_PEEKTEXT, 2983, 0x5598a9a8f7f0, [0x5598ab3235b0]) = 0 0x5598ab3235c0: 16 -64 -55 115 -97 127 0 0 0x5598ab3235c8: 0 0 2 0 0 0 0 0 0x5598ab3235d0: -96 -83 -39 115 -97 127 0 0 - ``` 这很有用,但也不是非常有用!如果你是一个像我一样的人类并且想知道它代表什么,那么你需要更多内容,比如像这样: @@ -92,10 +88,9 @@ $8 = {self = 94114195940880, vm = 0x5598ab322f20, stack = 0x7f9f73c9c010, passed_bmethod_me = 0x0, passed_ci = 0x0, top_self = 94114195612680, top_wrapper = 0, base_block = 0x0, root_lep = 0x0, root_svar = 8, thread_id = 140322820187904, - ``` -太好了。现在就更加有用了。gdb 是如何知道这些所有域的,比如 `stack_size` ?输入 `DWARF`。`DWARF` 是存储额外程序调试数据的一种方式,从而调试器比如 gdb 能够更好的工作。它通常存储为一部分二进制。如果我对我的 Ruby 二进制文件运行 `dwarfdump` 命令,那么我将会得到下面的输出: +太好了。现在就更加有用了。`gdb` 是如何知道这些所有域的,比如 `stack_size` ?是从 `DWARF` 得知的。`DWARF` 是存储额外程序调试数据的一种方式,从而像 `gdb` 这样的调试器能够工作的更好。它通常存储为二进制的一部分。如果我对我的 Ruby 二进制文件运行 `dwarfdump` 命令,那么我将会得到下面的输出: (我已经重新编排使得它更容易理解) @@ -128,7 +123,7 @@ DW_TAG_member ``` -所以,`ruby_current_thread` 的类型名为 `rb_thread_struct`,它的大小为 0x3e8 (或 1000 字节),它有许多成员项,`stack_size` 是其中之一,在偏移为 24 的地方,它有类型 `31\` 。`31` 是什么?不用担心,我们也可以在 DWARF 信息中查看。 +所以,`ruby_current_thread` 的类型名为 `rb_thread_struct`,它的大小为 `0x3e8` (即 1000 字节),它有许多成员项,`stack_size` 是其中之一,在偏移为 `24` 的地方,它有类型 `31` 。`31` 是什么?不用担心,我们也可以在 DWARF 信息中查看。 ``` < 1><0x00000031> DW_TAG_typedef @@ -141,67 +136,61 @@ DW_TAG_member ``` -所以,`stack_size` 具有类型 `size_t`,即 `long unsigned int`,它是 8 字节的。这意味着我们可以查看栈大小。 +所以,`stack_size` 具有类型 `size_t`,即 `long unsigned int`,它是 8 字节的。这意味着我们可以查看该栈的大小。 如果我们有了 DWARF 调试数据,该如何分解: 1. 查看 `ruby_current_thread` 所指向的内存区域 - -2. 加上 24 字节来得到 `stack_size` - +2. 加上 `24` 字节来得到 `stack_size` 3. 读 8 字节(以小端的格式,因为是在 x86 上) - 4. 得到答案! -在上面这个例子中是 131072 或 128 kb 。 +在上面这个例子中是 `131072`(即 128 kb)。 -对我来说,这使得调试信息的用途更加明显。如果我们不知道这些所有变量所表示的额外元数据,那么我们无法知道在 `0x5598ab325b0` 这一地址的字节是什么。 +对我来说,这使得调试信息的用途更加明显。如果我们不知道这些所有变量所表示的额外的元数据,那么我们无法知道存储在 `0x5598ab325b0` 这一地址的字节是什么。 -这就是为什么你可以从你的程序中单独安装一个程序的调试信息,因为 gdb 并不关心从何处获取额外的调试信息。 +这就是为什么你可以为你的程序单独安装程序的调试信息,因为 `gdb` 并不关心从何处获取这些额外的调试信息。 -### DWARF 很迷惑 +### DWARF 令人迷惑 -我最近阅读了大量的 DWARF 信息。现在,我使用 libdwarf,使用体验不是很好,这个 API 很令人迷惑,你将以一种奇怪的方式初始化所有东西,它真的很慢(需要花费 0.3 s 的时间来读取我的 Ruby 程序的所有调试信息,这真是可笑)。有人告诉我,libdw 比 elfutils 要好一些。 +我最近阅读了大量的 DWARF 知识。现在,我使用 libdwarf,使用体验不是很好,这个 API 令人迷惑,你将以一种奇怪的方式初始化所有东西,它真的很慢(需要花费 0.3 秒的时间来读取我的 Ruby 程序的所有调试信息,这真是可笑)。有人告诉我,来自 elfutils 的 libdw 要好一些。 -同样,你可以查看 `DW_AT_data_member_location` 来查看结构成员的偏移。我在 Stack Overflow 上查找如何完成这件事,并且得到[这个答案][2]。基本上,以下面这样一个检查开始: +同样,再提及一点,你可以查看 `DW_AT_data_member_location` 来查看结构成员的偏移。我在 Stack Overflow 上查找如何完成这件事,并且得到[这个答案][2]。基本上,以下面这样一个检查开始: ``` dwarf_whatform(attrs[i], &form, &error); if (form == DW_FORM_data1 || form == DW_FORM_data2 form == DW_FORM_data2 || form == DW_FORM_data4 form == DW_FORM_data8 || form == DW_FORM_udata) { - ``` 继续往前。为什么会有 800 万种不同的 `DW_FORM_data` 需要检查?发生了什么?我没有头绪。 -不管怎么说,我的印象是,DWARF 是一个庞大而复杂的标准(可能是人们用来生成 DWARF 的库不匹配),但是这是我们所拥有的,所以我们只能用它来工作。 +不管怎么说,我的印象是,DWARF 是一个庞大而复杂的标准(可能是人们用来生成 DWARF 的库稍微不兼容),但是我们有的就是这些,所以我们只能用它来工作。 -我能够编写代码并查看 DWARF 并且我的代码实际上大多数能够工作,这就很酷了,除了程序崩溃的时候。我就是这样工作的。 +我能够编写代码并查看 DWARF ,这就很酷了,并且我的代码实际上大多数能够工作。除了程序崩溃的时候。我就是这样工作的。 ### 展开栈路径 -在这篇文章的早期版本中,我说过,gdb 使用 libunwind 来展开栈路径,这样说并不总是对的。 +在这篇文章的早期版本中,我说过,`gdb` 使用 libunwind 来展开栈路径,这样说并不总是对的。 -有一位对 gdb 有深入研究的人发了大量邮件告诉我,他们花费了大量时间来尝试如何展开栈路径从而能够做得比 libunwind 更好。这意味着,如果你在程序的一个奇怪的中间位置停下来了,你所能够获取的调试信息又很少,那么你可以对栈做一些奇怪的事情,gdb 会尝试找出你位于何处。 +有一位对 `gdb` 有深入研究的人发了大量邮件告诉我,为了能够做得比 libunwind 更好,他们花费了大量时间来尝试如何展开栈路径。这意味着,如果你在程序的一个奇怪的中间位置停下来了,你所能够获取的调试信息又很少,那么你可以对栈做一些奇怪的事情,`gdb` 会尝试找出你位于何处。 ### gdb 能做的其他事 -我在这儿所描述的一些事请(查看内存,理解 DWARF 所展示的结构)并不是 gdb 能够做的全部事情。阅读 Brendan Gregg 的[昔日 gdb 例子][3],我们可以知道,gdb 也能够完成下面这些事情: +我在这儿所描述的一些事请(查看内存,理解 DWARF 所展示的结构)并不是 `gdb` 能够做的全部事情。阅读 Brendan Gregg 的[昔日 gdb 例子][3],我们可以知道,`gdb` 也能够完成下面这些事情: * 反汇编 - * 查看寄存器内容 在操作程序方面,它可以: * 设置断点,单步运行程序 - * 修改内存(这是一个危险行为) -了解 gdb 如何工作使得当我使用它的时候更加自信。我过去经常感到迷惑,因为 gdb 有点像 C,当你输入 `ruby_current_thread->cfp->iseq`,就好像是在写 C 代码。但是你并不是在写 C 代码。我很容易遇到 gdb 的限制,不知道为什么。 +了解 `gdb` 如何工作使得当我使用它的时候更加自信。我过去经常感到迷惑,因为 `gdb` 有点像 C,当你输入 `ruby_current_thread->cfp->iseq`,就好像是在写 C 代码。但是你并不是在写 C 代码。我很容易遇到 `gdb` 的限制,不知道为什么。 -知道使用 DWARF 来找出结构内容给了我一个更好的心理模型和更加正确的期望!这真是极好的! +知道使用 DWARF 来找出结构内容给了我一个更好的心智模型和更加正确的期望!这真是极好的! -------------------------------------------------------------------------------- @@ -209,7 +198,7 @@ via: https://jvns.ca/blog/2016/08/10/how-does-gdb-work/ 作者:[Julia Evans][a] 译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b1e21c90918b39a6f3f4bbc98e90cfc091782494 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 09:40:32 +0800 Subject: [PATCH 0179/1057] PUB:20160810 How does gdb work.md @ucasFL https://linux.cn/article-9491-1.html --- {translated/tech => published}/20160810 How does gdb work.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20160810 How does gdb work.md (100%) diff --git a/translated/tech/20160810 How does gdb work.md b/published/20160810 How does gdb work.md similarity index 100% rename from translated/tech/20160810 How does gdb work.md rename to published/20160810 How does gdb work.md From 0ff9d2d078b79596b0adb139ff665bab8168002d Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 12:37:07 +0800 Subject: [PATCH 0180/1057] PRF:20180209 How to setup and configure network bridge on Debian Linux.md @MjSeven --- ...onfigure network bridge on Debian Linux.md | 92 +++++++++++++------ 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md b/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md index c5962155af..1e7f4a5b9c 100644 --- a/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md +++ b/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md @@ -1,36 +1,48 @@ 如何在 Debian Linux 上设置和配置网桥 ===== -我是一个新 Debian Linux 用户,我想为 Debian Linux 上运行的虚拟化环境(KVM)设置网桥。那么我该如何在 Debian Linux 9.x 服务器上的 /etc/network/interfaces 中设置桥接网络呢? +Q:我是一个新 Debian Linux 用户,我想为 Debian Linux 上运行的虚拟化环境(KVM)设置网桥。那么我该如何在 Debian Linux 9.x 服务器上的 `/etc/network/interfaces` 中设置桥接网络呢? 如何你想为你的虚拟机分配 IP 地址并使其可从你的局域网访问,则需要设置网络桥接器。默认情况下,虚拟机使用 KVM 创建的专用网桥。但你需要手动设置接口,避免与网络管理员发生冲突。 ### 怎样安装 brctl -输入以下命令 [nixcmdn name=”apt”]/[apt-get 命令][1]: -`$ sudo apt install bridge-utils` +输入以下 [apt-get 命令][1]: + +``` +$ sudo apt install bridge-utils +``` ### 怎样在 Debian Linux 上设置网桥 -你需要编辑 /etc/network/interface 文件。不过,我建议在 /etc/network/interface.d/ 目录下放置一个全新的配置。在 Debian Linux 配置网桥的过程如下: +你需要编辑 `/etc/network/interface` 文件。不过,我建议在 `/etc/network/interface.d/` 目录下放置一个全新的配置。在 Debian Linux 配置网桥的过程如下: #### 步骤 1 - 找出你的物理接口 -使用 [ip 命令][2]: -`$ ip -f inet a s` +使用 [ip 命令][2]: + +``` +$ ip -f inet a s +``` + 示例输出如下: + ``` 2: eno1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 inet 192.168.2.23/24 brd 192.168.2.255 scope global eno1 valid_lft forever preferred_lft forever ``` -eno1 是我的物理网卡。 +`eno1` 是我的物理网卡。 #### 步骤 2 - 更新 /etc/network/interface 文件 -确保只有 lo(loopback 在 /etc/network/interface 中处于活动状态)。(译注:loopback 指本地环回接口,也称为回送地址)删除与 eno1 相关的任何配置。这是我使用 [cat 命令][3] 打印的配置文件: -`$ cat /etc/network/interface` +确保只有 `lo`(loopback 在 `/etc/network/interface` 中处于活动状态)。(LCTT 译注:loopback 指本地环回接口,也称为回送地址)删除与 `eno1` 相关的任何配置。这是我使用 [cat 命令][3] 打印的配置文件: + +``` +$ cat /etc/network/interface +``` + ``` # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). @@ -42,12 +54,16 @@ auto lo iface lo inet loopback ``` - #### 步骤 3 - 在 /etc/network/interfaces.d/br0 中配置网桥(br0) -使用文本编辑器创建一个 text 文件,比如 vi 命令: -`$ sudo vi /etc/network/interfaces.d/br0` +使用文本编辑器创建一个文本文件,比如 `vi` 命令: + +``` +$ sudo vi /etc/network/interfaces.d/br0 +``` + 在其中添加配置: + ``` ## static ip config file for br0 ## auto br0 @@ -68,6 +84,7 @@ iface br0 inet static ``` 如果你想使用 DHCP 来获得 IP 地址: + ``` ## DHCP ip config file for br0 ## auto br0 @@ -79,26 +96,47 @@ auto br0 [在 vi/vim 中保存并关闭文件][4]。 -#### 步骤 4 - [重新启动网络服务][5] +#### 步骤 4 - 重新启动网络服务 + +在重新启动网络服务之前,请确保防火墙已关闭。防火墙可能会引用较老的接口,例如 `eno1`。一旦服务重新启动,你必须更新 `br0` 接口的防火墙规则。键入以下命令重新启动防火墙: + +``` +$ sudo systemctl restart network-manager +``` -在重新启动网络服务之前,请确保防火墙已关闭。防火墙可能会引用较老的接口,例如 eno1。一旦服务重新启动,你必须更新 br0 接口的防火墙规则。键入以下命令重新启动防火墙: -`$ sudo systemctl restart network-manager` 确认服务已经重新启动: -`$ systemctl status network-manager` -借助 [ip 命令][2]寻找新的 br0 接口和路由表: -`$ ip a s $ ip r $ ping -c 2 cyberciti.biz` -示例输出: -![](https://www.cyberciti.biz/media/new/faq/2018/02/How-to-setup-and-configure-network-bridge-on-Debian-Linux.jpg) -你可以使用 brctl 命令查看网桥有关信息: -`$ brctl show` -显示当前网桥: -`$ bridge link` -![](https://www.cyberciti.biz/media/new/faq/2018/02/Show-current-bridges-and-what-interfaces-they-are-connected-to-on-Linux.jpg) +``` +$ systemctl status network-manager +``` + +借助 [ip 命令][2]寻找新的 `br0` 接口和路由表: + +``` +$ ip a s $ ip r $ ping -c 2 cyberciti.biz +``` + +示例输出: + +![](https://www.cyberciti.biz/media/new/faq/2018/02/How-to-setup-and-configure-network-bridge-on-Debian-Linux.jpg) + +你可以使用 brctl 命令查看网桥有关信息: + +``` +$ brctl show +``` + +显示当前网桥: + +``` +$ bridge link +``` + +![](https://www.cyberciti.biz/media/new/faq/2018/02/Show-current-bridges-and-what-interfaces-they-are-connected-to-on-Linux.jpg) ### 关于作者 -作者是 nixCraft 的创建者,也是经验丰富的系统管理员,DevOps 工程师以及 Linux 操作系统/ Unix shell 脚本的培训师。通过订阅 [RSS/XML feed][6] 或者 [weekly email newsletter][7]获得**关于 SysAdmin, Linux/Unix 和开源主题的最新教程。** +作者是 nixCraft 的创建者,也是经验丰富的系统管理员,DevOps 工程师以及 Linux 操作系统/ Unix shell 脚本的培训师。通过订阅 [RSS/XML 流][6] 或者 [每周邮件推送][7]获得关于 SysAdmin, Linux/Unix 和开源主题的最新教程。 -------------------------------------------------------------------------------- @@ -106,7 +144,7 @@ via: https://www.cyberciti.biz/faq/how-to-configuring-bridging-in-debian-linux/ 作者:[Vivek GIte][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 085ac835030c06403cbcb687e25e6394a61059f5 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 12:37:49 +0800 Subject: [PATCH 0181/1057] PUB:20180209 How to setup and configure network bridge on Debian Linux.md @MjSeven https://linux.cn/article-9492-1.html --- ...9 How to setup and configure network bridge on Debian Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180209 How to setup and configure network bridge on Debian Linux.md (100%) diff --git a/translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md b/published/20180209 How to setup and configure network bridge on Debian Linux.md similarity index 100% rename from translated/tech/20180209 How to setup and configure network bridge on Debian Linux.md rename to published/20180209 How to setup and configure network bridge on Debian Linux.md From d2eb9bc782c68044999778b1f673ae734cddc189 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 13:00:48 +0800 Subject: [PATCH 0182/1057] PRF:20180202 How do I edit files on the command line.md @CYLeft --- ...How do I edit files on the command line.md | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/translated/tech/20180202 How do I edit files on the command line.md b/translated/tech/20180202 How do I edit files on the command line.md index e559630730..ee5c19a748 100644 --- a/translated/tech/20180202 How do I edit files on the command line.md +++ b/translated/tech/20180202 How do I edit files on the command line.md @@ -1,11 +1,11 @@ -如何在命令行上编辑文件?-- 三个命令行编辑器使用教程 +快捷教程:如何在命令行上编辑文件 ====== 此次教程中,我们将向您展示三种命令行编辑文件的方式。本文一共覆盖了三种命令行编辑器,vi(或 vim)、nano 和 emacs。 -#### 在命令行上使用 Vi 或 Vim 编辑文件 +### 在命令行上使用 Vi 或 Vim 编辑文件 -您可以使用 vi 编辑文件。运行如下命令,打开文件: +您可以使用 `vi` 编辑文件。运行如下命令,打开文件: ``` vi /path/to/file @@ -13,13 +13,13 @@ vi /path/to/file 现在,您可以看见文件中的内容了(如果文件存在。请注意,如果此文件不存在,该命令会创建文件)。 -vi 最重要的命令莫过于此: +`vi` 最重要的命令莫过于此: -键入 `i` 进入 `Insert`(编辑)模式。如此,您可以编辑文本。 +键入 `i` 进入编辑Insert模式。如此,您可以编辑文本。 退出编辑模式请键入 `ESC`。 -正处于光标之下的字符,使用 `x` 键删除(您千万不要在编辑模式这样做,如果您这样做了,将不会删除光标下的字符,而是会在光标下插入 `x` 字符)。因此,当您仅仅使用 vi 打开文本(此时默认进入指令模式),此时您可以使用 `x` 键立即删除字符。在编辑模式下,您需要键入 `ESC` 退出编辑模式。 +正处于光标之下的字符,使用 `x` 键删除(您千万不要在编辑模式这样做,如果您这样做了,将不会删除光标下的字符,而是会在光标下插入 `x` 字符)。因此,当您仅仅使用 `vi` 打开文本(LCTT 译注:此时默认进入指令模式),此时您可以使用 `x` 键立即删除字符。在编辑模式下,您需要键入 `ESC` 退出编辑模式。 如果您做了修改,想要保存文件,请键入 `:x`(同样,您不能在编辑模式执行此操作。请按 `ESC` 退出编辑模式,完成此操作)。 @@ -29,19 +29,19 @@ vi 最重要的命令莫过于此: 请注意在上述所有操作中,您都可以使用方向键操控光标在文本中的位置。 -以上所有都是 vi 编辑器的内容。请注意,vim 编辑器或多或少也会支持这些操作,如果您有深层次了解 vim 的需求,请看 [这里][1]。 +以上所有都是 `vi` 编辑器的内容。请注意,`vim` 编辑器或多或少也会支持这些操作,如果您想深层次了解 `vim`,请看 [这里][1]。 -#### 使用 Nano 命令行编辑器编辑文件 +### 使用 Nano 命令行编辑器编辑文件 -接下来是 Nano 编辑器。您可以执行 'nano' 命令调用它: +接下来是 Nano 编辑器。您可以执行 `nano` 命令调用它: ``` nano ``` -这里是 nano 的用户界面: +这里是 `nano` 的用户界面: -[![Nano 命令行编辑器][2]][3] +![Nano 命令行编辑器][3] 您同样可以使用它启动文件。 @@ -55,105 +55,105 @@ nano [filename] nano test.txt ``` -[![在 nano 中打开文件][4]][5] +![在 nano 中打开文件][5] 如您所见的用户界面,大致被分成四个部分。编辑器顶部显示编辑器版本、正在编辑的文件和编辑状态。然后是实际编辑区域,在这里,您能看见文件的内容。编辑器下方高亮区展示着重要的信息,最后两行显示能执行基础任务地快捷键,切实地帮助初学者。 这里是您前期应当了解的快捷键快表。 -使用方向键浏览文本,退格键删除文本,**Ctrl+o** 保存文件修改。当您尝试保存时,nano 会征询您的确认(请参阅截图中主编辑器下方区域): +使用方向键浏览文本,退格键删除文本,`Ctrl+O` 保存文件修改。当您尝试保存时,`nano` 会征询您的确认(请参阅截图中主编辑器下方区域): -[![在 nano 中保存文件][6]][7] +![在 nano 中保存文件][7] -注意,在这个阶段,您有一个选项,可以保存不同的系统格式。键入 **Altd+d** 选择 DOS 格式,**Atl+m** 选择 Mac 格式。 +注意,在这个阶段,您有一个选项,可以保存不同的系统格式。键入 `Alt+D` 选择 DOS 格式,`Atl+M` 选择 Mac 格式。 -[![以 DOS 格式保存文件][8]][9] +![以 DOS 格式保存文件][9] 敲回车保存更改。 -[![文件已经被保存][10]][11] +![文件已经被保存][11] -继续,文本剪切使用 **Ctrl+K**,文本复制使用 **Ctrl+u**。这些快捷键同样可以用来粘贴剪切单个单词,但您需要先选择好单词,通常,您可以通过键入 **Alt+A**(光标在第一个单词下) 然后使用方向键选择完整的单词。 +继续,文本剪切使用 `Ctrl+K`,文本复制使用 `Ctrl+U`。这些快捷键同样可以用来粘贴剪切单个单词,但您需要先选择好单词,通常,您可以通过键入 `Alt+A`(光标在第一个单词下) 然后使用方向键选择完整的单词。 -现在来进行搜索操作。使用 **Ctrl+w** 可以执行一个简单的搜索,同时搜索和替换您可以使用 **Ctrl+\\**。 +现在来进行搜索操作。使用 `Ctrl+W` 可以执行一个简单的搜索,同时搜索和替换您可以使用 `Ctrl+\\`。 -[![使用 nano 在文件中搜索][12]][13] +![使用 nano 在文件中搜索][13] -这些就是 nano 的一些基础功,它能给您带来一些不错的开始,如果您是初次使用 nano 编辑器。更多内容,请阅读我们的完整内容,点击 [这里][14]。 +这些就是 `nano` 的一些基础功,它能给您带来一些不错的开始,如果您是初次使用 `nano` 编辑器。更多内容,请阅读我们的完整内容,点击 [这里][14]。 -#### 使用 Emacs 命令行编辑器编辑文件 +### 使用 Emacs 命令行编辑器编辑文件 -接下来登场的是 **Emacs**。如果系统未安装此软件,您可以使用下面的命令在您的系统中安装它: +接下来登场的是 Emacs。如果系统未安装此软件,您可以使用下面的命令在您的系统中安装它: ``` sudo apt-get install emacs ``` -和 nano 一致,您可以使用下面的方式在 emacs 中直接打开文件: +和 `nano` 一致,您可以使用下面的方式在 `emacs` 中直接打开文件: ``` emacs -nw [filename] ``` -**注意**:**-nw** 选项确保 emacs 在本窗口启动,而不是打开一个新窗口,默认情况下,它会打开一个新窗口。 +注意:`-nw` 选项确保 `emacs` 在本窗口启动,而不是打开一个新窗口,默认情况下,它会打开一个新窗口。 一个实例: + ``` emacs -nw test.txt - ``` 下面是编辑器的用户界面: -[![在 emacs 中打开文件][15]][16] +![在 emacs 中打开文件][16] -和 nano 一样,emacs 的界面同样被分割成了几个部分。第一部分是最上方的菜单区域,和您在图形界面下的应用程序一致。接下来是显示文本(您打开的文件文本)内容的主编辑区域。 +和 `nano` 一样,`emacs` 的界面同样被分割成了几个部分。第一部分是最上方的菜单区域,和您在图形界面下的应用程序一致。接下来是显示文本(您打开的文件文本)内容的主编辑区域。 -编辑区域下方坐落着另一个高亮菜单条,显示了文件名,编辑模式(如截图内的‘Text’)和状态(** 已修改,- 未修改,%% 只读状态)。最后是提供输入指令的区域,同时也能查看输出。 +编辑区域下方坐落着另一个高亮菜单条,显示了文件名,编辑模式(如截图内的 ‘Text’)和状态(`**` 为已修改,`-` 为未修改,`%%` 为只读)。最后是提供输入指令的区域,同时也能查看输出。 -现在开始基础操作,当您做了修改、想要保存时,在 **Ctrl+x** 之后键入 **Ctrl+s**。最后,在面板最后一行会向您显示一些信息:‘**Wrote ........’。这里有一个例子: +现在开始基础操作,当您做了修改、想要保存时,在 `Ctrl+x` 之后键入 `Ctrl+s`。最后,在面板最后一行会向您显示一些信息:‘Wrote ........’。这里有一个例子: -[![emascs 中保存文件][17]][18] +![emascs 中保存文件][18] -现在,如果您放弃修改并且退出时,在 **Ctrl+x** 之后键入**Ctrl+c**。编辑器将会立即询问,如下图: +现在,如果您放弃修改并且退出时,在 `Ctrl+x` 之后键入`Ctrl+c`。编辑器将会立即询问,如下图: -[![emacs 中抛弃修改][19]][20] +![emacs 中抛弃修改][20] -输入 ‘n’ 之后键入 ‘yes’,之后编辑器将会不保存而直接退出。 +输入 `n` 之后键入 `yes`,之后编辑器将会不保存而直接退出。 -请注意,Emacs 中 ‘C’ 代表 ‘Ctrl’,‘M’ 代表 ‘Alt’。比如,当你看见 C-x,这意味着 Ctrl+x。 +请注意,Emacs 中 `C` 代表 `Ctrl`,`M` 代表 `Alt`。比如,当你看见 `C-x`,这意味着按下 `Ctrl+x`。 -至于其他基本编辑器操作,以删除为例,大多数人都会,使用 Backspace/Delete 键。然而,这里的一些删除快捷键能够提高用户体验。比如,使用 **Ctrl+k** 删除一整行,**Alt+d** 删除一个单词,**Alt+k** 删除一个整句。 +至于其他基本编辑器操作,以删除为例,大多数人都会,使用 `Backspace`/`Delete` 键。然而,这里的一些删除快捷键能够提高用户体验。比如,使用 `Ctrl+k` 删除一整行,`Alt+d` 删除一个单词,`Alt+k` 删除一个整句。 -在键入 ‘ **Ctrl+k** ’ 之后键入 ‘ **u** ’ 将不会生效,输入 **Ctrl+g** 之后输入 **Crel+_** 撤销操作。使用 **Crel+s** 向前搜索,**Ctrl+r** 反向搜索。 +在键入 `Ctrl+k` 之后键入 `u` 将撤销操作,输入 `Ctrl+g` 之后输入 `Ctrl+_` 恢复撤销的操作。使用 `Ctrl+s` 向前搜索,`Ctrl+r` 反向搜索。 -[![使用 emacs 在文件中搜索][21]][22] +![使用 emacs 在文件中搜索][22] -继续,使用 Alt+Shift+% 执行替换操作。您将被询问替换单词。回复并回车。之后编辑器将会询问您是否替换。例如,下方截图展示了 emacs 询问使用者关于单词 ‘This’ 的替换操作。 +继续,使用 `Alt+Shift+%` 执行替换操作。您将被询问要替换单词。回复并回车。之后编辑器将会询问您是否替换。例如,下方截图展示了 `emacs` 询问使用者关于单词 ‘This’ 的替换操作。 -[![使用 emacs 替换单词][23]][24] +![使用 emacs 替换单词][24] -输入替换文本并回车。每一个替换操作 emacs 都会等待询问,下面是首次询问: +输入替换文本并回车。每一个替换操作 `emacs` 都会等待询问,下面是首次询问: -[![确定文本替换][25]][26] +![确定文本替换][26] -键入 'y' 之后,单词将会被替换。 +键入 `y` 之后,单词将会被替换。 -[![键入 y 确定操作][27]][28] +![键入 y 确定操作][28] -这些就是几乎所有的基础操作,您在开始使用 emacs 时需要了解掌握的。对了,我们忘记讨论如何访问顶部菜单,其实这些可以通过使用 F10 访问它们。 +这些就是几乎所有的基础操作,您在开始使用 `emacs` 时需要了解掌握的。对了,我们忘记讨论如何访问顶部菜单,其实这些可以通过使用 `F10` 访问它们。 -[![基础编辑器操作][29]][30] +![基础编辑器操作][30] -按 Esc 键三次,退出这些菜单。 +按 `Esc` 键三次,退出这些菜单。 -------------------------------------------------------------------------------- via: https://www.howtoforge.com/faq/how-to-edit-files-on-the-command-line -作者:[falko][a] +作者:[Falko Timme, Himanshu Arora][a] 译者:[CYLeft](https://github.com/CYLeft) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 91b5319ede493f96e102c87d5cb7b6bb0e6f2f2a Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 13:01:18 +0800 Subject: [PATCH 0183/1057] PUB:20180202 How do I edit files on the command line.md @CYLeft https://linux.cn/article-9493-1.html --- .../20180202 How do I edit files on the command line.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180202 How do I edit files on the command line.md (100%) diff --git a/translated/tech/20180202 How do I edit files on the command line.md b/published/20180202 How do I edit files on the command line.md similarity index 100% rename from translated/tech/20180202 How do I edit files on the command line.md rename to published/20180202 How do I edit files on the command line.md From 43979f7c852ebd1310102fbf72d8695dad98093c Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:02:58 +0800 Subject: [PATCH 0184/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=204=20command=20l?= =?UTF-8?q?ine=20note-taking=20applications=20for=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...line note-taking applications for Linux.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sources/tech/20180326 4 command line note-taking applications for Linux.md diff --git a/sources/tech/20180326 4 command line note-taking applications for Linux.md b/sources/tech/20180326 4 command line note-taking applications for Linux.md new file mode 100644 index 0000000000..1851637dfc --- /dev/null +++ b/sources/tech/20180326 4 command line note-taking applications for Linux.md @@ -0,0 +1,68 @@ +4 command line note-taking applications for Linux +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/note-taking.jpeg?itok=fiF5EBEb) +When you need to save a code snippet or a URL, an idea or a quote, you probably fire up a text editor or turn to a [desktop][1] or [web-based][2] note-taking tool. But those aren't your only options. If you spend time working in terminal windows, you can use one of the many note-taking tools available for the Linux command line. + +Let's take a look at of those four apps. + +### tnote + +[tnote][3] makes taking notes in a terminal window very simple—almost too simple. + +tnote is a single Python script. When you start it for the first time, it asks you to enter a password and a passphrase to encrypt the [SQLite database][4] that stores your notes. Once you've done that, press "A" to create a note. Type your note, then press CTRL-D to save it. + +Once you have a few (or more than a few) notes, you can view them or search for specific ones, words or phrases, or tags. tnote doesn't pack a lot of features, but it does get the job done. + +### Terminal Velocity + +If you've used Mac OS, you might have come across a popular open source note-taking application called [Notational Velocity][5], a simple and effective way to take notes. [Terminal Velocity][6] does a good job of bringing the Notational Velocity experience to the command line. + +Terminal Velocity opens your default text editor (set by the `$EDITOR` variable in your `.profile` or `.bashrc` file). Type your note, then save it. The note appears in the list in the Terminal Velocity window. + +Use the arrow keys on your keyboard to scroll through your list of notes. To view or edit a note, press Enter. If you have a long list of notes, you can enter the first few characters of the note's title in the `Find or Create` field to narrow down the list. From there, scroll to the note and press Enter to open it. + +### pygmynote + +Of the four applications in this article, [pygmynote][7] is probably the least user-friendly. It is, however, the most flexible. + +Like tnote, pygmynote saves your notes and attachments in an SQLite database. When you fire it up, pygmynote doesn’t look particularly useful. At any time, type `help` and press Enter to get a list of commands. + +You can add and edit notes, view and search for them, and add [tags][8] to your notes. Tags make finding notes easier, especially if you have a lot of them. + +What gives pygmynote flexibility is its ability to add attachments to your notes. Those attachments can be anything: an image, a text or word processor file, a PDF, a spreadsheet, or anything else relevant to the note. + +### jrnl + +[jrnl][9] is the odd application out here. As you've probably guessed from its name, jrnl is intended to be a journaling tool. But that doesn't mean you can't take notes with it. jrnl does that job very well. + +When you first start jrnl, it asks you where you want to put the file `journal.txt` (which stores your notes), and if you want to password-protect the file. If you decide to add a password, you need to enter it whenever you do anything with the application. + +You can enter notes in two ways: directly from the command line, or with your computer's default editor. You can add tags—for example,`@opensource.com`—to your notes, and give them a date and timestamp. Adding tags and dates can help you search for your notes (jrnl has a pretty decent search feature) if you have a lot of them. + +Since jrnl saves your notes in a plain text file, you can sync it across your devices using [ownCloud][10], [Nextcloud][11], or whatever file sharing/syncing service your prefer. + +Do you have a favorite tool or hack for taking notes at the command line? Feel free to share it with the community by leaving a comment. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/command-line-note-taking-applications + +作者:[Scott Nesbitt][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/scottnesbitt +[1]:https://opensource.com/life/16/9/4-desktop-note-taking-applications +[2]:https://opensource.com/alternatives/evernote +[3]:https://github.com/tasdikrahman/tnote +[4]:http://en.wikipedia.org/wiki/SQLite +[5]:http://notational.net/ +[6]:https://vhp.github.io/terminal_velocity/ +[7]:https://github.com/dmpop/pygmynote +[8]:https://en.wikipedia.org/wiki/Tag_(metadata) +[9]:http://jrnl.sh/ +[10]:https://owncloud.com/ +[11]:https://nextcloud.com/ From 09a6c2a22a88d9693748eb42c82b5a7e2e2caf5e Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:05:47 +0800 Subject: [PATCH 0185/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20crea?= =?UTF-8?q?te=20an=20open=20source=20stack=20using=20EFK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...o create an open source stack using EFK.md | 388 ++++++++++++++++++ 1 file changed, 388 insertions(+) create mode 100644 sources/tech/20180326 How to create an open source stack using EFK.md diff --git a/sources/tech/20180326 How to create an open source stack using EFK.md b/sources/tech/20180326 How to create an open source stack using EFK.md new file mode 100644 index 0000000000..e3fac7f1c1 --- /dev/null +++ b/sources/tech/20180326 How to create an open source stack using EFK.md @@ -0,0 +1,388 @@ +How to create an open source stack using EFK +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-rock-stack.png?itok=cynE4xcC) +Managing an infrastructure of servers is a non-trivial task. When one cluster is misbehaving, logging in to multiple servers, checking each log, and using multiple filters until you find the culprit is not an efficient use of resources. + +The first step to improve the methods that handle your infrastructure or applications is to implement a centralized logging system. This will enable you to gather logs from any application or system into a centralized location and filter, aggregate, compare, and analyze them. If there are servers or applications, there should be a unified logging layer. + +Thankfully, we have an open source stack to simplify this. With the combination of Elasticsearch, Fluentd, and Kibana (EFK), we can create a powerful stack to collect, store, and visualize data in a centralized location. + +Let’s start by defining each component to get the big picture. [Elasticsearch][1] is an open source distributed, RESTful search and analytics engine, or simply an object store where all logs are stored. [Fluentd][2] is an open source data collector that lets you unify the data collection and consumption for better use and understanding of data. And finally, [Kibana][3] is a web UI for Elasticsearch. + +A picture is worth a thousand words: + + +![EFK stack][5] + +EFK Stack using a centralized Fluentd aggregator. + +Image by Michael Zamot, CC BY + +There are other ways to collect logs, like running a small Fluentd forwarder in each host, but that’s beyond the scope of this article. + +### Requirements + +We will install each component in its own Docker container. With Docker we can deploy each component faster, focusing in EFK rather than distro-specific bits, and we can always delete the containers and start all over again. We will be using official, upstream images. + +To learn more about Docker, read [Vincent Batts][6]'s excellent article: [A beginners' guide to Docker][7]. + +Increase the mmap limits by running the following command as root: +``` +$ sudo sysctl -w vm.max_map_count=262144 + +``` + +To set this value permanently, update the `vm.max_map_count` setting in `/etc/sysctl.conf`. + +This is required; otherwise, Elasticsearch can crash. + +### Running Elasticsearch + +To allow the containers to communicate with each other, create a Docker network: +``` +$ sudo docker network create efk + +[...] + +``` + +Execute the following command to start Elasticsearch in Docker: +``` +$ sudo docker run --network=efk --name elasticsearch -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "cluster.name=docker-cluster" -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" --ulimit memlock=-1:-1 -v elasticdata:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.2 + +``` + +Verify the container is running: +``` +$ sudo docker ps + +CONTAINER ID        IMAGE                                                     COMMAND                  CREATED              STATUS              PORTS                                            NAMES + +6e0db1486ee2        docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.2   "/usr/local/bin/docke"   About a minute ago   Up About a minute   0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch + +``` + +Let’s decouple the command to understand what we just did: + + * We use `docker run` to create a new container. + * We use `--network` to attach the container to that specific network. + * We need to define a container name; it will be used as the hostname. + * The parameter `-p` maps our host ports to the container ports. Elasticsearch uses the ports 9200 and 9300. + * The multiple parameters with `-e` are environment variables that are passed to the container to change configurations. + * We define a custom `ulimit` to disable swapping for performance and node stability. + * Containers, by design, are ephemeral. This means they don’t store data, so in order to keep the data and logs safe, we need to create a volume and mount it inside the container. In our case it is mounted to `/usr/share/elasticsearch/data`. This is the path where Elasticsearch stores the data. + + + +Verify the volume was created: +``` +$ sudo docker volume ls + +[...] + +local               elasticdata + +``` + +This volume will survive even if you delete the container. + +Great! Elasticsearch is running. Let’s move on. + +### Running Kibana + +Kibana is a much simpler command. Execute the following command to spin it: +``` +$ sudo docker run --network=efk --name kibana -d -p 5601:5601 docker.elastic.co/kibana/kibana-oss:6.2.2 + +``` + +By default, Kibana will try to communicate to the host named elasticsearch. + +Verify that you can access Kibana in your browser at this URL: http://:5601 + +At this point, Elasticsearch is not indexing any data, so you won’t be able to do much yet. + +Let’s start collecting logs! + +### Running Fluentd + +The following steps are trickier, as the official Docker image doesn’t include the Elasticsearch plugin. We will customize. + +Create a directory called `fluentd` with a subdirectory called `plugins`: +``` +$ mkdir -p fluentd/plugins + +``` + +Now let’s create the Fluentd configuration file. Inside the directory `fluentd`, create a file called `fluent.conf` with the following content: +``` +$ cat fluentd/fluent.conf + + + +  type syslog + +  port 42185 + +  tag  rsyslog + + + + + + + +  type copy + +  + +    type elasticsearch + +    logstash_format true + +    host elasticsearch # Remember the name of the container + +    port 9200 + +  + + + +``` + +The block `` enables the `syslog` plugin, the port and address where it will listen. The block `` will match all logs coming from the `syslog` plugin and will send the data to Elasticsearch. + +Now create another file inside the Fluentd folder called `Dockerfile`: +``` +$ cat fluentd/Dockerfile + +FROM fluent/fluentd:v0.12-onbuild + + + +RUN apk add --update --virtual .build-deps \ + +        sudo build-base ruby-dev \ + + && sudo gem install \ + +        fluent-plugin-elasticsearch \ + + && sudo gem sources --clear-all \ + + && apk del .build-deps \ + + && rm -rf /var/cache/apk/* \ + +           /home/fluent/.gem/ruby/2.3.0/cache/*.gem + +``` + +This will modify the official Fluentd Docker image and add Elasticsearch support. + +The Fluentd directory should look like this: +``` +$ ls fluentd/ + +Dockerfile  fluent.conf  plugins + +``` + +Now we can build the container. Execute the following command within the Fluentd directory: +``` +$ sudo docker build fluentd/ + +[...] + +Successfully built + +``` + +Now we are ready to start the final piece of our stack. Execute the following command to start the container: +``` +$ sudo docker run -d --network efk --name fluentd -p 42185:42185/udp + +``` + +Your Unified Logging Stack is deployed. Now it’s time to point configure your host's rsyslog to send the data to Fluentd. + +Log into each of the nodes you want to collect logs from, and add the following line at the end of `/etc/rsyslog.conf` : +``` +*.* @:42185 + +``` + +Then restart `rsyslog` service: +``` +$ sudo systemctl restart rsyslog + +``` + +Don’t forget to check Kibana—all your logs are going to be there. + +### Wrapping everything up with Docker Compose + +We can use Docker Compose to combine all the steps we did previously into a single command. Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file (known as a Compose file) to configure an application's services; in our case, EFK services. + +To install Docker Compose, execute the following commands: +``` +$ sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose + + + +$ sudo chmod +x /usr/local/bin/docker-compose + +``` + +Verify it is working: +``` +$ docker-compose version + +docker-compose version 1.19.0, build 9e633ef + +``` + +Awesome! All the steps we did previously can be summarized with the following `docker-compose.yml` file (we still need to create the Fluentd folder and files): +``` +$ cat docker-compose.yml + +version: '2.1' + +services: + +  fluentd: + +    build: ./fluentd + +    links: + +      - "elasticsearch" + +    expose: + +      - 42185 + +    ports: + +      - "42185:42185/udp" + +    logging: + +        driver: "json-file" + +        options: + +            max-size: 100m + +            max-file: "5" + + + +  elasticsearch: + +    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.2 + +    container_name: elasticsearch + +    ports: + +      - "9200:9200" + +    environment: + +      - "discovery.type=single-node" + +      - "cluster.name=docker-cluster" + +      - "bootstrap.memory_lock=true" + +      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + +    ulimits: + +      memlock: + +        soft: -1 + +        hard: -1 + +    volumes: + +      - elasticdata:/usr/share/elasticsearch/data + + + +  kibana: + +    image: docker.elastic.co/kibana/kibana-oss:6.2.2 + +    container_name: kibana + +    links: + +      - "elasticsearch" + +    ports: + +      - "5601:5601" + + + +volumes: + +  elasticdata: + +    driver: local + +``` + +Then you can bring all the containers up with one command: +``` +$ sudo docker-compose up + +``` + +And if you want to delete all the containers (except the volumes): +``` +$ sudo docker-compose rm + +``` + +With one simple YAML file, your proof of concept is ready to be deployed anywhere, with consistent results. When you have tested the solution thoroughly, don't forget to read the official [Elasticsearch][8], [Fluentd][9], and [Kibana][10] documentation to make your implementation production grade. + +As you play with the EFK (and Docker) you will recognize how practical it is, and your life as a sysadmin will never be the same. + +### Further reading + +[Install Elasticsearch with Docker][8] + +[Installing Fluentd with Docker][11] + +[Unified Logging Layer: Turning Data into Action][12] + +[Docker Compose][13] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/efk-creating-open-source-stack + +作者:[Michael Zamot][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/mzamot +[1]:https://www.elastic.co/ +[2]:https://www.fluentd.org/ +[3]:https://www.elastic.co/products/kibana +[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/efk_stack_illustration.png?itok=Z0RDEi8p (EFK stack illustration) +[6]:https://opensource.com/users/vbatts +[7]:https://opensource.com/business/14/7/guide-docker +[8]:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html +[9]:https://docs.fluentd.org/v1.0/articles/quickstart +[10]:https://www.elastic.co/guide/en/kibana/current/introduction.html +[11]:https://docs.fluentd.org/v0.12/articles/install-by-docker +[12]:https://www.fluentd.org/blog/unified-logging-layer +[13]:https://docs.docker.com/compose/ From 6f6a029f3d221297a6e6051b26d3fb5723be6a49 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:07:09 +0800 Subject: [PATCH 0186/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Loop=20better:?= =?UTF-8?q?=20A=20deeper=20look=20at=20iteration=20in=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...r- A deeper look at iteration in Python.md | 939 ++++++++++++++++++ 1 file changed, 939 insertions(+) create mode 100644 sources/tech/20180327 Loop better- A deeper look at iteration in Python.md diff --git a/sources/tech/20180327 Loop better- A deeper look at iteration in Python.md b/sources/tech/20180327 Loop better- A deeper look at iteration in Python.md new file mode 100644 index 0000000000..1d4d627a80 --- /dev/null +++ b/sources/tech/20180327 Loop better- A deeper look at iteration in Python.md @@ -0,0 +1,939 @@ +Loop better: A deeper look at iteration in Python +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pez-candy.png?itok=tRoOn_iy) +Python's `for` loops don't work the way `for` loops do in other languages. In this article we're going to dive into Python's `for` loops to take a look at how they work under the hood and why they work the way they do. + +### Looping gotchas + +We're going to start off our journey by taking a look at some "gotchas." After we've learned how looping works in Python, we'll take another look at these gotchas and explain what's going on. + +#### Gotcha 1: Looping twice + +Let's say we have a list of numbers and a generator that will give us the squares of those numbers: +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> squares = (n**2 for n in numbers) + +``` + +We can pass our generator object to the `tuple` constructor to make a tuple out of it: +``` +>>> tuple(squares) + +(1, 4, 9, 25, 49) + +``` + +If we then take the same generator object and pass it to the `sum` function, we might expect that we'd get the sum of these numbers, which would be 88. +``` +>>> sum(squares) + +0 + +``` + +Instead we get `0`. + +#### Gotcha 2: Containment checking + +Let's take the same list of numbers and the same generator object: +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> squares = (n**2 for n in numbers) + +``` + +If we ask whether `9` is in our `squares` generator, Python will tell us that 9 is in `squares`. But if we ask the same question again, Python will tell us that 9 is not in `squares`. +``` +>>> 9 in squares + +True + +>>> 9 in squares + +False + +``` + +We asked the same question twice and Python gave us two different answers. + +#### Gotcha 3: Unpacking + +This dictionary has two key-value pairs: +``` +>>> counts = {'apples': 2, 'oranges': 1} + +``` + +Let's unpack this dictionary using multiple assignment: +``` +>>> x, y = counts + +``` + +You might expect that when unpacking this dictionary, we'll get key-value pairs or maybe we'll get an error. + +But unpacking dictionaries doesn't raise errors and it doesn't return key-value pairs. When you unpack dictionaries you get keys: +``` +>>> x + +'apples' + +``` + +### Review: Python's _for_ loop + +We'll come back to these gotchas after we've learned a bit about the logic that powers these Python snippets. + +Python doesn't have traditional `for` loops. To explain what I mean, let's take a look at a `for` loop in another programming language. + +This is a traditional C-style `for` loop written in JavaScript: +``` +let numbers = [1, 2, 3, 5, 7]; + +for (let i = 0; i < numbers.length; i += 1) { + +    print(numbers[i]) + +} + +``` + +JavaScript, C, C++, Java, PHP, and a whole bunch of other programming languages all have this kind of `for` loop. But Python **does not**. + +Python **does not** have traditional C-style `for` loops. We do have something that we _call_ a `for` loop in Python, but it works like a [foreach loop][1]. + +This is Python's flavor of `for` loop: +``` +numbers = [1, 2, 3, 5, 7] + +for n in numbers: + +    print(n) + +``` + +Unlike traditional C-style `for` loops, Python's `for` loops don't have index variables. There's no index initializing, bounds checking, or index incrementing. Python's `for` loops do _all the work_ of looping over our `numbers` list for us. + +So while we do have `for` loops in Python, we do not have have traditional C-style `for` loops. The thing that _we_ call a for loop works very differently. + +### Definitions: Iterables and sequences + +Now that we've addressed the index-free `for` loop in our Python room, let's get some definitions out of the way. + +An **iterable** is anything you can loop over with a `for` loop in Python. Iterables can be looped over, and anything that can be looped over is an iterable. +``` +for item in some_iterable: + +    print(item) + +``` + +Sequences are a very common type of iterable. Lists, tuples, and strings are all sequences. +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> coordinates = (4, 5, 7) + +>>> words = "hello there" + +``` + +Sequences are iterables that have a specific set of features. They can be indexed starting from `0` and ending at one less than the length of the sequence, they have a length, and they can be sliced. Lists, tuples, strings, and all other sequences work this way. +``` +>>> numbers[0] + +1 + +>>> coordinates[2] + +7 + +>>> words[4] + +'o' + +``` + +Lots of things in Python are iterables, but not all iterables are sequences. Sets, dictionaries, files, and generators are all iterables but none of these things are sequences. +``` +>>> my_set = {1, 2, 3} + +>>> my_dict = {'k1': 'v1', 'k2': 'v2'} + +>>> my_file = open('some_file.txt') + +>>> squares = (n**2 for n in my_set) + +``` + +So anything that can be looped over with a `for` loop is an iterable, and sequences are one type of iterable, but Python has many other kinds of iterables as well. + +### Python's _for_ loops don't use indexes + +You might think that under the hood Python's `for` loops use indexes to loop. Here we're manually looping over an iterable using a `while` loop and indexes: +``` +numbers = [1, 2, 3, 5, 7] + +i = 0 + +while i < len(numbers): + +    print(numbers[i]) + +    i += 1 + +``` + +This works for lists, but it won't work everything. This way of looping **only works for sequences**. + +If we try to manually loop over a set using indexes, we'll get an error: +``` +>>> fruits = {'lemon', 'apple', 'orange', 'watermelon'} + +>>> i = 0 + +>>> while i < len(fruits): + +...     print(fruits[i]) + +...     i += 1 + +... + +Traceback (most recent call last): + +File "", line 2, in + +TypeError: 'set' object does not support indexing + +``` + +Sets are not sequences, so they don't support indexing. + +We cannot manually loop over every iterable in Python by using indexes. This simply won't work for iterables that aren't sequences. + +### Iterators power _for_ loops + +So we've seen that Python's `for` loops must not be using indexes under the hood. Instead, Python's `for` loops use **iterators**. + +Iterators are the things that power iterables. You can get an iterator from any iterable. And you can use an iterator to manually loop over the iterable it came from. + +Let's take a look at how that works. + +Here are three iterables: a set, a tuple, and a string. +``` +>>> numbers = {1, 2, 3, 5, 7} + +>>> coordinates = (4, 5, 7) + +>>> words = "hello there" + +``` + +We can ask each of these iterables for an iterator using Python's built-in `iter` function. Passing an iterable to the `iter` function will always give us back an iterator, no matter what type of iterable we're working with. +``` +>>> iter(numbers) + + + +>>> iter(coordinates) + + + +>>> iter(words) + + + +``` + +Once we have an iterator, the one thing we can do with it is get its next item by passing it to the built-in `next` function. +``` +>>> numbers = [1, 2, 3] + +>>> my_iterator = iter(numbers) + +>>> next(my_iterator) + +1 + +>>> next(my_iterator) + +2 + +``` + +Iterators are stateful, meaning once you've consumed an item from them, it's gone. + +If you ask for the `next` item from an iterator and there are no more items, you'll get a `StopIteration` exception: +``` +>>> next(my_iterator) + +3 + +>>> next(my_iterator) + +Traceback (most recent call last): + +  File "", line 1, in + +StopIteration + +``` + +So you can get an iterator from every iterable. The only thing you can do with iterators is ask them for their next item using the `next` function. And if you pass them to `next` but they don't have a next item, a `StopIteration` exception will be raised. + +You can think of iterators as Pez dispensers that cannot be reloaded. You can take Pez out, but once a Pez is removed it can't be put back, and once the dispenser is empty, it's useless. + +### Looping without a _for_ loop + +Now that we've learned about iterators and the `iter` and `next` functions, we'll try to manually loop over an iterable without using a `for` loop. + +We'll do so by attempting to turn this `for` loop into a `while` loop: +``` +def funky_for_loop(iterable, action_to_do): + +    for item in iterable: + +        action_to_do(item) + +``` + +To do this we'll: + + 1. Get an iterator from the given iterable + 2. Repeatedly get the next item from the iterator + 3. Execute the body of the `for` loop if we successfully got the next item + 4. Stop our loop if we got a `StopIteration` exception while getting the next item + + +``` +def funky_for_loop(iterable, action_to_do): + +    iterator = iter(iterable) + +    done_looping = False + +    while not done_looping: + +        try: + +            item = next(iterator) + +        except StopIteration: + +            done_looping = True + +        else: + +            action_to_do(item) + +``` + +We've just reinvented a `for` loop by using a `while` loop and iterators. + +The above code pretty much defines the way looping works under the hood in Python. If you understand the way the built-in `iter` and `next` functions work for looping over things, you understand how Python's `for` loops work. + +In fact you'll understand a little bit more than just how `for` loops work in Python. All forms of looping over iterables work this way. + +The **iterator protocol** is a fancy way of saying "how looping over iterables works in Python." It's essentially the definition of the way the `iter` and `next` functions work in Python. All forms of iteration in Python are powered by the iterator protocol. + +The iterator protocol is used by `for` loops (as we've already seen): +``` +for n in numbers: + +    print(n) + +``` + +Multiple assignment also uses the iterator protocol: +``` +x, y, z = coordinates + +``` + +Star expressions use the iterator protocol: +``` +a, b, *rest = numbers + +print(*numbers) + +``` + +And many built-in functions rely on the iterator protocol: +``` +unique_numbers = set(numbers) + +``` + +Anything in Python that works with an iterable probably uses the iterator protocol in some way. Anytime you're looping over an iterable in Python, you're relying on the iterator protocol. + +### Generators are iterators + +So you might be thinking: Iterators seem cool, but they also just seem like an implementation detail and we, as users of Python, might not need to care about them. + +I have news for you: It's very common to work directly with iterators in Python. + +The `squares` object here is a generator: +``` +>>> numbers = [1, 2, 3] + +>>> squares = (n**2 for n in numbers) + +``` + +And generators are iterators, meaning you can call `next` on a generator to get its next item: +``` +>>> next(squares) + +1 + +>>> next(squares) + +4 + +``` + +But if you've ever used a generator before, you probably know that you can also loop over generators: +``` +>>> squares = (n**2 for n in numbers) + +>>> for n in squares: + +...     print(n) + +... + +1 + +4 + +9 + +``` + +If you can loop over something in Python, it's an **iterable**. + +So **generators are iterators** , but generators are also iterables. What's going on here? + +### I lied to you + +So when I explained how iterators worked earlier, I skipped over an important detail about them. + +**Iterators are iterables.** + +I'll say that again: Every iterator in Python is also an iterable, which means you can loop over iterators. + +Because iterators are also iterables, you can get an iterator from an iterator using the built-in `iter` function: +``` +>>> numbers = [1, 2, 3] + +>>> iterator1 = iter(numbers) + +>>> iterator2 = iter(iterator1) + +``` + +Remember that iterables give us iterators when we call `iter` on them. + +When we call `iter` on an iterator it will always give us itself back: +``` +>>> iterator1 is iterator2 + +True + +``` + +Iterators are iterables and all iterators are their own iterators. +``` +def is_iterator(iterable): + +    return iter(iterable) is iterable + +``` + +Confused yet? + +Let's recap these terms. + + * An iter **able** is something you're able to iterate over + * An iter **ator** is the agent that actually does the iterating over an iterable + + + +Additionally, in Python iterators are also iterables and they act as their own iterators. + +So iterators are iterables, but they don't have the variety of features that some iterables have. + +Iterators have no length and they can't be indexed: +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> iterator = iter(numbers) + +>>> len(iterator) + +TypeError: object of type 'list_iterator' has no len() + +>>> iterator[0] + +TypeError: 'list_iterator' object is not subscriptable + +``` + +From our perspective as Python programmers, the only useful things you can do with an iterator are to pass it to the built-in `next` function or to loop over it: +``` +>>> next(iterator) + +1 + +>>> list(iterator) + +[2, 3, 5, 7] + +``` + +And if we loop over an iterator a second time, we'll get nothing back: +``` +>>> list(iterator) + +[] + +``` + +You can think of iterators as **lazy iterables** that are **single-use** , meaning they can be looped over one time only. + +As you can see in the truth table below, iterables are not always iterators but iterators are always iterables: + +Object Iterable? Iterator? Iterable ✔️ ❓ Iterator ✔️ ✔️ Generator ✔️ ✔️ List ✔️ ❌ + +### The iterator protocol in full + +Let's define how iterators work from Python's perspective. + +Iterables can be passed to the `iter` function to get an iterator for them. + +Iterators: + + * Can be passed to the `next` function, which will give their next item or raise a `StopIteration` exception if there are no more items + * Can be passed to the `iter` function and will return themselves back + + + +The inverse of these statements also holds true: + + * Anything that can be passed to `iter` without a `TypeError` is an iterable + * Anything that can be passed to `next` without a `TypeError` is an iterator + * Anything that returns itself when passed to `iter` is an iterator + + + +That's the iterator protocol in Python. + +### Iterators enable laziness + +Iterators allow us to both work with and create **lazy iterables** that don't do any work until we ask them for their next item. Because we can create lazy iterables, we can make infinitely long iterables. And we can create iterables that are conservative with system resources, can save us memory, and can save us CPU time. + +### Iterators are everywhere + +You've already seen lots of iterators in Python. I've already mentioned that generators are iterators. Many of Python's built-in classes are iterators also. For example Python's `enumerate` and `reversed` objects are iterators. +``` +>>> letters = ['a', 'b', 'c'] + +>>> e = enumerate(letters) + +>>> e + + + +>>> next(e) + +(0, 'a') + +``` + +In Python 3, `zip`, `map`, and `filter` objects are iterators too. +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> letters = ['a', 'b', 'c'] + +>>> z = zip(numbers, letters) + +>>> z + + + +>>> next(z) + +(1, 'a') + +``` + +And file objects in Python are iterators also. +``` +>>> next(open('hello.txt')) + +'hello world\n' + +``` + +There are lots of iterators built into Python, in the standard library, and in third-party Python libraries. These iterators all act like lazy iterables by delaying work until the moment you ask them for their next item. + +### Creating your own iterator + +It's useful to know that you're already using iterators, but I'd like you to also know that you can create your own iterators and your own lazy iterables. + +This class makes an iterator that accepts an iterable of numbers and provides squares of each of the numbers as it's looped over. +``` +class square_all: + +    def __init__(self, numbers): + +        self.numbers = iter(numbers) + +    def __next__(self): + +        return next(self.numbers) * 2 + +    def __iter__(self): + +        return self + +``` + +But no work will be done until we start looping over an instance of this class. + +Here we have an infinitely long iterable `count` and you can see that `square_all` accepts `count` without fully looping over this infinitely long iterable: +``` +>>> from itertools import count + +>>> numbers = count(5) + +>>> squares = square_all(numbers) + +>>> next(squares) + +25 + +>>> next(squares) + +36 + +``` + +This iterator class works, but we don't usually make iterators this way. Usually when we want to make a custom iterator, we make a generator function: +``` +def square_all(numbers): + +    for n in numbers: + +        yield n**2 + +``` + +This generator function is equivalent to the class we made above, and it works essentially the same way. + +That `yield` statement probably seems magical, but it is very powerful: `yield` allows us to put our generator function on pause between calls from the `next` function. The `yield` statement is the thing that separates generator functions from regular functions. + +Another way we could implement this same iterator is with a generator expression. +``` +def square_all(numbers): + +    return (n**2 for n in numbers) + +``` + +This does the same thing as our generator function, but it uses a syntax that looks [like a list comprehension][2]. If you need to make a lazy iterable in your code, think of iterators and consider making a generator function or a generator expression. + +### How iterators can improve your code + +Once you've embraced the idea of using lazy iterables in your code, you'll find that there are lots of possibilities for discovering or creating helper functions that assist you in looping over iterables and processing data. + +#### Laziness and summing + +This is a `for` loop that sums up all billable hours in a Django queryset: +``` +hours_worked = 0 + +for event in events: + +    if event.is_billable(): + +        hours_worked += event.duration + +``` + +Here is code that does the same thing by using a generator expression for lazy evaluation: +``` +billable_times = ( + +    event.duration + +    for event in events + +    if event.is_billable() + +) + + + +hours_worked = sum(billable_times) + +``` + +Notice that the shape of our code has changed dramatically. + +Turning our billable times into a lazy iterable has allowed us to name something (`billable_times`) that was previously unnamed. This has also allowed us to use the `sum` function. We couldn't have used `sum` before because we didn't even have an iterable to pass to it. Iterators allow you to fundamentally change the way you structure your code. + +#### Laziness and breaking out of loops + +This code prints out the first 10 lines of a log file: +``` +for i, line in enumerate(log_file): + +    if i >= 10: + +        break + +    print(line) + +``` + +This code does the same thing, but we're using the `itertools.islice` function to lazily grab the first 10 lines of our file as we loop: +``` +from itertools import islice + + + +first_ten_lines = islice(log_file, 10) + +for line in first_ten_lines: + +    print(line) + +``` + +The `first_ten_lines` variable we've made is an iterator. Again, using an iterator allowed us to give a name to something (`first_ten_lines`) that was previously unnamed. Naming things can make our code more descriptive and more readable. + +As a bonus, we also removed the need for a `break` statement in our loop because the `islice` utility handles the breaking for us. + +You can find many more iteration helper functions in [itertools][3] in the standard library as well as in third-party libraries such as [boltons][4] and [more-itertools][5]. + +#### Creating your own iteration helpers + +You can find helper functions for looping in the standard library and in third-party libraries, but you can also make your own! + +This code makes a list of the differences between consecutive values in a sequence. +``` +current = readings[0] + +for next_item in readings[1:]: + +    differences.append(next_item - current) + +    current = next_item + +``` + +Notice that this code has an extra variable that we need to assign each time we loop. Also note that this code works only with things we can slice, like sequences. If `readings` were a generator, a zip object, or any other type of iterator, this code would fail. + +Let's write a helper function to fix our code. + +This is a generator function that gives us the current item and the item following it for every item in a given iterable: +``` +def with_next(iterable): + +    """Yield (current, next_item) tuples for each item in iterable.""" + +    iterator = iter(iterable) + +    current = next(iterator) + +    for next_item in iterator: + +        yield current, next_item + +        current = next_item + +``` + +We're manually getting an iterator from our iterable, calling `next` on it to grab the first item, then looping over our iterator to get all subsequent items, keeping track of our last item along the way. This function works not just with sequences, but with any type of iterable. + +This is the same code as before, but we're using our helper function instead of manually keeping track of `next_item`: +``` +differences = [] + +for current, next_item in with_next(readings): + +    differences.append(next_item - current) + +``` + +Notice that this code doesn't have awkward assignments to `next_item` hanging around our loop. The `with_next` generator function handles the work of keeping track of `next_item` for us. + +Also note that this code has been compacted enough that we could even [copy-paste our way into a list comprehension][2] if we wanted to. +``` +differences = [ + +    (next_item - current) + +    for current, next_item in with_next(readings) + +] + +``` + +### Looping gotchas revisited + +Now we're ready to jump back to those odd examples we saw earlier and try to figure out what was going on. + +#### Gotcha 1: Exhausting an iterator + +Here we have a generator object, `squares`: +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> squares = (n**2 for n in numbers) + +``` + +If we pass this generator to the `tuple` constructor, we'll get a tuple of its items back: +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> squares = (n**2 for n in numbers) + +>>> tuple(squares) + +(1, 4, 9, 25, 49) + +``` + +If we then try to compute the `sum` of the numbers in this generator, we'll get `0`: +``` +>>> sum(squares) + +0 + +``` + +This generator is now empty: we've exhausted it. If we try to make a tuple out of it again, we'll get an empty tuple: +``` +>>> tuple(squares) + +() + +``` + +Generators are iterators. And iterators are single-use iterables. They're like Hello Kitty Pez dispensers that cannot be reloaded. + +#### Gotcha 2: Partially consuming an iterator + +Again we have a generator object, `squares`: +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> squares = (n**2 for n in numbers) + +``` + +If we ask whether `9` is in this `squares` generator, we'll get `True`: +``` +>>> 9 in squares + +True + +``` + +But if we ask the same question again, we'll get `False`: +``` +>>> 9 in squares + +False + +``` + +When we ask whether `9` is in this generator, Python has to loop over this generator to find `9`. If we kept looping over it after checking for `9`, we'll only get the last two numbers because we've already consumed the numbers before this point: +``` +>>> numbers = [1, 2, 3, 5, 7] + +>>> squares = (n**2 for n in numbers) + +>>> 9 in squares + +True + +>>> list(squares) + +[25, 49] + +``` + +Asking whether something is contained in an iterator will partially consume the iterator. There is no way to know whether something is in an iterator without starting to loop over it. + +#### Gotcha 3: Unpacking is iteration + +When you loop over dictionaries you get keys: +``` +>>> counts = {'apples': 2, 'oranges': 1} + +>>> for key in counts: + +...     print(key) + +... + +apples + +oranges + +``` + +You also get keys when you unpack a dictionary: +``` +>>> x, y = counts + +>>> x, y + +('apples', 'oranges') + +``` + +Looping relies on the iterator protocol. Iterable unpacking also relies on the iterator protocol. Unpacking a dictionary is really the same as looping over the dictionary. Both use the iterator protocol, so you get the same result in both cases. + +### Recap and related resources + +Sequences are iterables, but not all iterables are sequences. When someone says the word "iterable," you can only assume they mean "something that you can iterate over." Don't assume iterables can be looped over twice, asked for their length, or indexed. + +Iterators are the most rudimentary form of iterables in Python. If you'd like to make a lazy iterable in your code, think of iterators and consider making a generator function or a generator expression. + +And finally, remember that every type of iteration in Python relies on the iterator protocol, so understanding the iterator protocol is the key to understanding quite a bit about looping in Python in general. + +Here are related articles and videos I recommend: + +This article is based on the Loop Better talk the author gave last year at [DjangoCon AU][6], [PyGotham][7], and [North Bay Python][8]. For more content like this, attend [PYCON][9], which will be held May 9-17, 2018, in Columbus, Ohio. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/loop-better-deeper-look-iteration-python + +作者:[Trey Hunner][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/treyhunner +[1]:https://en.wikipedia.org/wiki/Foreach_loop +[2]:http://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/ +[3]:https://docs.python.org/3/library/itertools.html +[4]:https://boltons.readthedocs.io +[5]:https://more-itertools.readthedocs.io +[6]:https://www.youtube.com/watch?v=JYuE8ZiDPl4 +[7]:https://www.youtube.com/watch?v=Wd7vcuiMhxU +[8]:https://www.youtube.com/watch?v=V2PkkMS2Ack +[9]:https://us.pycon.org/2018/ From 173bb8530b4fdffcf6e88275f4d08b8dd1ea8fa1 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:09:44 +0800 Subject: [PATCH 0187/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Start=20a=20blo?= =?UTF-8?q?g=20in=2030=20minutes=20with=20Hugo,=20a=20static=20site=20gene?= =?UTF-8?q?rator=20written=20in=20Go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..., a static site generator written in Go.md | 191 ++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md diff --git a/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md new file mode 100644 index 0000000000..465941491c --- /dev/null +++ b/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md @@ -0,0 +1,191 @@ +Start a blog in 30 minutes with Hugo, a static site generator written in Go +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) +Do you want to start a blog to share your latest adventures with various software frameworks? Do you love a project that is poorly documented and want to fix that? Or do you just want to create a personal website? + +Many people who want to start a blog have a significant caveat: lack of knowledge about a content management system (CMS) or time to learn. Well, what if I said you don't need to spend days learning a new CMS, setting up a basic website, styling it, and hardening it against attackers? What if I said you could create a blog in 30 minutes, start to finish, with [Hugo][1]? + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_1.png?itok=JgxBSOBG) + +Hugo is a static site generator written in Go. Why use Hugo, you ask? + + * Because there is no database, no plugins requiring any permissions, and no underlying platform running on your server, there's no added security concern. + * The blog is a set of static websites, which means lightning-fast serve time. Additionally, all pages are rendered at deploy time, so your server's load is minimal. + * Version control is easy. Some CMS platforms use their own version control system (VCS) or integrate Git into their interface. With Hugo, all your source files can live natively on the VCS of your choice. + + + +### Minutes 0-5: Download Hugo and generate a site + +To put it bluntly, Hugo is here to make writing a website fun again. Let's time the 30 minutes, shall we? + +To simplify the installation of Hugo, download the binary file. To do so: + + 1. Download the appropriate [archive][2] for your operating system. + + 2. Unzip the archive into a directory of your choice, for example `C:\hugo_dir` or `~/hugo_dir`; this path will be referred to as `${HUGO_HOME}`. + + 3. Open the command line and change into your directory: `cd ${HUGO_HOME}`. + + 4. Verify that Hugo is working: + + * On Unix: `${HUGO_HOME}/[hugo version]` + * On Windows: `${HUGO_HOME}\[hugo.exe version]` +For example, `c:\hugo_dir\hugo version`. + +For simplicity, I'll refer to the path to the Hugo binary (including the binary) as `hugo`. For example, `hugo version` would translate to `C:\hugo_dir\hugo version` on your computer. + +If you get an error message, you may have downloaded the wrong version. Also note there are many possible ways to install Hugo. See the [official documentation][3] for more information. Ideally, you put the Hugo binary on PATH. For this quick start, it's fine to use the full path of the Hugo binary. + + + + 5. Create a new site that will become your blog: `hugo new site awesome-blog`. + 6. Change into the newly created directory: `cd awesome-blog`. + + + +Congratulations! You have just created your new blog. + +### Minutes 5-10: Theme your blog + +With Hugo, you can either theme your blog yourself or use one of the beautiful, ready-made [themes][4]. I chose [Kiera][5] because it is deliciously simple. To install the theme: + + 1. Change into the themes directory: `cd themes`. + 2. Clone your theme: `git clone https://github.com/avianto/hugo-kiera kiera`. If you do not have Git installed: + * Download the .zip file from [GitHub][5]. + * Unzip it to your site's `themes` directory. + * Rename the directory from `hugo-kiera-master` to `kiera`. + 3. Change the directory to the awesome-blog level: `cd awesome-blog`. + 4. Activate the theme. Themes (including Kiera) often come with a directory called `exampleSite`, which contains example content and an example settings file. To activate Kiera, copy the provided `config.toml` file to your blog: + * On Unix: `cp themes/kiera/exampleSite/config.toml .` + * On Windows: `copy themes\kiera\exampleSite\config.toml .` + * Confirm `Yes` to override the old `config.toml` + 5. (Optional) You can start your server to visually verify the theme is activated: `hugo server -D` and access `http://localhost:1313` in your web browser. Once you've reviewed your blog, you can turn off the server by pressing `Ctrl+C` in the command line. Your blog is empty, but we're getting someplace. It should look something like this: + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_2.png?itok=PINOIOSU) + +You have just themed your blog! You can find hundreds of beautiful themes on the official [Hugo themes][4] site. + +### Minutes 10-20: Add content to your blog + +Whereas a bowl is most useful when it is empty, this is not the case for a blog. In this step, you'll add content to your blog. Hugo and the Kiera theme simplify this process. To add your first post: + + 1. Article archetypes are templates for your content. + 2. Add theme archetypes to your blog site: + * On Unix: `cp themes/kiera/archetypes/* archetypes/` + * On Windows: `copy themes\kiera\archetypes\* archetypes\` + * Confirm `Yes` to override the `default.md` archetype + 3. Create a new directory for your blog posts: + * On Unix: `mkdir content/posts` + * On Windows: `mkdir content\posts` + 4. Use Hugo to generate your post: + * On Unix: `hugo new posts/first-post.md` + * On Windows: `hugo new posts\first-post.md` + 5. Open the new post in a text editor of your choice: + * On Unix: `gedit content/posts/first-post.md` + * On Windows: `notepad content\posts\first-post.md` + + + +At this point, you can go wild. Notice that your post consists of two sections. The first one is separated by `+++`. It contains metadata about your post, such as its title. In Hugo, this is called front matter. After the front matter, the article begins. Create the first post: +``` ++++ + +title = "First Post" + +date = 2018-03-03T13:23:10+01:00 + +draft = false + +tags = ["Getting started"] + +categories = [] + ++++ + + + +Hello Hugo world! No more excuses for having no blog or documentation now! + +``` + +All you need to do now is start the server: `hugo server -D`. Open your browser and enter: `http://localhost:1313/`. +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_3.png?itok=I-_v0qLx) + +### Minutes 20-30: Tweak your site + +What we've done is great, but there are still a few niggles to iron out. For example, naming your site is simple: + + 1. Stop your server by pressing `Ctrl+C` on the command line. + 2. Open `config.toml` and edit settings such as the blog's title, copyright, name, your social network links, etc. + + + +When you start your server again, you'll see your blog has a bit more personalization. One more basic thing is missing: menus. That's a quick fix as well. Back in `config.toml`, insert the following at the bottom: +``` +[[menu.main]] + +    name = "Home" #Name in the navigation bar + +    weight = 10 #The larger the weight, the more on the right this item will be + +    url = "/" #URL address + +[[menu.main]] + +    name = "Posts" + +    weight = 20 + +    url = "/posts/" + +``` + +This adds menus for Home and Posts. You still need an About page. Instead of referencing it from the `config.toml` file, reference it from a markdown file: + + 1. Create an About file: `hugo new about.md`. Notice that it's `about.md`, not `posts/about.md`. The About page is not a blog post, so you don't want it displayed in the Posts section. + 2. Open the file in a text editor and enter the following: + + +``` ++++ + +title = "About" + +date = 2018-03-03T13:50:49+01:00 + +menu = "main" #Display this page on the nav menu + +weight = "30" #Right-most nav item + +meta = "false" #Do not display tags or categories + ++++ + + + +> Waves are the practice of the water. Shunryu Suzuki + +``` + +When you start your Hugo server and open `http://localhost:1313/`, you should see your new blog ready to be used. (Check out [my example][6] on my GitHub page.) If you'd like to change the active style of menu items to make the padding slightly nicer (like the GitHub live version), apply [this patch][7] to your `themes/kiera/static/css/styles.css` file. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/start-blog-30-minutes-hugo + +作者:[Marek Czernek][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/mczernek +[1]:https://gohugo.io/ +[2]:https://github.com/gohugoio/hugo/releases +[3]:https://gohugo.io/getting-started/installing/ +[4]:https://themes.gohugo.io/ +[5]:https://github.com/avianto/hugo-kiera +[6]:https://m-czernek.github.io/awesome-blog/ +[7]:https://github.com/avianto/hugo-kiera/pull/18/files From 67fa4f9317765ce9b99e2c18efad44c5ba3fbaa1 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:19:41 +0800 Subject: [PATCH 0188/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20ddgr=20?= =?UTF-8?q?=E2=80=93=20A=20Command=20Line=20Tool=20To=20Search=20DuckDuckG?= =?UTF-8?q?o=20From=20The=20Terminal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... To Search DuckDuckGo From The Terminal.md | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 sources/tech/20180312 ddgr - A Command Line Tool To Search DuckDuckGo From The Terminal.md diff --git a/sources/tech/20180312 ddgr - A Command Line Tool To Search DuckDuckGo From The Terminal.md b/sources/tech/20180312 ddgr - A Command Line Tool To Search DuckDuckGo From The Terminal.md new file mode 100644 index 0000000000..555a475651 --- /dev/null +++ b/sources/tech/20180312 ddgr - A Command Line Tool To Search DuckDuckGo From The Terminal.md @@ -0,0 +1,231 @@ +ddgr – A Command Line Tool To Search DuckDuckGo From The Terminal +====== +Bash tricks are really awesome in Linux that makes everything is possible in Linux. + +It really works well for developers or system admins because they are spending most of the time with terminal. Did you know why they are preferring this tricks? + +These trick will improve their productivity and also make them to work fast. + +### What Is ddgr + +[ddgr][1] is a command-line utility to search DuckDuckGo from the terminal. ddgr works out of the box with several text-based browsers if the BROWSER environment variable is set. + +Make sure your system should have installed any text-based browsers. You may know about [googler][2] that allow users to perform Google searches from the Linux command line. + +It’s highly popular among cmdline users and they are expect the similar utility for privacy-aware DuckDuckGo, that’s why ddgr came to picture. + +Unlike the web interface, you can specify the number of search results you would like to see per page. + +**Suggested Read :** +**(#)** [Googler – Google Search From The Linux Command Line][2] +**(#)** [Buku – A Powerful Command-line Bookmark Manager for Linux][3] +**(#)** [SoCLI – Easy Way To Search And Browse Stack Overflow From The Terminal][4] +**(#)** [RTV (Reddit Terminal Viewer) – A Simple Terminal Viewer For Reddit][5] + +### What Is DuckDuckGo + +DDG stands for DuckDuckGo. DuckDuckGo (DDG) is an Internet search engine that really protecting users search and privacy. + +They didn’t filter users personalized search results and It’s showing the same search results to all users for a given search term. + +Most of the users prefer google search engine, if you really worrying about privacy then you can blindly go with DuckDuckGo. + +### ddgr Features + + * Fast and clean (no ads, stray URLs or clutter), custom color + * Designed to deliver maximum readability at minimum space + * Specify the number of search results to show per page + * Navigate result pages from omniprompt, open URLs in browser + * Search and option completion scripts for Bash, Zsh and Fish + * DuckDuckGo Bang support (along with completion) + * Open the first result directly in browser (as in I’m Feeling Ducky) + * Non-stop searches: fire new searches at omniprompt without exiting + * Keywords (e.g. filetype:mime, site:somesite.com) support + * Limit search by time, specify region, disable safe search + * HTTPS proxy support, Do Not Track set, optionally disable User Agent + * Support custom url handler script or cmdline utility + * Comprehensive documentation, man page with handy usage examples + * Minimal dependencies + + + +### Prerequisites + +ddgr requires Python 3.4 or later. So, make sure you system should have Python 3.4 or later version. +``` +$ python3 --version +Python 3.6.3 + +``` + +### How To Install ddgr In Linux + +We can easily install ddgr using the following command based on the distributions. + +For **`Fedora`** , use [DNF Command][6] to install ddgr. +``` +# dnf install ddgr + +``` + +Alternatively we can use [SNAP Command][7] to install ddgr. +``` +# snap install ddgr + +``` + +For **`LinuxMint/Ubuntu`** , use [APT-GET Command][8] or [APT Command][9] to install ddgr. +``` +$ sudo add-apt-repository ppa:twodopeshaggy/jarun +$ sudo apt-get update +$ sudo apt-get install ddgr + +``` + +For **`Arch Linux`** based systems, use [Yaourt Command][10] or [Packer Command][11] to install ddgr from AUR repository. +``` +$ yaourt -S ddgr +or +$ packer -S ddgr + +``` + +For **`Debian`** , use [DPKG Command][12] to install ddgr. +``` +# wget https://github.com/jarun/ddgr/releases/download/v1.2/ddgr_1.2-1_debian9.amd64.deb +# dpkg -i ddgr_1.2-1_debian9.amd64.deb + +``` + +For **`CentOS 7`** , use [YUM Command][13] to install ddgr. +``` +# yum install https://github.com/jarun/ddgr/releases/download/v1.2/ddgr-1.2-1.el7.3.centos.x86_64.rpm + +``` + +For **`opensuse`** , use [zypper Command][14] to install ddgr. +``` +# zypper install https://github.com/jarun/ddgr/releases/download/v1.2/ddgr-1.2-1.opensuse42.3.x86_64.rpm + +``` + +### How To Launch ddgr + +Enter the `ddgr` command without any option on terminal to bring DuckDuckGo search. You will get the same output similar to below. +``` +$ ddgr + +``` + +![][16] + +### How To Search Using ddgr + +We can initiate the search through two ways. Either from omniprompt or directly from terminal. You can search any phrases which you want. + +Directly from terminal. +``` +$ ddgr 2daygeek + +``` + +![][17] + +From `omniprompt`. +![][18] + +### Omniprompt Shortcut + +Enter `?` to obtain the `omniprompt`, which will show you list of keywords and shortcut to work further with ddgr. +![][19] + +### How To Move Next,Previous, and Fist Page + +It allows user to move next page or previous page or first page. + + * `n:` Move to next set of search results + * `p:` Move to previous set of search results + * `f:` Jump to the first page + + + +![][20] + +### How To Initiate A New Search + +“ **d** ” option allow users to initiate a new search from omniprompt. For example, i searched about `2daygeek website` and now i’m going to initiate a new search with phrase “ **Magesh Maruthamuthu** “. + +From `omniprompt`. +``` +ddgr (? for help) d magesh maruthmuthu + +``` + +![][21] + +### Show Complete URLs In Search Result + +By default it shows only an article heading, add the “ **x** ” option in search to show complete article urls in search result. +``` +$ ddgr -n 5 -x 2daygeek + +``` + +![][22] + +### Limit Search Results + +By default search results shows 10 results per page. If you want to limit the page results for your convenience, you can do by passing `--num or -n` argument with ddgr. +``` +$ ddgr -n 5 2daygeek + +``` + +![][23] + +### Website Specific Search + +To search specific pages from the particular website, use the below format. This will fetch the results for given keywords from the website. For example, We are going search about “ **Package Manager** ” from 2daygeek website. See the results. +``` +$ ddgr -n 5 --site 2daygeek "package manager" + +``` + +![][24] + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/ddgr-duckduckgo-search-from-the-command-line-in-linux/ + +作者:[Magesh Maruthamuthu][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://www.2daygeek.com/author/magesh/ +[1]:https://github.com/jarun/ddgr +[2]:https://www.2daygeek.com/googler-google-search-from-the-command-line-on-linux/ +[3]:https://www.2daygeek.com/buku-command-line-bookmark-manager-linux/ +[4]:https://www.2daygeek.com/socli-search-and-browse-stack-overflow-from-linux-terminal/ +[5]:https://www.2daygeek.com/rtv-reddit-terminal-viewer-a-simple-terminal-viewer-for-reddit/ +[6]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[7]:https://www.2daygeek.com/snap-command-examples/ +[8]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[9]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[10]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ +[11]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ +[12]:https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/ +[13]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[14]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[15]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[16]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux1.png +[17]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-3.png +[18]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-2.png +[19]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-4.png +[20]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-5a.png +[21]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-6a.png +[22]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-7a.png +[23]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-8.png +[24]:https://www.2daygeek.com/wp-content/uploads/2018/03/ddgr-duckduckgo-command-line-search-for-linux-9a.png From d9b7013a095857088700d542374a7ca70b8e6a6a Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:21:22 +0800 Subject: [PATCH 0189/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Transfer=20File?= =?UTF-8?q?s=20From=20Computer=20To=20Mobile=20Devices=20By=20Scanning=20Q?= =?UTF-8?q?R=20Codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... To Mobile Devices By Scanning QR Codes.md | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md diff --git a/sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md b/sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md new file mode 100644 index 0000000000..2e00904282 --- /dev/null +++ b/sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md @@ -0,0 +1,133 @@ +Transfer Files From Computer To Mobile Devices By Scanning QR Codes +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-720x340.png) +Transferring files from a Computer to a smartphone is not a big deal. You can do this by mounting the mobile phone on your system using an USB cable, then transfer files from the file manager. Also, some third party applications, such as [**KDE Connect**][1] and [**AirDroid**][2], can help you to easily manage and transfer files from your system to Android devices. Today, I stumbled upon a super cool utility named **“Qr-filetransfer”**. It allows you to transfer files over WiFi from computer to mobile devices by scanning QR codes without leaving your Terminal. Yes, you read that right! The qr-filetransfer is a free, open source command line utility written using Go programming language. In this brief tutorial, we are going to learn to transfer files from Linux to any mobile devices using qr-transfer. + +### Installing Qr-filetransfer + +First, install Go language on your system. + +On Arch Linux and derivatives: +``` +$ sudo pacman -S go + +``` + +On RPM based systems like RHEL, CentOS, Fedora, run: +``` +$ sudo yum install golang + +``` + +Or, +``` +$ sudo dnf install golang + +``` + +On DEB based systems such as Debian, Ubuntu, Linux Mint, you can install it using command: +``` +$ sudo apt-get install golang + +``` + +On SUSE/openSUSE: +``` +$ sudo zypper install golang + +``` + +After installing Go language, run the following command to download qr-filetransfer application. +``` +$ go get github.com/claudiodangelis/qr-filetransfer + +``` + +The above command will download the contents of a qr-filetrnasfer GitHub repository in a directory named **“go”** in your current working directory. + +Copy the qt-filetransfer binary file to your PATH, for example /usr/local/bin/. +``` +$ sudo cp go/bin/qr-filetransfer /usr/local/bin/ + +``` + +Finally, make it executable as shown below. +``` +$ sudo chmod +x /usr/local/bin/qr-filetransfer + +``` + +### Transfer Files From Computer To Mobile Devices By Scanning QR Codes + +Make sure that your smartphone is connected to the same WiFi network as your computer. + +Then, launch qt-filetransfer tool along the with the file or folder path you want to transfer to your smartphone. + +For example, I am going to transfer a mp3 file. +``` +$ qr-filetransfer Chill\ Study\ Beats.mp3 + +``` + +At first launch, qr-filetransfer will ask you to choose the network interface to use like below. +``` +Choose the network interface to use (type the number): +[0] enp5s0 +[1] wlp9s0 + +``` + +I was going to transfer file using **wlp9s0** interface, so I typed “1”. Qr-filetransfer will remember this choice and you will never be prompted again, unless you pass the **-force** argument, or delete the **.qr-filetransfer.json** file that the program stores in the home directory of current user. + +Then, you will see the QR code as shown in the below picture. + +![][4] + +Open the QR code app (if it is not installed already, install any QR code reader app from play store) and scan the QR code displayed in your terminal. + +Once the QR code is read, you will be asked whether you want to copy the link or open the link. You can either copy the link and paste it manually on your mobile web browser or choose “Open link” to automatically open it in your mobile browser. + +![][5] + +Once the share link has been opened, the file will be downloaded in your smartphone. + +![][6] + +If the file is too big, zip the file, then transfer it +``` +$ qr-filetransfer -zip /path/to/file.txt + +``` + +To transfer a full directory, run: +``` +$ qr-filetransfer /path/to/directory + +``` + +Please note that the directory gets zipped before being transferred. + +Qr-filetransfer utility will only transfer the stuffs from your system to mobile and not vice versa. This project is very new, so there will be bugs. If you encountered any bugs, report them in the GitHub page given at the end of this guide. + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/transfer-files-from-computer-to-mobile-devices-by-scanning-qr-codes/ + +作者:[SK][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://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/kde-connect-access-files-notifications-android-devices/ +[2]:https://www.ostechnix.com/airdroid-share-files-and-folders-between-linux-and-android/ +[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-5.png +[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-6-4.png +[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-4.png From 6d19f640fdb2d90403fdb42ae8cc3ed48a1e14fb Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:24:18 +0800 Subject: [PATCH 0190/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Comp?= =?UTF-8?q?ress=20And=20Decompress=20Files=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Compress And Decompress Files In Linux.md | 210 ++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 sources/tech/20180324 How To Compress And Decompress Files In Linux.md diff --git a/sources/tech/20180324 How To Compress And Decompress Files In Linux.md b/sources/tech/20180324 How To Compress And Decompress Files In Linux.md new file mode 100644 index 0000000000..8766b9e39b --- /dev/null +++ b/sources/tech/20180324 How To Compress And Decompress Files In Linux.md @@ -0,0 +1,210 @@ +How To Compress And Decompress Files In Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/compress-720x340.jpg) +Compressing is quite useful when backing up important files and also sending large files over Internet. Please note that compressing an already compressed file adds extra overhead, hence you will get a slightly bigger file. So, stop compressing a compressed file. There are many programs to compress and decompress files in GNU/Linux. In this tutorial, we’re going to learn about two applications only. + +### Compress and decompress files + +The most common programs used to compress files in Unix-like systems are: + + 1. gzip + 2. bzip2 + + + +##### 1\. Compress and decompress files using Gzip program + +The gzip is an utility to compress and decompress files using Lempel-Ziv coding (LZ77) algorithm. + +**1.1 Compress files** + +To compress a file named **ostechnix.txt** , replacing it with a gzipped compressed version, run: +``` +$ gzip ostechnix.txt + +``` + +Gzip will replace the original file **ostechnix.txt** with a gzipped compressed version named **ostechnix.txt.gz**. + +The gzip command can also be used in other ways too. One fine example is we can create a compressed version of a specific command’s output. Look at the following command. +``` +$ ls -l Downloads/ | gzip > ostechnix.txt.gz + +``` + +The above command creates compressed version of the directory listing of Downloads folder. + +**1.2 Compress files and write the output to different files (Don’t replace the original file) +** + +By default, gzip program will compress the given file, replacing it with a gzipped compressed version. You can, however, keep the original file and write the output to standard output. For example, the following command, compresses **ostechnix.txt** and writes the output to **output.txt.gz**. +``` +$ gzip -c ostechnix.txt > output.txt.gz + +``` + +Similarly, to decompress a gzipped file specifying the output filename: +``` +$ gzip -c -d output.txt.gz > ostechnix1.txt + +``` + +The above command decompresses the **output.txt.gz** file and writes the output to **ostechnix1.txt** file. In both cases, it won’t delete the original file. + +**1.3 Decompress files** + +To decompress the file **ostechnix.txt.gz** , replacing it with the original uncompressed version, we do: +``` +$ gzip -d ostechnix.txt.gz + +``` + +We can also use gunzip to decompress the files. +``` +$ gunzip ostechnix.txt.gz + +``` + +**1.4 View contents of compressed files without decompressing them** + +To view the contents of the compressed file using gzip without decompressing it, use **-c** flag as shown below: +``` +$ gunzip -c ostechnix1.txt.gz + +``` + +Alternatively, use **zcat** utility like below. +``` +$ zcat ostechnix.txt.gz + +``` + +You can also pipe the output to “less” command to view the output page by page like below. +``` +$ gunzip -c ostechnix1.txt.gz | less + +$ zcat ostechnix.txt.gz | less + +``` + +Alternatively, there is a **zless** program which performs the same function as the pipeline above. +``` +$ zless ostechnix1.txt.gz + +``` + +**1.5 Compress file with gzip by specifying compression level** + +Another notable advantage of gzip is it supports compression level. It supports 3 compression levels as given below. + + * **1** – Fastest (Worst) + * **9** – Slowest (Best) + * **6** – Default level + + + +To compress a file named **ostechnix.txt** , replacing it with a gzipped compressed version with **best** compression level, we use: +``` +$ gzip -9 ostechnix.txt + +``` + +**1.6 Concatenate multiple compressed files** + +It is also possible to concatenate multiple compressed files into one. How? Have a look at the following example. +``` +$ gzip -c ostechnix1.txt > output.txt.gz + +$ gzip -c ostechnix2.txt >> output.txt.gz + +``` + +The above two commands will compress ostechnix1.txt and ostechnix2.txt and saves them in one file named **output.txt.gz**. + +You can view the contents of both files (ostechnix1.txt and ostechnix2.txt) without extracting them using any one of the following commands: +``` +$ gunzip -c output.txt.gz + +$ gunzip -c output.txt + +$ zcat output.txt.gz + +$ zcat output.txt + +``` + +For more details, refer the man pages. +``` +$ man gzip + +``` + +##### 2\. Compress and decompress files using bzip2 program + +The **bzip2** is very similar to gzip program, but uses different compression algorithm named the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. The files compressed using bzip2 will end with **.bz2** extension. + +Like I said, the usage of bzip2 is almost same as gzip. Just replace **gzip** in the above examples with **bzip2** , **gunzip** with **bunzip2** , **zcat** with **bzcat** and so on. + +To compress a file using bzip2, replacing it with compressed version, run: +``` +$ bzip2 ostechnix.txt + +``` + +If you don’t want to replace the original file, use **-c** flag and write the output to a new file. +``` +$ bzip2 -c ostechnix.txt > output.txt.bz2 + +``` + +To decompress a compressed file: +``` +$ bzip2 -d ostechnix.txt.bz2 + +``` + +Or, +``` +$ bunzip2 ostechnix.txt.bz2 + +``` + +To view the contents of a compressed file without decompressing it: +``` +$ bunzip2 -c ostechnix.txt.bz2 + +``` + +Or, +``` +$ bzcat ostechnix.txt.bz2 + +``` + +For more details, refer man pages. +``` +$ man bzip2 + +``` + +##### Summary + +In this tutorial, we learned what is gzip and bzip2 programs and how to use them to compress and decompress files with some examples in GNU/Linux. In this next, guide we are going to learn how to archive files and directories in Linux. + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-compress-and-decompress-files-in-linux/ + +作者:[SK][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://www.ostechnix.com/author/sk/ From 7c831f461f8b7229523b5950cf195cd404f33b46 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:25:52 +0800 Subject: [PATCH 0191/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Manage=20your?= =?UTF-8?q?=20workstation=20with=20Ansible:=20Automating=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... with Ansible- Automating configuration.md | 236 ++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 sources/tech/20180326 Manage your workstation with Ansible- Automating configuration.md diff --git a/sources/tech/20180326 Manage your workstation with Ansible- Automating configuration.md b/sources/tech/20180326 Manage your workstation with Ansible- Automating configuration.md new file mode 100644 index 0000000000..21821a070c --- /dev/null +++ b/sources/tech/20180326 Manage your workstation with Ansible- Automating configuration.md @@ -0,0 +1,236 @@ +Manage your workstation with Ansible: Automating configuration +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/robot_arm_artificial_ai.png?itok=8CUU3U_7) +Ansible is an amazing automation and configuration management tool. It is mainly used for servers and cloud deployments, and it gets far less attention for its use in workstations, both desktops and laptops, which is the focus of this series. + +In the [first part][1] of this series, I showed you basic usage of the `ansible-pull` command, and we created a playbook that installs a handful of packages. That wasn't extremely useful by itself, but it set the stage for further automation. + +In this article, everything comes together full circle, and by the end we will have a fully working solution for automating workstation configuration. This time, we'll set up our Ansible configuration such that future changes we make will automatically be applied to our workstations. At this point, I'm assuming you already worked through part one. If you haven't, feel free to do that now and then return to this article when you're done. You should already have a GitHub repository with the code from the first article inside it. We're going to build directly on what we did before. + +First, we need to do some reorganization because we're going to do more than just install packages. At this point, we currently have a playbook named `local.yml` with the following content: +``` +- hosts: localhost + +  become: true + +  tasks: + +  - name: Install packages + +    apt: name={{item}} + +    with_items: + +      - htop + +      - mc + +      - tmux + +``` + +That's all well and good if we only want to perform one task. As we add new things to our configuration, this file will become quite large and get very cluttered. It's better to organize our plays into individual files with each responsible for a different type of configuration. To achieve this, create what's called a taskbook, which is very much like a playbook but the contents are more streamlined. Let's create a directory for our taskbooks inside our Git repository: +``` +mkdir tasks + +``` + +The code inside our current `local.yml` playbook lends itself well to become a taskbook for installing packages. Let's move this file into the `tasks` directory we just created with a new name: +``` +mv local.yml tasks/packages.yml + +``` + +Now, we can edit our `packages.yml` taskbook and strip it down quite a bit. In fact, we can strip everything except for the individual task itself. Let's make `packages.yml` look like this: +``` +- name: Install packages + +  apt: name={{item}} + +  with_items: + +    - htop + +    - mc + +    - tmux + +``` + +As you can see, it uses the same syntax, but we stripped out everything that isn't necessary to the task it's performing. Now we have a dedicated taskbook for installing packages. However, we still need a file named `local.yml`, since `ansible-pull` still expects to find a file with that name. So we'll create a fresh one with this content in the root of our repository (not in the `tasks` directory): +``` +- hosts: localhost + +  become: true + +  pre_tasks: + +    - name: update repositories + +      apt: update_cache=yes + +      changed_when: False + + + +  tasks: + +    - include: tasks/packages.yml + +``` + +This new `local.yml` acts as an index that will import all our taskbooks. I've added a few new things to this file that you haven't seen yet in this series. First, at the beginning of the file, I added `pre_tasks`, which allows us to have Ansible perform a task before all the other tasks run. In this case, we're telling Ansible to update our distribution's repository index. This line does that for us: +``` +apt: update_cache=yes + +``` + +Normally the `apt` module allows us to install packages, but we can also tell it to update our repository index. The idea is that we want all our individual plays to work with a fresh index each time Ansible runs. This will help ensure we don't have an issue with a stale index while attempting to install a package. Note that the `apt` module works only with Debian, Ubuntu, and their derivatives. If you're running a different distribution, you'll want to use a module specific to your distribution rather than `apt`. See the documentation for Ansible if you need to use a different module. + +The following line is also worth further explanation: +``` +changed_when: False + +``` + +This line on an individual task stops Ansible from reporting the results of the play as changed even when it results in a change in the system. In this case, we don't care if the repository index contains new data; it almost always will, since repositories are always changing. We don't care about changes to `apt` repositories, as index changes are par for the course. If we omit this line, we'll see the summary at the end of the process report that something has changed, even if it was merely about the repository being updated. It's better to ignore these types of changes. + +Next is our normal tasks section, and we import the taskbook we created. Each time we add another taskbook, we add another line here: +``` +tasks: + +  - include: tasks/packages.yml + +``` + +If you were to run the `ansible-pull` command here, it should essentially do the same thing as it did in the last article. The difference is that we have improved our organization and we can more efficiently expand on it. The `ansible-pull` command syntax, to save you from finding the previous article, is this: +``` +sudo ansible-pull -U https://github.com//ansible.git + +``` + +If you recall, the `ansible-pull` command pulls down a Git repository and applies the configuration it contains. + +Now that our foundation is in place, we can expand upon our Ansible config and add features. Specifically, we'll add configuration to automate the deployment of future changes to our workstations. To support this goal, the first thing we should do is to create a user specifically to apply our Ansible configuration. This isn't required—we can continue to run our Ansible configuration under our own user. But using a separate user segregates this to a system process that will run in the background, without our involvement. + +We could create this user with the normal method, but since we're using Ansible, we should shy away from manual changes. Instead, we'll create a taskbook to handle user creation. This taskbook will create just one user for now, but you can always add additional plays to this taskbook to add additional users. I'll call this user `ansible`, but you can name it something else if you wish (if you do, make sure to update all occurrences). Let's create a taskbook named `users.yml` and place this code inside of it: +``` +- name: create ansible user + +  user: name=ansible uid=900 + +``` + +Next, we need to edit our `local.yml` file and append this new taskbook to the file, so it will look like this: +``` +- hosts: localhost + +  become: true + +  pre_tasks: + +    - name: update repositories + +      apt: update_cache=yes + +      changed_when: False + + + +  tasks: + +    - include: tasks/users.yml + +    - include: tasks/packages.yml + +``` + +Now when we run our `ansible-pull` command, a user named `ansible` will be created on the system. Note that I specifically declared `User ID 900` for this user by using the `UID` option. This isn't required, but it's recommended. The reason is that UIDs under 1,000 are typically not shown on the login screen, which is great because there's no reason we would need to log into a desktop session as our `ansible` user. UID 900 is arbitrary; it should be any number under 1,000 that's not already in use. You can find out if UID 900 is in use on your system with the following command: +``` +cat /etc/passwd |grep 900 + +``` + +However, you shouldn't run into a problem with this UID because I've never seen it used by default in any distribution I've used so far. + +Now, we have an `ansible` user that will later be used to apply our Ansible configuration automatically. Next, we can create the actual cron job that will be used to automate this. Rather than place this in the `users.yml` taskbook we just created, we should separate this into its own file. Create a taskbook named `cron.yml` in the tasks directory and place the following code inside: +``` +- name: install cron job (ansible-pull) + +  cron: user="ansible" name="ansible provision" minute="*/10" job="/usr/bin/ansible-pull -o -U https://github.com//ansible.git > /dev/null" + +``` + +The syntax for the cron module should be fairly self-explanatory. With this play, we're creating a cron job to be run as the `ansible` user. The job will execute every 10 minutes, and the command it will execute is this: +``` +/usr/bin/ansible-pull -o -U https://github.com//ansible.git > /dev/null + +``` + +Also, we can put additional cron jobs we want all our workstations to have into this one file. We just need to add additional plays to add new cron jobs. However, simply adding a new taskbook for cron isn't enough—we'll also need to add it to our `local.yml` file so it will be called. Place the following line with the other includes: +``` +- include: tasks/cron.yml + +``` + +Now when `ansible-pull` is run, it will set up a new cron job that will be run as the `ansible` user every 10 minutes. But, having an Ansible job running every 10 minutes isn't ideal because it will take considerable CPU power. It really doesn't make sense for Ansible to run every 10 minutes unless we've changed something in the Git repository. + +However, we've already solved this problem. Notice the `-o` option I added to the `ansible-pull` command in the cron job that we've never used before. This option tells Ansible to run only if the repository has changed since the last time `ansible-pull` was called. If the repository hasn't changed, it won't do anything. This way, you're not wasting valuable CPU for no reason. Sure, some CPU will be used when it pulls down the repository, but not nearly as much as it would use if it were applying your entire configuration all over again. When `ansible-pull` does run, it will go through all the tasks in the Playbook and taskbooks, but at least it won't run for no purpose. + +Although we've added all the required components to automate `ansible-pull`, it actually won't work properly yet. The `ansible-pull` command will run with `sudo`, which would give it access to perform system-level commands. However, our `ansible` user is not set up to perform tasks as `sudo`. Therefore, when the cron job triggers, it will fail. Normally we could just use `visudo` and manually set the `ansible` user up to have this access. However, we should do things the Ansible way from now on, and this is a great opportunity to show you how the `copy` module works. The `copy` module allows you to copy a file from your Ansible repository to somewhere else in the filesystem. In our case, we'll copy a config file for `sudo` to `/etc/sudoers.d/` so that the `ansible` user can perform administrative tasks. + +Open up the `users.yml` taskbook, and add the following play to the bottom: +``` +- name: copy sudoers_ansible + +  copy: src=files/sudoers_ansible dest=/etc/sudoers.d/ansible owner=root group=root mode=0440 + +``` + +The `copy` module, as we can see, copies a file from our repository to somewhere else. In this case, we're grabbing a file named `sudoers_ansible` (which we will create shortly) and copying it to `/etc/sudoers.d/ansible` with `root` as the owner. + +Next, we need to create the file that we'll be copying. In the root of your Ansible repository, create a `files` directory:​ +``` +mkdir files + +``` + +Then, in the `files` directory we just created, create the `sudoers_ansible` file with the following content: +``` +ansible ALL=(ALL) NOPASSWD: ALL + +``` + +Creating a file in `/etc/sudoers.d`, like we're doing here, allows us to configure `sudo` for a specific user. Here we're allowing the `ansible` user full access to the system via `sudo` without a password prompt. This will allow `ansible-pull` to run as a background task without us needing to run it manually. + +Now, you can run `ansible-pull` again to pull down the latest changes: +``` +sudo ansible-pull -U https://github.com//ansible.git + +``` + +From this point forward, the cron job for `ansible-pull` will run every 10 minutes in the background and check your repository for changes. If it finds changes, it will run your playbook and apply your taskbooks. + +So now we have a fully working solution. When you first set up a new laptop or desktop, you'll run the `ansible-pull` command manually, but only the first time. From that point forward, the `ansible` user will take care of subsequent runs in the background. When you want to make a change to your workstation machines, you simply pull down your Git repository, make the changes, then push those changes back to the repository. Then, the next time the cron job fires on each machine, it will pull down those changes and apply them. You now only have to make changes once, and all your workstations will follow suit. This method may be a bit unconventional though. Normally, you'd have an `inventory` file with your machines listed and several roles each machine could be a member of. However, the `ansible-pull` method, as described in this article, is a very efficient way of managing workstation configuration. + +I have updated the code in my [GitHub repository][2] for this article, so feel free to browse the code there and check your syntax against mine. Also, I moved the code from the previous article into its own directory in that repository. + +In part 3, we'll close out the series by using Ansible to configure GNOME desktop settings. I'll show you how to set your wallpaper and lock screen, apply a desktop theme, and more. + +In the meantime, it's time for a little homework assignment. Most of us have configuration files we like to maintain for various applications we use. This could be configuration files for Bash, Vim, or whatever tools you use. I challenge you now to automate copying these configuration files to your machines via the Ansible repository we've been working on. In this article, I've shown you how to copy a file, so take a look at that and see if you can apply that knowledge to your personal files. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/manage-your-workstation-configuration-ansible-part-2 + +作者:[Jay LaCroix][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/jlacroix +[1]:https://opensource.com/article/18/3/manage-workstation-ansible +[2]:https://github.com/jlacroix82/ansible_article.git From 58b9e44d9b4da48f36f276c5a70fb38ba95964a8 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:27:11 +0800 Subject: [PATCH 0192/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Reliable=20IoT?= =?UTF-8?q?=20event=20logging=20with=20syslog-ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...liable IoT event logging with syslog-ng.md | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 sources/tech/20180327 Reliable IoT event logging with syslog-ng.md diff --git a/sources/tech/20180327 Reliable IoT event logging with syslog-ng.md b/sources/tech/20180327 Reliable IoT event logging with syslog-ng.md new file mode 100644 index 0000000000..89ffed382f --- /dev/null +++ b/sources/tech/20180327 Reliable IoT event logging with syslog-ng.md @@ -0,0 +1,81 @@ +Reliable IoT event logging with syslog-ng +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openwires_fromRHT_520_0612LL.png?itok=PqZi55Ab) +For any device connected to the internet or a network, it's essential that you log events so you know what the device is doing and can address any potential problems. Increasingly those devices include Internet of Things (IoT) devices and embedded systems. + +One monitoring tool to consider is the open source [syslog-ng][1] application, an enhanced logging daemon with a focus on portability and central log collection. It collects logs from many different sources, processes and filters them, and stores or routes them for further analysis. Most of syslog-ng is written in efficient and highly portable C code. It's suitable for a wide range of scenarios, whether you need something simple enough to run with a really small footprint on underpowered devices or a solution powerful enough to reside in your data center and collect logs from tens of thousands of devices. + +You probably noticed the abundance of buzzwords I wrote in that single paragraph. To clarify what this all means, let's go over them, but this time slower and in more depth. + +### Logging + +First things first. Logging is the recording of events on a computer. On a typical Linux machine, you can find these log messages in the `/var/log` directory. For example, if you log into your machine through SSH, you will find a message similar to this in one of the files: + +`Jan 14 11:38:48 ``linux``-0jbu sshd[7716]: Accepted ``publickey`` for root from 127.0.0.1 port 48806 ssh2` + +It could be about your CPU running too hot, a document downloaded through HTTP, or just about anything one of your applications considers important. + +### syslog-ng + +As I wrote above, the syslog-ng application is an enhanced logging daemon with a focus on portability and central log collection. Daemon means syslog-ng is an application running continuously in the background; in this case, it's collecting log messages. + +While Linux testing for many of today's applications is limited to x86_64 machines, syslog-ng also works on many BSD and commercial UNIX variants. What is even more important from the embedded/IoT standpoint is that it runs on many different CPU architectures, including 32- and 64-bit ARM, PowerPC, MIPS, and more. (Sometimes I learn about new architectures just by reading about how syslog-ng is used.) + +Why is central collection of logs such a big deal? One reason is ease of use, as it creates a single place to check instead of tens or thousands of devices. Another reason is availability—you can check a device's log messages even if the device is unavailable for any reason. A third reason is security; when your device is hacked, checking the logs can uncover traces of the hack. + +### Four roles of syslog-ng + +Syslog-ng has four major roles: collecting, processing, filtering, and storing log messages. + +**Collecting messages:** syslog-ng can collect from a wide variety of [platform-specific sources][2], like `/dev/log`, `journal`, or `sun-streams`. As a central log collector, it speaks both the legacy (`rfc3164`) and the new (`rfc5424`) syslog protocols and all their variants over User Datagram Protocol (UDP), TCP, and encrypted connections. You can also collect log messages (or any kind of text data) from pipes, sockets, files, and even application output. + +**Processing log messages:** The possibilities here are almost endless. You can classify, normalize, and structure log messages with built-in parsers. You can even write your own parser in Python if none of the available parsers suits your needs. You can also enrich messages with geolocation data or additional fields based on the message content. Log messages can be reformatted to suit the requirements of the application processing the logs. You can also rewrite log messages—not to falsify messages, of course—for things such as anonymizing log messages as required by many compliance regulations. + +**Filtering logs:** There are two main uses for filtering logs: To discard surplus log messages—like debug-level messages—to save on storage, and for log routing—making sure the right logs reach the right destinations. An example of the latter is forwarding all authentication-related messages to a security information and event management (SIEM) system. + +**Storing messages:** Traditionally, files were saved locally or sent to a central syslog server; either way, they'd be sent to [flat files][3]. Over the years, syslog-ng began supporting SQL databases, and in the past few years Big Data destinations, including HDFS, Kafka, MongoDB, and Elasticsearch, were added to syslog-ng. + +### Message formats + +When you look at your log messages under the `/var/log` directory, you will see (like in the SSH message above) most are in the form: + +`date + host name + application name + an almost complete English sentence` + +Where each application event is described by a different sentence, creating a report based on this data is quite a painful job. + +The solution to this mess is to use structured logging. In this case, events are represented as name-value pairs instead of freeform log messages. For example, an SSH login can be described by the application name, source IP address, username, authentication method, and so on. + +You can take a structured approach for your log messages right from the beginning. When working with legacy log messages, you can use the different parsers in syslog-ng to turn unstructured (and some of the structured) message formats into name-value pairs. Once you have your logs available as name-value pairs, reporting, alerting, and simply finding the information you are looking for becomes a lot easier. + +### Logging IoT + +Let's start with a tricky question: Which version of syslog-ng is the most popular? Before you answer, consider these facts: The project started 20 years ago, Red Hat Enterprise Linux EPEL has version 3.5, and the current version is 3.14. When I ask this question during my presentations, the audience members usually suggest the one in their favorite Linux distribution. Surprisingly, the correct answer is version 1.6, almost 15 years old. That's because it is the version included in the Amazon Kindle e-book readers, so it's running on over 100 million devices worldwide. Another example of a consumer device running syslog-ng is the BMW i3 all-electric car. + +The Kindle uses syslog-ng to collect all possible information about what the user is doing on the device. On the BMW, syslog-ng does very complex, content-based filtering of log messages, and most it likely records only the most important logs. + +Networking and storage are other categories of devices that often use syslog-ng. Networking and storage are other categories of devices that often use syslog-ng. Some better known examples are the Turris Omnia open source Linux router and Synology NAS devices. In most cases, syslog-ng started out as a logging client on these devices, but in some cases it's evolved into a central logging server with a rich web interface. + +You can find syslog-ng in industrial devices, as well. It runs on all real-time Linux devices from National Instruments doing measurements and automation. It is also used to collect logs from customer-developed applications. Configuration is done from the command line, but a nice GUI is available to browse the logs. + +Finally, there are some large-scale projects, such as cars and airplanes, where syslog-ng runs on both the client and server side. The common theme here is that syslog-ng collects all log and metrics data, sends it to a central cluster of servers where logs are processed, and saves it to one of the supported Big Data destinations where it waits for further analysis. + +### Overall benefits for IoT + +There are several benefits of using syslog-ng in an IoT environment. First, it delivers high performance and reliable log collection. It also simplifies the architecture, as system and application logs and metrics data can be collected together. Third, it makes it easier to use data, as data is parsed and presented in a ready-to-use format. Finally, efficient routing and filtering by syslog-ng can significantly decrease processing load. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/logging-iot-events-syslog-ng + +作者:[Peter Czanik][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/czanik +[1]:https://syslog-ng.com/open-source-log-management +[2]:https://syslog-ng.com/documents/html/syslog-ng-ose-latest-guides/en/syslog-ng-ose-guide-admin/html/sources.html +[3]:https://en.wikipedia.org/wiki/Flat_file_database From 29c90230becfa1cc3fd34d41c72602f95f7f3b15 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:30:47 +0800 Subject: [PATCH 0193/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20buil?= =?UTF-8?q?d=20a=20digital=20pinhole=20camera=20with=20a=20Raspberry=20Pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ital pinhole camera with a Raspberry Pi.md | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..60a19fb581 --- /dev/null +++ b/sources/tech/20180327 How to build a digital pinhole camera with a Raspberry Pi.md @@ -0,0 +1,149 @@ +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 From 9248d68497ae24c4fb55dde4431d76c329cc7850 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:31:46 +0800 Subject: [PATCH 0194/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Arch?= =?UTF-8?q?ive=20Files=20And=20Directories=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Archive Files And Directories In Linux.md | 281 ++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 sources/tech/20180326 How To Archive Files And Directories In Linux.md diff --git a/sources/tech/20180326 How To Archive Files And Directories In Linux.md b/sources/tech/20180326 How To Archive Files And Directories In Linux.md new file mode 100644 index 0000000000..804bc554b3 --- /dev/null +++ b/sources/tech/20180326 How To Archive Files And Directories In Linux.md @@ -0,0 +1,281 @@ +How To Archive Files And Directories In Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Archive-Files-And-Directories-In-Linux-720x340.png) +In our previous tutorial, we discussed how to [**compress and decompress files using gzip and bzip2**][1] programs. In this tutorial, we are going to learn how to archive files in Linux. Aren’t archiving and compressing same? Some of you might often think these terms refers the same meaning. But, both are completely different. Archiving is the process of the combining multiple files and directories (same or different size) into one file. On the other hand, compressing is the process of reducing the size of of a file(s) or directory(s). Archiving is often used as part of the system backups or when moving the data from one system to another. Hope you understand the difference between archiving and compressing. Now, let us get into the topic. + +### Archive files and directories + +The most common programs to archive files and directories are; + + 1. tar + 2. zip + + + +This is a big topic. So, I am going to publish this article in two parts. In the first part, we will see how to archive files and directories using Tar command. + +##### Archive files and directories using Tar command + +**Tar** is an Unix command which stands for **T** ape **A** rchive. It is used to combine or store multiple files (same or different size) into a single file. There are 4 main operating modes in tar utility. + + 1. **c** – Create an archive from a file(s) or directory(s). + 2. **x** – Extract an archive. + 3. **r** – Append files to the end of an archive. + 4. **t** – List the contents of the archive. + + + +For complete list of modes, refer the man pages. + +**Create a new archive** + +For the purpose of this guide, I will be using a folder named **ostechnix** that contains three different type of files. +``` +$ ls ostechnix/ +file.odt image.png song.mp3 + +``` + +Now, let us create a new tar archive of the the directory ostechnix. +``` +$ tar cf ostechnix.tar ostechnix/ + +``` + +Here, **c** flag refers create new archive and **f** refers the file name. + +Similarly, to create an archive from a set of files in the current working directory, use this command: +``` +$ tar cf archive.tar file1 file2 file 3 + +``` + +**Extract archives** + +To extract an archive in the current directory, simply do: +``` +$ tar xf ostechnix.tar + +``` + +We can also extract the archive in a different directory using **C** flag(capital c). For example, the following command extracts the given archive file in **Downloads** directory. +``` +$ tar xf ostechnix.tar -C Downloads/ + +``` + +Alternatively, go to the Downloads folder and extract the archive inside it like below. +``` +$ cd Downloads/ + +$ tar xf ../ostechnix.tar + +``` + +Some times you may want to extract files of a specific type. For example, the following command extracts the “.png” type files. +``` +$ tar xf ostechnix.tar --wildcards "*.png" + +``` + +**Create gzipped and bzipped archives** + +By default, Tar creates the archive file ends with **.tar**. Also, tar command can be used in conjunction with the compression utilities **gzip** and **bzip2**. The files ends with **.tar** extensions refer the plain tar archive, the files ends with **tar.gz** or **.tgz** refers a **gzipped** archive, and the tar files ends with **tar.bz2** or **.tbz** refers **bzipped** archive, respectively. + +First, let us **create a gzipped** archive: +``` +$ tar czf ostechnix.tar.gz ostechnix/ + +``` + +Or, +``` +$ tar czf ostechnix.tgz ostechnix/ + +``` + +Here, we use **z** flag to compress the archive using gzip compression method. + +You can use **v** flag to view the progress while creating the archive. +``` +$ tar czvf ostechnix.tar.gz ostechnix/ +ostechnix/ +ostechnix/file.odt +ostechnix/image.png +ostechnix/song.mp3 + +``` + +Here, **v** refers verbose. + +To create gzipped archive from a list of files: +``` +$ tar czf archive.tgz file1 file2 file3 + +``` + +To extract the gzipped archive in the current directory, use: +``` +$ tar xzf ostechnix.tgz + +``` + +To extract the archive in a different folder, use -C flag. +``` +$ tar xzf ostechnix.tgz -C Downloads/ + +``` + +Now, let us create **bzipped archive**. + +To do so, use **j** flag like below. + +Create an archive of a directory: +``` +$ tar cjf ostechnix.tar.bz2 ostechnix/ + +``` + +Or, +``` +$ tar cjf ostechnix.tbz ostechnix/ + +``` + +Create archive from list of files: +``` +$ tar cjf archive.tar.bz2 file1 file2 file3 + +``` + +Or, +``` +$ tar cjf archive.tbz file1 file2 file3 + +``` + +To display the progress, use **v** flag. + +Now, let us extract bzipped archive in the current directory. To do so, we do: +``` +$ tar xjf ostechnix.tar.bz2 + +``` + +Or, extract the archive to some other directory: +``` +$ tar xjf ostechnix.tar.bz2 -C Downloads + +``` + +**Create archive of multiple directories and/or files at a time** + +This is another coolest feature of tar command. To create an gzipped archive of multiple directories or files at once, use this command: +``` +$ tar czvf ostechnix.tgz Downloads/ Documents/ ostechnix/file.odt + +``` + +The above command will create an archive of **Downloads** , **Documents** directories and **file.odt** file in **ostechnix** directory and save the archive in the current working directory. + +**Exclude directories and/or files from while creating an archive** + +This is quite useful when backing up your data. You can exclude the non-important files or directories from your backup. This is where **–exclude** switch comes in help. For example, you want to create an archive of your /home directory, but exclude Downloads, Documents, Pictures, Music directories. + +This is how we do it. +``` +$ tar czvf ostechnix.tgz /home/sk --exclude=/home/sk/Downloads --exclude=/home/sk/Documents --exclude=/home/sk/Pictures --exclude=/home/sk/Music + +``` + +The above command will create an gzipped archive of my $HOME directory, excluding Downloads, Documents, Pictures and Music folders. To create bzipped archive, replace **z** with **j** and use the extension .bz2 in the above example. + +**List contents of archive files without extracting them** + +To list the contents of an archive file, we use **t** flag. +``` +$ tar tf ostechnix.tar +ostechnix/ +ostechnix/file.odt +ostechnix/image.png +ostechnix/song.mp3 + +``` + +To view the verbose output, use **v** flag. +``` +$ tar tvf ostechnix.tar +drwxr-xr-x sk/users 0 2018-03-26 19:52 ostechnix/ +-rw-r--r-- sk/users 9942 2018-03-24 13:49 ostechnix/file.odt +-rw-r--r-- sk/users 36013 2015-09-30 11:52 ostechnix/image.png +-rw-r--r-- sk/users 112383 2018-02-22 14:35 ostechnix/song.mp3 + +``` + +**Append files to existing archives** + +Files or directories can be added/updated to the existing archives using **r** flag. Take a look at the following command. +``` +$ tar rf ostechnix.tar ostechnix/ sk/ example.txt + +``` + +The above command will add the directory named **sk** and a file named **example.txt** to ostechnix.tar archive. + +You can verify if the files are added or not using command: +``` +$ tar tvf ostechnix.tar +drwxr-xr-x sk/users 0 2018-03-26 19:52 ostechnix/ +-rw-r--r-- sk/users 9942 2018-03-24 13:49 ostechnix/file.odt +-rw-r--r-- sk/users 36013 2015-09-30 11:52 ostechnix/image.png +-rw-r--r-- sk/users 112383 2018-02-22 14:35 ostechnix/song.mp3 +drwxr-xr-x sk/users 0 2018-03-26 19:52 sk/ +-rw-r--r-- sk/users 0 2018-03-26 19:39 sk/linux.txt +-rw-r--r-- sk/users 0 2018-03-26 19:56 example.txt + +``` + +##### **TL;DR** + +**Create tar archives:** + + * **Plain tar archive:** tar -cf archive.tar file1 file2 file3 + * **Gzipped tar archive:** tar -czf archive.tgz file1 file2 file3 + * **Bzipped tar archive:** tar -cjf archive.tbz file1 file2 file3 + + + +**Extract tar archives:** + + * **Plain tar archive:** tar -xf archive.tar + * **Gzipped tar archive:** tar -xzf archive.tgz + * **Bzipped tar archive:** tar -xjf archive.tbz + + + +We just have covered the basic usage of tar command. It is enough to get started with tar command. However, if you to know more details, refer the man pages. +``` +$ man tar + +``` + +And, that’s all for now. In the next part, we will see how to archives files and directories using Zip utility. + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-archive-files-and-directories-in-linux-part-1/ + +作者:[SK][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://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/how-to-compress-and-decompress-files-in-linux/ From 78499d0b609c55330b64d8a4ad24221b72a6db20 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 15:34:53 +0800 Subject: [PATCH 0195/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Protecting=20Co?= =?UTF-8?q?de=20Integrity=20with=20PGP=20=E2=80=94=20Part=207:=20Protectin?= =?UTF-8?q?g=20Online=20Accounts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...GP - Part 7- Protecting Online Accounts.md | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 sources/talk/20180327 Protecting Code Integrity with PGP - Part 7- Protecting Online Accounts.md diff --git a/sources/talk/20180327 Protecting Code Integrity with PGP - Part 7- Protecting Online Accounts.md b/sources/talk/20180327 Protecting Code Integrity with PGP - Part 7- Protecting Online Accounts.md new file mode 100644 index 0000000000..8ebb9af3f6 --- /dev/null +++ b/sources/talk/20180327 Protecting Code Integrity with PGP - Part 7- Protecting Online Accounts.md @@ -0,0 +1,146 @@ +Protecting Code Integrity with PGP — Part 7: Protecting Online Accounts +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/online-pgp.jpg?itok=BWc_Bk6q) +So far in this tutorial series, we've provided practical guidelines for using PGP, including basic concepts and steps for generating and protecting your keys. If you missed the previous articles, you can catch up below. In this final article, we offer additional guidance for protecting your online accounts, which is of paramount importance today. + +[Part 1: Basic Concepts and Tools][1] + +[Part 2: Generating Your Master Key][2] + +[Part 3: Generating PGP Subkeys][3] + +[Part 4: Moving Your Master Key to Offline Storage][4] + +[Part 5: Moving Subkeys to a Hardware Device][5] + +[Part 6: Using PGP with Git][6] + +### Checklist + + * Get a U2F-capable device (ESSENTIAL) + + * Enable 2-factor authentication for your online accounts (ESSENTIAL) + + * GitHub/GitLab + + * Google + + * Social media + + * Use U2F as primary mechanism, with TOTP as fallback (ESSENTIAL) + + + + +#### Considerations + +You may have noticed how a lot of your online developer identity is tied to your email address. If someone can gain access to your mailbox, they would be able to do a lot of damage to you personally, and to your reputation as a free software developer. Protecting your email accounts is just as important as protecting your PGP keys. + +##### Two-factor authentication with Fido U2F + +[Two-factor authentication][7] is a mechanism to improve account security by requiring a physical token in addition to a username and password. The goal is to make sure that even if someone steals your password (via keylogging, shoulder surfing, or other means), they still wouldn't be able to gain access to your account without having in their possession a specific physical device ("something you have" factor). + +The most widely known mechanisms for 2-factor authentication are: + + * SMS-based verification + + * Time-based One-Time Passwords (TOTP) via a smartphone app, such as the "Google Authenticator" or similar solutions + + * Hardware tokens supporting Fido U2F + + + + +SMS-based verification is easiest to configure, but has the following important downsides: it is useless in areas without signal (e.g. most building basements), and can be defeated if the attacker is able to intercept or divert SMS messages, for example by cloning your SIM card. + +TOTP-based multi-factor authentication offers more protection than SMS, but has important scaling downsides (there are only so many tokens you can add to your smartphone app before finding the correct one becomes unwieldy). Plus, there's no avoiding the fact that your secret key ends up stored on the smartphone itself -- which is a complex, globally connected device that may or may not have been receiving timely security patches from the manufacturer. + +Most importantly, neither TOTP nor SMS methods protect you from phishing attacks -- if the phisher is able to steal both your account password and the 2-factor token, they can replay them on the legitimate site and gain access to your account. + +[Fido U2F][8] is a standard developed specifically to provide a mechanism for 2-factor authentication and to combat credential phishing. The U2F protocol will store each site's unique key on the USB token and will prevent you from accidentally giving the attacker both your password and your one-time token if you try to use it on anything other than the legitimate website. + +Both Chrome and Firefox support U2F 2-factor authentication, and hopefully other browsers will soon follow. + +##### Get a token capable of Fido U2F + +There are [many options available][9] for hardware tokens with Fido U2F support, but if you're already ordering a smartcard-capable physical device, then your best option is a Yubikey 4, which supports both. + +##### Enable 2-factor authentication on your online accounts + +You definitely want to enable this option on the email provider you are using (especially if it is Google, which has excellent support for U2F). Other sites where this functionality should be enabled are: + + * GitHub: it probably occurred to you when you uploaded your PGP public key that if anyone else is able to gain access to your account, they can replace your key with their own. If you publish code on GitHub, you should take care of your account security by protecting it with U2F-backed authentication. + + * GitLab: for the same reasons as above. + + * Google: if you have a google account, you will be surprised how many sites allow logging in with Google authentication instead of site-specific credentials. + + * Facebook: same as above, a lot of online sites offer the option to authenticate using a Facebook account. You should 2-factor protect your Facebook account even if you do not use it. + + * Other sites, as you deem necessary. See [dongleauth.info][10] for inspiration. + + + + +##### Configure TOTP failover, if possible + +Many sites will allow you to configure multiple 2-factor mechanisms, and the recommended setup is: + + * U2F token as the primary mechanism + + * TOTP phone app as the secondary mechanism + + + + +This way, even if you lose your U2F token, you should be able to re-gain access to your account. Alternatively, you can enroll multiple U2F tokens (e.g. you can get another cheap token that only does U2F and use it for backup reasons). + +### Further reading + +By this point you have accomplished the following important tasks: + + 1. Created your developer identity and protected it using PGP cryptography. + + 2. Configured your environment so your identity is not easily stolen by moving your master key offline and your subkeys to an external hardware device. + + 3. Configured your git environment to ensure that anyone using your project is able to verify the integrity of the repository and its entire history. + + 4. Secured your online accounts using 2-factor authentication. + + + + +You are already in a good place, but you should also read up on the following topics: + + * How to secure your team communication (see the document in this repository). Decisions regarding your project development and governance require just as much careful protection as any committed code, if not so. Make sure that your team communication is trusted and the integrity of all decisions is verified. + + * How to secure your workstation (see the document in this repository). Your goal is to minimize risky behaviour that would cause your project code to be contaminated, or your developer identity to be stolen. + + * How to write secure code (see various documentation related to the programming languages and libraries used by your project). Bad, insecure code is still bad, insecure code even if there is a PGP signature on the commit that introduced it. + + + + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-7-protecting-online-accounts + +作者:[Konstantin Ryabitsev][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://www.linux.com/users/mricon +[1]:https://www.linux.com/blog/learn/2018/2/protecting-code-integrity-pgp-part-1-basic-pgp-concepts-and-tools +[2]:https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-part-2-generating-and-protecting-your-master-pgp-key +[3]:https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-part-3-generating-pgp-subkeys +[4]:https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-4-moving-your-master-key-offline-storage +[5]:https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-5-moving-subkeys-hardware-device +[6]:https://www.linux.com/blog/learn/pgp/2018/3/protecting-code-integrity-pgp-part-6-using-pgp-git +[7]:https://en.wikipedia.org/wiki/Multi-factor_authentication +[8]:https://en.wikipedia.org/wiki/Universal_2nd_Factor +[9]:http://www.dongleauth.info/dongles/ +[10]:http://www.dongleauth.info/ From d1bc02ddb141fc77579e9980afb2c267608ca3db Mon Sep 17 00:00:00 2001 From: gongqi0632 Date: Thu, 29 Mar 2018 16:02:10 +0800 Subject: [PATCH 0196/1057] gongqi0632 translating --- ...ssons Learned from Growing an Open Source Project Too Fast.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md b/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md index 6ae7cbea2c..be1a25c776 100644 --- a/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md +++ b/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md @@ -1,3 +1,4 @@ +gongqi0632 translating Lessons Learned from Growing an Open Source Project Too Fast ====== ![open source project][1] From bf0b1f21b952474474af7a08485b2c3d8f4380ce Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 16:12:39 +0800 Subject: [PATCH 0197/1057] PRF:20180102 How To Find (Top-10) Largest Files In Linux.md @jessie-pang --- ...To Find (Top-10) Largest Files In Linux.md | 216 ++++++------------ 1 file changed, 76 insertions(+), 140 deletions(-) diff --git a/translated/tech/20180102 How To Find (Top-10) Largest Files In Linux.md b/translated/tech/20180102 How To Find (Top-10) Largest Files In Linux.md index 37765828bf..12726d369d 100644 --- a/translated/tech/20180102 How To Find (Top-10) Largest Files In Linux.md +++ b/translated/tech/20180102 How To Find (Top-10) Largest Files In Linux.md @@ -1,12 +1,11 @@ -如何查找 Linux 中最大的 10 个文件 +如何在 Linux 中查找最大的 10 个文件 ====== - -当系统的磁盘空间不足时,您可能更愿意使用 `df`、`du` 或 `ncdu` 命令进行检查,但这些命令只会显示当前目录的文件,并不会显示整个系统范围的文件。 +当系统的磁盘空间不足时,您可能会使用 `df`、`du` 或 `ncdu` 命令进行检查,但这些命令只会显示当前目录的文件,并不会显示整个系统范围的文件。 您得花费大量的时间才能用上述命令获取系统中最大的文件,因为要进入到每个目录重复运行上述命令。 -这个方法比较麻烦,也并不恰当。 +这种方法比较麻烦,也并不恰当。 如果是这样,那么该如何在 Linux 中找到最大的 10 个文件呢? @@ -14,7 +13,7 @@ 本教程中,我们将教您如何使用以下四种方法在 Linux 系统中查找最大的前 10 个文件。 -### 方法 1: +### 方法 1 在 Linux 中没有特定的命令可以直接执行此操作,因此我们需要将多个命令结合使用。 @@ -31,40 +30,26 @@ 84M /var/lib/snapd/snaps/core_3604.snap 84M /var/lib/snapd/snaps/core_3440.snap 84M /var/lib/snapd/snaps/core_3247.snap - ``` -**详解:** +详解: -**`find`**:在目录结构中搜索文件的命令 +- `find`:在目录结构中搜索文件的命令 +- `/`:在整个系统(从根目录开始)中查找 +- `-type`:指定文件类型 + - `f`:普通文件 +- `-print0`:在标准输出显示完整的文件名,其后跟一个空字符(null) +- `|`:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 +- `xargs`:将标准输入转换成命令行参数的命令 +- `-0`:以空字符(null)而不是空白字符(LCTT 译者注:即空格、制表符和换行)来分割记录 +- `du -h`:以可读格式计算磁盘空间使用情况的命令 +- `sort`:对文本文件进行排序的命令 +- `-r`:反转结果 +- `-h`:用可读格式打印输出 +- `head`:输出文件开头部分的命令 +- `n -10`:打印前 10 个文件 -**`/`**:在整个系统(从根目录开始)中查找 - -**`-type`**:指定文件类型 - -**`f`**:普通文件 - -**`-print0`**:输出完整的文件名,其后跟一个空字符 - -**`|`**:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 - -**`xargs`**:将标准输入转换成命令行参数的命令 - -**`-0`**:以空字符(null)而不是空白字符(whitespace)(LCTT 译者注:即空格、制表符和换行)来分割记录 - -**`du -h`**:以可读格式计算磁盘空间使用情况的命令 - -**`sort`**:对文本文件进行排序的命令 - -**`-r`**:反转结果 - -**`-h`**:用可读格式打印输出 - -**`head`**:输出文件开头部分的命令 - -**`n -10`**:打印前 10 个文件 - -### 方法 2: +### 方法 2 这是查找 Linux 系统中最大的前 10 个文件的另一种方法。我们依然使用多个命令共同完成这个任务。 @@ -81,44 +66,29 @@ 84M /var/lib/snapd/snaps/core_3604.snap 84M /var/lib/snapd/snaps/core_3440.snap 84M /var/lib/snapd/snaps/core_3247.snap - ``` -**详解:** +详解: -**`find`**:在目录结构中搜索文件的命令 +- `find`:在目录结构中搜索文件的命令 +- `/`:在整个系统(从根目录开始)中查找 +- `-type`:指定文件类型 + - `f`:普通文件 +- `-exec`:在所选文件上运行指定命令 +- `du`:计算文件占用的磁盘空间的命令 +- `-S`:不包含子目录的大小 +- `-h`:以可读格式打印 +- `{}`:递归地查找目录,统计每个文件占用的磁盘空间 +- `|`:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 +- `sort`:对文本文件进行按行排序的命令 +- `-r`:反转结果 +- `-h`:用可读格式打印输出 +- `head`:输出文件开头部分的命令 +- `n -10`:打印前 10 个文件 -**`/`**:在整个系统(从根目录开始)中查找 +### 方法 3 -**`-type`**:指定文件类型 - -**`f`**:普通文件 - -**`-exec`**:在所选文件上运行指定命令 - -**`du`**:计算文件占用的磁盘空间的命令 - -**`-S`**:不包含子目录的大小 - -**`-h`**:以可读格式打印 - -**`{}`**:递归地查找目录,统计每个文件占用的磁盘空间 - -**`|`**:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 - -**`sort`**:对文本文件进行按行排序的命令 - -**`-r`**:反转结果 - -**`-h`**:用可读格式打印输出 - -**`head`**:输出文件开头部分的命令 - -**`n -10`**:打印前 10 个文件 - -### 方法 3: - -这里介绍另一种方法,在 Linux 系统中搜索最大的前 10 个文件。 +这里介绍另一种在 Linux 系统中搜索最大的前 10 个文件的方法。 ``` # find / -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} @@ -133,48 +103,30 @@ 564M /home/magi/.gdfuse/magi/cache/0B5nso_FPaZFqTFU0XzkzUlJUZzA 1.1G /home/magi/ubuntu-17.04-desktop-amd64.iso 1.4G /swapfile - ``` -**详解:** +详解: -**`find`**:在目录结构中搜索文件的命令 +- `find`:在目录结构中搜索文件的命令 +- `/`:在整个系统(从根目录开始)中查找 +- `-type`:指定文件类型 + - `f`:普通文件 +- `-print0`:输出完整的文件名,其后跟一个空字符(null) +- `|`:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 +- `xargs`:将标准输入转换成命令行参数的命令 +- `-0`:以空字符(null)而不是空白字符来分割记录 +- `du`:计算文件占用的磁盘空间的命令 +- `sort`:对文本文件进行按行排序的命令 +- `-n`:根据数字大小进行比较 +- `tail -10`:输出文件结尾部分的命令(最后 10 个文件) +- `cut`:从每行删除特定部分的命令 +- `-f2`:只选择特定字段值 +- `-I{}`:将初始参数中出现的每个替换字符串都替换为从标准输入读取的名称 +- `-s`:仅显示每个参数的总和 +- `-h`:用可读格式打印输出 +- `{}`:递归地查找目录,统计每个文件占用的磁盘空间 -**`/`**:在整个系统(从根目录开始)中查找 - -**`-type`**:指定文件类型 - -**`f`**:普通文件 - -**`-print0`**:输出完整的文件名,其后跟一个空字符 - -**`|`**:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 - -**`xargs`**:将标准输入转换成命令行参数的命令 - -**`-0`**:以空字符(null)而不是空白字符(whitespace)来分割记录 - -**`du`**:计算文件占用的磁盘空间的命令 - -**`sort`**:对文本文件进行按行排序的命令 - -**`-n`**:根据数字大小进行比较 - -**`tail -10`**:输出文件结尾部分的命令(最后 10 个文件) - -**`cut`**:从每行删除特定部分的命令 - -**`-f2`**:只选择特定字段值 - -**`-I{}`**:将初始参数中出现的每个替换字符串都替换为从标准输入读取的名称 - -**`-s`**:仅显示每个参数的总和 - -**`-h`**:用可读格式打印输出 - -**`{}`**:递归地查找目录,统计每个文件占用的磁盘空间 - -### 方法 4: +### 方法 4 还有一种在 Linux 系统中查找最大的前 10 个文件的方法。 @@ -191,42 +143,26 @@ 87896064 /var/lib/snapd/snaps/core_3604.snap 87793664 /var/lib/snapd/snaps/core_3440.snap 87089152 /var/lib/snapd/snaps/core_3247.snap - ``` -**详解:** +详解: -**`find`**:在目录结构中搜索文件的命令 - -**`/`**:在整个系统(从根目录开始)中查找 - -**`-type`**:指定文件类型 - -**`f`**:普通文件 - -**`-ls`**:在标准输出中以 `ls -dils` 的格式列出当前文件 - -**`|`**:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 - -**`sort`**:对文本文件进行按行排序的命令 - -**`-k`**:按指定列进行排序 - -**`-r`**:反转结果 - -**`-n`**:根据数字大小进行比较 - -**`head`**:输出文件开头部分的命令 - -**`-10`**:打印前 10 个文件 - -**`column`**:将其输入格式化为多列的命令 - -**`-t`**:确定输入包含的列数并创建一个表 - -**`awk`**:样式扫描和处理语言 - -**`'{print $7,$11}'`**:只打印指定的列 +- `find`:在目录结构中搜索文件的命令 +- `/`:在整个系统(从根目录开始)中查找 +- `-type`:指定文件类型 + - `f`:普通文件 +- `-ls`:在标准输出中以 `ls -dils` 的格式列出当前文件 +- `|`:控制操作符,将一条命令的输出传递给下一个命令以供进一步处理 +- `sort`:对文本文件进行按行排序的命令 +- `-k`:按指定列进行排序 +- `-r`:反转结果 +- `-n`:根据数字大小进行比较 +- `head`:输出文件开头部分的命令 +- `-10`:打印前 10 个文件 +- `column`:将其输入格式化为多列的命令 +- `-t`:确定输入包含的列数并创建一个表 +- `awk`:模式扫描和处理语言 +- `'{print $7,$11}'`:只打印指定的列 -------------------------------------------------------------------------------- @@ -234,7 +170,7 @@ via: https://www.2daygeek.com/how-to-find-search-check-print-top-10-largest-bigg 作者:[Magesh Maruthamuthu][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 0e233b20aef6d1006d041764ffabf8c0f847d21a Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 29 Mar 2018 16:13:07 +0800 Subject: [PATCH 0198/1057] PUB:20180102 How To Find (Top-10) Largest Files In Linux.md @jessie-pang --- .../20180102 How To Find (Top-10) Largest Files In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180102 How To Find (Top-10) Largest Files In Linux.md (100%) diff --git a/translated/tech/20180102 How To Find (Top-10) Largest Files In Linux.md b/published/20180102 How To Find (Top-10) Largest Files In Linux.md similarity index 100% rename from translated/tech/20180102 How To Find (Top-10) Largest Files In Linux.md rename to published/20180102 How To Find (Top-10) Largest Files In Linux.md From c12a09a2fb3e0e48a830c2f9cded6113b9416556 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 16:25:41 +0800 Subject: [PATCH 0199/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Working=20with?= =?UTF-8?q?=20calendars=20on=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0180326 Working with calendars on Linux.md | 270 ++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 sources/tech/20180326 Working with calendars on Linux.md diff --git a/sources/tech/20180326 Working with calendars on Linux.md b/sources/tech/20180326 Working with calendars on Linux.md new file mode 100644 index 0000000000..12cbb9e70a --- /dev/null +++ b/sources/tech/20180326 Working with calendars on Linux.md @@ -0,0 +1,270 @@ +Working with calendars on Linux +====== + +![](https://images.idgesg.net/images/article/2018/03/calendars-100753173-large.jpg) +Linux systems can provide more help with your schedule than just reminding you what day today is. You have a lot of options for displaying calendars — some that are likely to prove helpful and others that just might boggle your mind. + +### date + +To begin, you probably know that you can show the current date with the **date** command. +``` +$ date +Mon Mar 26 08:01:41 EDT 2018 + +``` + +### cal and ncal + +You can show the entire month with the **cal** command. With no arguments, cal displays the current month and, by default, highlights the current day by reversing the foreground and background colors. +``` +$ cal + March 2018 +Su Mo Tu We Th Fr Sa + 1 2 3 + 4 5 6 7 8 9 10 +11 12 13 14 15 16 17 +18 19 20 21 22 23 24 +25 26 27 28 29 30 31 + +``` + +If you want to display the current month in a “sideways” format, you can use the **ncal** command. +``` +$ ncal + March 2018 +Su 4 11 18 25 +Mo 5 12 19 26 +Tu 6 13 20 27 +We 7 14 21 28 +Th 1 8 15 22 29 +Fr 2 9 16 23 30 +Sa 3 10 17 24 31 + +``` + +That command can be especially useful if, for example, you just want to see the dates for some particular day of the week. +``` +$ ncal | grep Th +Th 1 8 15 22 29 + +``` + +The ncal command can also display the entire year in the "sideways" format. Just provide the year along with the command. +``` +$ ncal 2018 + 2018 + January February March April +Su 7 14 21 28 4 11 18 25 4 11 18 25 1 8 15 22 29 +Mo 1 8 15 22 29 5 12 19 26 5 12 19 26 2 9 16 23 30 +Tu 2 9 16 23 30 6 13 20 27 6 13 20 27 3 10 17 24 +We 3 10 17 24 31 7 14 21 28 7 14 21 28 4 11 18 25 +Th 4 11 18 25 1 8 15 22 1 8 15 22 29 5 12 19 26 +Fr 5 12 19 26 2 9 16 23 2 9 16 23 30 6 13 20 27 +Sa 6 13 20 27 3 10 17 24 3 10 17 24 31 7 14 21 28 +... + +``` + +You can also display the entire year with **cal**. Just remember that you need all four digits for the year. If you type "cal 18", you'll get a calendar year for 18 AD, not 2018. +``` +$ cal 2018 + 2018 + January February March +Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa + 1 2 3 4 5 6 1 2 3 1 2 3 + 7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10 +14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17 +21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24 +28 29 30 31 25 26 27 28 25 26 27 28 29 30 31 + + + April May June +Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa + 1 2 3 4 5 6 7 1 2 3 4 5 1 2 + 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 +15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16 +22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 +29 30 27 28 29 30 31 24 25 26 27 28 29 30 + + + July August September +Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa + 1 2 3 4 5 6 7 1 2 3 4 1 + 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 +15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 +22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 +29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 + 30 + + October November December +Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa + 1 2 3 4 5 6 1 2 3 1 + 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 +14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 +21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 +28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 + 30 31 + +``` + +For a particular year and month, use the -d option win a command like this. +``` +$ cal -d 1949-03 + March 1949 +Su Mo Tu We Th Fr Sa + 1 2 3 4 5 + 6 7 8 9 10 11 12 +13 14 15 16 17 18 19 +20 21 22 23 24 25 26 +27 28 29 30 31 + +``` + +Another potentially useful calendaring option is the **cal** command’s -j option. Let's take a look at what that shows you. +``` +$ cal -j + March 2018 + Su Mo Tu We Th Fr Sa + 60 61 62 + 63 64 65 66 67 68 69 + 70 71 72 73 74 75 76 + 77 78 79 80 81 82 83 + 84 85 86 87 88 89 90 + +``` + +"What???" you might be asking. OK, that -j option is displaying Julian dates — the numeric day of the year that runs from 1 to 365 most years. So, 1 is January 1st and 32 is February 1st. The command **cal -j 2018** will show you the entire year, ending like this: +``` +$ cal -j 2018 | tail -9 + + November December + Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa + 305 306 307 335 +308 309 310 311 312 313 314 336 337 338 339 340 341 342 +315 316 317 318 319 320 321 343 344 345 346 347 348 349 +322 323 324 325 326 327 328 350 351 352 353 354 355 356 +329 330 331 332 333 334 357 358 359 360 361 362 363 + 364 365 + +``` + +This kind of display might help remind you of how many days have gone by since you made that New Year's resolution that you haven't yet acted on. + +Run a similar command for 2020, and you’ll note that it’s a leap year. +``` +$ cal -j 2020 | tail -9 + + November December + Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa +306 307 308 309 310 311 312 336 337 338 339 340 +313 314 315 316 317 318 319 341 342 343 344 345 346 347 +320 321 322 323 324 325 326 348 349 350 351 352 353 354 +327 328 329 330 331 332 333 355 356 357 358 359 360 361 +334 335 362 363 364 365 366 + +``` + +### calendar + +Another interesting and potentially overwhelming command can inform you about holidays. This command has a lot of options, but let’s just say that you’d like to see a list of upcoming holidays and noteworthy days. The calendar's **-l** option allows you to select how many days you want to see beyond today, so 0 means "today only". +``` +$ calendar -l 0 +Mar 26 Benjamin Thompson born, 1753, Count Rumford; physicist +Mar 26 David Packard died, 1996; age of 83 +Mar 26 Popeye statue unveiled, Crystal City TX Spinach Festival, 1937 +Mar 26 Independence Day in Bangladesh +Mar 26 Prince Jonah Kuhio Kalanianaole Day in Hawaii +Mar 26* Seward's Day in Alaska (last Monday) +Mar 26 Emerson, Lake, and Palmer record "Pictures at an Exhibition" live, 1971 +Mar 26 Ludwig van Beethoven dies in Vienna, Austria, 1827 +Mar 26 Bonne fête aux Lara ! +Mar 26 Aujourd'hui, c'est la St(e) Ludger. +Mar 26 N'oubliez pas les Larissa ! +Mar 26 Ludwig van Beethoven in Wien gestorben, 1827 +Mar 26 Emánuel + +``` + +For most of us, that's a bit more celebrating than we can manage in a single day. If you're seeing something like this, you can blame it on your **calendar.all** file that's telling the system what international calendars you'd like to include. You can, of course, pare this down by removing some of the lines in this file that include other files. The lines look like these: +``` +#include +#include +#include +#include +#include +#include +#include + +``` + +Say we cut our display down to world calendars only by removing all but the first #include line shown above. We'd then see this: +``` +$ calendar -l 0 +Mar 26 Benjamin Thompson born, 1753, Count Rumford; physicist +Mar 26 David Packard died, 1996; age of 83 +Mar 26 Popeye statue unveiled, Crystal City TX Spinach Festival, 1937 +Mar 26 Independence Day in Bangladesh +Mar 26 Prince Jonah Kuhio Kalanianaole Day in Hawaii +Mar 26* Seward's Day in Alaska (last Monday) +Mar 26 Emerson, Lake, and Palmer record "Pictures at an Exhibition" live, 1971 +Mar 26 Ludwig van Beethoven dies in Vienna, Austria, 1827 + +``` + +Clearly, the world calendar's special days are quite numerous. A display like this could, however, keep you from forgetting the all-important Popeye statue unveiling day and its role in observing the "spinach capital of the world." + +A more useful calendaring choice might be to put work-related calendars in a special file and use that calendar in the calendar.all file to determine what events you will see when you run the command. +``` +$ cat /usr/share/calendar/calendar.all +/* + * International and national calendar files + * + * This is the calendar master file. In the standard setup, it is + * included by /etc/calendar/default, so you can make any system-wide + * changes there and they will be kept when you upgrade. If you want + * to edit this file, copy it into /etc/calendar/calendar.all and + * edit it there. + * + */ + +#ifndef _calendar_all_ +#define _calendar_all_ + +#include +#include <== + +#endif /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var !_calendar_all_ */ + +``` + +The format for calendar files is very simple — mm/dd for the date, a tab, and the event's description. +``` +$ cat calendar.work +03/26 Describe how the cal and calendar commands work +03/27 Throw a party! + +``` + +### notes and nostalgia + +Note that the calendar command might not be available for all Linux distributions. You might have to remember the Popeye statue unveiling day on your own. + +And in case you're wondering, you can display a calendar as far ahead as the year 9999 — even for the prophetic [2525][1]. + +Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3265752/linux/working-with-calendars-on-linux.html + +作者:[Sandra Henry-Stocker][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://www.networkworld.com/author/Sandra-Henry_Stocker/ +[1]:https://www.youtube.com/watch?v=izQB2-Kmiic +[2]:https://www.facebook.com/NetworkWorld/ +[3]:https://www.linkedin.com/company/network-world From ebe5b809cca848d4c17836e85b1e666682708457 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 29 Mar 2018 16:28:39 +0800 Subject: [PATCH 0200/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Do=20continuous?= =?UTF-8?q?=20deployment=20with=20Github=20and=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nuous deployment with Github and Python.md | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 sources/tech/20180328 Do continuous deployment with Github and Python.md diff --git a/sources/tech/20180328 Do continuous deployment with Github and Python.md b/sources/tech/20180328 Do continuous deployment with Github and Python.md new file mode 100644 index 0000000000..88f6e52bac --- /dev/null +++ b/sources/tech/20180328 Do continuous deployment with Github and Python.md @@ -0,0 +1,185 @@ +Do continuous deployment with Github and Python +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/03/cd-github-python-945x400.jpg) +Developers can create many useful services using Github’s webhooks. From triggering a CI job on a Jenkins instance to provisioning machines in the cloud, the possibilities are almost limitless. This tutorial shows how to use Python and the Flask framework to build a simple continuous deployment service. + +The continuous deployment service in this example is a simple Flask application with a REST endpoint that will receive Github’s webhook requests. After validating each request to check that it comes from the correct Github repository, the service pulls changes to the local copy of the repository. That way every time a new commit is pushed to the remote Github repository, the local repository is automatically updated. + +### Flask web service + +It is easy to build a small web service with Flask. Here’s a look at the project structure. +``` +├── app +│   ├── __init__.py +│   └── webhooks.py +├── requirements.txt +└── wsgi.py + +``` + +First, create the application. The application code goes under the app directory. + +Two files ( __init__.py and webhooks.py) compose the Flask application. The former has the code needed to create the Flask application and add configuration to it. The latter has the endpoints logic. This is where the app receives the data from the Github request. + +Here is the app/__init__.py content: +``` +import os +from flask import Flask + +from .webhooks import webhook + +def create_app(): + """ Create, configure and return the Flask application """ + + app = Flask(__name__) + app.config['GITHUB_SECRET'] = os.environ.get('GITHUB_SECRET') + app.config['REPO_PATH'] = os.environ.get('REPO_PATH') + app.register_blueprint(webhook) + + return(app) + +``` + +The function creates two configuration variables: + + * **GITHUB_SECRET** holds a secret passphrase, used to authenticate the Github requests. + * **REPO_PATH** holds the path of the repository to automatically update. + + + +This code uses [Flask Blueprints][1] to organize the application endpoints. Using blueprints allows logical grouping of APIs, making applications easier to maintain. It is generally considered a good practice. + +Here is the content of app/webhooks.py: +``` +import hmac +from flask import request, Blueprint, jsonify, current_app +from git import Repo + +webhook = Blueprint('webhook', __name__, url_prefix='') + +@webhook.route('/github', methods=['POST']) +def handle_github_hook(): + """ Entry point for github webhook """ + + signature = request.headers.get('X-Hub-Signature') + sha, signature = signature.split('=') + + secret = str.encode(current_app.config.get('GITHUB_SECRET')) + + hashhex = hmac.new(secret, request.data, digestmod='sha1').hexdigest() + if hmac.compare_digest(hashhex, signature): + repo = Repo(current_app.config.get('REPO_PATH')) + origin = repo.remotes.origin + origin.pull('--rebase') + + commit = request.json['after'][0:6] + print('Repository updated with commit {}'.format(commit)) + return jsonify({}), 200 + +``` + +First the code creates a new Blueprint webhook. Then it adds a new endpoint to the Blueprint using a Flask route. This route will be called by any POST request on the /github URL endpoint. + +#### Verifying the request + +When the service receives a request on this endpoint, it must first verify that the request comes from Github and from the correct repository. Github gives a signature in the request header X-Hub-Signature. This signature is generated using a secret (GITHUB_SECRET), the [HMAC][2] hex digest of the request body, and then hashed using the sha1 hash function. + +To verify the request the service needs to calculate locally the signature and compare it to the signature received in the request header. This is done by the hmac.compare_digest function. + +#### Custom hook logic + +After validating the request, it can now be processd. This tutorial uses the [GitPython][3] module to interface with a git repository. From the GitPython module the Repo object is used to access the remote repository called origin. The service pulls the latest changes locally from the origin repository, also using the –rebase option to avoid issues with merges. + +A debug print statement displays the short commit hash received from the request body. This example shows how to use the request body. For more details about the data available in the body, check [github’s documentation][4]. + +Finally the service returns a empty JSON string and a 200 status code. This tells Github’s webhook server the request was received. + +### Deploying the service + +To run the service, this example uses the [gunicorn][5] web server. First install the service dependencies. On a supported Fedora server, use this command with [sudo][6]: +``` +sudo dnf install python3-gunicorn python3-flask python3-GitPython + +``` + +Now edit the wsgi.py file used by gunicorn to run the service: +``` +from app import create_app + +application = create_app() + +``` + +To deploy this service, clone this git [repository][7] or use your own git repository with this command: +``` +git clone https://github.com/cverna/github_hook_deployment.git /opt/ + +``` + +The next step is to configure the environment variables needed by the service. Run these commands: +``` +export GITHUB_SECRET=asecretpassphraseusebygithubwebhook +export REPO_PATH=/opt/github_hook_deployment/ + +``` + +This tutorial uses the webhook service Github repository, but you could use a different repository if you wish. Finally, start the webserver with these commands: +``` +cd /opt/github_hook_deployment/ +gunicorn --bind 0.0.0.0 wsgi:application --reload + +``` + +These options bind the web server to the 0.0.0.0 ip address, meaning it will accept requests coming from any host. The –reload option ensures the web server restarts when the code changes. This is where the continuous deployment magic happens. Every Github request received pulls the latest change in the repository, and gunicorn detects these changes and automatically restarts the application. + +**Note: **In order to receive the requests from github, the web service must be deployed on a server with a public IP address. An easy way to do this is to use your favorite cloud provider such as DigitalOcean, AWS, Linode, etc. + +### Configure Github + +The last part of this tutorial configures Github to send the webhook request to the web service. This is key to continuous deployment. + +From your Github repository settings, select the Webhook menu and click on Add Webhook. Enter the following information: + + * **Payload URL:** The URL of the service, for example + * **Content type:** Select application/json + * **Secret:** The **GITHUB_SECRET** environment variable defined earlier + + + +Then click the Add Webhook button. + +![][8] + +Github will now send a request to the service every time a push event happens on this repository. + +### Conclusion + +This tutorial has shown you how to write a Flask based web service that receives requests from a Github webhook and does continuous deployment. You should now be able to build your own useful services using this tutorial as a starting base. + +#### Like this: + +Like + +Loading... + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/continuous-deployment-github-python/ + +作者:[Author Archive;Author Website;Clément Verna][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://fedoramagazine.org +[1]:http://flask.pocoo.org/docs/0.12/blueprints/ +[2]:https://en.wikipedia.org/wiki/HMAC +[3]:https://gitpython.readthedocs.io/en/stable/index.html +[4]:https://developer.github.com/v3/activity/events/types/#webhook-payload-example-26 +[5]:http://gunicorn.org/ +[6]:https://fedoramagazine.org/howto-use-sudo/ +[7]:https://github.com/cverna/github_hook_deployment.git +[8]:https://fedoramagazine.org/wp-content/uploads/2018/03/Screenshot-2018-3-26-cverna-github_hook_deployment1.png From 1ac845b70cf9581e37da030b189d28954bec9bff Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 29 Mar 2018 18:16:23 +0800 Subject: [PATCH 0201/1057] Delete 20171212 Oh My Fish- Make Your Shell Beautiful.md --- ...2 Oh My Fish- Make Your Shell Beautiful.md | 255 ------------------ 1 file changed, 255 deletions(-) delete mode 100644 sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md diff --git a/sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md b/sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md deleted file mode 100644 index 99fea8b744..0000000000 --- a/sources/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md +++ /dev/null @@ -1,255 +0,0 @@ -Translating by MjSeven - -Oh My Fish! Make Your Shell Beautiful -====== -![](https://www.ostechnix.com/wp-content/uploads/2017/12/oh-my-fish-720x340.jpg) - -A few days ago, we discussed how to [**install** **Fish shell**][1], a robust, fully-usable shell that ships with many cool features out of the box such as autosuggestions, built-in search functionality, syntax highlighting, web based configuration and a lot more. Today, we are going to discuss how to make our Fish shell beautiful and elegant using **Oh My Fish** (shortly **omf** ). It is a Fishshell framework that allows you to install packages which extend or modify the look and feel of your shell. It is easy to use, fast and extensible. Using omf, you can easily install themes that enriches the look of your shell and install plugins to tweak your fish shell as per your wish. - -#### Install Oh My Fish - -Installing omf is not a big deal. All you have to do is just run the following command in your fish shell. -``` -curl -L https://get.oh-my.fish | fish -``` - -![][3] - -Once the installation has completed, you will see the the prompt has automatically changed as shown in the above picture. Also, you will notice that the current time on the right of the shell window. - -That's it. Let us go ahead and tweak our fish shell. - -#### Now, Let Us Make Our Fish Shell Beautiful - -To list all installed packages, run: -``` -omf list -``` - -This command will display both the installed themes and plugins. Please note that a package can be either a theme or plugin. Installing packages means installing themes or plugins. - -All official and community supported packages (both plugins and themes) are hosted in the [**main Omf repository**][4]. In this repository, you can see a whole bunch of repositories that contains a lot of plugins and themes. - -Now let us see the list of available and installed themes. To do so, run: -``` -omf theme -``` - -[![][2]][5] - -As you can see, we have only one installed theme, which is default, and a whole bunch of available themes. You can preview all available themes [**here**][6] before installing it. This page contains all theme details, features, a sample screenshot of each theme and which theme is suitable for whom. - -**Installing a new theme** - -Allow me to install a theme, for example **clearance theme - **a minimalist fish shell theme for people who use git a lot. To do so, run: -``` -omf install clearance -``` - -[![][2]][7] - -As you see in the above picture, the look of fish prompt has changed immediately after installing the new theme. - -Let me browse through the file system and see how it looks like. - -[![][2]][8] - -Not bad! It is really simple theme. It distinguishes the current working directory, folders and files with different color. As you may notice, it also displays the current working directory on top of the prompt. Currently, **clearance** is my default theme. - -**Changing theme** - -Like I already said, the theme will be applied immediately after installing it. If you have more than one themes, you can switch to a different theme using the following command: -``` -omf theme -``` - -Example: -``` -omf theme agnoster -``` - -Now I am using "agnoster" theme. Here is how agnoster theme changed the look of my shell. - -[![][2]][9] - -**Installing Plugins** - -For instance, I am going to install weather plugin. To do so, just run: -``` -omf install weather -``` - -The weather plugin depends on [jq][10]. So, you might need to install jq as well. It is mostly available in the default repositories of any Linux distro. So, you can install it using the default package manager. For example, the following command will install jq in Arch Linux and its variants. -``` -sudo pacman -S jq -``` - -Now, check your weather from your fish shell using command: -``` -weather -``` - -[![][2]][11] - -**Searching packages** - -To search for a theme or plugin, do: -``` -omf search -``` - -Example: -``` -omf search nvm -``` - -To limit the search to themes, use **-t** flag. -``` - omf search -t chain -``` - -This command will only search for themes that contains the string "chain". - -To limit the search to plugins, use **-p** flag. -``` - omf search -p emacs -``` - -**Updating packages** - -To update only the core (omf itself), run: -``` -omf update omf -``` - -If it is up-to-date, you would see the following output: -``` -Oh My Fish is up to date. -You are now using Oh My Fish version 6. -Updating https://github.com/oh-my-fish/packages-main master... Done! -``` - -To update all packages: -``` -omf update -``` - -To selectively update packages, just include the packages names as shown below. -``` -omf update clearance agnoster -``` - -**Displaying information about a package** - -When you want to know the information about a theme or plugin, use this command: -``` -omf describe clearance -``` - -This command will show the information about a package. -``` -Package: clearance -Description: A minimalist fish shell theme for people who use git -Repository: https://github.com/oh-my-fish/theme-clearance -Maintainer: -``` - -**Removing packages** - -To remove a package, for example emacs, run: -``` -omf remove emacs -``` - -**Managing Repositories** - -By default, the official repository is added automatically when you install Oh My Fish. This repository contains all packages built by the developers. To manage user-installed package repositories, use this command: -``` -omf repositories [list|add|remove] -``` - -To list installed repositories, run: -``` -omf repositories list -``` - -To add a repository: -``` -omf repositories add -``` - -Example: -``` -omf repositories add https://github.com/ostechnix/theme-sk -``` - -To remove a repository: -``` -omf repositories remove -``` - -**Troubleshooting Oh My Fish** - -Omf is smart enough to help you if things went wrong. It will list what to do to fix an issue. For example, I removed and installed clearance package and got file conflicting error. Luckily, Oh My Fish instructed me what to do before continuing. So, I simply ran the following to know how to fix the error: -``` -omf doctor -``` - -And fixed the issued the error by running the following command: -``` -rm ~/.config/fish/functions/fish_prompt.fish -``` - -[![][2]][12] - -Whenever you ran into a problem, just run 'omf doctor' command and try all suggested workarounds. - -**Getting help** - -To display help section, run: -``` -omf -h -``` - -Or, -``` -omf --help -``` - -**Uninstalling Oh My Fish** - -To uninstall Oh My Fish, run this command: -``` -omf destroy -``` - -Go ahead and start customizing your fish shell. For more details, refer the project's GitHub page. - -That's all for now folks. I will be soon here with another interesting guide. Until then, stay tuned with OSTechNix! - -Cheers! - - - --------------------------------------------------------------------------------- -via: https://www.ostechnix.com/oh-fish-make-shell-beautiful/ - -作者:[SK][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/author/sk/ -[1]:https://www.ostechnix.com/install-fish-friendly-interactive-shell-linux/ -[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[3]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-1-1.png () -[4]:https://github.com/oh-my-fish -[5]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-5.png () -[6]:https://github.com/oh-my-fish/oh-my-fish/blob/master/docs/Themes.md -[7]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-3.png () -[8]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-4.png () -[9]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-6.png () -[10]:https://stedolan.github.io/jq/ -[11]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-7.png () -[12]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-8.png () From 72868070ace3260e9f9d0818eb7c21e2b212d1a7 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 29 Mar 2018 18:16:56 +0800 Subject: [PATCH 0202/1057] Create 20171212 Oh My Fish- Make Your Shell Beautiful.md --- ...2 Oh My Fish- Make Your Shell Beautiful.md | 253 ++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md diff --git a/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md b/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md new file mode 100644 index 0000000000..7fad56f9ac --- /dev/null +++ b/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md @@ -0,0 +1,253 @@ +Oh My Fish! 让你的 Shell 漂亮起来 +===== + +![](https://www.ostechnix.com/wp-content/uploads/2017/12/oh-my-fish-720x340.jpg) + +几天前,我们讨论了如何 [**安装** **Fish shell**][1],一个健壮的,完全可用的 shell,带有许多很酷的功能,如自动建议,内置搜索功能,语法高亮显示,基于 web 配置等等。今天,我们将讨论如何使用 **Oh My Fish** (简称 **omf** ) 让我们的 Fish shell 变得漂亮且优雅。它是一个 Fishshell 框架,允许你安装扩展或更改 shell 外观的软件包。它简单易用,快速可扩展。使用 omf,你可以根据你的想法,很容易地安装主题,丰富你的外观和安装插件来调整你的 fish shell。 + +#### 安装 Oh My Fish + +安装 omf 很简单。你要做的只是在你的 fish shell 中运行下面的命令。 +``` +curl -L https://get.oh-my.fish | fish +``` + +![][3] + +一旦安装完成,你将看到提示已经自动更改,如上图所所示。另外,你会注意到当前时间在 shell 窗口的右边。 + +就是这样。让我们继续并调整我们的 fish shell。 + +#### 现在,让我们将 Fish Shell 变漂亮 + +列出所有的安装包,运行: +``` +omf list +``` + +这条命令将显示已安装的主题和插件。请注意,包可以是主题或插件。安装包意味着安装主题和插件。 + +所有官方和社区支持的包(包括插件和主题)都托管在 [**Omf 主仓库**][4] 中。在这个主仓库中,你可以看到大量的仓库,其中包含大量的插件和主题。 + +现在让我们看一下可用的和已安装的主题列表。为此,运行: +``` +omf theme +``` + +![][5] + +如你所见,我们只有一个已安装的主题,这是默认的,但是还有大量可用的主题。在安装之前,你在[**这里**][6]可以预览所有可用的主题。这个页面包含了所有的主题细节,特性,每个主题的截图示例,以及哪个主题适合谁。 + +**安装一个新主题** + +请允许我安装一个主题,例如 **clearance theme - **一个极简的 fish shell 主题,供那些经常使用 git 的人使用。为此,运行: +``` +omf install clearance +``` + +![][7] + +如上图所示,在安装新主题后,fish 的提示立即发生了变化。 + +让我浏览一下系统文件,看看它如何显示。 + +![][8] + +看起来不坏!这是一个非常简单的主题。它将当前工作目录,文件夹和文件以不同的颜色区分开来。你可能会注意到,它还会在提示符的顶部显示当前工作目录。现在,**clearance** 是我的默认主题。 + +**改变主题** + +就像我之前说的一样,这个主题在安装后被立即应用。如果你有多个主题,你可以使用以下命令切换到另一个不同的主题: +``` +omf theme +``` + +例如: +``` +omf theme agnoster +``` + +现在我正在使用 "agnoster" 主题。 agnoster 就是这样改变了我 shell 的外观。 + +![][9] + +**安装插件** + +例如,我想安装一个天气插件。为此,,只要运行: +``` +omf install weather +``` + +天气插件依赖于 [jq][10](LCTT 译注:jq 是一个轻量级且灵活的命令行JSON处理器)。所以,你可能也需要安装 jq。它通常在 Linux 发行版的默认仓库中存在。因此,你可以使用默认的包管理器来安装它。例如,以下命令将在 Arch Linux 及其衍生版中安装 jq。 +``` +sudo pacman -S jq +``` + +现在,在 fish shell 中使用以下命令查看天气: +``` +weather +``` + +![][11] + +**寻找包** + +要搜索主题或插件,请执行以下操作: +``` +omf search +``` + +例如: +``` +omf search nvm +``` + +为了限制搜索的主题范围,使用 **-t** 选项。 +``` + omf search -t chain +``` + +这条命令只会搜索主题名字中包含 "chain" 的主题。 + +为了限制搜索的插件范围,使用 **-p** 选项。 +``` + omf search -p emacs +``` + +**更新包** + +要仅更新核心功能(omf 本身),运行: +``` +omf update omf +``` + +如果是最新的,你会看到以下输出: +``` +Oh My Fish is up to date. +You are now using Oh My Fish version 6. +Updating https://github.com/oh-my-fish/packages-main master... Done! +``` + +更新所有包: +``` +omf update +``` + +要有选择地更新软件包,只需包含如下所示的包名称: +``` +omf update clearance agnoster +``` + +**显示关于包的信息** + +当你想知道关于一个主题或插件的信息时,使用以下命令: +``` +omf describe clearance +``` + +这条命令将显示关于包的信息。 +``` +Package: clearance +Description: A minimalist fish shell theme for people who use git +Repository: https://github.com/oh-my-fish/theme-clearance +Maintainer: +``` + +**移除包** + +移除一个包,例如 emacs,运行: +``` +omf remove emacs +``` + +**管理仓库** + +默认情况下,当你安装了 Oh My Fish 时,会自动添加官方仓库。这个仓库包含了开发人员构建的所有包。要管理用户安装的仓库包,使用这条命令: +``` +omf repositories [list|add|remove] +``` + +列出所有安装的仓库,运行: +``` +omf repositories list +``` + +添加一个仓库: +``` +omf repositories add +``` + +例如: +``` +omf repositories add https://github.com/ostechnix/theme-sk +``` + +移除一个仓库: +``` +omf repositories remove +``` + +**Troubleshooting Oh My Fish** + +如果出现了错误,omf 足够聪明来帮助你,它可以列出解决问题的方法。例如,我删除并安装了 clearance 包(这句不太理解,希望校正者注意),得到了文件冲突的错误。幸运的是,在继续之前,Oh My Fish 会指示我该怎么做。因此,我只是简单地运行了以下代码来了解如何修正错误。 +``` +omf doctor +``` + +通过运行以下命令来解决错误: +``` +rm ~/.config/fish/functions/fish_prompt.fish +``` + +![][12] + +无论你何时遇到问题,只要运行 'omf doctor' 命令,并尝试所有的建议方法。 + +**获取帮助** + +显示帮助部分,运行: +``` +omf -h +``` + +或者 +``` +omf --help +``` + +**卸载 Oh My Fish** + +卸载 Oh My Fish,运行以下命令: +``` +omf destroy +``` + +继续前进,开始自定义你的 fish shell。获取更多细节,请参考项目的 GitHub 页面。 + +这就是全部了。我很快将会在这里开始另一个有趣的指导。在此之前,请继续关注 OSTechNix! + +干杯! + + +-------------------------------------------------------------------------------- +via: https://www.ostechnix.com/oh-fish-make-shell-beautiful/ + +作者:[SK][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/author/sk/ +[1]:https://www.ostechnix.com/install-fish-friendly-interactive-shell-linux/ +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-1-1.png() +[4]:https://github.com/oh-my-fish +[5]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-5.png() +[6]:https://github.com/oh-my-fish/oh-my-fish/blob/master/docs/Themes.md +[7]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-3.png() +[8]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-4.png() +[9]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-6.png() +[10]:https://stedolan.github.io/jq/ +[11]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-7.png() +[12]:http://www.ostechnix.com/wp-content/uploads/2017/12/Oh-My-Fish-8.png() From b6a1786208fd6f1bd70e19ad77c81154c2d01f79 Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 30 Mar 2018 00:58:34 +0800 Subject: [PATCH 0203/1057] PRF:20180201 How I coined the term open source.md @fuzheng1998 --- ...80201 How I coined the term open source.md | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/translated/talk/20180201 How I coined the term open source.md b/translated/talk/20180201 How I coined the term open source.md index c8e72e917c..2dd310ecb8 100644 --- a/translated/talk/20180201 How I coined the term open source.md +++ b/translated/talk/20180201 How I coined the term open source.md @@ -1,87 +1,90 @@ -[fuzheng1998 translating] 我是如何创造“开源”这个词的 ============================================================ -### Christine Peterson 最终公开讲述了二十年前那决定命运的一天。 + +> Christine Peterson 最终公开讲述了二十年前那决定命运的一天。 ![How I coined the term 'open source'](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb "How I coined the term 'open source'") + 图片来自: opensource.com -几天后, 2 月 3 日, 术语“[开源软件][6]”创立 20 周年的纪念日即将到来。由于开源软件渐受欢迎并且为这个时代强有力的重要变革提供动力,我们仔细反思了它的初生到崛起。 +2 月 3 日是术语“[开源软件][6]open source software”创立 20 周年的纪念日。由于开源软件渐受欢迎,并且为这个时代强有力的重要变革提供了动力,我们仔细反思了它的初生到崛起。 -我是 “开源软件” 这个词的始作俑者,它是我在前瞻技术协会(Foresight Institute)担任执行董事时想出的。并非向上面的一个程序开发者一样,我感谢 Linux 程序员 Todd Anderson 对这个术语的支持并将它提交小组讨论。 +我是 “开源软件” 这个词的始作俑者,它是我在前瞻协会Foresight Institute担任执行董事时提出的。我不像其它人是个软件开发者,所以感谢 Linux 程序员 Todd Anderson 对这个术语的支持并将它提交小组讨论。 -这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些有关该术语的记叙,例如 Eric Raymond 和 Richard Stallman 写的,而我的,则写于 2006 年 1 月 2 日。 +这是我对于它如何想到的,如何提出的,以及后续影响的记叙。当然,还有一些有关该术语的其它记叙,例如 Eric Raymond 和 Richard Stallman 写的,而我的,则写于 2006 年 1 月 2 日。 -直到今天,它终于公诸于世。 +但直到今天,我才公诸于世。 * * * -推行术语“开源软件”是特地为了这个领域让新手和商业人士更加易懂,它的推广被认为对于更大的用户社区很有必要。早期称号的问题是,“自由软件” 并非有政治含义,但是那对于新手来说貌似对于价格的关注令人感到心烦意乱。一个术语需要聚焦于关键的源代码而且不会被立即把概念跟那些新东西混淆。一个恰好想出并且满足这些要求的第一个术语被快速接受:开源(open source)。 +推行术语“开源软件”是特别为了让新手和商业人士更加理解这个领域,对它的推广被认为对于更广泛的用户社区很有必要。早期的称呼“自由软件free software”不适用并非是因为含有政治意义,而是对于新手来说会误导关注于价格。所以需要一个关注于关键的源代码,而且不会让新用户混淆概念的术语。第一个在正确时间出现并且满足这些要求的术语被迅速接受了:开源open source。 -这个术语很长一段时间被用在“情报”(即间谍活动)的背景下,但据我所知,1998 年以前软件领域使用该术语尚未得到证实。下面这个就是讲述了术语“开源软件”如何流行起来并且变成了一项产业和一场运动名称的故事。 +这个术语很长一段时间被用在“情报”(即间谍活动)活动中,但据我所知,确实在 1998 年以前软件领域从未使用过该术语。下面这个就是讲述了术语“开源软件”如何流行起来,并且变成了一项产业和一场运动名称的故事。 ### 计算机安全会议 -在 1997 年的晚些时候,为期一周的会议将被在前瞻技术协会(Foresight Insttitue) 举行来讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,并且认为软件安全是二者的安全性以及可靠性的核心。我们在那确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 +在 1997 年的晚些时候,前瞻协会Foresight Institute开始举办周会讨论计算机安全问题。这个协会是一个非盈利性智库,它专注于纳米技术和人工智能,而二者的安全性及可靠性取决于软件安全。我们确定了自由软件是一个改进软件安全可靠性且具有发展前景的方法,并将寻找推动它的方式。 对自由软件的兴趣开始在编程社区外开始增长,而且越来越清晰,一个改变世界的机会正在来临。然而,该怎么做我们并不清楚,因为我们当时正在摸索中。 -在这些会议中,我们讨论了一些由于使人迷惑不解的因素而采用一个新术语的必要性。观点主要有以下:对于那些新接触“自由软件”的人把 "free" 当成了价格上的 “免费” 。老资格的成员们开始解释,通常像下面所说的:“我们的意思是自由的,而不是免费啤酒上的。"在这个点子上,一个软件方面的讨论变成了一个关于酒精价格的讨论。问题不在于解释不了含义——问题是重要概念的名称不应该使新手们感到困惑。所以需要一个更清晰的术语了。关于自由软件术语并没有政治上的问题;问题是缺乏对新概念的认识。 +在这些会议中,由于“容易混淆”的因素,我们讨论了采用一个新术语的必要性。观点主要如下:对于那些新接触“自由软件”的人会把 “free” 当成了价格上的 “免费” 。老资格的成员们开始解释,通常像下面所说的:“我们指的是 ‘freedom’ 中的自由,而不是‘免费啤酒’的免费。”在这一点上,关于软件方面的讨论就会变成了关于酒精饮料价格的讨论。问题不在于解释不了它的含义 —— 问题在于重要概念的术语不应该使新手们感到困惑。所以需要一个更清晰的术语。自由软件一词并没有政治上的问题;问题在于这个术语不能对新人清晰表明其概念。 -### 网景发布 +### 开放的网景 -1998 年 2 月 2 日,Eric Raymond 抵达访问网景并与它一起计划采用免费软件样式的许可证发布浏览器代码。我们那晚在前瞻位于罗斯阿尔托斯(Los Altos)的办公室制定了策略并改进了我们的要旨。除了 Eric 和我,活跃的参与者还有 Brian Behlendorf,Michael Tiemann,Todd Anderson,Mark S. Miller and Ka-Ping Yee。但在那次会议上,这个领域仍然被描述成“自由软件”,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 +1998 年 2 月 2 日,Eric Raymond 访问网景公司,并与它一起计划采用自由软件风格的许可证发布其浏览器的源代码。我们那晚在前瞻协会位于罗斯阿尔托斯Los Altos的办公室开会,商讨并完善了我们的计划。除了 Eric 和我,积极参与者还有 Brian Behlendorf、Michael Tiemann、Todd Anderson、Mark S. Miller 和 Ka-Ping Yee。但在那次会议上,这一领域仍然被描述成“自由软件”,或者用 Brian 的话说, 叫“可获得源代码的” 软件。 -在这个镇上,Eric 把前瞻协会(Foresight) 作为行动的大本营。他一开始访问行程,他就被几个网景法律和市场部门的员工通电话。当他挂电话后,我被要求带着电话跟他们——一男一女,可能是 Mitchell Baker——这样我才能谈论对于新术语的需求。他们原则上是立即同意了,但详细条款并未达成协议。 +在这个镇上,Eric 把前瞻协会作为行动的大本营。他访问行程期间,他接到了网景的法律和市场部门人员的电话。当他聊完后,我要求和他们(一男一女,可能是 Mitchell Baker)通电话,以便我告诉他们一个新的术语的必要性。他们原则上立即同意了,但我们在具体术语上并未达成一致。 -在那周的会议中,我仍然专注于起一个更好的名字并提出术语 “开源软件”。 虽然那不是完美的,但我觉得足够好了。我依靠至少另外四个人运营这个项目:Eric Drexler、Mark Miller,以及 Todd Anderson 和他这样的人,然而一个从事市场公关的朋友觉得术语 “open” 被滥用了并且相信我们能做更好再说。理论上它是对的,可我想不出更好的了,所以我想尝试并推广它。 事后一想我应该直接向 Eric Raymond 提案,但在那时我并不是很了解他,所以我采取了间接的策略。 +在那周的会议中,我始终专注于起一个更好的名字并提出了 “开源软件”一词。 虽然不太理想,但我觉得足够好了。我找到至少四个人征求意见:Eric Drexler、Mark Miller 以及 Todd Anderson 都喜欢它,而一个从事市场公关的朋友觉得术语 “open” 被滥用了,并且觉得我们能找到一个更好。理论上他是对的,可我想不出更好的了,所以我想试着先推广它。事后想起来,我应该直接向 Eric Raymond 提议,但在那时我并不是很了解他,所以我采取了间接的策略。 -Todd 强烈同意需要新的术语并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术是一个加分项,但不足以让我认真地接受自由软件问题的工作。作为一个Linux程序员,Todd 将会更仔细地聆听它。 +Todd 强烈同意需要一个新的术语,并提供协助推广它。这很有帮助,因为作为一个非编程人员,我在自由软件社区的影响力很弱。我从事的纳米技术教育是一个加分项,但不足以让我在自由软件问题上非常得到重视。而作为一个 Linux 程序员,Todd 的话更容易被倾听。 -### 关键的会议 +### 关键性会议 -那周之后,1998 年的 2 月 5 日,一伙人在 VA research 进行头脑风暴商量对策。与会者——除了 Eric Raymond,Todd和我之外,还有 Larry Augustin,Sam Ockman,还有 Jon“maddog”Hall 的电话。 +那周稍晚时候,1998 年的 2 月 5 日,一伙人在 VA Research 进行头脑风暴商量对策。与会者除了 Eric Raymond、Todd 和我之外,还有 Larry Augustin、Sam Ockman,和 Jon Hall (“maddog”)通过电话参与。 -会议的主要议题是推广策略,特别是要接洽的公司。 我几乎没说什么,而是在寻找机会推广已经提交讨论的术语。我觉得突然脱口而出那句话没什么用,“你们技术人员应当开始讨论我的新术语了。”他们大多数与会者不认识我,而且据我所知,他们可能甚至不同意对新术语的急切需求,或者是某种渴望。 +会议的主要议题是推广策略,特别是要联系的公司。 我几乎没说什么,但是一直在寻找机会介绍提议的术语。我觉得我直接说“你们这些技术人员应当开始使用我的新术语了。”没有什么用。大多数与会者不认识我,而且据我所知,他们可能甚至不同意现在就迫切需要一个新术语。 -幸运的是,Todd 是明智的。他没有主张社区应该用哪个特定的术语,而是间接地做了一些事——一件和社区里有强烈意愿的人做的明智之举。他简单地在其他话题中使用那个术语——把他放进对话里看看会发生什么。我警觉起来,希望得到一个答复,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了术语的使用。 +幸运的是,Todd 一直留心着。他没有主张社区应该用哪个特定的术语,而是面对社区这些固执的人间接地做了一些事。他仅仅是在其它话题中使用了那个术语 —— 把它放进对话里看看会发生什么。我很紧张,期待得到回应,但是起初什么也没有。讨论继续进行原来的话题。似乎只有他和我注意了这个术语的使用。 -不仅如此——模因演化(人类学术语)在起作用。几分钟后,另一个人明显地,没有提醒地,在仍然进行话题讨论而没说术语的情况下,用了这个术语。Todd 和我面面相觑对视:是的我们都注意到了发生的事。我很激动——它起作用了!但我保持了安静:我在小组中仍然地位不高。可能有些人都奇怪为什么 Eric 会最终邀请我。 +不仅如此——模因演化(LCTT 译注:人类学术语)在起作用。几分钟后,另一个人使用了这个术语,显然没有注意到,而在继续进行话题讨论。Todd 和我用眼角互觑了一下:是的,我们都注意到发生了什么。我很激动——它或许有用!但我保持了安静:我在小组中仍然地位不高。可能有些人都奇怪为什么 Eric 会邀请我。 -临近会议尾声,可能是 Todd or Eric,[术语问题][8] 被明确提出。Maddog 提及了一个早期的术语“可自由分发的,和一个新的术语“合作开发的”。Eric 列出了“自由软件”、“开源软件”,并把 "自由软件源" 作为一个主要选项。Todd宣传 “开源” 模型,然后Eric 支持了他。我什么也没说,让 Todd 和 Eric 共同促进开源名字达成共识。对于大多数与会者,他们很清楚改名不是在这讨论的最重要议题;那只是一个次要的相关议题。 我在会议中只有大约10%的说明放在了术语问答中。 +临近会议尾声,可能是 Todd 或 Eric,明确提出了[术语问题][8]。Maddog 提及了一个早期的术语“可自由分发的”,和一个新的术语“合作开发的”。Eric 列出了“自由软件”、“开源软件”和“软件源”作为主要选项。Todd 提议使用“开源”,然后 Eric 支持了他。我没说太多,就让 Todd 和 Eric(轻松、非正式地)就“开源”这个名字达成了共识。显然对于大多数与会者,改名并不是在这讨论的最重要议题;那只是一个次要的相关议题。从我的会议记录中看只有大约 10% 的内容是术语的。 -但是我很高兴。在那有许多社区的关键领导人,并且他们喜欢这新名字,或者至少没反对。这是一个好的信号信号。可能我帮不上什么忙; Eric Raymond 被相当好地放在了一个宣传模因的好位子上,而且他的确做到了。立即签约参加行动,帮助建立 [Opensource.org][9] 并在新术语的宣传中发挥重要作用。 +但是我很高兴。在那有许多社区的关键领导人,并且他们喜欢这新名字,或者至少没反对。这是一个好的信号。可能我帮不上什么忙; Eric Raymond 更适合宣传新的名称,而且他也这么做了。Bruce Perens 立即表示支持,帮助建立了 [Opensource.org][9] 并在新术语的宣传中发挥了重要作用。 -对于这个成功的名字,那很必要,甚至是相当渴望, 因此 Tim O'Reilly 同意以社区的名义在公司积极使用它。在官方即将发布的 the Netscape Navigator(网景浏览器)代码中的术语使用也为此帮了忙。 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 +为了让这个名字获得认同,Tim O'Reilly 同意在代表社区的多个项目中积极使用它,这是很必要,甚至是非常值得的。并且在官方即将发布的 Netscape Navigator(网景浏览器)代码中也使用了此术语。 到二月底, O'Reilly & Associates 还有网景公司(Netscape) 已经开始使用新术语。 -### 名字的诞生 +### 名字的宣传 -在那之后的一段时间,这条术语由 Eric Raymond 向媒体推广,由 Tim O'Reilly 向商业推广,并由二人向编程社区推广,那似乎传播的相当快。 +在那之后的一段时间,这条术语由 Eric Raymond 向媒体推广,由 Tim O'Reilly 向商业推广,并由二人向编程社区推广,它似乎传播的相当快。 -1998 年 4 月 17 日, Tim O'Reilly 提前宣布首届 “[自由软件峰会][10]” ,在 4 月14 日之前,它以首届 “[开源峰会][11]” 被提及。 +1998 年 4 月 17 日,Tim O'Reilly 召集了该领域的一些重要领袖的峰会,宣布为第一次 “[自由软件峰会][10]” ,在 4 月14 日之后,它又被称作首届 “[开源峰会][11]”。 -这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。读 Slashdot(科技资讯网站)已经成了一个必需操作, 甚至对于那些像我一样只能外围地参与者亦是如此。我坚信新术语能对快速传播到商业很有帮助,能被公众广泛使用。 +这几个月对于开源来说是相当激动人心的。似乎每周都有一个新公司宣布加入计划。读 Slashdot(LCTT 译注:科技资讯网站)已经成了一个必需操作,甚至对于那些像我一样只能外围地参与者亦是如此。我坚信新术语能对快速传播到商业很有帮助,能被公众广泛使用。 -尽管快捷的谷歌搜索表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,特别是和偏爱它的人们沟通的时候。 +尽管在谷歌搜索一下表明“开源”比“自由软件”出现的更多,但后者仍然有大量的使用,在和偏爱它的人们沟通的时候我们应该包容。 -### 一丝快感 +### 快乐的感觉 -当一个被 Eric Raymond 写的有关修改术语的早期的陈述被发布在了开放源代码促进会的网站上时,我上了 VA 头脑风暴会议的名单,但并不是作为一个术语的创始人。这是我自己的错,我没告诉 Eric 细节。我当时一时冲动只想让它表决通过然后我只是呆在后台,但是 Todd 不这样认为。他认为我总有一天将作为“开源软件”这个名词的创造者而感到高兴。他向 Eric 解释了这个情况,Eric 及时更新了它的网站。 +当 Eric Raymond 写的有关术语更改的[早期声明][12]被发布在了开源促进会Open Source Initiative的网站上时,我被列在 VA 头脑风暴会议的名单上,但并不是作为术语的创始人。这是我自己的失误,我没告诉 Eric 细节。我的想法就是让它过去吧,我呆在幕后就好,但是 Todd 不这样认为。他认为我总有一天会为被称作“开源软件”这个名词的创造者而高兴。他向 Eric 解释了这个情况,Eric 及时更新了网站。 -想出这个短语只是一个小贡献,但是我得承认我十分感激那些把它归功于我的人。每次我听到它,它都给我些许激动的喜悦,到现在也时常感受到。 +想出这个短语只是一个小贡献,但是我很感激那些把它归功于我的人。每次我听到它(现在经常听到了),它都给我些许的感动。 -说服团队的大功劳归功于 Eric Raymond 和 Tim O'Reilly,这是他们搞定的。感谢他们对我的评价,并感谢 Todd Anderson 在整个过程中的角色。以上内容并非完整的开源历史记录,对很多没有无名人士表示歉意。那些寻求更完整讲述的人应该参考本文和网上其他地方的链接。 +说服社区的巨大功劳要归功于 Eric Raymond 和 Tim O'Reilly,是他们让这一切成为可能。感谢他们对我的归功,并感谢 Todd Anderson 所做的一切。以上内容并非完整的开源一词的历史,让我对很多没有提及的关键人士表示歉意。那些寻求更完整讲述的人应该参考本文和网上其他地方的链接。 ### 关于作者 - [![photo of Christine Peterson](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/cp2016_crop2_185.jpg?itok=vUkSjFig)][13] Christine Peterson - Christine Peterson 撰写,举办讲座,并向媒体介绍未来强大的技术,特别是纳米技术,人工智能和长寿。她是著名的纳米科技公共利益集团的创始人和过去的前瞻技术协会主席。前瞻向公众、技术团体和政策制定者提供未来强大的技术的教育以及告诉它是如何引导他们的长期影响。她服务于 [机器智能 ][2]咨询委员会……[更多关于 Christine Peterson][3][关于我][4] +[![photo of Christine Peterson](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/cp2016_crop2_185.jpg?itok=vUkSjFig)][13] + +Christine Peterson 撰写、举办讲座,并向媒体介绍未来强大的技术,特别是在纳米技术,人工智能和长寿方面。她是纳米科技公益组织前瞻协会的共同创始人和前任主席。前瞻协会向公众、技术团体和政策制定者提供未来强大的技术的教育以及告诉它是如何引导他们的长期影响。她服务于[机器智能][2]咨询委员会……[更多关于 Christine Peterson][3] -------------------------------------------------------------------------------- via: https://opensource.com/article/18/2/coining-term-open-source-software -作者:[ Christine Peterson][a] +作者:[Christine Peterson][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 178ae6c624d942ebe5f0614875c66d62a4133f93 Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 30 Mar 2018 00:59:00 +0800 Subject: [PATCH 0204/1057] PUB:20180201 How I coined the term open source.md @fuzheng1998 --- .../20180201 How I coined the term open source.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180201 How I coined the term open source.md (100%) diff --git a/translated/talk/20180201 How I coined the term open source.md b/published/20180201 How I coined the term open source.md similarity index 100% rename from translated/talk/20180201 How I coined the term open source.md rename to published/20180201 How I coined the term open source.md From a50766ad31d5033cfc7e273b1d101f50b76d7847 Mon Sep 17 00:00:00 2001 From: Snowden Fu Date: Fri, 30 Mar 2018 06:54:02 +0800 Subject: [PATCH 0205/1057] 2018-3-30 --- ... Why Linux is better than Windows or macOS for security.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md index 0b09b13c86..7ff2effe28 100644 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -27,9 +27,9 @@ Still, would it be wise to reconsider? Are the three leading desktop OSes differ 给你的用户部署的那个操作系统确实对你的安全态度产生了影响,但那并不是一个可靠的安全措施For one thing, a breach these days is more likely to come about because an attacker probed your users, not your systems. A [survey][1] of hackers who attended a recent DEFCON conference revealed that “84 percent use social engineering as part of their attack strategy.” Deploying a secure operating system is an important starting point, but without user education, strong firewalls and constant vigilance, even the most secure networks can be invaded. And of course there’s always the risk of user-downloaded software, extensions, utilities, plug-ins and other software that appears benign but becomes a path for malware to appear on the system. -And no matter which platform you choose, one of the best ways to keep your system secure is to ensure that you apply software updates promptly. Once a patch is in the wild, after all, the hackers can reverse engineer it and find a new exploit they can use in their next wave of attacks. +无论你选择哪种平台,保持你系统安全最好的方法之一就是确保立即应用了软件更新。Once a patch is in the wild, after all, the hackers can reverse engineer it and find a new exploit they can use in their next wave of attacks. -And don’t forget the basics. Don’t use root, and don’t grant guest access to even older servers on the network. Teach your users how to pick really good passwords and arm them with tools such as [1Password][2] that make it easier for them to have different passwords on every account and website they use. +而且别忘了最基本的。别用 root 权限,别授权用户连接到网络中的老服务器上。教你的用户如何挑选一个真正的好密码并且使用例如 [1Password][2] 这样的工具让他们在使用不同密码网站和账户更加简单。 Because the bottom line is that every decision you make regarding your systems will affect your security, even the operating system your users do their work on. From 9c5293f1682756637e49a61c2d25b6a6c5fa5b55 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 30 Mar 2018 08:47:26 +0800 Subject: [PATCH 0206/1057] translated --- ...0107 Caffeinated 6.828- Exercise- Shell.md | 106 ------------------ ...0107 Caffeinated 6.828- Exercise- Shell.md | 105 +++++++++++++++++ 2 files changed, 105 insertions(+), 106 deletions(-) delete mode 100644 sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md create mode 100644 translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md diff --git a/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md b/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md deleted file mode 100644 index 2eb36f7e81..0000000000 --- a/sources/tech/20140107 Caffeinated 6.828- Exercise- Shell.md +++ /dev/null @@ -1,106 +0,0 @@ -translating---geekpi - -Caffeinated 6.828: Exercise: Shell -====== - -This assignment will make you more familiar with the Unix system call interface and the shell by implementing several features in a small shell. You can do this assignment on any operating system that supports the Unix API (a Linux Athena machine, your laptop with Linux or Mac OS, etc.). Please submit your shell to the the [submission web site][1] at any time before the first lecture. - -While you shouldn't be shy about emailing the [staff mailing list][2] if you get stuck or don't understand something in this exercise, we do expect you to be able to handle this level of C programming on your own for the rest of the class. If you're not very familiar with C, consider this a quick check to see how familiar you are. Again, do feel encouraged to ask us for help if you have any questions. - -Download the [skeleton][3] of the xv6 shell, and look it over. The skeleton shell contains two main parts: parsing shell commands and implementing them. The parser recognizes only simple shell commands such as the following: -``` -ls > y -cat < y | sort | uniq | wc > y1 -cat y1 -rm y1 -ls | sort | uniq | wc -rm y - -``` - -Cut and paste these commands into a file `t.sh` - -You can compile the skeleton shell as follows: -``` -$ gcc sh.c - -``` - -which produces a file named `a.out`, which you can run: -``` -$ ./a.out < t.sh - -``` - -This execution will panic because you have not implemented several features. In the rest of this assignment you will implement those features. - -### Executing simple commands - -Implement simple commands, such as: -``` -$ ls - -``` - -The parser already builds an `execcmd` for you, so the only code you have to write is for the ' ' case in `runcmd`. To test that you can run "ls". You might find it useful to look at the manual page for `exec`; type `man 3 exec`. - -You do not have to implement quoting (i.e., treating the text between double-quotes as a single argument). - -### I/O redirection - -Implement I/O redirection commands so that you can run: -``` -echo "6.828 is cool" > x.txt -cat < x.txt - -``` - -The parser already recognizes '>' and '<', and builds a `redircmd` for you, so your job is just filling out the missing code in `runcmd` for those symbols. Make sure your implementation runs correctly with the above test input. You might find the man pages for `open` (`man 2 open`) and `close` useful. - -Note that this shell will not process quotes in the same way that `bash`, `tcsh`, `zsh` or other UNIX shells will, and your sample file `x.txt` is expected to contain the quotes. - -### Implement pipes - -Implement pipes so that you can run command pipelines such as: -``` -$ ls | sort | uniq | wc - -``` - -The parser already recognizes "|", and builds a `pipecmd` for you, so the only code you must write is for the '|' case in `runcmd`. Test that you can run the above pipeline. You might find the man pages for `pipe`, `fork`, `close`, and `dup` useful. - -Now you should be able the following command correctly: -``` -$ ./a.out < t.sh - -``` - -Don't forget to submit your solution to the [submission web site][1], with or without challenge solutions. - -### Challenge exercises - -If you'd like to experiment more, you can add any feature of your choice to your shell. You might try one of the following suggestions: - - * Implement lists of commands, separated by `;` - * Implement subshells by implementing `(` and `)` - * Implement running commands in the background by supporting `&` and `wait` - * Implement quoting of arguments - - - -All of these require making changing to the parser and the `runcmd` function. - --------------------------------------------------------------------------------- - -via: https://sipb.mit.edu/iap/6.828/lab/shell/ - -作者:[mit][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://sipb.mit.edu -[1]:https://exokernel.scripts.mit.edu/submit/ -[2]:mailto:sipb-iap-6.828@mit.edu -[3]:https://sipb.mit.edu/iap/6.828/files/sh.c diff --git a/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md b/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md new file mode 100644 index 0000000000..50fb5b6167 --- /dev/null +++ b/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md @@ -0,0 +1,105 @@ +Caffeinated 6.828:练习 shell +====== + +通过在 shell 中实现多项功能,该作业将使你更加熟悉 Unix 系统调用接口和 shell。你可以在支持 Unix API 的任何操作系统(一台 Linux Athena 机器、装有 Linux 或 Mac OS 的笔记本电脑等)上完成此作业。请在第一次上课前将你的 shell 提交到[网站][1]。 + +如果你在练习中遇到困难或不理解某些内容时,你不要害羞给[员工邮件列表][2]发送邮件,但我们确实希望全班的人能够自行处理这级别的 C 编程。如果你对 C 不是很熟悉,可以认为这个是你对 C 熟悉程度的检查。再说一次,如果你有任何问题,鼓励你向我们寻求帮助。 + +下载 xv6 shell 的[框架][3],然后查看它。框架 shell 包含两个主要部分:解析 shell 命令并实现它们。解析器只能识别简单的 shell 命令,如下所示: +``` +ls > y +cat < y | sort | uniq | wc > y1 +cat y1 +rm y1 +ls | sort | uniq | wc +rm y + +``` + +将这些命令剪切并粘贴到 `t.sh `中。 + +你可以按如下方式编译框架 shell: +``` +$ gcc sh.c + +``` + +它会生成一个名为 `a.out` 的文件,你可以运行它: +``` +$ ./a.out < t.sh + +``` + +执行会崩溃,因为你还没有实现几个功能。在本作业的其余部分中,你将实现这些功能。 + +### 执行简单的命令 + +实现简单的命令,例如: +``` +$ ls + +``` + +解析器已经为你构建了一个 `execcmd`,所以你唯一需要编写的代码是 `runcmd` 中的 case ' '。要测试你可以运行 “ls”。你可能会发现查看 `exec` 的手册页是很有用的。输入 `man 3 exec`。 + +你不必实现引用(即将双引号之间的文本视为单个参数)。 + +### I/O 重定向 + +实现 I/O 重定向命令,这样你可以运行: +``` +echo "6.828 is cool" > x.txt +cat < x.txt + +``` + +解析器已经识别出 '>' 和 '<',并且为你构建了一个 `redircmd`,所以你的工作就是在 `runcmd` 中为这些符号填写缺少的代码。确保你的实现在上面的测试输入中正确运行。你可能会发现 `open`(`man 2 open`) 和 `close` 的 man 手册页很有用。 + +请注意,此 shell 不会像 `bash`、`tcsh`、`zsh` 或其他 UNIX shell 那样处理引号,并且你的示例文件 `x.txt` 预计包含引号。 + +### 实现管道 + +实现管道,这样你可以运行命令管道,例如: +``` +$ ls | sort | uniq | wc + +``` + +解析器已经识别出 “|”,并且为你构建了一个 `pipecmd`,所以你必须编写的唯一代码是 `runcmd` 中的 case '|'。测试你可以运行上面的管道。你可能会发现 `pipe`、`fork`、`close` 和 `dup` 的 man 手册页很有用。 + +现在你应该可以正确地使用以下命令: + +``` +$ ./a.out < t.sh + +``` + +无论是否完成挑战任务,不要忘记将你的答案提交给[网站][1]。 + +### 挑战练习 + +如果你想进一步尝试,可以将所选的任何功能添加到你的 shell。你可以尝试以下建议之一: + + * 实现由 `;` 分隔的命令列表 +  * 通过实现 `(` 和 `)` 来实现子 shell +  * 通过支持 `&` 和 `wait` 在后台执行命令 +  * 实现参数引用 + + + +所有这些都需要改变解析器和 `runcmd` 函数。 + +-------------------------------------------------------------------------------- + +via: https://sipb.mit.edu/iap/6.828/lab/shell/ + +作者:[mit][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://sipb.mit.edu +[1]:https://exokernel.scripts.mit.edu/submit/ +[2]:mailto:sipb-iap-6.828@mit.edu +[3]:https://sipb.mit.edu/iap/6.828/files/sh.c From 434457b5f645ae6f26a7a125a7dab735c695d9a7 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 30 Mar 2018 08:51:33 +0800 Subject: [PATCH 0207/1057] translating --- ...0180326 4 command line note-taking applications for Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180326 4 command line note-taking applications for Linux.md b/sources/tech/20180326 4 command line note-taking applications for Linux.md index 1851637dfc..f2d06d50e5 100644 --- a/sources/tech/20180326 4 command line note-taking applications for Linux.md +++ b/sources/tech/20180326 4 command line note-taking applications for Linux.md @@ -1,3 +1,5 @@ +translating---geekpi + 4 command line note-taking applications for Linux ====== From 3f68acf76dcb4bb6a635a7cd41a64b225798b284 Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 30 Mar 2018 10:28:01 +0800 Subject: [PATCH 0208/1057] PRF:20171117 Command line fun- Insult the user when typing wrong bash command.md @CYLeft --- ...the user when typing wrong bash command.md | 92 +++++++++++++------ 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/translated/tech/20171117 Command line fun- Insult the user when typing wrong bash command.md b/translated/tech/20171117 Command line fun- Insult the user when typing wrong bash command.md index 3f1cacfaab..77acb72719 100644 --- a/translated/tech/20171117 Command line fun- Insult the user when typing wrong bash command.md +++ b/translated/tech/20171117 Command line fun- Insult the user when typing wrong bash command.md @@ -1,57 +1,75 @@ -命令行乐趣:恶搞输错 Bash 命令的用户 +命令行乐趣:嘲讽输错 Bash 命令的用户 ====== -你可以通过配置 sudo 命令去恶搞输入错误密码的用户。但是之后,shell 的恶搞提示语可能会滥用于输入错误命令的用户。 +你可以通过配置 `sudo` 命令去嘲讽输入错误密码的用户。但是现在,当用户在 shell 输错命令时,就能嘲讽他了(滥用?)。 -## 你好 bash-insulter +### 你好 bash-insulter 来自 Github 页面: -> 当用户键入错误命令,随机嘲讽。它使用了一个 bash4.x. 版本的全新内置错误处理函数,叫 command_not_found_handle。 +> 当用户键入错误命令,随机嘲讽。它使用了一个 bash4.x. 版本的全新内置错误处理函数,叫 `command_not_found_handle`。 -## 安装 +### 安装 键入下列 git 命令克隆一个仓库: -`git clone https://github.com/hkbakke/bash-insulter.git bash-insulter` + +``` +git clone https://github.com/hkbakke/bash-insulter.git bash-insulter +``` + 示例输出: + ``` Cloning into 'bash-insulter'... remote: Counting objects: 52, done. remote: Compressing objects: 100% (49/49), done. remote: Total 52 (delta 12), reused 12 (delta 2), pack-reused 0 Unpacking objects: 100% (52/52), done. - ``` -用文本编辑器,编辑你的 ~/.bashrc 或者 /etc/bash.bashrc 文件,比如说使用 vi: -`$ vi ~/.bashrc` -在其后追加这一行(具体了解请查看 [if..else..fi 声明][1] 和 [命令源码][2]): +用文本编辑器,比如说使用 `vi`,编辑你的 `~/.bashrc` 或者 `/etc/bash.bashrc` 文件: + +``` +$ vi ~/.bashrc +``` + +在其后追加这一行(具体了解请查看 [if..else..fi 声明][1] 和 [source 命令][2]): + ``` if [ -f $HOME/bash-insulter/src/bash.command-not-found ]; then source $HOME/bash-insulter/src/bash.command-not-found fi ``` -保存并关闭文件。重新登陆,如果不想退出账号也可以手动运行它: +保存并关闭文件。重新登录,如果不想退出账号也可以手动运行它: + ``` $ . $HOME/bash-insulter/src/bash.command-not-found ``` -## 如何使用它? +### 如何使用它? 尝试键入一些无效命令: + ``` $ ifconfigs $ dates ``` + 示例输出: + [![一个有趣的 bash 钩子功能,嘲讽输入了错误命令的你。][3]][3] -## 自定义 +### 自定义 + +你需要编辑 `$HOME/bash-insulter/src/bash.command-not-found`: + +``` +$ vi $HOME/bash-insulter/src/bash.command-not-found +``` -你需要编辑 $HOME/bash-insulter/src/bash.command-not-found: -`$ vi $HOME/bash-insulter/src/bash.command-not-found` 示例代码: + ``` command_not_found_handle () { local INSULTS=( @@ -104,15 +122,28 @@ command_not_found_handle () { } ``` -## sudo 嘲讽 +### 赠品:sudo 嘲讽 + +编辑 `sudoers` 文件: + +``` +$ sudo visudo +``` -编辑 sudoers 文件: -`$ sudo visudo` 追加下面这一行: -`Defaults insults` + +``` +Defaults insults +``` + 或者像下面尾行增加一句嘲讽语: -`Defaults !lecture,tty_tickets,!fqdn,insults` + +``` +Defaults !lecture,tty_tickets,!fqdn,insults +``` + 这是我的文件: + ``` Defaults env_reset Defaults mail_badpass @@ -140,19 +171,26 @@ root ALL = (ALL:ALL) ALL #includedir /etc/sudoers.d ``` -Try it out: +试一试: + ``` -$ sudo -k # clear old stuff so that we get a fresh prompt +$ sudo -k # 清除缓存,从头开始 $ sudo ls /root/ $ sudo -i ``` -样例对话: + +样例对话: + [![当输入错误密码时,你会被一个有趣的的 sudo 嘲讽语戏弄。][4]][4] -## 你好 sl +### 赠品:你好 sl + +[sl 或是 UNIX 经典捣蛋软件][5] 游戏。当你错误的把 `ls` 输入成 `sl`,将会有一辆蒸汽机车穿过你的屏幕。 + +``` +$ sl +``` -[sl 或是 UNIX 经典捣蛋软件][5] 游戏。当你错误的把 “ls” 输入成 “sl”,将会有一辆蒸汽机车穿过你的屏幕。 -`$ sl` [![Linux / UNIX 桌面乐趣: 蒸汽机车][6]][5] -------------------------------------------------------------------------------- @@ -161,7 +199,7 @@ via: https://www.cyberciti.biz/howto/insult-linux-unix-bash-user-when-typing-wro 作者:[Vivek Gite][a] 译者:[CYLeft](https://github.com/CYLeft) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 9dbf514adeabaf2789cced95114a3c959569a849 Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 30 Mar 2018 10:28:39 +0800 Subject: [PATCH 0209/1057] PUB:20171117 Command line fun- Insult the user when typing wrong bash command.md @CYLeft https://linux.cn/article-9497-1.html --- ...nd line fun- Insult the user when typing wrong bash command.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171117 Command line fun- Insult the user when typing wrong bash command.md (100%) diff --git a/translated/tech/20171117 Command line fun- Insult the user when typing wrong bash command.md b/published/20171117 Command line fun- Insult the user when typing wrong bash command.md similarity index 100% rename from translated/tech/20171117 Command line fun- Insult the user when typing wrong bash command.md rename to published/20171117 Command line fun- Insult the user when typing wrong bash command.md From 7325862ec20f747df942c28ed4293a48c9ca914a Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 30 Mar 2018 16:24:01 +0800 Subject: [PATCH 0210/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Getting=20start?= =?UTF-8?q?ed=20with=20Jupyter=20Notebooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Getting started with Jupyter Notebooks.md | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 sources/tech/20180328 Getting started with Jupyter Notebooks.md diff --git a/sources/tech/20180328 Getting started with Jupyter Notebooks.md b/sources/tech/20180328 Getting started with Jupyter Notebooks.md new file mode 100644 index 0000000000..133b93451f --- /dev/null +++ b/sources/tech/20180328 Getting started with Jupyter Notebooks.md @@ -0,0 +1,90 @@ +Getting started with Jupyter Notebooks +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ) +Since the days of papyrus, publishers have struggled with formatting data in ways that engage readers. This is a particular issue in the areas of mathematics, science, and programming, where well-designed charts, illustrations, and equations can be key to helping people understand technical information. + +[The Jupyter Notebook][1] is addressing this problem by reimagining how we produce instructional texts. Jupyter (which I first learned about at [All Things Open][2] in October 2017) is an open source application that enables users to create interactive, shareable notebooks that contain live code, equations, visualizations, and text. + +Jupyter evolved from the [IPython Project][3], which features an interactive shell and a browser-based notebook with support for code, text, and mathematical expressions. Jupyter offers support for over 40 programming languages, including Python, R, and Julia, and its code can be exported to HTML, LaTeX, PDF, images, and videos or as [IPython][4] notebooks to be shared with other users. + +Fun fact: "Jupyter" is an acronym for "Julia, Python, and R." + +Some of its uses, according to Project Jupyter's website, include "data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more." Scientific institutions are using Jupyter Notebooks to explain research results. The code, which can come from actual data, can be tweaked and re-tweaked to visualize different results and scenarios. In this way, Jupyter Notebooks have become living texts and reports. + +### Installing and starting Jupyter + +The Jupyter software is open source, licensed under the [modified BSD license][5], and it can be [installed on Linux, MacOS, or Windows][6]. There are a number of ways to install Jupyter; I tried the PIP and the [Anaconda][7] installs on Linux and MacOS. A PIP install requires that Python is already installed on your computer; Jupyter recommends Python 3. + +Since Python 3 was already installed on my computers, I installed Jupyter by running the following commands in the terminal (on Linux or Mac): +``` +$ python3 -m pip install --upgrade pip + +$ python3 -m pip install jupyter + +``` + +Entering the following command at the terminal prompt started the application right away: +``` +$ jupyter notebook + +``` + +Soon my browser opened and displayed my Jupyter Notebook server at `http://localhost:8888`. (Supported browsers are Google Chrome, Firefox, and Safari.) + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_1.png?itok=UyM1GuVG) + +There's a drop-down menu labeled "New" in the upper-right corner. It enabled me to quickly create a new notebook for my own instructions and code. Note that my new notebook defaults to Python 3, which is my current environment. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_2.png?itok=alDI432q) + +A new notebook with some default values, which can be changed (including the name of the notebook), opened. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_3.png?itok=9zjG-5JC) +Notebooks have two different modes: Command and Edit. Command mode allows you to add or delete cells. You can enter Command mode by pressing the Escape key, and you can get into Edit mode by pressing the Enter key or by clicking in a cell. + +A green highlight around a cell indicates you are in Edit mode, and a blue highlight means you're in Command mode. The following notebook is in Command mode and ready for me to execute the Python code in the cell. Note that I've changed the name of the notebook to First Notebook. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_4.png?itok=-QPxcuFX) + +### Using Jupyter + +A strength of Jupyter Notebooks is that besides being able to enter code, you can also add Markdown with narrative and explanatory text. I wanted to add a heading, so I added a cell above my code and typed a heading in Markdown. When I pressed `Ctrl+Enter`, my heading converted to HTML. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_5.png?itok=-sr9A8-W) + +I can add output from a Bash command or script by appending an `!` to a command. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_6.png?itok=o_g38ECp) + +I can also take advantage of IPython's [line magic and cell magic][8] commands. You can list the magic commands by appending a `%` or `%%` sign to commands inside a code cell. For example, `%lsmagic` produces all the magic commands that can be used in Jupyter notebooks. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_7.png?itok=uit0PtND) + +Examples of these magic commands include `%pwd`, which outputs the present working directory (e.g., `/Users/YourName`) and `%ls`, which lists all the files and subdirectories in the current working directory. Another magic command displays charts generated from `matplotlib` in the notebook. `%%html` renders anything in that cell as HTML, which is useful for embedding video and links. There are cell magic commands for JavaScript and Bash, also. + +If you need more information about using Jupyter Notebooks and its features, the Help section is incredibly complete. + +People are using Jupyter Notebooks in many interesting ways; you can find some great examples in this [gallery][9]. How are you using Jupyter notebooks? Please share your ideas in the comments below. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/getting-started-jupyter-notebooks + +作者:[Don Watkins][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/don-watkins +[1]:http://jupyter.org/ +[2]:https://allthingsopen.org/ +[3]:http://ipython.org/ +[4]:https://en.wikipedia.org/wiki/IPython +[5]:https://opensource.org/licenses/BSD-3-Clause +[6]:http://jupyter.org/install.html +[7]:https://www.anaconda.com/download/#linux +[8]:http://ipython.readthedocs.io/en/stable/interactive/magics.html +[9]:https://github.com/jupyter/jupyter/wiki/a-gallery-of-interesting-jupyter-notebooks#mathematics From 41f1ac8eb16596231f2ef7a1285f68fc1c1c2197 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 30 Mar 2018 16:25:37 +0800 Subject: [PATCH 0211/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20College=20stude?= =?UTF-8?q?nt=20reflects=20on=20getting=20started=20in=20open=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...lects on getting started in open source.md | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sources/talk/20180328 College student reflects on getting started in open source.md 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 new file mode 100644 index 0000000000..4e757fe2f9 --- /dev/null +++ b/sources/talk/20180328 College student reflects on getting started in open source.md @@ -0,0 +1,44 @@ +College student reflects on getting started in open source +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_2.png?itok=JPlR5aCA) +I just completed the first semester of my second year in college, and I'm reflecting on what I learned in my classes. One class, in particular, stood out to me: "[Foundations of an Open Source World][1]," taught by Dr. Bryan Behrenshausen at Duke University. I enrolled in the class at the last minute because it seemed interesting and, if I’m being honest because it fit my schedule. + +On the first day, Dr. Behrenshausen asked if we students knew or had used any open source programs. Until that day I had hardly heard [the term “open source”][2] and certainly wasn't cognizant of any products that fell into that category. As the semester went on, however, it dawned on me that the passion I have towards my career aspirations would not exist without open source. + +### Audacity and GIMP + +My interest in technology started at age 12. Charged with the task of cutting music for my dance team, I searched the web for hours until I found Audacity, an open source audio editor. Audacity opened doors for me; no longer was I confined to repetitive eight-counts of the same beat. I started receiving requests left and right from others who wanted unique renditions of their favorite songs. + +Weeks later, I stumbled upon a GIF on the internet of a cat with a Pop-Tart torso and a rainbow trail flying through space. I searched “how to make moving images” and discovered [GIMP][3], an open source graphics editor, and used it to create a GIF of "The Simpsons" for my brother’s birthday present. + +My budding interest grew into a full-time obsession: creating artwork on my clunky, laggy laptop. Since I didn’t have much luck with charcoal, paint, or watercolors, I used [graphic design][4] as an outlet for creative expression. I spent hours in the computer lab learning the basics of HTML and CSS on [W3Schools][5] so that I could fill an online portfolio with my childish GIFs. A few months later, I published my first website on [WordPress][6]. + +### Why open source + +Open source allows us to not only achieve our goals but to discover interests that drive those goals. + +Fast-forward nearly a decade. Many things have changed, although some have stayed consistent: I still make graphics (mostly flyers), edit music for a dance group, and design websites (sleeker, more effective ones, I hope). The products I used have gone through countless version upgrades. But the most dramatic change is my approach to open source resources. + +Considering the significance of open source products in my life has made me cherish the open movement and its mission. Open source projects remind me that there are initiatives in tech that promote social good and self-learning without being exclusive to those who are socioeconomically advantaged. My middle-school self, like countless others, couldn’t afford to purchase the Adobe Creative Suite, GarageBand, or Squarespace. Open source platforms allow us to not only achieve our goals but to discover interests that drive those goals by broadening our access networks. + +My advice? Enroll in a class on a whim. It just might change the way you view the world. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/college-getting-started + +作者:[Christine Hwang][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/christinehwang +[1]:https://ssri.duke.edu/news/new-course-explores-open-source-principles +[2]:https://opensource.com/node/42001 +[3]:https://www.gimp.org/ +[4]:https://opensource.com/node/30251 +[5]:https://www.w3schools.com/ +[6]:https://opensource.com/node/31441 From 953cfb13c8e409520ce562f34a5c0dbdb003bc9a Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 30 Mar 2018 16:42:37 +0800 Subject: [PATCH 0212/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Use?= =?UTF-8?q?=20Instagram=20In=20Terminal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...180328 How To Use Instagram In Terminal.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 sources/tech/20180328 How To Use Instagram In Terminal.md diff --git a/sources/tech/20180328 How To Use Instagram In Terminal.md b/sources/tech/20180328 How To Use Instagram In Terminal.md new file mode 100644 index 0000000000..bfa1149c15 --- /dev/null +++ b/sources/tech/20180328 How To Use Instagram In Terminal.md @@ -0,0 +1,67 @@ +How To Use Instagram In Terminal +====== +![](https://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-720x340.png) +Instagram doesn’t need introduction. It is one of a popular social network platform, like Facebook and Twitter, to share photos and videos either publicly or privately to pre-approved followers. It was launched in 2010 by two entrepreneurs namely **Kevin Systrom** and **Mike Krieger**. In 2012, the social network giant Facebook has acquired Instagram. Instagram is available for free on Android and iOS devices. We can also use it in desktop systems via a web browser. And, the cool thing is now you can use Instagram in Terminal on any Unix-like operating systems. Are you excited? Well, read on to know how to view your Instagram feed on your Terminal. + +### Instagram In Terminal + +First, install **pip3** as described in the following link. + +Then, git clone the repository of “instagram-terminal-news-feed” script. +``` +$ git clone https://github.com/billcccheng/instagram-terminal-news-feed.git + +``` + +The above command will clone the contents of instagram script in a directory named “instagram-terminal-news-feed” in your current working directory. Cd to that directory: +``` +$ cd instagram-terminal-news-feed/ + +``` + +Then, run the following command to install instagram terminal feed: +``` +$ pip3 install -r requirements.txt + +``` + +Now, run the following command to launch instagram in terminal in your Linux box. +``` +$ python3 start.py + +``` + +Enter your Instagram username and password and browse your Instagram feed right from the Terminal. Your instragram username and password will only be stored locally in the file called **credential.json**. So, you don’t need to worry about it. You can also just don’t save your credentials which is the default option. + +Here is some screenshots of [**My Instagram page**][1]. + +![][3] + +![][4] + +![][5] + +Please note that you can only view your feed. You can’t follow anyone, like or comment posts. This is just a instagram feed reader. + +This project is freely available on GitHub, so you can view the source code, improve it, add more features, fix any bugs if there are any. + +Have fun! Cheers!! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-use-instagram-in-terminal/ + +作者:[SK][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://www.ostechnix.com/author/sk/ +[1]:https://www.instagram.com/ostechnix/ +[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-1.png +[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-2.png +[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-3-2.png From 409fcf7fa01866650170b297d2232ff7a2dd4ea2 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 30 Mar 2018 16:56:24 +0800 Subject: [PATCH 0213/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Protect=20Your?= =?UTF-8?q?=20Websites=20with=20Let's=20Encrypt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rotect Your Websites with Let-s Encrypt.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md diff --git a/sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md b/sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md new file mode 100644 index 0000000000..e38875f292 --- /dev/null +++ b/sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md @@ -0,0 +1,87 @@ +Protect Your Websites with Let's Encrypt +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/lock-1920.jpg?itok=7sjbOYkU) +Back in the bad old days, setting up basic HTTPS with a certificate authority cost as much as several hundred dollars per year, and the process was difficult and error-prone to set up. Now we have [Let's Encrypt][1] for free, and the whole thing takes just a few minutes. + +### Why Encrypt? + +Why encrypt your sites? Because unencrypted HTTP sessions are wide open to multiple abuses: + + + Eavesdropping on your users + + Capturing user logins + + Injecting ads and "important" messages + + Injecting spyware + + Injecting SEO spam and links + + Injecting cryptocurrency miners + +Internet service providers lead the code-injecting offenders. How to foil their nefarious desires? Your best defense is HTTPS. Let's review how HTTPS works. + +### Chain of Trust + +You could set up asymmetric encryption between your site and everyone who is allowed to access it. This is very strong protection: GPG (GNU Privacy Guard, see [How to Encrypt Email in Linux][2]), and OpenSSH are common tools for asymmetric encryption. These rely on public-private key pairs. You can freely share public keys, while your private keys must be protected and never shared. The public key encrypts, and the private key decrypts. + +This is a multi-step process that does not scale for random web-surfing, however, because it requires exchanging public keys before establishing a session, and you have to generate and manage key pairs. An HTTPS session automates public key distribution, and sensitive sites, such as shopping and banking, are verified by a third-party certificate authority (CA) such as Comodo, Verisign, or Thawte. + +When you visit an HTTPS site, it provides a digital certificate to your web browser. This certificate verifies that your session is strongly encrypted and supplies information about the site, such as organization's name, the organization that issued the certificate, and the name of the certificate authority. You can see all of this information, and the digital certificate, by clicking on the little padlock in your web browser's address bar (Figure 1). + + +![page information][4] + +Figure 1: Click on the padlock in your web browser's address bar for information. + +[Used with permission][5] + +The major web browsers, including Opera, Firefox, Chromium, and Chrome, all rely on the certificate authority to verify the authenticity of the site's digital certificate. The little padlock gives the status at a glance; green = strong SSL encryption and verified identity. Web browsers also warn you about malicious sites, sites with incorrectly configured SSL certificates, and they treat self-signed certificates as untrusted. + +So how do web browsers know who to trust? Browsers include a root store, a batch of root certificates, which are stored in `/usr/share/ca-certificates/mozilla/`. Site certificates are verified against your root store. Your root store is maintained by your package manager, just like any other software on your Linux system. On Ubuntu, they are supplied by the `ca-certificates` package. The root store itself is [maintained by Mozilla][6] for Linux. + +As you can see, it takes a complex infrastructure to make all of this work. If you perform any sensitive online transactions, such as shopping or banking, you are trusting a whole lot of unknown people to protect you. + +### Encryption Everywhere + +Let's Encrypt is a global certificate authority, similar to the commercial CAs. Let's Encrypt was founded by the non-profit Internet Security Research Group (ISRG) to make it easier to secure Websites. I don't consider it sufficient for shopping and banking sites, for reasons which I will get to shortly, but it's great for securing blogs, news, and informational sites that don't have financial transactions. + +There are at least three ways to use Let's Encrypt. The best way is with the [Certbot client][7], which is maintained by the Electronic Frontier Foundation (EFF). This requires shell access to your site. + +If you are on shared hosting then you probably don't have shell access. The easiest method in this case is using a [host that supports Let's Encrypt][8]. + +If your host does not support Let's Encrypt, but supports custom certificates, then you can [create and upload your certificate manually][8] with Certbot. It's a complex process, so you'll want to study the documentation thoroughly. + +When you have installed your certificate use [SSL Server Test][9] to test your site. + +Let's Encrypt digital certificates are good for 90 days. When you install Certbot it should also install a cron job for automatic renewal, and it includes a command to test that the automatic renewal works. You may use your existing private key or certificate signing request (CSR), and it supports wildcard certificates. + +### Limitations + +Let's Encrypt has some limitations: it performs only domain validation, that is, it issues a certificate to whoever controls the domain. This is basic SSL. It does not support Organization Validation (OV) or Extended Validation (EV) because it is not possible to automate identity validation. I would not trust a banking or shopping site that uses Let's Encrypt-- let 'em spend the bucks for a complete package that includes identity validation. + +As a free-of-cost service run by a non-profit organization there is no commercial support, but only documentation and community support, both of which are quite good. + +The Internet is full of malice. Everything should be encrypted. Start with [Let's Encrypt][10]to protect your site visitors. + +Learn more about Linux through the free ["Introduction to Linux" ][11]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/3/protect-your-websites-lets-encrypt + +作者:[CARLA SCHRODER][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://www.linux.com/users/cschroder +[1]:https://letsencrypt.org +[2]:https://www.linux.com/learn/how-encrypt-email-linux +[3]:https://www.linux.com/files/images/fig-11png-0 +[4]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fig-1_1_1.png?itok=_PPiSNx6 (page information) +[5]:https://www.linux.com/licenses/category/used-permission +[6]:https://www.mozilla.org/en-US/about/governance/policies/security-group/certs/policy/ +[7]:https://certbot.eff.org/ +[8]:https://community.letsencrypt.org/t/web-hosting-who-support-lets-encrypt/6920 +[9]:https://www.ssllabs.com/ssltest/ +[10]:https://letsencrypt.org/ +[11]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From ff8debb744bfdc44104bf7bded0a654ab317a4fb Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 30 Mar 2018 17:26:29 +0800 Subject: [PATCH 0214/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Dry=20=E2=80=93?= =?UTF-8?q?=20An=20Interactive=20CLI=20Manager=20For=20Docker=20Containers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ctive CLI Manager For Docker Containers.md | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 sources/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md diff --git a/sources/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md b/sources/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md new file mode 100644 index 0000000000..0aa181165e --- /dev/null +++ b/sources/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md @@ -0,0 +1,153 @@ +Dry – An Interactive CLI Manager For Docker Containers +====== +Docker is a software that allows operating-system-level virtualization also known as containerization. + +It uses the resource isolation features of the Linux kernel such as cgroups and kernel namespaces, and others to allows independent containers to run within a single Linux instance. + +Docker provides a way to run applications securely isolated in a container, packaged with all its dependencies and libraries. + +### What Is Dry + +[Dry][1] is a command line utility to manage & monitor Docker containers and images. + +It shows information about Containers, Images, Name of the containers, Networks, Running commands in the containers, and status, and, if running a Docker Swarm, it also shows all kinds of information about the state of the Swarm cluster. + +It can connect to both local or remote Docker daemons. Docker host shows `unix:///var/run/docker.sock` if the local Docker connected. + +Docker host shows `tcp://IP Address:Port Number` or `tcp://Host Name:Port Number` if the remote Docker connected. + +It could provide you the similar output metrics like `docker ps` but it has more verbose and colored output than “docker ps”. + +It also has an additional NAME column which comes handy at times when you have many containers you are not a memory champion. + +**Suggested Read :** +**(#)** [Portainer – A Simple Docker Management GUI][2] +**(#)** [Rancher – A Complete Container Management Platform For Production Environment][3] +**(#)** [cTop – A Command-Line Tool For Container Monitoring And Management In Linux][4] + +### How To Install Dry On Linux + +The latest dry utility can be installed through single shell script on Linux. It does not require external libraries. Most of the Docker commands are available in dry with the same behavior. +``` +$ curl -sSf https://moncho.github.io/dry/dryup.sh | sudo sh + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 10 100 10 0 0 35 0 --:--:-- --:--:-- --:--:-- 35 +dryup: downloading dry binary +######################################################################## 100.0% +dryup: Moving dry binary to its destination +dryup: dry binary was copied to /usr/local/bin, now you should 'sudo chmod 755 /usr/local/bin/dry' + +``` + +Change the file permission to `755` using the below command. +``` +$ sudo chmod 755 /usr/local/bin/dry + +``` + +For Arch Linux users can install from AUR repository with help of **[Packer][5]** or **[Yaourt][6]** package manager. +``` +$ yaourt -S dry-bin +or +$ packer -S dry-bin + +``` + +If you wants to run dry as a Docker container, run the following command. Make sure Docker should be installed on your system for this as a prerequisites. + +**Suggested Read :** +**(#)** [How to install Docker in Linux][7] +**(#)** [How to play with Docker images on Linux][8] +**(#)** [How to play with Docker containers on Linux][9] +**(#)** [How to Install, Run Applications inside Docker Containers][10] +``` +$ docker run -it -v /var/run/docker.sock:/var/run/docker.sock moncho/dry + +``` + +### How To Launch & Use Dry + +Simply run the `dry` command from your terminal to launch the utility. The default output for dry is similar to below. +``` +$ dry + +``` + +![][12] + +### How To Monitor Docker Using Dry + +You can open the monitor mode in dry by pressing `m` key. +![][13] + +### How To Manage Container Using Dry + +To monitor any containers, just hit `Enter` on that. Dry allows you to perform activity such as logs, inspect, kill, remove container, stop, start, restart, stats, and image history. +![][14] + +### How To Monitor Container Resource Utilization + +Dry allows users to monitor particular container resource utilization using `Stats+Top` option. + +We can achieve this by navigating to container management page (Follow the above steps and hit the `Stats+Top` option). Alternatively we can press `s` key to open container resource utilization page. + +![][15] + +### How To Check Container, Image, & Local Volume Disk Usage + +We can check disk usage of containers, images, and local volumes using `F8` key. + +This will clearly display the total number of containers, images, and volumes, and how many are active, and total disk usage and reclaimable size details. +![][16] + +### How To Check Downloaded Images + +Press `2` key to list all the downloaded images. +![][17] + +### How To Show Network List + +Press `3` key to list all the networks and it’s gateway. +![][18] + +### How To List All Docker Containers + +Press `F2` key to list all the containers (This output includes Running & Stopped containers). +![][19] + +### Dry Keybinds + +To view keybinds, navigate to help page or [dry github][1] page. + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/dry-an-interactive-cli-manager-for-docker-containers/ + +作者:[Magesh Maruthamuthu][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://www.2daygeek.com/author/magesh/ +[1]:https://github.com/moncho/dry +[2]:https://www.2daygeek.com/portainer-a-simple-docker-management-gui/ +[3]:https://www.2daygeek.com/rancher-a-complete-container-management-platform-for-production-environment/ +[4]:https://www.2daygeek.com/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux/ +[5]:https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/ +[6]:https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/ +[7]:https://www.2daygeek.com/install-docker-on-centos-rhel-fedora-ubuntu-debian-oracle-archi-scentific-linux-mint-opensuse/ +[8]:https://www.2daygeek.com/list-search-pull-download-remove-docker-images-on-linux/ +[9]:https://www.2daygeek.com/create-run-list-start-stop-attach-delete-interactive-daemonized-docker-containers-on-linux/ +[10]:https://www.2daygeek.com/install-run-applications-inside-docker-containers/ +[11]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[12]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-1.png +[13]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-2.png +[14]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-3.png +[15]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-4.png +[16]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-5.png +[17]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-6.png +[18]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-7.png +[19]:https://www.2daygeek.com/wp-content/uploads/2018/03/dry-an-interactive-cli-manager-for-docker-containers-8.png From acd34ff19a751cd2f90af62fb6bcb68ddadcdd97 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Fri, 30 Mar 2018 21:58:32 +0800 Subject: [PATCH 0215/1057] Update 20171109 How to record statistics about a Linux machine-s uptime.md --- ...9 How to record statistics about a Linux machine-s uptime.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md b/sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md index 1a5be11efa..9b26d7cf7c 100644 --- a/sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md +++ b/sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md @@ -1,3 +1,5 @@ +Translating by MjSeven + How to record statistics about a Linux machine’s uptime ====== Linux/Unix sysadmins have a weird obsession with server uptime. There is a xkcd comic devoted to this subject where a good sysadmin is an unstoppable force that it stands between the forces of darkness and your cat blog's servers. From be904a27cdf5311d3c988681cc378c25dbdf185b Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 30 Mar 2018 22:24:48 +0800 Subject: [PATCH 0216/1057] PRF:20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md @MjSeven --- ... Productivity Apps You Haven-t Heard Of.md | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md b/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md index 904bfb5eb0..ebf7592b07 100644 --- a/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md +++ b/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md @@ -1,71 +1,71 @@ -你从没听过的 10 个免费的 Linux 高效率应用程序 +你没听过的 10 个免费的 Linux 生产力应用程序 ===== ![](https://www.maketecheasier.com/assets/uploads/2017/09/Linux-productivity-apps-00-Featured.jpg) -高效率的应用程序确实可以让你工作变得更轻松。如果你是一位 Linux 用户,这 10 个不太知名的 Linux 桌面应用程序可以帮助到你。事实上,Linux 用户可能已经听说过列表上的所有应用,但对于那些没有超越主流应用的人来说,这些应用是未知的。 +高效率的应用程序确实可以让你工作变得更轻松。如果你是一位 Linux 用户,这 10 个不太知名的 Linux 桌面应用程序可以帮助到你。事实上,Linux 用户可能已经听说过这个列表上的所有应用,但对于那些只用过主流应用的人来说,应该是不知道这些应用的。 ### 1. Tomboy/Gnote ![linux-productivity-apps-01-tomboy][1] -[Tomboy][2] 是一个简单的便签应用。它不仅仅适用于 Linux,你也可以在 Unix,Windows 和 macOS 上获得它。Tomboy 很容易使用-你写一个便条,选择是否让它粘贴在你的桌面上,当你完成它时删除它。 +[Tomboy][2] 是一个简单的便签应用。它不仅仅适用于 Linux,你也可以在 Unix、Windows 和 macOS 上获得它。Tomboy 很容易使用——你写一个便条,选择是否让它粘贴在你的桌面上,当你完成它时删除它。 ### 2. MyNotex ![linux-productivity-apps-02-mynotex][3] -如果你想要一个更多功能的便签,但是仍喜欢一个小而简单的应用程序,而不是一个巨大的套件,请查看 [MyNotex][4]。除了简单的笔记和检索之外,它还带有一些不错的功能,例如格式化,键盘快捷键和附件等等。你也可以将其用作图片管理器。 +如果你想要一个更多功能的便签,但是仍喜欢一个小而简单的应用程序,而不是一个巨大的套件,请看看 [MyNotex][4]。除了简单的笔记和检索之外,它还带有一些不错的功能,例如格式化、键盘快捷键和附件等等。你也可以将其用作图片管理器。 ### 3. Trojitá ![linux-productivity-apps-03-trojita][5] -尽管你可以没有桌面电子右键客户端,但如果你已经习惯了有几十个可用的桌面电子右键客户端,请尝试 [Trojita][6]。这有利于生产力,因为它是一个快速轻量级的电子邮件客户端,但它提供了一个好的电子邮件客户端必须具备的所有功能(以及更多)。 +尽管你可以没有桌面电子邮件客户端,但如果你想要一个的话,在几十个的桌面电子邮件客户端里,请尝试下 [Trojita][6]。这有利于生产力,因为它是一个快速而轻量级的电子邮件客户端,但它提供了一个好的电子邮件客户端所必须具备的所有功能(以及更多)。 ### 4. Kontact ![linux-productivity-apps-04-kontact][7] -个人信息管理器 (PIM) 是一款出色的生产力工具。我的个人喜好是 [Kontact][8]。尽管它已经有几年没有更新,但它仍然是一个非常有用的 PIM 工具,用于管理电子邮件,地址簿,日历,任务,新闻源等。Kontact 是一个本地 KDE,但你也可以在其他桌面上使用它。 +个人信息管理器(PIM)是一款出色的生产力工具。我的个人喜好是 [Kontact][8]。尽管它已经有几年没有更新,但它仍然是一个非常有用的 PIM 工具,用于管理电子邮件、地址簿、日历、任务、新闻源等。Kontact 是一个 KDE 原生程序,但你也可以在其他桌面上使用它。 ### 5. Osmo ![linux-productivity-apps-05-osmo][9] -[Osmo][10] 是以一款更先进的应用,包括日历,任务,联系人和 notes 功能。它还附带一些额外的功能,比如加密的私有数据备份和地图上的地理位置,以及对 notes 、任务、、联系人登录强大搜索功能。 +[Osmo][10] 是一款更先进的应用,包括日历、任务、联系人和便签功能。它还附带一些额外的功能,比如加密私有数据备份和地图上的地理位置,以及对便签、任务、联系人等的强大搜索功能。 ### 6. Catfish ![linux-productivity-apps-06-catfish][11] -一个好的搜索工具是高生产力的表现。[Catfish][12] 是一个必须尝试的搜索工具。它是一个 GTK+ 工具,非常快速,轻量级。Catfish 会利用 Zeitgeist 的自动完成功能,你还可以按日期和类型过滤搜索结果。 +没有好的搜索工具就没有高生产力。[Catfish][12] 是一个必须尝试的搜索工具。它是一个 GTK+ 工具,非常快速,轻量级。Catfish 会利用 Zeitgeist 的自动完成功能,你还可以按日期和类型过滤搜索结果。 ### 7. KOrganizer ![linux-productivity-apps-07-korganizer][13] -[KOrganizer][14] 是我上面提到的 Kontact 应用程序的日历和调度组件。如果你不需要完整的 PIM 应用程序,只需要日历和日程安排,则可以使用 KOrganizer。KOrganizer 提供快速的待办事项和快速事件条目,以及事件和待办事项的附件。 +[KOrganizer][14] 是我上面提到的 Kontact 应用程序的日历和计划组件。如果你不需要完整的 PIM 应用程序,只需要日历和日程安排,则可以使用 KOrganizer。KOrganizer 提供快速的待办事项和快速事件条目,以及事件和待办事项的附件。 ### 8. Evolution ![linux-productivity-apps-08-evolution][15] -如果你不是 KDE 应用程序的粉丝,但你仍然需要一个好的 PIM,那么试试 GNOME 的 [Evolution][16]。Evolution 并不是一个你从没听过的不太受欢迎的应用程序,但因为它有用,所以它出现在这个列表中。也许你已经听说过 Evolution 是一个电子邮件客户端,但它远不止于此-你可以用它来管理日历,邮件,地址簿和任务。 +如果你不是 KDE 应用程序的粉丝,但你仍然需要一个好的 PIM,那么试试 GNOME 的 [Evolution][16]。Evolution 并不是一个你从没听过的少见的应用程序,但因为它有用,所以它出现在这个列表中。也许你已经听说过 Evolution 是一个电子邮件客户端,但它远不止于此——你可以用它来管理日历、邮件、地址簿和任务。 ### 9. Freeplane ![linux-productivity-apps-09-freeplane][17] -我不知道你们中的大多数是否每天都使用思维导图软件,但是如果你使用,请选择 [Freeplane][18]。这是一款免费的思维导图和知识管理软件,可用于商业或娱乐。你可以创建笔记,将其排列在云或图表中,使用日历和提醒设置任务等。 +我不知道你们中的大多数是否每天都使用思维导图软件,但是如果你使用,请选择 [Freeplane][18]。这是一款免费的思维导图和知识管理软件,可用于商业或娱乐。你可以创建笔记,将其排列在云图或图表中,使用日历和提醒设置任务等。 ### 10. Calligra Flow ![linux-productivity-apps-10-calligra-flow][19] -最后,如果你需要流程图和图标工具,请尝试 [Calligra Flow][20]。你可以将其视为开放源代码 [Microsoft Visio][21] 的替代品,但 Calligra Flow 不提供 Viso 提供的所有特权。不过,你可以使用它来创建网络图,组织结构图,流程图等等。 +最后,如果你需要流程图和图表工具,请尝试 [Calligra Flow][20]。你可以将其视为开放源代码的 [Microsoft Visio][21] 替代品,但 Calligra Flow 不提供 Viso 提供的所有特性。不过,你可以使用它来创建网络图、组织结构图、流程图等等。 -生产力工具不仅可以加快工作速度,还可以让你更有条理。我敢打赌,在某些方面几乎没有人不使用生产力工具。尝试这里列出的应用程序可以使你的工作效率更高,还能让你的生活至少轻松一些。 +生产力工具不仅可以加快工作速度,还可以让你更有条理。我敢打赌,几乎没有人不使用某种形式的生产力工具。尝试这里列出的应用程序可以使你的工作效率更高,还能让你的生活至少轻松一些。 -------------------------------------------------------------------------------- @@ -73,7 +73,7 @@ via: https://www.maketecheasier.com/free-linux-productivity-apps-you-havent-hear 作者:[Ada Ivanova][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 d239e654e35d81c0173489279a95e9f6aa998b2c Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 30 Mar 2018 22:36:26 +0800 Subject: [PATCH 0217/1057] PUB:20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md @MjSeven https://linux.cn/article-9498-1.html --- ...171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md (100%) diff --git a/translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md b/published/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md similarity index 100% rename from translated/tech/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md rename to published/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md From c612264030f40d9f78298a7e4df48d95cccce3ad Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 31 Mar 2018 00:34:34 +0800 Subject: [PATCH 0218/1057] PRF:20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md @amwps290 --- ...aging Systemd Units From Linux Terminal.md | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md b/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md index 29300c3b02..902d8a4e12 100644 --- a/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md +++ b/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md @@ -1,96 +1,90 @@ -# chkservice -Linux终端管理系统单元的工具 +chkservice:在 Linux 终端管理 systemd 单元的工具 +================ -systemd 即系统守护进程是一个新的初始化系统和系统管理工具,这个 systemd 非常流行,大部分的 Linux 发行版开始使用这种新的初始化系统。 +systemd 意即系统守护进程system daemon,是一个新的初始化系统和系统管理工具,它现在非常流行,大部分的 Linux 发行版开始使用这种新的初始化系统。 -Systemctl 是一个 systemd 的工具,它可以帮助我们管理 systemd 守护进程。 它控制系统启动和服务,使用并行化方式,套接字和 D-Bus 激活启动服务,提供按需启动守护进程,使用 Linux 控制组跟踪进程,维护挂载和自动挂载点。 +`systemctl` 是一个 systemd 的工具,它可以帮助我们管理 systemd 守护进程。 它控制系统的启动程序和服务,使用并行化方式,为启动的服务激活套接字和 D-Bus,提供守护进程的按需启动,使用 Linux 控制组跟踪进程,维护挂载和自动挂载点。 -此外,它还提供了守护进程日志、用于控制基本系统配置如主机名、日期、地区、维护登录用户列表和运行容器和虚拟机、系统帐户、运行时目录和设置,以及守护进程来管理简单的网络配置、网络时间同步、日志转发和名称解析。 +此外,它还提供了日志守护进程、用于控制基本系统配置的功能,如主机名、日期、地区、维护已登录用户列表和运行容器和虚拟机、系统帐户、运行时目录和设置,以及管理简单网络配置、网络时间同步、日志转发和名称解析的守护进程。 ### 什么是 chkservice -[chkservice][1] 是一个基于 ncurses 的在终端中管理系统资源的工具。它提供了一个非常全面的系统资源视图,可以使它们非常容易修改。 +[chkservice][1] 是一个基于 ncurses 的在终端中管理 systemd 单元的工具。它提供了一个非常全面的 systemd 服务的视图,使得它们非常容易修改。 -只有拥有超级管理权限才能够改变系统资源状态和系统启动脚本。 +只有拥有超级管理权限才能够改变 systemd 单元的状态和 sysv 系统启动脚本。 ### 在 Linux 安装 chkservice -我们可以通过两种方式安装 chkservice,通过包安装或者手动安装。 +我们可以通过两种方式安装 `chkservice`,通过包安装或者手动安装。 -对于 `Debian/Ubuntu`,使用 [APT-GET Command][2] 或 [APT Command][3] 安装 chkservice. +对于 Debian/Ubuntu,使用 [APT-GET 命令][2] 或 [APT 命令][3] 安装 `chkservice`。 ``` $ sudo add-apt-repository ppa:linuxenko/chkservice $ sudo apt-get update $ sudo apt-get install chkservice - ``` -对于 `Arch Linux` 系的系统,使用 [Yaourt Command][4] 或 [Packer Command][5] 从 AUR 库安装 chkservice。 +对于 Arch Linux 系的系统,使用 [Yaourt 命令][4] 或 [Packer 命令][5] 从 AUR 库安装 `chkservice`。 ``` $ yaourt -S chkservice -or +或 $ packer -S chkservice - ``` -对于 **`Fedora`** , 使用 [DNF Command][6] 安装 chkservice。 +对于 Fedora,使用 [DNF 命令][6] 安装 `chkservice`。 ``` $ sudo dnf copr enable srakitnican/default $ sudo dnf install chkservice - ``` -对于 `Debian` 系系统,使用 [DPKG Command][7] 安装 chkservice。 +对于 Debian 系系统,使用 [DPKG 命令][7] 安装 `chkservice`。 ``` $ wget https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.deb $ sudo dpkg -i chkservice_0.1.0-amd64.deb - ``` -对于 `RPM` 系的系统,使用 [DNF Command][8] 安装 chkservice。 +对于 RPM 系的系统,使用 [DNF 命令][8] 安装 `chkservice`。 ``` $ sudo yum install https://github.com/linuxenko/chkservice/releases/download/0.1/chkservice_0.1.0-amd64.rpm - ``` ### 如何使用 chkservice -只需输入以下命令即可启动 chkservice 工具。 输出分为四部分。 - - * **`第一部分:`** 这一部分显示了守护进程的状态,比如可用的 [X] 或者不可用的 [] 或者静态的 [s] 或者被掩藏的 -m- - * **`第二部分:`** 这一部分显示守护进程的状态例如开始 [ >] 或者停止 [=] - * **`第三部分:`** 这一部分显示单元的名称 - * **`第四部分:`** 这一部分简短地显示了守护进程的一些信息 +只需输入以下命令即可启动 `chkservice` 工具。 输出分为四部分。 + * **第一部分:** 这一部分显示了守护进程的状态,比如可用的 `[X]` 或者不可用的 `[ ]` 或者静态的 `[s]` 或者被掩藏的 `-m-` + * **第二部分:** 这一部分显示守护进程的状态例如开始 `>` 或者停止 `=` + * **第三部分:** 这一部分显示单元的名称 + * **第四部分:** 这一部分简短地显示了守护进程的一些信息 ``` $ sudo chkservice - ``` ![][10] -要查看帮助页面,点击 `?` 按钮。 这将向您显示管理 systemd 服务的可用选项。 +要查看帮助页面,按下 `?`。 这将向您显示管理 systemd 服务的可用选项。 ![][11] -选择要启用或禁用的守护进程,然后点击`空格键`按钮。 +选择要启用或禁用的守护进程,然后点击空格键。 ![][12] -选择你想开始或停止的守护进程,然后点击 `s` 按钮。 +选择你想开始或停止的守护进程,然后按下 `s`。 ![][13] -选择要重新启动的守护进程,然后按 `r` 按钮。 点击 `r` 键后,您可以在顶部看到更新的提示。 +选择要重新启动的守护进程,然后按下 `r`,之后,您可以在顶部看到更新的提示。 ![][14] -按 `q` 按钮退出。 +按下 `q` 退出。 -------------------------------------------------------------------------------- @@ -98,7 +92,7 @@ via: https://www.2daygeek.com/chkservice-a-tool-for-managing-systemd-units-from- 作者:[Ramya Nuvvula][a] 译者:[amwps290](https://github.com/amwps290) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d9f4350fde9b313208c035a9a0bb4e8c325a8dfb Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 31 Mar 2018 00:35:02 +0800 Subject: [PATCH 0219/1057] PUB:20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md @amwps290 https://linux.cn/article-9499-1.html --- ...ice - A Tool For Managing Systemd Units From Linux Terminal.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md (100%) diff --git a/translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md b/published/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md similarity index 100% rename from translated/tech/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md rename to published/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md From 72ec377521baace0ae21e9770bd023649bbaec8d Mon Sep 17 00:00:00 2001 From: qhwdw Date: Sat, 31 Mar 2018 16:44:31 +0800 Subject: [PATCH 0220/1057] Translated by qhwdw --- ... Caffeinated 6.828- Lab 1- Booting a PC.md | 625 ------------------ ... Caffeinated 6.828- Lab 1- Booting a PC.md | 616 +++++++++++++++++ 2 files changed, 616 insertions(+), 625 deletions(-) delete mode 100644 sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md create mode 100644 translated/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md diff --git a/sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md b/sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md deleted file mode 100644 index c73e8fe80f..0000000000 --- a/sources/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md +++ /dev/null @@ -1,625 +0,0 @@ -Translating by qhwdw -Caffeinated 6.828: Lab 1: Booting a PC -====== - -### Introduction - -This lab is split into three parts. The first part concentrates on getting familiarized with x86 assembly language, the QEMU x86 emulator, and the PC's power-on bootstrap procedure. The second part examines the boot loader for our 6.828 kernel, which resides in the `boot` directory of the `lab` tree. Finally, the third part delves into the initial template for our 6.828 kernel itself, named JOS, which resides in the `kernel` directory. - -#### Software Setup - -The files you will need for this and subsequent lab assignments in this course are distributed using the [Git][1] version control system. To learn more about Git, take a look at the [Git user's manual][2], or, if you are already familiar with other version control systems, you may find this [CS-oriented overview of Git][3] useful. - -The URL for the course Git repository is `https://exokernel.scripts.mit.edu/joslab.git`. To install the files in your Athena account, you need to clone the course repository, by running the commands below. You can log into a public Athena host with `ssh -X athena.dialup.mit.edu`. -``` -athena% mkdir ~/6.828 -athena% cd ~/6.828 -athena% add git -athena% git clone https://exokernel.scripts.mit.edu/joslab.git lab -Cloning into lab... -athena% cd lab -athena% - -``` - -Git allows you to keep track of the changes you make to the code. For example, if you are finished with one of the exercises, and want to checkpoint your progress, you can commit your changes by running: -``` -athena% git commit -am 'my solution for lab1 exercise 9' -Created commit 60d2135: my solution for lab1 exercise 9 - 1 files changed, 1 insertions(+), 0 deletions(-) -athena% - -``` - -You can keep track of your changes by using the `git diff` command. Running `git diff` will display the changes to your code since your last commit, and `git diff origin/lab1` will display the changes relative to the initial code supplied for this lab. Here, `origin/lab1` is the name of the git branch with the initial code you downloaded from our server for this assignment. - -We have set up the appropriate compilers and simulators for you on Athena. To use them, run `add exokernel`. You must run this command every time you log in (or add it to your `~/.environment` file). If you get obscure errors while compiling or running `qemu`, double check that you added the course locker. - -If you are working on a non-Athena machine, you'll need to install `qemu` and possibly `gcc` following the directions on the [tools page][4]. We've made several useful debugging changes to `qemu` and some of the later labs depend on these patches, so you must build your own. If your machine uses a native ELF toolchain (such as Linux and most BSD's, but notably not OS X), you can simply install `gcc` from your package manager. Otherwise, follow the directions on the tools page. - -#### Hand-In Procedure - -We use different Git repositories for you to hand in your lab. The hand-in repositories reside behind an SSH server. You will get your own hand-in repository, which is inaccessible by any other students. To authenticate yourself with the SSH server, you should have an RSA key pair, and let the server know your public key. - -The lab code comes with a script that helps you to set up access to your hand-in repository. Before running the script, you must have an account at our [submission web interface][5]. On the login page, type in your Athena user name and click on "Mail me my password". You will receive your `6.828` password in your mailbox shortly. Note that every time you click the button, the system will assign you a new random password. - -Now that you have your `6.828` password, in the `lab` directory, set up the hand-in repository by running: -``` -athena% make handin-prep -Using public key from ~/.ssh/id_rsa: -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0lnnkoHSi4JDFA ... -Continue? [Y/n] Y - -Login to 6.828 submission website. -If you do not have an account yet, sign up at https://exokernel.scripts.mit.edu/submit/ -before continuing. -Username: -Password: -Your public key has been successfully updated. -Setting up hand-in Git repository... -Adding remote repository ssh://josgit@exokernel.mit.edu/joslab.git as 'handin'. -Done! Use 'make handin' to submit your lab code. -athena% - -``` - -The script may also ask you to generate a new key pair if you did not have one: -``` -athena% make handin-prep -SSH key file ~/.ssh/id_rsa does not exists, generate one? [Y/n] Y -Generating public/private rsa key pair. -Your identification has been saved in ~/.ssh/id_rsa. -Your public key has been saved in ~/.ssh/id_rsa.pub. -The key fingerprint is: -xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx -The keyʼs randomart image is: -+--[ RSA 2048]----+ -| ........ | -| ........ | -+-----------------+ -Using public key from ~/.ssh/id_rsa: -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0lnnkoHSi4JDFA ... -Continue? [Y/n] Y -..... -athena% - -``` - -When you are ready to hand in your lab, first commit your changes with git commit, and then type make handin in the `lab` directory. The latter will run git push handin HEAD, which pushes the current branch to the same name on the remote `handin` repository. -``` -athena% git commit -am "ready to submit my lab" -[lab1 c2e3c8b] ready to submit my lab - 2 files changed, 18 insertions(+), 2 deletions(-) - -athena% make handin -Handin to remote repository using 'git push handin HEAD' ... -Counting objects: 59, done. -Delta compression using up to 4 threads. -Compressing objects: 100% (55/55), done. -Writing objects: 100% (59/59), 49.75 KiB, done. -Total 59 (delta 3), reused 0 (delta 0) -To ssh://josgit@am.csail.mit.edu/joslab.git - * [new branch] HEAD -> lab1 -athena% - -``` - -If you have made changes to your hand-in repository, an email receipt will be sent to you to confirm the submission. You can run make handin (or git push handin) as many times as you want. The late hours of your submission for a specific lab is based on the latest hand-in (push) time of the corresponding branch. - -In the case that make handin does not work properly, try fixing the problem with Git commands. Or you can run make tarball. This will make a tar file for you, which you can then upload via our [web interface][5]. `make handin` provides more specific directions. - -For Lab 1, you do not need to turn in answers to any of the questions below. (Do answer them for yourself though! They will help with the rest of the lab.) - -We will be grading your solutions with a grading program. You can run make grade to test your solutions with the grading program. - -### Part 1: PC Bootstrap - -The purpose of the first exercise is to introduce you to x86 assembly language and the PC bootstrap process, and to get you started with QEMU and QEMU/GDB debugging. You will not have to write any code for this part of the lab, but you should go through it anyway for your own understanding and be prepared to answer the questions posed below. - -#### Getting Started with x86 assembly - -If you are not already familiar with x86 assembly language, you will quickly become familiar with it during this course! The [PC Assembly Language Book][6] is an excellent place to start. Hopefully, the book contains mixture of new and old material for you. - -Warning: Unfortunately the examples in the book are written for the NASM assembler, whereas we will be using the GNU assembler. NASM uses the so-called Intel syntax while GNU uses the AT&T syntax. While semantically equivalent, an assembly file will differ quite a lot, at least superficially, depending on which syntax is used. Luckily the conversion between the two is pretty simple, and is covered in [Brennan's Guide to Inline Assembly][7]. - -> **Exercise 1** -> -> Familiarize yourself with the assembly language materials available on [the 6.828 reference page][8]. You don't have to read them now, but you'll almost certainly want to refer to some of this material when reading and writing x86 assembly. - -We do recommend reading the section "The Syntax" in [Brennan's Guide to Inline Assembly][7]. It gives a good (and quite brief) description of the AT&T assembly syntax we'll be using with the GNU assembler in JOS. - -Certainly the definitive reference for x86 assembly language programming is Intel's instruction set architecture reference, which you can find on [the 6.828 reference page][8] in two flavors: an HTML edition of the old [80386 Programmer's Reference Manual][9], which is much shorter and easier to navigate than more recent manuals but describes all of the x86 processor features that we will make use of in 6.828; and the full, latest and greatest [IA-32 Intel Architecture Software Developer's Manuals][10] from Intel, covering all the features of the most recent processors that we won't need in class but you may be interested in learning about. An equivalent (and often friendlier) set of manuals is [available from AMD][11]. Save the Intel/AMD architecture manuals for later or use them for reference when you want to look up the definitive explanation of a particular processor feature or instruction. - -#### Simulating the x86 - -Instead of developing the operating system on a real, physical personal computer (PC), we use a program that faithfully emulates a complete PC: the code you write for the emulator will boot on a real PC too. Using an emulator simplifies debugging; you can, for example, set break points inside of the emulated x86, which is difficult to do with the silicon version of an x86. - -In 6.828 we will use the [QEMU Emulator][12], a modern and relatively fast emulator. While QEMU's built-in monitor provides only limited debugging support, QEMU can act as a remote debugging target for the [GNU debugger][13] (GDB), which we'll use in this lab to step through the early boot process. - -To get started, extract the Lab 1 files into your own directory on Athena as described above in "Software Setup", then type make (or gmake on BSD systems) in the `lab` directory to build the minimal 6.828 boot loader and kernel you will start with. (It's a little generous to call the code we're running here a "kernel," but we'll flesh it out throughout the semester.) -``` -athena% cd lab -athena% make -+ as kern/entry.S -+ cc kern/init.c -+ cc kern/console.c -+ cc kern/monitor.c -+ cc kern/printf.c -+ cc lib/printfmt.c -+ cc lib/readline.c -+ cc lib/string.c -+ ld obj/kern/kernel -+ as boot/boot.S -+ cc -Os boot/main.c -+ ld boot/boot -boot block is 414 bytes (max 510) -+ mk obj/kern/kernel.img - -``` - -(If you get errors like "undefined reference to `__udivdi3'", you probably don't have the 32-bit gcc multilib. If you're running Debian or Ubuntu, try installing the gcc-multilib package.) - -Now you're ready to run QEMU, supplying the file `obj/kern/kernel.img`, created above, as the contents of the emulated PC's "virtual hard disk." This hard disk image contains both our boot loader (`obj/boot/boot`) and our kernel (`obj/kernel`). -``` -athena% make qemu - -``` - -This executes QEMU with the options required to set the hard disk and direct serial port output to the terminal. Some text should appear in the QEMU window: -``` -Booting from Hard Disk... -6828 decimal is XXX octal! -entering test_backtrace 5 -entering test_backtrace 4 -entering test_backtrace 3 -entering test_backtrace 2 -entering test_backtrace 1 -entering test_backtrace 0 -leaving test_backtrace 0 -leaving test_backtrace 1 -leaving test_backtrace 2 -leaving test_backtrace 3 -leaving test_backtrace 4 -leaving test_backtrace 5 -Welcome to the JOS kernel monitor! -Type 'help' for a list of commands. -K> - -``` - -Everything after '`Booting from Hard Disk...`' was printed by our skeletal JOS kernel; the `K>` is the prompt printed by the small monitor, or interactive control program, that we've included in the kernel. These lines printed by the kernel will also appear in the regular shell window from which you ran QEMU. This is because for testing and lab grading purposes we have set up the JOS kernel to write its console output not only to the virtual VGA display (as seen in the QEMU window), but also to the simulated PC's virtual serial port, which QEMU in turn outputs to its own standard output. Likewise, the JOS kernel will take input from both the keyboard and the serial port, so you can give it commands in either the VGA display window or the terminal running QEMU. Alternatively, you can use the serial console without the virtual VGA by running make qemu-nox. This may be convenient if you are SSH'd into an Athena dialup. - -There are only two commands you can give to the kernel monitor, `help` and `kerninfo`. -``` -K> help -help - display this list of commands -kerninfo - display information about the kernel -K> kerninfo -Special kernel symbols: - entry f010000c (virt) 0010000c (phys) - etext f0101a75 (virt) 00101a75 (phys) - edata f0112300 (virt) 00112300 (phys) - end f0112960 (virt) 00112960 (phys) -Kernel executable memory footprint: 75KB -K> - -``` - -The `help` command is obvious, and we will shortly discuss the meaning of what the `kerninfo` command prints. Although simple, it's important to note that this kernel monitor is running "directly" on the "raw (virtual) hardware" of the simulated PC. This means that you should be able to copy the contents of `obj/kern/kernel.img` onto the first few sectors of a real hard disk, insert that hard disk into a real PC, turn it on, and see exactly the same thing on the PC's real screen as you did above in the QEMU window. (We don't recommend you do this on a real machine with useful information on its hard disk, though, because copying `kernel.img` onto the beginning of its hard disk will trash the master boot record and the beginning of the first partition, effectively causing everything previously on the hard disk to be lost!) - -#### The PC's Physical Address Space - -We will now dive into a bit more detail about how a PC starts up. A PC's physical address space is hard-wired to have the following general layout: -``` -+------------------+ <- 0xFFFFFFFF (4GB) -| 32-bit | -| memory mapped | -| devices | -| | -/\/\/\/\/\/\/\/\/\/\ - -/\/\/\/\/\/\/\/\/\/\ -| | -| Unused | -| | -+------------------+ <- depends on amount of RAM -| | -| | -| Extended Memory | -| | -| | -+------------------+ <- 0x00100000 (1MB) -| BIOS ROM | -+------------------+ <- 0x000F0000 (960KB) -| 16-bit devices, | -| expansion ROMs | -+------------------+ <- 0x000C0000 (768KB) -| VGA Display | -+------------------+ <- 0x000A0000 (640KB) -| | -| Low Memory | -| | -+------------------+ <- 0x00000000 - -``` - -The first PCs, which were based on the 16-bit Intel 8088 processor, were only capable of addressing 1MB of physical memory. The physical address space of an early PC would therefore start at `0x00000000` but end at `0x000FFFFF` instead of `0xFFFFFFFF`. The 640KB area marked "Low Memory" was the only random-access memory (RAM) that an early PC could use; in fact the very earliest PCs only could be configured with 16KB, 32KB, or 64KB of RAM! - -The 384KB area from `0x000A0000` through `0x000FFFFF` was reserved by the hardware for special uses such as video display buffers and firmware held in non-volatile memory. The most important part of this reserved area is the Basic Input/Output System (BIOS), which occupies the 64KB region from `0x000F0000` through `0x000FFFFF`. In early PCs the BIOS was held in true read-only memory (ROM), but current PCs store the BIOS in updateable flash memory. The BIOS is responsible for performing basic system initialization such as activating the video card and checking the amount of memory installed. After performing this initialization, the BIOS loads the operating system from some appropriate location such as floppy disk, hard disk, CD-ROM, or the network, and passes control of the machine to the operating system. - -When Intel finally "broke the one megabyte barrier" with the 80286 and 80386 processors, which supported 16MB and 4GB physical address spaces respectively, the PC architects nevertheless preserved the original layout for the low 1MB of physical address space in order to ensure backward compatibility with existing software. Modern PCs therefore have a "hole" in physical memory from `0x000A0000` to `0x00100000`, dividing RAM into "low" or "conventional memory" (the first 640KB) and "extended memory" (everything else). In addition, some space at the very top of the PC's 32-bit physical address space, above all physical RAM, is now commonly reserved by the BIOS for use by 32-bit PCI devices. - -Recent x86 processors can support more than 4GB of physical RAM, so RAM can extend further above `0xFFFFFFFF`. In this case the BIOS must arrange to leave a second hole in the system's RAM at the top of the 32-bit addressable region, to leave room for these 32-bit devices to be mapped. Because of design limitations JOS will use only the first 256MB of a PC's physical memory anyway, so for now we will pretend that all PCs have "only" a 32-bit physical address space. But dealing with complicated physical address spaces and other aspects of hardware organization that evolved over many years is one of the important practical challenges of OS development. - -#### The ROM BIOS - -In this portion of the lab, you'll use QEMU's debugging facilities to investigate how an IA-32 compatible computer boots. - -Open two terminal windows. In one, enter `make qemu-gdb` (or `make qemu-nox-gdb`). This starts up QEMU, but QEMU stops just before the processor executes the first instruction and waits for a debugging connection from GDB. In the second terminal, from the same directory you ran `make`, run `make gdb`. You should see something like this, -``` -athena% make gdb -GNU gdb (GDB) 6.8-debian -Copyright (C) 2008 Free Software Foundation, Inc. -License GPLv3+: GNU GPL version 3 or later -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. Type "show copying" -and "show warranty" for details. -This GDB was configured as "i486-linux-gnu". -+ target remote localhost:1234 -The target architecture is assumed to be i8086 -[f000:fff0] 0xffff0: ljmp $0xf000,$0xe05b -0x0000fff0 in ?? () -+ symbol-file obj/kern/kernel -(gdb) - -``` - -The `make gdb` target runs a script called `.gdbrc`, which sets up GDB to debug the 16-bit code used during early boot and directs it to attach to the listening QEMU. - -The following line: -``` -[f000:fff0] 0xffff0: ljmp $0xf000,$0xe05b - -``` - -is GDB's disassembly of the first instruction to be executed. From this output you can conclude a few things: - - * The IBM PC starts executing at physical address `0x000ffff0`, which is at the very top of the 64KB area reserved for the ROM BIOS. - * The PC starts executing with `CS = 0xf000` and `IP = 0xfff0`. - * The first instruction to be executed is a `jmp` instruction, which jumps to the segmented address `CS = 0xf000` and `IP = 0xe05b`. - - - -Why does QEMU start like this? This is how Intel designed the 8088 processor, which IBM used in their original PC. Because the BIOS in a PC is "hard-wired" to the physical address range `0x000f0000-0x000fffff`, this design ensures that the BIOS always gets control of the machine first after power-up or any system restart - which is crucial because on power-up there is no other software anywhere in the machine's RAM that the processor could execute. The QEMU emulator comes with its own BIOS, which it places at this location in the processor's simulated physical address space. On processor reset, the (simulated) processor enters real mode and sets CS to `0xf000` and the IP to `0xfff0`, so that execution begins at that (CS:IP) segment address. How does the segmented address 0xf000:fff0 turn into a physical address? - -To answer that we need to know a bit about real mode addressing. In real mode (the mode that PC starts off in), address translation works according to the formula: physical address = 16 * segment + offset. So, when the PC sets CS to `0xf000` and IP to `0xfff0`, the physical address referenced is: -``` -16 * 0xf000 + 0xfff0 # in hex multiplication by 16 is - = 0xf0000 + 0xfff0 # easy--just append a 0. - = 0xffff0 - -``` - -`0xffff0` is 16 bytes before the end of the BIOS (`0x100000`). Therefore we shouldn't be surprised that the first thing that the BIOS does is `jmp` backwards to an earlier location in the BIOS; after all how much could it accomplish in just 16 bytes? - -> **Exercise 2** -> -> Use GDB's `si` (Step Instruction) command to trace into the ROM BIOS for a few more instructions, and try to guess what it might be doing. You might want to look at [Phil Storrs I/O Ports Description][14], as well as other materials on the [6.828 reference materials page][8]. No need to figure out all the details - just the general idea of what the BIOS is doing first. - -When the BIOS runs, it sets up an interrupt descriptor table and initializes various devices such as the VGA display. This is where the "`Starting SeaBIOS`" message you see in the QEMU window comes from. - -After initializing the PCI bus and all the important devices the BIOS knows about, it searches for a bootable device such as a floppy, hard drive, or CD-ROM. Eventually, when it finds a bootable disk, the BIOS reads the boot loader from the disk and transfers control to it. - -### Part 2: The Boot Loader - -Floppy and hard disks for PCs are divided into 512 byte regions called sectors. A sector is the disk's minimum transfer granularity: each read or write operation must be one or more sectors in size and aligned on a sector boundary. If the disk is bootable, the first sector is called the boot sector, since this is where the boot loader code resides. When the BIOS finds a bootable floppy or hard disk, it loads the 512-byte boot sector into memory at physical addresses 0x7c00 through `0x7dff`, and then uses a `jmp` instruction to set the CS:IP to `0000:7c00`, passing control to the boot loader. Like the BIOS load address, these addresses are fairly arbitrary - but they are fixed and standardized for PCs. - -The ability to boot from a CD-ROM came much later during the evolution of the PC, and as a result the PC architects took the opportunity to rethink the boot process slightly. As a result, the way a modern BIOS boots from a CD-ROM is a bit more complicated (and more powerful). CD-ROMs use a sector size of 2048 bytes instead of 512, and the BIOS can load a much larger boot image from the disk into memory (not just one sector) before transferring control to it. For more information, see the ["El Torito" Bootable CD-ROM Format Specification][15]. - -For 6.828, however, we will use the conventional hard drive boot mechanism, which means that our boot loader must fit into a measly 512 bytes. The boot loader consists of one assembly language source file, `boot/boot.S`, and one C source file, `boot/main.c` Look through these source files carefully and make sure you understand what's going on. The boot loader must perform two main functions: - - 1. First, the boot loader switches the processor from real mode to 32-bit protected mode, because it is only in this mode that software can access all the memory above 1MB in the processor's physical address space. Protected mode is described briefly in sections 1.2.7 and 1.2.8 of [PC Assembly Language][6], and in great detail in the Intel architecture manuals. At this point you only have to understand that translation of segmented addresses (segment:offset pairs) into physical addresses happens differently in protected mode, and that after the transition offsets are 32 bits instead of 16. - 2. Second, the boot loader reads the kernel from the hard disk by directly accessing the IDE disk device registers via the x86's special I/O instructions. If you would like to understand better what the particular I/O instructions here mean, check out the "IDE hard drive controller" section on [the 6.828 reference page][8]. You will not need to learn much about programming specific devices in this class: writing device drivers is in practice a very important part of OS development, but from a conceptual or architectural viewpoint it is also one of the least interesting. - - - -After you understand the boot loader source code, look at the file `obj/boot/boot.asm`. This file is a disassembly of the boot loader that our GNUmakefile creates after compiling the boot loader. This disassembly file makes it easy to see exactly where in physical memory all of the boot loader's code resides, and makes it easier to track what's happening while stepping through the boot loader in GDB. Likewise, `obj/kern/kernel.asm` contains a disassembly of the JOS kernel, which can often be useful for debugging. - -You can set address breakpoints in GDB with the `b` command. For example, `b *0x7c00` sets a breakpoint at address `0x7C00`. Once at a breakpoint, you can continue execution using the `c` and `si` commands: `c` causes QEMU to continue execution until the next breakpoint (or until you press Ctrl-C in GDB), and `si N` steps through the instructions `N` at a time. - -To examine instructions in memory (besides the immediate next one to be executed, which GDB prints automatically), you use the `x/i` command. This command has the syntax `x/Ni ADDR`, where `N` is the number of consecutive instructions to disassemble and `ADDR` is the memory address at which to start disassembling. - -> **Exercise 3** -> -> Take a look at the [lab tools guide][16], especially the section on GDB commands. Even if you're familiar with GDB, this includes some esoteric GDB commands that are useful for OS work. - -Set a breakpoint at address 0x7c00, which is where the boot sector will be loaded. Continue execution until that breakpoint. Trace through the code in `boot/boot.S`, using the source code and the disassembly file `obj/boot/boot.asm` to keep track of where you are. Also use the `x/i` command in GDB to disassemble sequences of instructions in the boot loader, and compare the original boot loader source code with both the disassembly in `obj/boot/boot.asm` and GDB. - -Trace into `bootmain()` in `boot/main.c`, and then into `readsect()`. Identify the exact assembly instructions that correspond to each of the statements in `readsect()`. Trace through the rest of `readsect()` and back out into `bootmain()`, and identify the begin and end of the `for` loop that reads the remaining sectors of the kernel from the disk. Find out what code will run when the loop is finished, set a breakpoint there, and continue to that breakpoint. Then step through the remainder of the boot loader. - -Be able to answer the following questions: - - * At what point does the processor start executing 32-bit code? What exactly causes the switch from 16- to 32-bit mode? - * What is the last instruction of the boot loader executed, and what is the first instruction of the kernel it just loaded? - * Where is the first instruction of the kernel? - * How does the boot loader decide how many sectors it must read in order to fetch the entire kernel from disk? Where does it find this information? - - - -#### Loading the Kernel - -We will now look in further detail at the C language portion of the boot loader, in `boot/main.c`. But before doing so, this is a good time to stop and review some of the basics of C programming. - -> **Exercise 4** -> -> Download the code for [pointers.c][17], run it, and make sure you understand where all of the printed values come from. In particular, make sure you understand where the pointer addresses in lines 1 and 6 come from, how all the values in lines 2 through 4 get there, and why the values printed in line 5 are seemingly corrupted. -> -> If you're not familiar with pointers, The C Programming Language by Brian Kernighan and Dennis Ritchie (known as 'K&R') is a good reference. Students can purchase this book (here is an [Amazon Link][18]) or find one of [MIT's 7 copies][19]. 3 copies are also available for perusal in the [SIPB Office][20]. -> -> [A tutorial by Ted Jensen][21] that cites K&R heavily is available in the course readings. -> -> Warning: Unless you are already thoroughly versed in C, do not skip or even skim this reading exercise. If you do not really understand pointers in C, you will suffer untold pain and misery in subsequent labs, and then eventually come to understand them the hard way. Trust us; you don't want to find out what "the hard way" is. - -To make sense out of `boot/main.c` you'll need to know what an ELF binary is. When you compile and link a C program such as the JOS kernel, the compiler transforms each C source ('`.c`') file into an object ('`.o`') file containing assembly language instructions encoded in the binary format expected by the hardware. The linker then combines all of the compiled object files into a single binary image such as `obj/kern/kernel`, which in this case is a binary in the ELF format, which stands for "Executable and Linkable Format". - -Full information about this format is available in [the ELF specification][22] on [our reference page][8], but you will not need to delve very deeply into the details of this format in this class. Although as a whole the format is quite powerful and complex, most of the complex parts are for supporting dynamic loading of shared libraries, which we will not do in this class. - -For purposes of 6.828, you can consider an ELF executable to be a header with loading information, followed by several program sections, each of which is a contiguous chunk of code or data intended to be loaded into memory at a specified address. The boot loader does not modify the code or data; it loads it into memory and starts executing it. - -An ELF binary starts with a fixed-length ELF header, followed by a variable-length program header listing each of the program sections to be loaded. The C definitions for these ELF headers are in `inc/elf.h`. The program sections we're interested in are: - - * `.text`: The program's executable instructions. - * `.rodata`: Read-only data, such as ASCII string constants produced by the C compiler. (We will not bother setting up the hardware to prohibit writing, however.) - * `.data`: The data section holds the program's initialized data, such as global variables declared with initializers like `int x = 5;`. - - - -When the linker computes the memory layout of a program, it reserves space for uninitialized global variables, such as `int x;`, in a section called `.bss` that immediately follows `.data` in memory. C requires that "uninitialized" global variables start with a value of zero. Thus there is no need to store contents for `.bss` in the ELF binary; instead, the linker records just the address and size of the `.bss` section. The loader or the program itself must arrange to zero the `.bss` section. - -Examine the full list of the names, sizes, and link addresses of all the sections in the kernel executable by typing: -``` -athena% i386-jos-elf-objdump -h obj/kern/kernel - -``` - -You can substitute `objdump` for `i386-jos-elf-objdump` if your computer uses an ELF toolchain by default like most modern Linuxen and BSDs. - -You will see many more sections than the ones we listed above, but the others are not important for our purposes. Most of the others are to hold debugging information, which is typically included in the program's executable file but not loaded into memory by the program loader. - -Take particular note of the "VMA" (or link address) and the "LMA" (or load address) of the `.text` section. The load address of a section is the memory address at which that section should be loaded into memory. In the ELF object, this is stored in the `ph->p_pa` field (in this case, it really is a physical address, though the ELF specification is vague on the actual meaning of this field). - -The link address of a section is the memory address from which the section expects to execute. The linker encodes the link address in the binary in various ways, such as when the code needs the address of a global variable, with the result that a binary usually won't work if it is executing from an address that it is not linked for. (It is possible to generate position-independent code that does not contain any such absolute addresses. This is used extensively by modern shared libraries, but it has performance and complexity costs, so we won't be using it in 6.828.) - -Typically, the link and load addresses are the same. For example, look at the `.text` section of the boot loader: -``` -athena% i386-jos-elf-objdump -h obj/boot/boot.out - -``` - -The BIOS loads the boot sector into memory starting at address 0x7c00, so this is the boot sector's load address. This is also where the boot sector executes from, so this is also its link address. We set the link address by passing `-Ttext 0x7C00` to the linker in `boot/Makefrag`, so the linker will produce the correct memory addresses in the generated code. - -> **Exercise 5** -> -> Trace through the first few instructions of the boot loader again and identify the first instruction that would "break" or otherwise do the wrong thing if you were to get the boot loader's link address wrong. Then change the link address in `boot/Makefrag` to something wrong, run make clean, recompile the lab with make, and trace into the boot loader again to see what happens. Don't forget to change the link address back and make clean again afterward! - -Look back at the load and link addresses for the kernel. Unlike the boot loader, these two addresses aren't the same: the kernel is telling the boot loader to load it into memory at a low address (1 megabyte), but it expects to execute from a high address. We'll dig in to how we make this work in the next section. - -Besides the section information, there is one more field in the ELF header that is important to us, named `e_entry`. This field holds the link address of the entry point in the program: the memory address in the program's text section at which the program should begin executing. You can see the entry point: -``` -athena% i386-jos-elf-objdump -f obj/kern/kernel - -``` - -You should now be able to understand the minimal ELF loader in `boot/main.c`. It reads each section of the kernel from disk into memory at the section's load address and then jumps to the kernel's entry point. - -> **Exercise 6** -> -> We can examine memory using GDB's x command. The [GDB manual][23] has full details, but for now, it is enough to know that the command `x/Nx ADDR` prints `N` words of memory at `ADDR`. (Note that both `x`s in the command are lowercase.) Warning: The size of a word is not a universal standard. In GNU assembly, a word is two bytes (the 'w' in xorw, which stands for word, means 2 bytes). - -Reset the machine (exit QEMU/GDB and start them again). Examine the 8 words of memory at `0x00100000` at the point the BIOS enters the boot loader, and then again at the point the boot loader enters the kernel. Why are they different? What is there at the second breakpoint? (You do not really need to use QEMU to answer this question. Just think.) - -### Part 3: The Kernel - -We will now start to examine the minimal JOS kernel in a bit more detail. (And you will finally get to write some code!). Like the boot loader, the kernel begins with some assembly language code that sets things up so that C language code can execute properly. - -#### Using virtual memory to work around position dependence - -When you inspected the boot loader's link and load addresses above, they matched perfectly, but there was a (rather large) disparity between the kernel's link address (as printed by objdump) and its load address. Go back and check both and make sure you can see what we're talking about. (Linking the kernel is more complicated than the boot loader, so the link and load addresses are at the top of `kern/kernel.ld`.) - -Operating system kernels often like to be linked and run at very high virtual address, such as `0xf0100000`, in order to leave the lower part of the processor's virtual address space for user programs to use. The reason for this arrangement will become clearer in the next lab. - -Many machines don't have any physical memory at address `0xf0100000`, so we can't count on being able to store the kernel there. Instead, we will use the processor's memory management hardware to map virtual address `0xf0100000` (the link address at which the kernel code expects to run) to physical address `0x00100000` (where the boot loader loaded the kernel into physical memory). This way, although the kernel's virtual address is high enough to leave plenty of address space for user processes, it will be loaded in physical memory at the 1MB point in the PC's RAM, just above the BIOS ROM. This approach requires that the PC have at least a few megabytes of physical memory (so that physical address `0x00100000` works), but this is likely to be true of any PC built after about 1990. - -In fact, in the next lab, we will map the entire bottom 256MB of the PC's physical address space, from physical addresses `0x00000000` through `0x0fffffff`, to virtual addresses `0xf0000000` through `0xffffffff` respectively. You should now see why JOS can only use the first 256MB of physical memory. - -For now, we'll just map the first 4MB of physical memory, which will be enough to get us up and running. We do this using the hand-written, statically-initialized page directory and page table in `kern/entrypgdir.c`. For now, you don't have to understand the details of how this works, just the effect that it accomplishes. Up until `kern/entry.S` sets the `CR0_PG` flag, memory references are treated as physical addresses (strictly speaking, they're linear addresses, but boot/boot.S set up an identity mapping from linear addresses to physical addresses and we're never going to change that). Once `CR0_PG` is set, memory references are virtual addresses that get translated by the virtual memory hardware to physical addresses. `entry_pgdir` translates virtual addresses in the range `0xf0000000` through `0xf0400000` to physical addresses `0x00000000` through `0x00400000`, as well as virtual addresses `0x00000000` through `0x00400000` to physical addresses `0x00000000` through `0x00400000`. Any virtual address that is not in one of these two ranges will cause a hardware exception which, since we haven't set up interrupt handling yet, will cause QEMU to dump the machine state and exit (or endlessly reboot if you aren't using the 6.828-patched version of QEMU). - -> **Exercise 7** -> -> Use QEMU and GDB to trace into the JOS kernel and stop at the `movl %eax, %cr0`. Examine memory at `0x00100000` and at `0xf0100000`. Now, single step over that instruction using the `stepi` GDB command. Again, examine memory at `0x00100000` and at `0xf0100000`. Make sure you understand what just happened. - -What is the first instruction after the new mapping is established that would fail to work properly if the mapping weren't in place? Comment out the `movl %eax, %cr0` in `kern/entry.S`, trace into it, and see if you were right. - -#### Formatted Printing to the Console - -Most people take functions like `printf()` for granted, sometimes even thinking of them as "primitives" of the C language. But in an OS kernel, we have to implement all I/O ourselves. - -Read through `kern/printf.c`, `lib/printfmt.c`, and `kern/console.c`, and make sure you understand their relationship. It will become clear in later labs why `printfmt.c` is located in the separate `lib` directory. - -> **Exercise 8** -> -> We have omitted a small fragment of code - the code necessary to print octal numbers using patterns of the form "%o". Find and fill in this code fragment. -> -> Be able to answer the following questions: -> -> 1. Explain the interface between `printf.c` and `console.c`. Specifically, what function does `console.c` export? How is this function used by `printf.c`? -> -> 2. Explain the following from `console.c`: -[code] > if (crt_pos >= CRT_SIZE) { -> int i; -> memcpy(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t)); -> for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i++) -> crt_buf[i] = 0x0700 | ' '; -> crt_pos -= CRT_COLS; -> } -> -``` -> -> 3. For the following questions you might wish to consult the notes for Lecture 1. These notes cover GCC's calling convention on the x86. -> -> Trace the execution of the following code step-by-step: -[code] > int x = 1, y = 3, z = 4; -> cprintf("x %d, y %x, z %d\n", x, y, z); -> -``` -> -> 1. In the call to `cprintf()`, to what does `fmt` point? To what does `ap` point? -> 2. List (in order of execution) each call to `cons_putc`, `va_arg`, and `vcprintf`. For `cons_putc`, list its argument as well. For `va_arg`, list what `ap` points to before and after the call. For `vcprintf` list the values of its two arguments. -> 4. Run the following code. -[code] > unsigned int i = 0x00646c72; -> cprintf("H%x Wo%s", 57616, &i); -> -``` -> -> What is the output? Explain how this output is arrived at in the step-by-step manner of the previous exercise. [Here's an ASCII table][24] that maps bytes to characters. -> -> The output depends on that fact that the x86 is little-endian. If the x86 were instead big-endian what would you set `i` to in order to yield the same output? Would you need to change `57616` to a different value? -> -> [Here's a description of little- and big-endian][25] and [a more whimsical description][26]. -> -> 5. In the following code, what is going to be printed after `y=`? (note: the answer is not a specific value.) Why does this happen? -[code] > cprintf("x=%d y=%d", 3); -> -``` -> -> 6. Let's say that GCC changed its calling convention so that it pushed arguments on the stack in declaration order, so that the last argument is pushed last. How would you have to change `cprintf` or its interface so that it would still be possible to pass it a variable number of arguments? -> -> - - -#### The Stack - -In the final exercise of this lab, we will explore in more detail the way the C language uses the stack on the x86, and in the process write a useful new kernel monitor function that prints a backtrace of the stack: a list of the saved Instruction Pointer (IP) values from the nested `call` instructions that led to the current point of execution. - -> **Exercise 9** -> -> Determine where the kernel initializes its stack, and exactly where in memory its stack is located. How does the kernel reserve space for its stack? And at which "end" of this reserved area is the stack pointer initialized to point to? - -The x86 stack pointer (`esp` register) points to the lowest location on the stack that is currently in use. Everything below that location in the region reserved for the stack is free. Pushing a value onto the stack involves decreasing the stack pointer and then writing the value to the place the stack pointer points to. Popping a value from the stack involves reading the value the stack pointer points to and then increasing the stack pointer. In 32-bit mode, the stack can only hold 32-bit values, and esp is always divisible by four. Various x86 instructions, such as `call`, are "hard-wired" to use the stack pointer register. - -The `ebp` (base pointer) register, in contrast, is associated with the stack primarily by software convention. On entry to a C function, the function's prologue code normally saves the previous function's base pointer by pushing it onto the stack, and then copies the current `esp` value into `ebp` for the duration of the function. If all the functions in a program obey this convention, then at any given point during the program's execution, it is possible to trace back through the stack by following the chain of saved `ebp` pointers and determining exactly what nested sequence of function calls caused this particular point in the program to be reached. This capability can be particularly useful, for example, when a particular function causes an `assert` failure or `panic` because bad arguments were passed to it, but you aren't sure who passed the bad arguments. A stack backtrace lets you find the offending function. - -> **Exercise 10** -> -> To become familiar with the C calling conventions on the x86, find the address of the `test_backtrace` function in `obj/kern/kernel.asm`, set a breakpoint there, and examine what happens each time it gets called after the kernel starts. How many 32-bit words does each recursive nesting level of `test_backtrace` push on the stack, and what are those words? - -The above exercise should give you the information you need to implement a stack backtrace function, which you should call `mon_backtrace()`. A prototype for this function is already waiting for you in `kern/monitor.c`. You can do it entirely in C, but you may find the `read_ebp()` function in `inc/x86.h` useful. You'll also have to hook this new function into the kernel monitor's command list so that it can be invoked interactively by the user. - -The backtrace function should display a listing of function call frames in the following format: -``` -Stack backtrace: - ebp f0109e58 eip f0100a62 args 00000001 f0109e80 f0109e98 f0100ed2 00000031 - ebp f0109ed8 eip f01000d6 args 00000000 00000000 f0100058 f0109f28 00000061 - ... - -``` - -The first line printed reflects the currently executing function, namely `mon_backtrace` itself, the second line reflects the function that called `mon_backtrace`, the third line reflects the function that called that one, and so on. You should print all the outstanding stack frames. By studying `kern/entry.S` you'll find that there is an easy way to tell when to stop. - -Within each line, the `ebp` value indicates the base pointer into the stack used by that function: i.e., the position of the stack pointer just after the function was entered and the function prologue code set up the base pointer. The listed `eip` value is the function's return instruction pointer: the instruction address to which control will return when the function returns. The return instruction pointer typically points to the instruction after the `call` instruction (why?). Finally, the five hex values listed after `args` are the first five arguments to the function in question, which would have been pushed on the stack just before the function was called. If the function was called with fewer than five arguments, of course, then not all five of these values will be useful. (Why can't the backtrace code detect how many arguments there actually are? How could this limitation be fixed?) - -Here are a few specific points you read about in K&R Chapter 5 that are worth remembering for the following exercise and for future labs. - - * If `int *p = (int*)100`, then `(int)p + 1` and `(int)(p + 1)` are different numbers: the first is `101` but the second is `104`. When adding an integer to a pointer, as in the second case, the integer is implicitly multiplied by the size of the object the pointer points to. - * `p[i]` is defined to be the same as `*(p+i)`, referring to the i'th object in the memory pointed to by p. The above rule for addition helps this definition work when the objects are larger than one byte. - * `&p[i]` is the same as `(p+i)`, yielding the address of the i'th object in the memory pointed to by p. - - - -Although most C programs never need to cast between pointers and integers, operating systems frequently do. Whenever you see an addition involving a memory address, ask yourself whether it is an integer addition or pointer addition and make sure the value being added is appropriately multiplied or not. - -> **Exercise 11** -> -> Implement the backtrace function as specified above. Use the same format as in the example, since otherwise the grading script will be confused. When you think you have it working right, run make grade to see if its output conforms to what our grading script expects, and fix it if it doesn't. After you have handed in your Lab 1 code, you are welcome to change the output format of the backtrace function any way you like. - -At this point, your backtrace function should give you the addresses of the function callers on the stack that lead to `mon_backtrace()` being executed. However, in practice you often want to know the function names corresponding to those addresses. For instance, you may want to know which functions could contain a bug that's causing your kernel to crash. - -To help you implement this functionality, we have provided the function `debuginfo_eip()`, which looks up `eip` in the symbol table and returns the debugging information for that address. This function is defined in `kern/kdebug.c`. - -> **Exercise 12** -> -> Modify your stack backtrace function to display, for each `eip`, the function name, source file name, and line number corresponding to that `eip`. - -In `debuginfo_eip`, where do `__STAB_*` come from? This question has a long answer; to help you to discover the answer, here are some things you might want to do: - - * look in the file `kern/kernel.ld` for `__STAB_*` - * run i386-jos-elf-objdump -h obj/kern/kernel - * run i386-jos-elf-objdump -G obj/kern/kernel - * run i386-jos-elf-gcc -pipe -nostdinc -O2 -fno-builtin -I. -MD -Wall -Wno-format -DJOS_KERNEL -gstabs -c -S kern/init.c, and look at init.s. - * see if the bootloader loads the symbol table in memory as part of loading the kernel binary - - - -Complete the implementation of `debuginfo_eip` by inserting the call to `stab_binsearch` to find the line number for an address. - -Add a `backtrace` command to the kernel monitor, and extend your implementation of `mon_backtrace` to call `debuginfo_eip` and print a line for each stack frame of the form: -``` -K> backtrace -Stack backtrace: - ebp f010ff78 eip f01008ae args 00000001 f010ff8c 00000000 f0110580 00000000 - kern/monitor.c:143: monitor+106 - ebp f010ffd8 eip f0100193 args 00000000 00001aac 00000660 00000000 00000000 - kern/init.c:49: i386_init+59 - ebp f010fff8 eip f010003d args 00000000 00000000 0000ffff 10cf9a00 0000ffff - kern/entry.S:70: +0 -K> - -``` - -Each line gives the file name and line within that file of the stack frame's `eip`, followed by the name of the function and the offset of the `eip` from the first instruction of the function (e.g., `monitor+106` means the return `eip` is 106 bytes past the beginning of `monitor`). - -Be sure to print the file and function names on a separate line, to avoid confusing the grading script. - -Tip: printf format strings provide an easy, albeit obscure, way to print non-null-terminated strings like those in STABS tables. `printf("%.*s", length, string)` prints at most `length` characters of `string`. Take a look at the printf man page to find out why this works. - -You may find that some functions are missing from the backtrace. For example, you will probably see a call to `monitor()` but not to `runcmd()`. This is because the compiler in-lines some function calls. Other optimizations may cause you to see unexpected line numbers. If you get rid of the `-O2` from `GNUMakefile`, the backtraces may make more sense (but your kernel will run more slowly). - -**This completes the lab.** In the `lab` directory, commit your changes with `git commit` and type `make handin` to submit your code. - --------------------------------------------------------------------------------- - -via: https://sipb.mit.edu/iap/6.828/lab/lab1/ - -作者:[mit][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://sipb.mit.edu -[1]:http://www.git-scm.com/ -[2]:http://www.kernel.org/pub/software/scm/git/docs/user-manual.html -[3]:http://eagain.net/articles/git-for-computer-scientists/ -[4]:https://sipb.mit.edu/iap/6.828/tools -[5]:https://exokernel.scripts.mit.edu/submit/ -[6]:https://sipb.mit.edu/iap/6.828/readings/pcasm-book.pdf -[7]:http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html -[8]:https://sipb.mit.edu/iap/6.828/reference -[9]:https://sipb.mit.edu/iap/6.828/readings/i386/toc.htm -[10]:http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html -[11]:http://developer.amd.com/documentation/guides/Pages/default.aspx#manuals -[12]:http://www.qemu.org/ -[13]:http://www.gnu.org/software/gdb/ -[14]:http://web.archive.org/web/20040404164813/members.iweb.net.au/%7Epstorr/pcbook/book2/book2.htm -[15]:https://sipb.mit.edu/iap/6.828/readings/boot-cdrom.pdf -[16]:https://sipb.mit.edu/iap/6.828/labguide -[17]:https://sipb.mit.edu/iap/6.828/files/pointers.c -[18]:http://www.amazon.com/C-Programming-Language-2nd/dp/0131103628/sr=8-1/qid=1157812738/ref=pd_bbs_1/104-1502762-1803102?ie=UTF8&s=books -[19]:http://library.mit.edu/F/AI9Y4SJ2L5ELEE2TAQUAAR44XV5RTTQHE47P9MKP5GQDLR9A8X-10422?func=item-global&doc_library=MIT01&doc_number=000355242&year=&volume=&sub_library= -[20]:http://sipb.mit.edu/ -[21]:https://sipb.mit.edu/iap/6.828/readings/pointers.pdf -[22]:https://sipb.mit.edu/iap/6.828/readings/elf.pdf -[23]:http://sourceware.org/gdb/current/onlinedocs/gdb_9.html#SEC63 -[24]:http://web.cs.mun.ca/%7Emichael/c/ascii-table.html -[25]:http://www.webopedia.com/TERM/b/big_endian.html -[26]:http://www.networksorcery.com/enp/ien/ien137.txt diff --git a/translated/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md b/translated/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md new file mode 100644 index 0000000000..aadd987591 --- /dev/null +++ b/translated/tech/20140110 Caffeinated 6.828- Lab 1- Booting a PC.md @@ -0,0 +1,616 @@ +Caffeinated 6.828:实验 1:PC 的引导过程 +====== + +### 简介 + +这个实验分为三个部分。第一部分主要是为了熟悉使用 x86 汇编语言、QEMU x86 仿真器、以及 PC 的加电引导过程。第二部分查看我们的 6.828 内核的引导加载器,它位于 `lab` 树的 `boot` 目录中。第三部分深入到我们的名为 JOS 的 6.828 内核模型内部,它在 `kernel` 目录中。 + +#### 软件安装 + +本课程中你需要的文件和接下来的实验任务所需要的文件都是通过使用 [Git][1] 版本控制系统来分发的。学习更多关于 Git 的知识,请查看 [Git 用户手册][2],或者,如果你熟悉其它的版本控制系统,这个 [面向 CS 的 Git 概述][3] 可能对你有帮助。 + +本课程在 Git 仓库中的地址是 `https://exokernel.scripts.mit.edu/joslab.git`。在你的 Athena 帐户中安装文件,你需要运行如下的命令去克隆课程仓库。你也可以使用 `ssh -X athena.dialup.mit.edu` 去登入到一个公共的 Athena 主机。 +``` +athena% mkdir ~/6.828 +athena% cd ~/6.828 +athena% add git +athena% git clone https://exokernel.scripts.mit.edu/joslab.git lab +Cloning into lab... +athena% cd lab +athena% + +``` + +Git 可以帮你跟踪代码中的变化。比如,如果你完成了一个练习,想在你的进度中打一个检查点,你可以运行如下的命令去提交你的变更: +``` +athena% git commit -am 'my solution for lab1 exercise 9' +Created commit 60d2135: my solution for lab1 exercise 9 + 1 files changed, 1 insertions(+), 0 deletions(-) +athena% + +``` + +你可以使用 `git diff` 命令跟踪你的变更。运行 `git diff` 将显示你的代码自最后一次提交之后的变更,而 `git diff origin/lab1` 将显示这个实验相对于初始代码的变更。在这里,`origin/lab1` 是为了完成这个作业,从我们的服务器上下载的初始代码在 Git 分支上的名字。 + +在 Athena 上,我们为你配置了合适的编译器和模拟器。如果你要去使用它们,请运行 `add exokernel` 命令。 每次登入 Athena 主机你都必须要运行这个命令(或者你可以将它添加到你的 `~/.environment` 文件中)。如果你在编译或者运行 `qemu` 时出现晦涩难懂的错误,可以双击 "check" 将它添加到你的课程收藏夹中。 + +如果你使用的是非 Athena 机器,你需要安装 `qemu` 和 `gcc`,它们在 [工具页面][4] 目录中。为了以后的实验需要,我们做了一些 `qemu` 调试方面的变更和补丁,因此,你必须构建你自己的工具。如果你的机器使用原生的 ELF 工具链(比如,Linux 和大多数 BSD,但不包括 OS X),你可以简单地从你的包管理器中安装 `gcc`。除此之外,都应该按工具页面的指导去做。 + +#### 动手过程 + +我们为了你便于做实验,为你使用了不同的 Git 仓库。做实验用的仓库位于一个 SSH 服务器后面。你可以拥有你自己的实验仓库,其他的任何同学都不可访问你的这个仓库。为了通过 SSH 服务器的认证,你必须有一对 RSA 密钥,并让服务器知道你的公钥。 + +实验代码同时还带有一个脚本,它可以帮你设置如何访问你的实验仓库。在运行这个脚本之前,你必须在我们的 [submission web 界面][5] 上有一个帐户。在登陆页面上,输入你的 Athena 用户名,然后点击 "Mail me my password"。在你的邮箱中将马上接收到一封包含有你的 `6.828` 课程密码的邮件。注意,每次你点击这个按钮的时候,系统将随机给你分配一个新密码。 + +现在,你已经有了你的 `6.828` 密码,在 `lab` 目录下,运行如下的命令去配置实践仓库: +``` +athena% make handin-prep +Using public key from ~/.ssh/id_rsa: +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0lnnkoHSi4JDFA ... +Continue? [Y/n] Y + +Login to 6.828 submission website. +If you do not have an account yet, sign up at https://exokernel.scripts.mit.edu/submit/ +before continuing. +Username: +Password: +Your public key has been successfully updated. +Setting up hand-in Git repository... +Adding remote repository ssh://josgit@exokernel.mit.edu/joslab.git as 'handin'. +Done! Use 'make handin' to submit your lab code. +athena% + +``` + +如果你没有 RSA 密钥对,这个脚本可能会询问你是否生成一个新的密钥对: +``` +athena% make handin-prep +SSH key file ~/.ssh/id_rsa does not exists, generate one? [Y/n] Y +Generating public/private rsa key pair. +Your identification has been saved in ~/.ssh/id_rsa. +Your public key has been saved in ~/.ssh/id_rsa.pub. +The key fingerprint is: +xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx +The keyʼs randomart image is: ++--[ RSA 2048]----+ +| ........ | +| ........ | ++-----------------+ +Using public key from ~/.ssh/id_rsa: +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0lnnkoHSi4JDFA ... +Continue? [Y/n] Y +..... +athena% + +``` + +当你开始动手做实验时,在 `lab` 目录下,输入 `make handin` 去使用 git 做第一次提交。后面将运行 `git push handin HEAD`,它将推送当前分支到远程 `handin` 仓库的同名分支上。 +``` +athena% git commit -am "ready to submit my lab" +[lab1 c2e3c8b] ready to submit my lab + 2 files changed, 18 insertions(+), 2 deletions(-) + +athena% make handin +Handin to remote repository using 'git push handin HEAD' ... +Counting objects: 59, done. +Delta compression using up to 4 threads. +Compressing objects: 100% (55/55), done. +Writing objects: 100% (59/59), 49.75 KiB, done. +Total 59 (delta 3), reused 0 (delta 0) +To ssh://josgit@am.csail.mit.edu/joslab.git + * [new branch] HEAD -> lab1 +athena% + +``` + +如果在你的实验仓库上产生变化,你将收到一封电子邮件,让你去确认这个提交。以后,你可能会多次去运行 `run make handin`(或者 `git push handin`)。对于一个指定实验的最后提交时间是由相应分支的最新推送(最后一个推送)的时间决定的。 + +在这个案例中,`make handin` 运行可能并不正确,你可以使用 Git 命令去尝试修复这个问题。或者,你可以去运行 `make tarball`。它将为你生成一个 tar 文件,这个文件可以通过我们的 [web 界面][5] 来上传。`make handin` 提供了很多特殊说明。 + +对于实验 1,你不需要去回答下列的任何一个问题。(尽管你不用自己回答,但是它们对下面的实验有帮助) + +我们将使用一个评级程序来分级你的解决方案。你可以使用这个评级程序去测试你的解决方案的分级情况。 + +### 第一部分:PC 引导 + +第一个练习的目的是向你介绍 x86 汇编语言和 PC 引导过程,你可以使用 QEMU 和 QEMU/GDB 调试开始你的练习。这部分的实验你不需要写任何代码,但是,通过这个实验,你将对 PC 引导过程有了你自己的理解,并且为回答后面的问题做好准备。 + +#### 从使用 x86 汇编语言开始 + +如果你对 x86 汇编语言的使用还不熟悉,通过这个课程,你将很快熟悉它!如果你想学习它,[PC 汇编语言][6] 这本书是一个很好的开端。希望这本书中有你所需要的一切内容。 + +警告:很不幸,这本书中的示例是为 NASM 汇编语言写的,而我们使用的是 GNU 汇编语言。NASM 使用所谓的 Intel 语法,而 GNU 使用 AT&T 语法。虽然在语义上是等价的,但是根据你使用的语法不同,至少从表面上看,汇编文件的差别还是挺大的。幸运的是,这两种语法的转换很简单,在 [Brennan's Guide to Inline Assembly][7] 有详细的介绍。 + +> **练习 1** +> +> 熟悉在 [6.828 参考页面][8] 上列出的你想去使用的可用汇编语言。你不需要现在就去阅读它们,但是在你阅读和写 x86 汇编程序的时候,你可以去参考相关的内容。 + +我并不推荐你阅读 [Brennan's Guide to Inline Assembly][7] 上的 “语法” 章节。虽然它对 AT&T 汇编语法描述的很好(并且非常详细),而且我们在 JOS 中使用的 GNU 汇编就是它。 + +对于 x86 汇编语言程序最终还是需要参考 Intel 的指令集架构,你可以在 [6.828 参考页面][8] 上找到它,它有两个版本:一个是 HTML 版的,是老的 [80386 程序员参考手册][9],它比起最新的手册更简短,更易于查找,但是,它包含了我们的 6.828 上所使用的 x86 处理器的所有特性;而更全面的、更新的、更好的是,来自 Intel 的 [IA-32 Intel 架构软件开发者手册][10],它涵盖了我们在课程中所需要的、(并且可能有些是你不感兴趣的)大多数处理器的全部特性。另一个差不多的(并且经常是很友好的)一套手册是 [来自 AMD][11] 的。当你为了一个特定的处理器特性或者指令,去查找最终的解释时,保存的最新的 Intel/AMD 架构手册或者它们的参考就很有用了。 + +#### 仿真 x86 + +与在一台真实的、物理的、个人电脑上引导一个操作系统不同,我们使用程序去如实地仿真一台完整的 PC:你在仿真器中写的代码,也能够引导一台真实的 PC。使用仿真器可以简化调试工作;比如,你可以在仿真器中设置断点,而这在真实的机器中是做不到的。 + +在 6.828 中,我们将使用 [QEMU 仿真器][12],它是一个现代化的并且速度非常快的仿真器。虽然 QEMU 内置的监视功能提供了有限的调试支持,但是,QEMU 也可以做为 [GNU 调试器][13] (GDB) 的远程调试目标,我们在这个实验中将使用它来一步一步完成引导过程。 + +在开始之前,按照前面 “软件安装“ 中在 Athena 主机上描述的步骤,提取实验 1 的文件到你自己的目录中,然后,在 `lab` 目录中输入 `make`(如果是 BSD 的系统,是输入 `gmake` )来构建最小的 6.828 引导加载器和用于启动的内核。(把在这里我们运行的这些代码称为 ”内核“ 有点夸大,但是,通过这个学期的课程,我们将把这些代码充实起来,成为真正的 ”内核“) +``` +athena% cd lab +athena% make ++ as kern/entry.S ++ cc kern/init.c ++ cc kern/console.c ++ cc kern/monitor.c ++ cc kern/printf.c ++ cc lib/printfmt.c ++ cc lib/readline.c ++ cc lib/string.c ++ ld obj/kern/kernel ++ as boot/boot.S ++ cc -Os boot/main.c ++ ld boot/boot +boot block is 414 bytes (max 510) ++ mk obj/kern/kernel.img + +``` + +(如果你看到有类似 ”undefined reference to `__udivdi3'" 这样的错误,可能是因为你的电脑上没有 32 位的 ”gcc multilib“。如果你运行在 Debian 或者 Ubuntu,你可以尝试去安装 ”gcc-multilib“ 包。) + +现在,你可以去运行 QEMU 了,并将上面创建的 `obj/kern/kernel.img` 文件提供给它,以作为仿真 PC 的 “虚拟硬盘”,这个虚拟硬盘中包含了我们的引导加载器(`obj/boot/boot`) 和我们的内核(`obj/kernel`)。 +``` +athena% make qemu +``` + +运行 QEMU 时需要使用选项去设置硬盘,以及指示串行端口输出到终端。在 QEMU 窗口中将出现一些文本内容: +``` +Booting from Hard Disk... +6828 decimal is XXX octal! +entering test_backtrace 5 +entering test_backtrace 4 +entering test_backtrace 3 +entering test_backtrace 2 +entering test_backtrace 1 +entering test_backtrace 0 +leaving test_backtrace 0 +leaving test_backtrace 1 +leaving test_backtrace 2 +leaving test_backtrace 3 +leaving test_backtrace 4 +leaving test_backtrace 5 +Welcome to the JOS kernel monitor! +Type 'help' for a list of commands. +K> +``` + +在 '`Booting from Hard Disk...`' 之后的内容,就是由我们的基本 JOS 内核输出的:`K>` 是包含在我们的内核中的小型监听器或者交互式控制程序的提示符。内核输出的这些行也会出现在你运行 QEMU 的普通 shell 窗口中。这是因为测试和实验分级的原因,我们配置了 JOS 的内核,使它将控制台输出不仅写入到虚拟的 VGA 显示器(就是 QEMU 窗口),也写入到仿真 PC 的虚拟串口上,QEMU 会将虚拟串口上的信息转发到它的标准输出上。同样,JOS 内核也将接收来自键盘和串口的输入,因此,你既可以从 VGA 显示窗口中输入命令,也可以从运行 QEMU 的终端窗口中输入命令。或者,你可以通过运行 `make qemu-nox` 来取消虚拟 VGA 的输出,只使用串行控制台来输出。如果你是通过 SSH 拨号连接到 Athena 主机,这样可能更方便。 + +在这里有两个可以用来监视内核的命令,它们是 `help` 和 `kerninfo`。 +``` +K> help +help - display this list of commands +kerninfo - display information about the kernel +K> kerninfo +Special kernel symbols: + entry f010000c (virt) 0010000c (phys) + etext f0101a75 (virt) 00101a75 (phys) + edata f0112300 (virt) 00112300 (phys) + end f0112960 (virt) 00112960 (phys) +Kernel executable memory footprint: 75KB +K> + +``` + +`help` 命令的用途很明确,我们将简短地讨论一下 `kerninfo` 命令输出的内容。虽然它很简单,但是,需要重点注意的是,这个内核监视器是 “直接” 运行在仿真 PC 的 “原始(虚拟)硬件” 上的。这意味着你可以去拷贝 `obj/kern/kernel.img` 的内容到一个真实硬盘的前几个扇区,然后将那个硬盘插入到一个真实的 PC 中,打开这个 PC 的电源,你将在一台真实的 PC 屏幕上看到和上面在 QEMU 窗口完全一样的内容。(我们并不推荐你在一台真实机器上这样做,因为拷贝 `kernel.img` 到硬盘的前几个扇区将覆盖掉那个硬盘上原来的主引导记录,这将导致这个硬盘上以前的内容丢失!) + +#### PC 的物理地址空间 + +我们现在将更深入去了解 ”关于 PC 是如何启动“ 的更多细节。一台 PC 的物理地址空间是硬编码为如下的布局: +``` ++------------------+ <- 0xFFFFFFFF (4GB) +| 32-bit | +| memory mapped | +| devices | +| | +/\/\/\/\/\/\/\/\/\/\ + +/\/\/\/\/\/\/\/\/\/\ +| | +| Unused | +| | ++------------------+ <- depends on amount of RAM +| | +| | +| Extended Memory | +| | +| | ++------------------+ <- 0x00100000 (1MB) +| BIOS ROM | ++------------------+ <- 0x000F0000 (960KB) +| 16-bit devices, | +| expansion ROMs | ++------------------+ <- 0x000C0000 (768KB) +| VGA Display | ++------------------+ <- 0x000A0000 (640KB) +| | +| Low Memory | +| | ++------------------+ <- 0x00000000 + +``` + +首先,这台 PC 是基于 16 位的 Intel 8088 处理器,它仅能处理 1 MB 的物理地址。所以,早期 PC 的物理地址空间开始于 `0x00000000`,结束于 `0x000FFFFF` 而不是 `0xFFFFFFFF`。被标记为 “低位内存” 的区域是早期 PC 唯一可以使用的随机访问内存(RAM);事实上,更早期的 PC 仅可以配置 16KB、32KB、或者 64KB 的内存! + +从 `0x000A0000` 到 `0x000FFFFF` 的 384 KB 的区域是为特定硬件保留的区域,比如,视频显示缓冲和保存在非易失存储中的固件。这个保留区域中最重要的部分是基本输入/输出系统(BIOS),它位于从 `0x000F0000` 到 `0x000FFFFF` 之间的 64KB 大小的区域。在早期的 PC 中,BIOS 在真正的只读存储(ROM)中,但是,现在的 PC 的 BIOS 都保存在可更新的 FLASH 存储中。BIOS 负责执行基本系统初始化工作,比如,激活视频卡和检查已安装的内存数量。这个初始化工作完成之后,BIOS 从相关位置加载操作系统,比如从软盘、硬盘、CD-ROM、或者网络,然后将机器的控制权传递给操作系统。 + +当 Intel 最终在 80286 和 80386 处理器上 “打破了 1MB 限制” 之后,这两个处理器各自支持 16MB 和 4GB 物理地址空间,尽管如此,为了确保向下兼容现存软件,PC 架构还是保留着 1 MB 以内物理地址空间的原始布局。因此,现代 PC 的物理内存,在 `0x000A0000` 和 `0x00100000` 之间有一个 "黑洞区域“,将内存分割为 ”低位“ 或者 ”传统内存“ 区域(前 640 KB)和 ”扩展内存“(其它的部分)。除此之外,在 PC 的 32 位物理地址空间顶部之上的一些空间,在全部的物理内存上面,现在一般都由 BIOS 保留给 32 位的 PCI 设备使用。 + +最新的 x86 处理器可以支持超过 4GB 的物理地址空间,因此,RAM 可以进一步扩展到 `0xFFFFFFFF` 之上。在这种情况下,BIOS 必须在 32 位可寻址空间顶部之上的系统 RAM 上,设置第二个 ”黑洞区域“,以便于为这些 32 位的设备映射留下空间。因为 JOS 设计的限制,它仅可以使用 PC 物理内存的前 256 MB,因此,我们将假设所有的 PC ”仅仅“ 拥有 32 位物理地址空间。但是处理复杂的物理地址空间和其它部分的硬件系统,将涉及到许多年前操作系统开发所遇到的实际挑战之一。 + +#### ROM BIOS + +在实验的这一部分中,你将使用 QEMU 的调试功能去研究 IA-32 相关的计算机是如何引导的。 + +打开两个终端窗口,在其中一个中,输入 `make qemu-gdb`(或者 `make qemu-nox-gdb`),这将启动 QEMU,但是处理器在运行第一个指令之前将停止 QEMU,以等待来自 GDB 的调试连接。在第二个终端窗口中,从相同的目录中运行 `make`,以及运行 `make gdb`。你将看到如下的输出。 +``` +athena% make gdb +GNU gdb (GDB) 6.8-debian +Copyright (C) 2008 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. Type "show copying" +and "show warranty" for details. +This GDB was configured as "i486-linux-gnu". ++ target remote localhost:1234 +The target architecture is assumed to be i8086 +[f000:fff0] 0xffff0: ljmp $0xf000,$0xe05b +0x0000fff0 in ?? () ++ symbol-file obj/kern/kernel +(gdb) + +``` + +`make gdb` 的运行目标是一个称为 `.gdbrc` 的脚本,它设置了 GDB 在早期引导期间调试所用到的 16 位代码,并且将它指向到正在监听的 QEMU 上。 + +下列行: +``` +[f000:fff0] 0xffff0: ljmp $0xf000,$0xe05b +``` + +是 GDB 运行的第一个指令的反汇编。这个输出包含如下的信息: + + * IBM PC 从物理地址 `0x000ffff0` 开始运行,这个地址位于为 ROM BIOS 保留的 64 KB 区域的顶部。 + * PC 使用 `CS = 0xf000` 和 `IP = 0xfff0` 开始运行。 + * 运行的第一个指令是一个 `jmp` 指令,它跳转段地址 `CS = 0xf000` 和 `IP = 0xe05b`。 + + + +为什么 QEMU 是这样开始的呢?这是因为 Intel 设计的 8088 处理器是这样做的,这个处理器是 IBM 最早用在他们的 PC 上的处理器。因为在一台 PC 中,BIOS 是硬编码在物理地址范围 `0x000f0000-0x000fffff` 中的,这样的设计确保了在机器接通电源或者任何系统重启之后,BIOS 总是能够首先控制机器 —— 这是至关重要的,因为机器接通电源之后,在机器的内存中没有处理器可以运行的任何软件。QEMU 仿真器有它自己的 BIOS,它的位置在处理器的模拟地址空间中。在处理器复位之后,(模拟的)处理器进入了实模式,然后设置 CS 为 `0xf000` 、IP 为 `0xfff0`,所以,运行开始于那个(CS:IP)段地址。那么,段地址 0xf000:fff0 是如何转到物理地址的呢? + +在回答这个问题之前,我们需要了解有关实模式地址的知识。在实模式(PC 启动之后就处于实模式)中,物理地址是根据这个公式去转换的:物理地址 = 16 * 段地址 + 偏移。因此,当 PC 设置 CS 为 `0xf000` 、IP 为 `0xfff0` 之后,物理地址指向到: +``` +16 * 0xf000 + 0xfff0 # in hex multiplication by 16 is + = 0xf0000 + 0xfff0 # easy--just append a 0. + = 0xffff0 + +``` + +`0xffff0` 是 BIOS (`0x100000`) 结束之前的 16 字节。因此,BIOS 所做的第一件事情是向后 `jmp` 到 BIOS 中的早期位置就一点也不奇怪了;毕竟只有 16 字节,还能指望它做些什么呢? + +> **练习 2** +> +> 使用 GDB 的 `si`(步进指令)指令去跟踪进入到 ROM BIOS 的更多指令,然后尝试猜测它可能会做什么。你可能需要去查看 [Phil Storrs I/O 端口描述][14],以及在 [6.828 参考资料页面][8] 上的其它资料。不需要了解所有的细节 —— 只要搞明白 BIOS 首先要做什么就可以了。 + +当 BIOS 运行后,它将设置一个中断描述符表和初始化各种设备,比如, VGA 显示。在这时,你在 QEMU 窗口中将出现 "`Starting SeaBIOS`" 的信息。 + +在初始化 PCI 产品线和 BIOS 知道的所有重要设备之后,它将搜索可引导设备,比如,一个软盘、硬盘、或者 CD-ROM。最后,当它找到可引导磁盘之后,BIOS 从可引导硬盘上读取引导加载器,然后将控制权交给它。 + +### 第二部分:引导加载器 + +在 PC 的软盘和硬盘中,将它们分割成 512 字节大小的区域,每个区域称为一个扇区。一个扇区就是磁盘的最小转存单元:每个读或写操作都必须是一个或多个扇区大小,并且按扇区边界进行对齐。如果磁盘是可引导盘,第一个扇区则为引导扇区,因为,第一个扇区中驻留有引导加载器的代码。当 BIOS 找到一个可引导软盘或者硬盘时,它将 512 字节的引导扇区加载进物理地址为 0x7c00 到 `0x7dff` 的内存中,然后使用一个 `jmp` 指令设置 CS:IP 为 `0000:7c00`,并传递控制权到引导加载器。与 BIOS 加载地址一样,这些地址是任意的 —— 但是它们对于 PC 来说是固定的,并且是标准化的。 + +后来,随着 PC 的技术进步,它们可以从 CD-ROM 中引导,因此,PC 架构师趁机对引导过程进行轻微的调整。最后的结果使现代的 BIOS 从 CD-ROM 中引导的过程更复杂(并且功能更强大)。CD-ROM 使用 2048 字节大小的扇区,而不是 512 字节的扇区,并且,BIOS 在传递控制权之前,可以从磁盘上加载更大的(不止是一个扇区)引导镜像到内存中。更多内容,请查看 ["El Torito" 可引导 CD-ROM 格式规范][15]。 + +不过对于 6.828,我们将使用传统的硬盘引导机制,意味着我们的引导加载器必须小于 512 字节。引导加载器是由一个汇编源文件 `boot/boot.S` 和一个 C 源文件 `boot/main.c` 构成,仔细研究这些源文件可以让你彻底理解引导加载器都做了些什么。引导加载器必须要做两件主要的事情: + + 1. 第一,引导加载器将处理器从实模式切换到 32 位保护模式,因为只有在 32 位保护模式中,软件才能够访问处理器中 1 MB 以上的物理地址空间。关于保护模式将在 [PC 汇编语言][6] 的 1.2.7 和 1.2.8 节中详细描述,更详细的内容请参阅 Intel 架构手册。在这里,你只要理解在保护模式中段地址(段基地址:偏移量)与物理地址转换的差别就可以了,并且转换后的偏移是 32 位而不是 16 位。 + 2. 第二,引导加载器通过 x86 的专用 I/O 指令直接访问 IDE 磁盘设备寄存器,从硬盘中读取内核。如果你想去更好地了解在这里说的专用 I/O 指令,请查看 [6.828 参考页面][8] 上的 ”IDE 硬盘控制器“ 章节。你不用学习太多的专用设备编程方面的内容:在实践中,写设备驱动程序是操作系统开发中的非常重要的部分,但是,从概念或者架构的角度看,它也是最让人乏味的部分。 + + + +理解了引导加载器源代码之后,我们来看一下 `obj/boot/boot.asm` 文件。这个文件是在引导加载器编译过程中,由我们的 GNUmakefile 创建的引导加载器的反汇编文件。这个反汇编文件让我们可以更容易地看到引导加载器代码所处的物理内存位置,并且也可以更容易地跟踪在 GDB 中步进的引导加载器发生了什么事情。同样的,`obj/kern/kernel.asm` 文件中包含了 JOS 内核的一个反汇编,它也经常被用于内核调试。 + +你可以使用 `b` 命令在 GDB 中设置中断点地址。比如,`b *0x7c00` 命令在地址 `0x7C00` 处设置了一个断点。当处于一个断点中时,你可以使用 `c` 和 `si` 命令去继续运行:`c` 命令让 QEMU 继续运行,直到下一个断点为止(或者是你在 GDB 中按下了 Ctrl - C),而 `si N` 命令是每次步进 `N` 个指令。 + +要检查内存中的指令(除了要立即运行的下一个指令之外,因为它是由 GDB 自动输出的),你可以使用 `x/i` 命令。这个命令的语法是 `x/Ni ADDR`,其中 `N` 是连接的指令个数,`ADDR` 是开始反汇编的内存地址。 + +> **练习 3** +> +> 查看 [实验工具指南][16],特别是 GDB 命令的相关章节。即便你熟悉使用 GDB 也要好好看一看,GDB 的一些命令比较难理解,但是它对操作系统的工作很有帮助。 + +在地址 0x7c00 处设置断点,它是加载后的引导扇区的位置。继续运行,直到那个断点。在 `boot/boot.S` 中跟踪代码,使用源代码和反汇编文件 `obj/boot/boot.asm` 去保持跟踪。你也可以使用 GDB 中的 `x/i` 命令去反汇编引导加载器接下来的指令,比较引导加载器源代码与在 `obj/boot/boot.asm` 和 GDB 中的反汇编文件。 + +在 `boot/main.c` 文件中跟踪进入 `bootmain()` ,然后进入 `readsect()`。识别 `readsect()` 中相关的每一个语句的准确汇编指令。跟踪 `readsect()` 中剩余的指令,然后返回到 `bootmain()` 中,识别 `for` 循环的开始和结束位置,这个循环从磁盘上读取内核的剩余扇区。找出循环结束后运行了什么代码,在这里设置一个断点,然后继续。接下来再走完引导加载器的剩余工作。 + +完成之后,就能够回答下列的问题了: + + * 处理器开始运行 32 代码时指向到什么地方?从 16 位模式切换到 32 位模式的真实原因是什么? + * 引导加载器执行的最后一个指令是什么,内核加载之后的第一个指令是什么? + * 内核的第一个指令在哪里? + * 为从硬盘上获取完整的内核,引导加载器如何决定有多少扇区必须被读入?在哪里能找到这些信息? + + + +#### 加载内核 + +我们现在来进一步查看引导加载器在 `boot/main.c` 中的 C 语言部分的详细细节。在继续之前,我们先停下来回顾一下 C 语言编程的基础知识。 + +> **练习 4** +> +> 下载 [pointers.c][17] 的源代码,运行它,然后确保你理解了输出值的来源的所有内容。尤其是,确保你理解了第 1 行和第 6 行的指针地址的来源、第 2 行到第 4 行的值是如何得到的、以及为什么第 5 行指向的值表面上看像是错误的。 +> +> 如果你对指针的使用不熟悉,Brian Kernighan 和 Dennis Ritchie(就是大家知道的 'K&R')写的《C Programming Language》是一个非常好的参考书。同学们可以去买这本书(这里是 [Amazon 购买链接][18]),或者在 [MIT 的图书馆有 7 个拷贝][19] 中找到其中一个。在 [SIPB Office][20] 也有三个拷贝可以细读。 +> +> 在课程阅读中,[Ted Jensen 写的教程][21] 可以使用,它大量引用了 K&R 的内容。 +> +> 警告:除非你特别精通 C 语言,否则不要跳过这个阅读练习。如果你没有真正理解了 C 语言中的指针,在接下来的实验中你将非常痛苦,最终你将很难理解它们。相信我们;你将不会遇到什么是 ”最困难的方式“。 + +要了解 `boot/main.c`,你需要了解一个 ELF 二进制格式的内容。当你编译和链接一个 C 程序时,比如,JOS 内核,编译器将每个 C 源文件('`.c`')转换为一个包含预期硬件平台的汇编指令编码的二进制格式的对象文件('`.o`'),然后链接器将所有编译过的对象文件组合成一个单个的二进制镜像,比如,`obj/kern/kernel`,在本案例中,它就是 ELF 格式的二进制文件,它表示是一个 ”可运行和可链接格式“。 + +关于这个格式的全部信息可以在 [我们的参考页面][8] 上的 [ELF 规范][22] 中找到,但是,你并不需要深入地研究这个格式 的细节。虽然完整的格式是非常强大和复杂的,但是,大多数复杂的部分是为了支持共享库的动态加载,在我们的课程中,并不需要做这些。 + +鉴于 6.828 的目的,你可以认为一个 ELF 可运行文件是一个用于加载信息的头文件,接下来的几个程序节,根据加载到内存中的特定地址的不同,每个都是连续的代码块或数据块。引导加载器并不修改代码或者数据;它加载它们到内存,然后开始运行它。 + +一个 ELF 二进制文件使用一个固定长度的 ELF 头开始,紧接着是一个可变长度的程序头,列出了每个加载的程序节。C 语言在 `inc/elf.h` 中定义了这些 ELF 头。在程序节中我们感兴趣的部分有: + + * `.text`:程序的可运行指令。 + * `.rodata`:只读数据,比如,由 C 编译器生成的 ASCII 字符串常量。(然而我们并不需要操心设置硬件去禁止写入它) + * `.data`:保持在程序的初始化数据中的数据节,比如,初始化声明所需要的全局变量,比如,像 `int x = 5;`。 + + + +当链接器计算程序的内存布局的时候,它为未初始化的全局变量保留一些空间,比如,`int x;`,在内存中的被称为 `.bss` 的节后面会马上跟着一个 `.data`。C 规定 "未初始化的" 全局变量以一个 0 值开始。因此,在 ELF 二进制中 `.bss` 中并不存储内容;而是,链接器只记录地址和`.bss` 节的大小。加载器或者程序自身必须在 `.bss` 节中写入 0。 + +通过输入如下的命令来检查在内核中可运行的所有节的名字、大小、以及链接地址的列表: +``` +athena% i386-jos-elf-objdump -h obj/kern/kernel +``` + +如果在你的计算机上默认使用的是一个 ELF 工具链,比如像大多数现代的 Linux 和 BSD,你可以使用 `objdump` 来代替 `i386-jos-elf-objdump`。 + +你将看到更多的节,而不仅是上面列出的那几个,但是,其它的那些节对于我们的实验目标来说并不重要。其它的那些节中大多数都是为了保留调试信息,它们一般包含在程序的可执行文件中,但是,这些节并不会被程序加载器加载到内存中。 + +我们需要特别注意 `.text` 节中的 "VMA"(或者链接地址)和 "LMA"(或者加载地址)。一个节的加载地址是那个节加载到内存中的地址。在 ELF 对象中,它保存在 `ph->p_pa` 域(在本案例中,它实际上是物理地址,不过 ELF 规范在这个域的意义方面规定的很模糊)。 + +一个节的链接地址是这个节打算在内存中运行时的地址。链接器在二进制代码中以变量的方式去编码这个链接地址,比如,当代码需要全局变量的地址时,如果二进制代码从一个未链接的地址去运行,结果将是无法运行。(它一般是去生成一个不包含任何一个绝对地址的、与位置无关的代码。现在的共享库大量使用的就是这种方法,但这是以性能和复杂性为代价的,所以,我们在 6.828 中不使用这种方法。) + +一般情况下,链接和加载地址是一样的。比如,通过如下的命令去查看引导加载器的 `.text` 节: +``` +athena% i386-jos-elf-objdump -h obj/boot/boot.out +``` + +BIOS 加载引导扇区到内存中的 0x7c00 地址,因此,这就是引导扇区的加载地址。这也是引导扇区的运行地址,因此,它也是链接地址。我们在`boot/Makefrag` 中通过传递 `-Ttext 0x7C00` 给链接器来设置链接地址,因此,链接器将在生成的代码中产生正确的内存地址。 + +> **练习 5** +> +> 如果你得到一个错误的引导加载器链接地址,通过再次跟踪引导加载器的前几个指令,你将会发现第一个指令会 ”中断“ 或者出错。然后在 `boot/Makefrag` 修改链接地址来修复错误,运行 `make clean`,使用 `make` 重新编译,然后再次跟踪引导加载器去查看会发生什么事情。不要忘了改回正确的链接地址,然后再次 `make clean`! + +我们继续来看内核的加载和链接地址。与引导加载器不同,这里有两个不同的地址:内核告诉引导加载器加载它到内存的低位地址(小于 1 MB 的地址),但是它期望在一个高位地址来运行。我们将在下一节中深入研究它是如何实现的。 + +除了节的信息之外,在 ELF 头中还有一个对我们很重要的域,它叫做 `e_entry`。这个域保留着程序入口的链接地址:程序的 `.text` 节中的内存地址就是将要被执行的程序的地址。你可以用如下的命令来查看程序入口链接地址: +``` +athena% i386-jos-elf-objdump -f obj/kern/kernel +``` + +你现在应该能够理解在 `boot/main.c` 中的最小的 ELF 加载器了。它从硬盘中读取内核的每个节,并将它们节的加载地址读入到内存中,然后跳转到内核的入口点。 + +> **练习 6** +> +> 我们可以使用 GDB 的 `x` 命令去检查内存。[GDB 手册][23] 上讲的非常详细,但是现在,我们知道命令 `x/Nx ADDR` 是输出地址 `ADDR` 上 `N` 个词(word~~,致校对,word 有“单词”、“命令”、“消息”、“结论” 等意思,到底哪个更适合,我个人认为根据上下文,”单词“ 更适合一些,这里推送的 ”词“ 可能是指令,也可能是数据~~)就够了。(注意在命令中所有的 `x` 都是小写。)警告:词(word)的多少并没有一个普遍的标准。在 GNU 汇编中,一个词(word)是两个字节(在 xorw 中的 'w',它在这个词中就是 2 个字节)。 + +重置机器(退出 QEMU/GDB 然后再次启动它们)。检查内存中在 `0x00100000` 地址上的 8 个词(word),输出 BIOS 上的引导加载器入口,然后再次找出引导载器上的内核的入口。为什么它们不一样?在第二个断点上有什么内容?(你并不用真的在 QEMU 上去回答这个问题,只需要思考就可以。) + +### 第三部分:内核 + +我们现在开始去更详细地研究最小的 JOS 内核。(最后你还将写一些代码!)就像引导加载器一样,内核也是从一些汇编语言代码设置一些东西开始的,以便于 C 语言代码可以正确运行。 + +#### 使用虚拟内存去解决位置依赖问题 + +前面在你检查引导加载器的链接和加载地址时,它们是完全一样的,但是内核的链接地址(可以通过 `objdump` 来输出)和它的加载地址之间差别很大。可以回到前面去看一下,以确保你明白我们所讨论的内容。(链接内核比引导加载器更复杂,因此,链接和加载地址都在 `kern/kernel.ld` 的顶部。) + +操作系统内核经常链接和运行在高位的虚拟地址,比如,`0xf0100000`,为的是给让用户程序去使用处理器的虚拟地址空间的低位部分。至于为什么要这么安排,在下一个实验中我们将会知道。 + +许多机器在 `0xf0100000` 处并没有物理地址,因此,我们不能指望在那个位置可以存储内核。相反,我们使用处理器的内存管理硬件去映射虚拟地址 `0xf0100000`(内核代码打算运行的链接地址)到物理地址 `0x00100000`(引导加载器将内核加载到内存的物理地址的位置)。通过这种方法,虽然内核的虚拟地址是高位的,离用户程序的地址空间足够远,它将被加载到 PC 的物理内存的 1MB 的位置,只处于 BIOS ROM 之上。这种方法要求 PC 至少要多于 1 MB 的物理内存(以便于物理地址 `0x00100000` 可以工作),这在上世纪九十年代以后生产的PC 上应该是没有问题的。 + +实际上,在下一个实验中,我们将映射整个 256 MB 的 PC 的物理地址空间,从物理地址 `0x00000000` 到 `0x0fffffff`,映射到虚拟地址 `0xf0000000` 到 `0xffffffff`。你现在就应该明白了为什么 JOS 只能使用物理内存的前 256 MB 的原因了。 + +现在,我们只映射前 4 MB 的物理内存,它足够我们的内核启动并运行。我们通过在 `kern/entrypgdir.c` 中手工写入静态初始化的页面目录和页面表就可以实现。现在,你不需要理解它们是如何工作的详细细节,只需要达到目的就行了。将上面的 `kern/entry.S` 文件中设置 `CR0_PG` 标志,内存引用就被视为物理地址(严格来说,它们是线性地址,但是,在 `boot/boot.S` 中设置了一个从线性地址到物理地址的映射标识,我们绝对不能改变它)。一旦 `CR0_PG` 被设置,内存引用的就是虚拟地址,这个虚拟地址是通过虚拟地址硬件将物理地址转换得到的。`entry_pgdir` 将把从 `0x00000000` 到 `0x00400000` 的物理地址范围转换在 `0xf0000000` 到 `0xf0400000` 的范围内的虚拟地址。任何不在这两个范围之一中的地址都将导致硬件异常,因为,我们还没有设置中断去处理这种情况,这种异常将导致 QEMU 去转储机器状态然后退出。(或者如果你没有在 QEMU 中应用 6.828 专用补丁,将导致 QEMU 无限重启。) + +> **练习 7** +> +> 使用 QEMU 和 GDB 去跟踪进入到 JOS 内核,然后停止在 `movl %eax, %cr0` 指令处。检查 `0x00100000` 和 `0xf0100000` 处的内存。现在使用GDB 的 `stepi` 命令去单步执行那个指令。再次检查 `0x00100000` 和 `0xf0100000` 处的内存。确保你能理解这时发生的事情。 + +新映射建立之后的第一个指令是什么?如果没有映射到位,它将不能正常工作。在 `kern/entry.S` 中注释掉 `movl %eax, %cr0`。然后跟踪它,看看你的猜测是否正确。 + +#### 格式化控制台的输出 + +大多数人认为像 `printf()` 这样的函数是天生就有的,有时甚至认为这是 C 语言的 ”原语“。但是在操作系统的内核中,我们需要自己去实现所有的 I/O。 + +通过阅读 `kern/printf.c`、`lib/printfmt.c`、以及 `kern/console.c`,确保你理解了它们之间的关系。在后面的实验中,你将会明白为什么 `printfmt.c` 是位于单独的 `lib` 目录中。 + +> **练习 8** +> +> 我们将省略掉一小部分代码片断 —— 这部分代码片断是使用 ”%o" 模式输出八进制数字所需要的。找到它并填充到这个代码片断中。 +> +> 然后你就能够回答下列的问题: +> +> 1. 解释 `printf.c` 和 `console.c` 之间的接口。尤其是,`console.c` 出口的函数是什么?这个函数是如何被 `printf.c` 使用的? +> +> 2. 在 `console.c` 中解释下列的代码: +> +> ``` +> if (crt_pos >= CRT_SIZE) { +> int i; +> memcpy(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t)); +> for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i++) +> crt_buf[i] = 0x0700 | ' '; +> crt_pos -= CRT_COLS; +> } +> ``` +> +> 3. 下列的问题你可能需要参考第一节课中的笔记。这些笔记涵盖了 GCC 在 x86 上的调用规则。 +> +> 一步一步跟踪下列代码的运行: +> +> ``` +> int x = 1, y = 3, z = 4; +> cprintf("x %d, y %x, z %d\n", x, y, z); +> ``` +> +> 1. 在调用 `cprintf()` 时,`fmt` 做了些什么?`ap` 做了些什么? +> 2. (按运行顺序)列出 `cons_putc`、`va_arg`、以及 `vcprintf` 的调用列表。对于 `cons_putc`,同时列出它的参数。对于`va_arg`,列出调用之前和之后的 `ap` 内容?对于 `vcprintf`,列出它的两个参数值。 +> +> 4. 运行下列代码: +> +> ``` +> unsigned int i = 0x00646c72; +> cprintf("H%x Wo%s", 57616, &i); +> ``` +> 输出是什么?解释如何在前面的练习中一步一步实现这个输出。这是一个 [ASCII 表][24],它是一个字节到字符串的映射表。 +> +> 这个输出取决于 x86 是小端法这一事实。如果这个 x86 采用大端法格式,你怎么去设置 `i`,以产生相同的输出?你需要将 `57616` 改变为一个不同值吗? +> +> [这是小端法和大端法的描述][25] 和 [一个更古怪的描述][26]。 +> +> 5. 在下列代码中,`y=` 会输出什么?(注意:这个问题没有确切值)为什么会发生这种情况? +> `cprintf("x=%d y=%d", 3);` +> +> +> 6. 假设修改了 GCC 的调用规则,以便于按声明的次序在栈上推送参数,这样最后的参数就是最后一个推送进去的。那你如何去改变 `cprintf` 或者它的接口,以便它仍然可以传递数量可变的参数? + + +#### 栈 + +在本实验的最后一个练习中,我们将理详细地解释在 x86 中 C 语言是如何使用栈的,以及在这个过程中,我们将写一个新的内核监视函数,这个函数将输出栈的回溯信息:一个保存了指令指针(IP)值的列表,这个列表中有嵌套的 `call` 指令运行在当前运行点的指针值。 + +> **练习 9** +> +> 搞清楚内核在什么地方初始化栈,以及栈在内存中的准确位置。内核如何为栈保留空间?以及这个保留区域的 “结束” 位置是指向初始化结束后的指针吗? + +x86 栈指针(`esp` 寄存器)指向当前使用的栈的最低位置。在这个区域中那个位置以下的所有部分都是空闲的。给一个栈推送一个值涉及下移栈指针和栈指针指向的位置中写入值。从栈中弹出一个值涉及到从栈指针指向的位置读取值和上移栈指针。在 32 位模式中,栈中仅能保存 32 位值,并且 `esp` 通常分为四部分。各种 x86 指令,比如,`call`,是 “硬编码” 去使用栈指针寄存器的。 + +相比之下,`ebp`(基指针)寄存器,按软件惯例主要是由栈关联的。在进入一个 C 函数时,函数的前序代码在函数运行期间,通常会通过推送它到栈中来保存前一个函数的基指针,然后拷贝当前的 `esp` 值到 `ebp` 中。如果一个程序中的所有函数都遵守这个规则,那么,在程序运行过程中的任何一个给定时间点,通过在 `ebp` 中保存的指针链和精确确定的函数嵌套调用顺序是如何到达程序中的这个特定的点,就可以通过栈来跟踪回溯。这种跟踪回溯的函数在实践中非常有用,比如,由于给某个函数传递了一个错误的参数,导致一个 `assert` 失败或者 `panic`,但是,你并不能确定是谁传递了错误的参数。栈的回溯跟踪可以让你找到这个惹麻烦的函数。 + +> **练习 10** +> +> 要熟悉 x86 上的 C 调用规则,可以在 `obj/kern/kernel.asm` 文件中找到函数 `test_backtrace` 的地址,设置一个断点,然后检查在内核启动后,每次调用它时发生了什么。每个递归嵌套的 `test_backtrace` 函数在栈上推送了多少个词(word),这些词(word)是什么? + +上面的练习可以给你提供关于实现栈跟踪回溯函数的一些信息,为实现这个函数,你应该去调用 `mon_backtrace()`。在 `kern/monitor.c` 中已经给你提供了这个函数的一个原型。你完全可以在 C 中去使用它,但是,你可能需要在 `inc/x86.h` 中使用到 `read_ebp()` 函数。你应该在这个新函数中实现一个到内核监视命令的钩子,以便于用户可以与它交互。 + +这个跟踪回溯函数将以下面的格式显示一个函数调用列表: +``` +Stack backtrace: + ebp f0109e58 eip f0100a62 args 00000001 f0109e80 f0109e98 f0100ed2 00000031 + ebp f0109ed8 eip f01000d6 args 00000000 00000000 f0100058 f0109f28 00000061 + ... +``` + +输出的第一行列出了当前运行的函数,名字为 `mon_backtrace`,就是它自己,第二行列出了被 `mon_backtrace` 调用的函数,第三行列出了另一个被调用的函数,依次类推。你可以输出所有未完成的栈帧。通过研究 `kern/entry.S`,你可以发现,有一个很容易的方法告诉你何时停止。 + +在每一行中,`ebp` 表示了那个函数进入栈的基指针:即,栈指针的位置,它就是函数进入之后,函数的前序代码设置的基指针。`eip` 值列出的是函数的返回指令指针:当函数返回时,指令地址将控制返回。返回指令指针一般指向 `call` 指令之后的指令(想一想为什么?)。在 `args` 之后列出的五个十六进制值是在问题中传递给函数的前五个参数。当然,如果函数调用时传递的参数少于五个,那么,在这里就不会列出全部五个值了。(为什么跟踪回溯代码不能检测到调用时实际上传递了多少个参数?如何去修复这个 ”缺陷“?) + +下面是在阅读 K&R 的书中的第 5 章中的一些关键点,为了接下来的练习和将来的实验,你应该记住它们。 + + * 如果 `int *p = (int*)100`,那么 `(int)p + 1` 和 `(int)(p + 1)` 是不同的数字:前一个是 `101`,但是第二个是 `104`。当在一个指针上加一个整数时,就像第二种情况,这个整数将隐式地与指针所指向的对象相乘。 + * `p[i]` 的定义与 `*(p+i)` 定义是相同的,都反映了在内存中由 `p` 指向的第 `i` 个对象。当对象大于一个字节时,上面的加法规则可以使这个定义正常工作。 + * `&p[i]` 与 `(p+i)` 是相同的,获取在内存中由 p 指向的第 `i` 个对象的地址。 + + + +虽然大多数 C 程序不需要在指针和整数之间转换,但是操作系统经常做这种转换。不论何时,当你看到一个涉及内存地址的加法时,你要问你自己,你到底是要做一个整数加法还是一个指针加法,以确保做完加法后的值是正确的,而不是相乘后的结果。 + +> **练 11** +> +> 实现一个像上面详细描述的那样的跟踪回溯函数。一定使用与示例中相同的输出格式,否则,将会引发评级脚本的识别混乱。在你认为你做的很好的时候,运行 `make grade` 这个评级脚本去查看它的输出是否是我们的脚本所期望的结果,如果不是去修改它。你提交了你的实验 1 代码后,我们非常欢迎你将你的跟踪回溯函数的输出格式修改成任何一种你喜欢的格式。 + +在这时,你的跟踪回溯函数将能够给你提供导致 `mon_backtrace()` 被运行的,在栈上调用它的函数的地址。但是,在实践中,你经常希望能够知道这个地址相关的函数名字。比如,你可能希望知道是哪个有 Bug 的函数导致了你的内核崩溃。 + +为帮助你实现这个功能,我们提供了 `debuginfo_eip()` 函数,它在符号表中查找 `eip`,然后返回那个地址的调试信息。这个函数定义在 `kern/kdebug.c` 文件中。 + +> **练习 12** +> +> 修改你的栈跟踪回溯函数,对于每个 `eip`,显示相关的函数名字、源文件名、以及那个 `eip` 的行号。 + +在 `debuginfo_eip` 中,`__STAB_*` 来自哪里?这个问题的答案很长;为帮助你找到答案,下面是你需要做的一些事情: + + * 在 `kern/kernel.ld` 文件中查找 `__STAB_*` + * 运行 i386-jos-elf-objdump -h obj/kern/kernel + * 运行 i386-jos-elf-objdump -G obj/kern/kernel + * 运行 i386-jos-elf-gcc -pipe -nostdinc -O2 -fno-builtin -I. -MD -Wall -Wno-format -DJOS_KERNEL -gstabs -c -S kern/init.c, and look at init.s。 + * 如果引导加载器在加载二进制内核时,将符号表作为内核的一部分加载进内存中,那么,去查看它。 + + + +通过在 `stab_binsearch` 中插入调用,可以完成在 `debuginfo_eip` 中通过地址找到行号的功能。 + +在内核监视中添加一个 `backtrace` 命令,扩展你实现的 `mon_backtrace` 的功能,通过调用 `debuginfo_eip`,然后以下面的格式来输出每个栈帧行: +``` +K> backtrace +Stack backtrace: + ebp f010ff78 eip f01008ae args 00000001 f010ff8c 00000000 f0110580 00000000 + kern/monitor.c:143: monitor+106 + ebp f010ffd8 eip f0100193 args 00000000 00001aac 00000660 00000000 00000000 + kern/init.c:49: i386_init+59 + ebp f010fff8 eip f010003d args 00000000 00000000 0000ffff 10cf9a00 0000ffff + kern/entry.S:70: +0 +K> +``` + +每行都给出了文件名和在那个文件中栈帧的 `eip` 所在的行,紧接着是函数的名字和那个函数的第一个指令到 `eip` 的偏移量(比如,`monitor+106` 意味着返回 `eip` 是从 `monitor` 开始之后的 106 个字节)。 + +为防止评级脚本引起混乱,应该将文件和函数名输出在单独的行上。 + +提示:`printf` 格式的字符串提供一个易用(尽管有些难理解)的方式去输出非空终止(non-null-terminated)字符串,就像在 STABS 表中的这些一样。`printf("%.*s", length, string)` 输出 `string` 中的最多 `length` 个字符。查阅 `printf` 的 man 页面去搞清楚为什么这样工作。 + +你可以从 `backtrace` 中找到那些没有的功能。比如,你或者可能看到一个到 `monitor()` 的调用,但是没有到 `runcmd()` 中。这是因为编译器的行内(in-lines)函数调用。其它的优化可能导致你看到一些意外的行号。如果你从 `GNUMakefile` 删除 `-O2` 参数,`backtraces` 可能会更有意义(但是你的内核将运行的更慢)。 + +**到此为止, 在 `lab` 目录中的实验全部完成**,使用 `git commit` 提交你的改变,然后输入 `make handin` 去提交你的代码。 + +-------------------------------------------------------------------------------- + +via: https://sipb.mit.edu/iap/6.828/lab/lab1/ + +作者:[mit][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://sipb.mit.edu +[1]:http://www.git-scm.com/ +[2]:http://www.kernel.org/pub/software/scm/git/docs/user-manual.html +[3]:http://eagain.net/articles/git-for-computer-scientists/ +[4]:https://sipb.mit.edu/iap/6.828/tools +[5]:https://exokernel.scripts.mit.edu/submit/ +[6]:https://sipb.mit.edu/iap/6.828/readings/pcasm-book.pdf +[7]:http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html +[8]:https://sipb.mit.edu/iap/6.828/reference +[9]:https://sipb.mit.edu/iap/6.828/readings/i386/toc.htm +[10]:http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html +[11]:http://developer.amd.com/documentation/guides/Pages/default.aspx#manuals +[12]:http://www.qemu.org/ +[13]:http://www.gnu.org/software/gdb/ +[14]:http://web.archive.org/web/20040404164813/members.iweb.net.au/%7Epstorr/pcbook/book2/book2.htm +[15]:https://sipb.mit.edu/iap/6.828/readings/boot-cdrom.pdf +[16]:https://sipb.mit.edu/iap/6.828/labguide +[17]:https://sipb.mit.edu/iap/6.828/files/pointers.c +[18]:http://www.amazon.com/C-Programming-Language-2nd/dp/0131103628/sr=8-1/qid=1157812738/ref=pd_bbs_1/104-1502762-1803102?ie=UTF8&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;s=books +[19]:http://library.mit.edu/F/AI9Y4SJ2L5ELEE2TAQUAAR44XV5RTTQHE47P9MKP5GQDLR9A8X-10422?func=item-global&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;doc_library=MIT01&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;doc_number=000355242&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;year=&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;volume=&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;sub_library= +[20]:http://sipb.mit.edu/ +[21]:https://sipb.mit.edu/iap/6.828/readings/pointers.pdf +[22]:https://sipb.mit.edu/iap/6.828/readings/elf.pdf +[23]:http://sourceware.org/gdb/current/onlinedocs/gdb_9.html#SEC63 +[24]:http://web.cs.mun.ca/%7Emichael/c/ascii-table.html +[25]:http://www.webopedia.com/TERM/b/big_endian.html +[26]:http://www.networksorcery.com/enp/ien/ien137.txt \ No newline at end of file From 258126feae20ccfe0245d46bd1d506777a4ade41 Mon Sep 17 00:00:00 2001 From: cmn <2545489745@qq.com> Date: Sat, 31 Mar 2018 21:37:57 +0800 Subject: [PATCH 0221/1057] translated --- ...p - A CLI Tool For Container Monitoring.md | 121 ------------------ ...p - A CLI Tool For Container Monitoring.md | 120 +++++++++++++++++ 2 files changed, 120 insertions(+), 121 deletions(-) delete mode 100644 sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md create mode 100644 translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md diff --git a/sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md b/sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md deleted file mode 100644 index 15ada04057..0000000000 --- a/sources/tech/20180221 cTop - A CLI Tool For Container Monitoring.md +++ /dev/null @@ -1,121 +0,0 @@ -translating by kimii -cTop - A CLI Tool For Container Monitoring -====== -Recent days Linux containers are famous, even most of us already working on it and few of us start learning about it. - -We have already covered article about the famous GUI (Graphical User Interface) tools such as Portainer & Rancher. This will help us to manage containers through GUI. - -This tutorial will help us to understand and monitor Linux containers through cTop command. It’s a command-line tool like top command. - -### What’s cTop - -[ctop][1] provides a concise and condensed overview of real-time metrics for multiple containers. It’s Top-like interface for container metrics. - -It displays containers metrics such as CPU utilization, Memory utilization, Disk I/O Read & Write, Process ID (PID), and Network Transmit(TX – Transmit FROM this server) and receive(RX – Receive TO this server). - -ctop comes with built-in support for Docker and runC; connectors for other container and cluster systems are planned for future releases. -It doesn’t requires any arguments and uses Docker host variables by default. - -**Suggested Read :** -**(#)** [Portainer – A Simple Docker Management GUI][2] -**(#)** [Rancher – A Complete Container Management Platform For Production Environment][3] - -### How To Install cTop - -Developer offers a simple shell script, which help us to use ctop instantly. What we have to do, just download the ctop shell file at `/bin` directory for global access. Finally assign the execute permission to ctop shell file. - -Download the ctop shell file @ `/usr/local/bin` directory. -``` -$ sudo wget https://github.com/bcicen/ctop/releases/download/v0.7/ctop-0.7-linux-amd64 -O /usr/local/bin/ctop - -``` - -Set execute permission to ctop shell file. -``` -$ sudo chmod +x /usr/local/bin/ctop - -``` - -Alternatively you can install and run ctop through docker. Make sure you should have installed docker as a pre-prerequisites for this. To install docker, refer the following link. - -**Suggested Read :** -**(#)** [How to install Docker in Linux][4] -**(#)** [How to play with Docker images on Linux][5] -**(#)** [How to play with Docker containers on Linux][6] -**(#)** [How to Install, Run Applications inside Docker Containers][7] -``` -$ docker run --rm -ti \ - --name=ctop \ - -v /var/run/docker.sock:/var/run/docker.sock \ - quay.io/vektorlab/ctop:latest - -``` - -### How To Use cTop - -Just launch the ctop utility without any arguments. By default it’s bind with `a` key which display of all containers (running and non-running). -ctop header shows your system time and total number of containers. -``` -$ ctop - -``` - -You might get the output similar to below. -![][9] - -### How To Manage Containers - -You can able to administrate the containers using ctop. Select a container that you want to manage then hit `Enter` button and choose required options like start, stop, remove, etc,. -![][10] - -### How To Sort Containers - -By default ctop sort the containers using state field. Hit `s` key to sort the containers in the different aspect. -![][11] - -### How To View the Containers Metrics - -If you want to view more details & metrics about the container, just select the corresponding which you want to view then hit `o` key. -![][12] - -### How To View Container Logs - -Select the corresponding container which you want to view the logs then hit `l` key. -![][13] - -### Display Only Active Containers - -Run ctop command with `-a` option to show active containers only. -![][14] - -### Open Help Dialog Box - -Run ctop, just hit `h`key to open help section. -![][15] - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux/ - -作者:[2DAYGEEK][a] -译者:[译者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/2daygeek/ -[1]:https://github.com/bcicen/ctop -[2]:https://www.2daygeek.com/portainer-a-simple-docker-management-gui/ -[3]:https://www.2daygeek.com/rancher-a-complete-container-management-platform-for-production-environment/ -[4]:https://www.2daygeek.com/install-docker-on-centos-rhel-fedora-ubuntu-debian-oracle-archi-scentific-linux-mint-opensuse/ -[5]:https://www.2daygeek.com/list-search-pull-download-remove-docker-images-on-linux/ -[6]:https://www.2daygeek.com/create-run-list-start-stop-attach-delete-interactive-daemonized-docker-containers-on-linux/ -[7]:https://www.2daygeek.com/install-run-applications-inside-docker-containers/ -[8]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[9]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-1.png -[10]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-2.png -[11]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-3.png -[12]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-4a.png -[13]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-7.png -[14]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-5.png -[15]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-6.png diff --git a/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md b/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md new file mode 100644 index 0000000000..3abee66227 --- /dev/null +++ b/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md @@ -0,0 +1,120 @@ +cTop - 用于容器监控的 CLI 工具 +====== +最近 Linux 容器很火,我们中的大多数人甚至已经在使用它,同时一些人也开始学习它。 + +我们已经介绍了有名的 GUI(用户图形界面) 工具如 Portainer 和 Rancher 。这将会有助于我们通过 GUI 管理容器。 + +这篇指南将会通过 cTop 命令帮助我们理解和监控 Linux 容器。它是一个类似 top 命令的命令行工具。 + +### 什么是 cTop + +[ctop][1] 为多个容器提供了一个简洁凝练的实时指标概览。它是一个类 Top 的针对容器指标的界面。 + +它展示了容器指标比如 CPU 利用率,内存利用率,磁盘 I/O 读写,进程 ID(PID)和网络发送(TX - 从此服务器发送)以及接受(RX - 此服务器接受)。 + +ctop 伴随着对 Docker 和 runc 的内建支持;对其他容器和集群系统的连接计划在未来版本中推出。 +它不需要任何参数并且默认使用 Docker 主机变量。 + +**建议阅读:** +**(#)** [Portainer – 一个简单的 Docker 管理 GUI][2] +**(#)** [Rancher – 一个完整的生产环境容器管理平台][3] + +### 如何安装 cTop + +开发者提供了一个简单的 shell 脚本来帮助我们直接使用 ctop。我们要做的,只是在“/bin”目录下下载 ctop shell 文件来保证全局访问。最后给予 ctop 脚本文件执行权限。 + +在“/usr/local/bin”目录下下载 ctop shell 脚本。 +``` +$ sudo wget https://github.com/bcicen/ctop/releases/download/v0.7/ctop-0.7-linux-amd64 -O /usr/local/bin/ctop + +``` + +对 ctop shell 脚本设置执行权限。 +``` +$ sudo chmod +x /usr/local/bin/ctop + +``` + +另外你可以通过 docker 来安装和运行 ctop。在此之前先确保你已经安装过 docker。为了安装 docker,参考以下链接。 + +**建议阅读:** +**(#)** [如何在 Linux 上安装 Docker][4] +**(#)** [如何在 Linux 上玩转 Docker 镜像][5] +**(#)** [如何在 Linux 上玩转 Docker 容器][6] +**(#)** [如何在 Docker 容器中安装,运行应用][7] +``` +$ docker run --rm -ti \ + --name=ctop \ + -v /var/run/docker.sock:/var/run/docker.sock \ + quay.io/vektorlab/ctop:latest + +``` + +### 如何使用 cTop + +直接启动 ctop 程序而不用任何参数。默认它与“a”键绑定来展示所有容器(运行的和没运行的)。 +ctop 头部显示你的系统时间和容器的总数。 +``` +$ ctop + +``` + +你可能得到以下类似输出。 +![][9] + +### 如何管理容器 + +你可以使用 ctop 来管理容器。选择一个你想要管理的容器然后按下“Enter”键,选择所需选项如 start,stop,remove 等。 +![][10] + +### 如何给容器排序 + +默认 ctop 使用 state 字段来给容器排序。按下“s”键来用不同的方面给容器排序。 +![][11] + +### 如何查看容器指标 + +如何你想要查看关于容器的更多细节和指标,只用选择你想要查看的相应容器然后按“o”键。 +![][12] + +### 如何查看容器日志 + +选择你想要查看日志的相应容器然后按“l”键。 +![][13] + +### 仅显示活动容器 + +使用“-a”选项运行 ctop 命令来仅显示活动容器 +![][14] + +### 打开帮助对话框 + +运行 ctop,只需按“h”键来打开帮助部分。 +![][15] + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux/ + +作者:[2DAYGEEK][a] +译者:[kimii](https://github.com/kimii) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com/author/2daygeek/ +[1]:https://github.com/bcicen/ctop +[2]:https://www.2daygeek.com/portainer-a-simple-docker-management-gui/ +[3]:https://www.2daygeek.com/rancher-a-complete-container-management-platform-for-production-environment/ +[4]:https://www.2daygeek.com/install-docker-on-centos-rhel-fedora-ubuntu-debian-oracle-archi-scentific-linux-mint-opensuse/ +[5]:https://www.2daygeek.com/list-search-pull-download-remove-docker-images-on-linux/ +[6]:https://www.2daygeek.com/create-run-list-start-stop-attach-delete-interactive-daemonized-docker-containers-on-linux/ +[7]:https://www.2daygeek.com/install-run-applications-inside-docker-containers/ +[8]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[9]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-1.png +[10]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-2.png +[11]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-3.png +[12]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-4a.png +[13]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-7.png +[14]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-5.png +[15]:https://www.2daygeek.com/wp-content/uploads/2018/02/ctop-a-command-line-tool-for-container-monitoring-and-management-in-linux-6.png From e9947bd5308fa976a72231ad173d96a12a96fbaa Mon Sep 17 00:00:00 2001 From: kimii <2545489745@qq.com> Date: Sat, 31 Mar 2018 13:56:15 +0000 Subject: [PATCH 0222/1057] Update 20180328 Do continuous deployment with Github and Python.md --- .../20180328 Do continuous deployment with Github and Python.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180328 Do continuous deployment with Github and Python.md b/sources/tech/20180328 Do continuous deployment with Github and Python.md index 88f6e52bac..0452f8c669 100644 --- a/sources/tech/20180328 Do continuous deployment with Github and Python.md +++ b/sources/tech/20180328 Do continuous deployment with Github and Python.md @@ -1,3 +1,4 @@ +translating by kimii Do continuous deployment with Github and Python ====== From 3ba13f6579acac1a187f16867c157010c6191e6c Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 31 Mar 2018 23:15:12 +0800 Subject: [PATCH 0223/1057] PRF:20170210 Evolutional Steps of Computer Systems.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lontow 恭喜你,完成了第一篇翻译,翻译的很好! --- ...0 Evolutional Steps of Computer Systems.md | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/translated/talk/20170210 Evolutional Steps of Computer Systems.md b/translated/talk/20170210 Evolutional Steps of Computer Systems.md index 80fdb66927..0b28a3588e 100644 --- a/translated/talk/20170210 Evolutional Steps of Computer Systems.md +++ b/translated/talk/20170210 Evolutional Steps of Computer Systems.md @@ -1,5 +1,6 @@ -计算机系统的进化论 +计算机系统进化论 ====== + 纵观现代计算机的历史,从与系统的交互方式方面,可以划分为数个进化阶段。而我更倾向于将之归类为以下几个阶段: 1. 数字系统 @@ -8,13 +9,11 @@ 4. 信息中心系统 5. 无应用系统 - - 下面我们详细聊聊这几种分类。 ### 数字系统 -在我看来,[ 早期计算机 ][1],只被设计用来处理数字。它们能够加,减,乘,除。在它们中有一些能够运行像是微分和积分之类的更复杂的数学操作。 +在我看来,[早期计算机][1],只被设计用来处理数字。它们能够加、减、乘、除。在它们中有一些能够运行像是微分和积分之类的更复杂的数学操作。 当然,如果你把字符映射成数字,它们也可以计算字符串。但这多少有点“数字的创造性使用”的意思,而不是直接处理各种信息。 @@ -28,53 +27,50 @@ 应用中心系统是第一个真正的通用系统。它们的主要使用风格很像专用应用系统,但是它们拥有以时间片模式(一个接一个)或以多任务模式(多应用同时)运行的多个应用程序。 -上世纪 70 年代的[ 早期的个人电脑 ][3]是第一种受大量人们欢迎的应用中心系统。 +上世纪 70 年代的 [早期的个人电脑][3]是第一种受人们欢迎的应用中心系统。 -如今的现在操作系统 —— Windows , macOS , 大多数 GNU/Linux 桌面环境 —— 一直遵循相同的法则。 +如今的现在操作系统 —— Windows 、macOS 、大多数 GNU/Linux 桌面环境 —— 一直遵循相同的法则。 当然,应用中心系统还可以再细分为两种子类: 1. 紧密型应用中心系统 2. 松散型应用中心系统 - - -精密型应用中心系统像是 [Windows 3.1][4] (拥有程序管理器和文件管理器)或者甚至 [ Windows 95 ][5] 的最初版本都没有预定义文件夹层次。用户启动文本处理程序(像 [ WinWord ][6])并且把文件保存在 WinWord 的程序文件夹中。在使用表格处理程序的时候,又把文件保存在表格处理工具的程序文件夹中。诸如此类。用户几乎不创建自己的文件层次结构,可能由于此举的不方便,用户单方面的懒惰,或者他们认为根本没有必要。那时,每个用户拥有几十个至多几百个文件。 +紧密型应用中心系统像是 [Windows 3.1][4] (拥有程序管理器和文件管理器)或者甚至 [Windows 95][5] 的最初版本都没有预定义的文件夹层次。用户启动文本处理程序(像 [ WinWord ][6])并且把文件保存在 WinWord 的程序文件夹中。在使用表格处理程序的时候,又把文件保存在表格处理工具的程序文件夹中。诸如此类。用户几乎不创建自己的文件层次结构,可能由于此举的不方便、用户单方面的懒惰,或者他们认为根本没有必要。那时,每个用户拥有几十个至多几百个文件。 为了访问文件中的信息,用户常常先打开一个应用程序,然后通过程序中的“文件/打开”功能来获取处理过的数据文件。 - 在 Windows 平台的[ Windows 95][5] SP2 中,«[ 我的文档 ][7]»首次被使用。有了这样一个文件层次结构的样板,应用设计者开始把 «[我的文档][7]» 作为程序的默认 保存 / 打开 目录,抛弃了原来将软件产品安装目录作为默认目录的做法。这样一来,用户渐渐适应了这种模式,并且开始自己维护文件夹层次。 +在 Windows 平台的 [Windows 95][5] SP2 中,“[我的文档][7]”首次被使用。有了这样一个文件层次结构的样板,应用设计者开始把 “[我的文档][7]” 作为程序的默认的保存 / 打开目录,抛弃了原来将软件产品安装目录作为默认目录的做法。这样一来,用户渐渐适应了这种模式,并且开始自己维护文件夹层次。 - 松散型应用中心系统(通过文件管理器来提取文件)应用而生。在这种系统下,当打开一个文件的时候,操作系统会自动启动与之相关的应用程序。这是一次小而精妙的用法转变。这种应用中心系统的用法模式一直是个人电脑的主要用法模式。 +松散型应用中心系统(通过文件管理器来提取文件)应运而生。在这种系统下,当打开一个文件的时候,操作系统会自动启动与之相关的应用程序。这是一次小而精妙的用法转变。这种应用中心系统的用法模式一直是个人电脑的主要用法模式。 - 然而,这种模式有很多的缺点。例如,对于一个给定的项目,为了防止数据提取出现问题,需要维护一个包含所有相关文件的严格文件夹层次结构。不幸的是,人们并不总能这样做。更进一步说,[ 这种模式不能很好的扩展 ][8]。 桌面搜索引擎和高级数据组织工具(像[ tagstore ][9])可以起到一点改善作用。正如研究显示的那样,只有一少部分人正在使用那些高级文件提取工具。大多数的用户不使用替代提取工具或者辅助提取技术在文件系统中寻找文件。 +然而,这种模式有很多的缺点。例如,为了防止数据提取出现问题,需要维护一个包含给定项目的所有相关文件的严格文件夹层次结构。不幸的是,人们并不总能这样做。更进一步说,[这种模式不能很好的扩展][8]。 桌面搜索引擎和高级数据组织工具(像 [tagstore][9])可以起到一点改善作用。正如研究显示的那样,只有一少部分人正在使用那些高级文件提取工具。大多数的用户不使用替代提取工具或者辅助提取技术在文件系统中寻找文件。 ### 信息中心系统 -解决上述问题的可行办法之一就是从应用中心系统转换到信息中心系统。 +解决上述需要将所有文件都放到一个文件夹的问题的可行办法之一就是从应用中心系统转换到信息中心系统。 -信息中心系统将项目的所有信息联合起来,放在一个地方,放在同一个应用程序里。 -因此,我们再也不需要计算项目预算时,打开表格处理程序;写工程报告时,打开文本处理程序;处理图片文件时,又打开另一个工具。 +信息中心系统将项目的所有信息联合起来,放在一个地方,放在同一个应用程序里。因此,我们再也不需要计算项目预算时,打开表格处理程序;写工程报告时,打开文本处理程序;处理图片文件时,又打开另一个工具。 上个月的预算情况在客户会议笔记的右下方,客户会议笔记又在画板的右下方,而画板又在另一些要去完成的任务的右下方。在各个层之间没有文件或者应用程序来回切换的麻烦。 -早期,IBM [ OS/2 ][10], Microsoft [ OLE ][11] 和 [NeXT][12] 都做过类似的尝试。但都由于各种原因没有取得重大成功。从 [ Plan 9][14] 发展而来的 [ACme][13] 是一个令人兴奋的信息中心环境。它在一个应用程序中包含了多种应用程序。但是相比 Windows 和 GNU/Linux 而言,它从不是一个值得注意的系统发行版(即使在系统接口级别)。 +早期,IBM [OS/2][10]、 Microsoft [OLE][11] 和 [NeXT][12] 都做过类似的尝试。但都由于种种原因没有取得重大成功。从 [Plan 9][14] 发展而来的 [ACme][13] 是一个非常有趣的信息中心环境。它在一个应用程序中包含了[多种应用程序][15]。但是即时是它移植到了 Windows 和 GNU/Linux,也从来没有成为一个引起关注的软件。 -信息中心系统的现代形式是高级 [ 个人 wikis ][16](像 [ TheBrain ][17]和[ Microsoft OneNote ][18])。 +信息中心系统的现代形式是高级 [个人维基][16](像 [TheBrain][17] 和 [Microsoft OneNote][18])。 -我选择的个人工具是带 [Org-mode][19] 扩展的 [GNU/Emacs][20]。在用电脑的时候,我几乎不能没有 Org-mode 。为了访问外部数据资源,我创建了一个可以将多种数据导入 Org-mode 的插件 —— [Memacs][20] 。我喜欢将表格数据计算放到日程任务的右下方,然后是行内图片,内部和外部链接,等等。它是一个真正的用户不用必须切换程序或者切换严格层次文件系统文件夹的信息中心系统。同时,用简单的或高级的标签也可以进行多分类。一个命令可以派生多种视图。比如,一个视图有日历,待办事项。另一个视图是租借事宜。等等。它对 Org-mode 用户没有限制。只有你想不到,没有它做不到。 +我选择的个人工具是带 [Org 模式][19] 扩展的 [GNU/Emacs][20] 平台。在用电脑的时候,我几乎不能没有 Org 模式 。为了访问外部数据资源,我创建了一个可以将多种数据导入 Org 模式的插件 —— [Memacs][20] 。我喜欢将表格数据计算放到日程任务的右下方,然后是行内图片,内部和外部链接,等等。它是一个真正的用户不用必须操心程序或者严格的层次文件系统文件夹的信息中心系统。同时,用简单的或高级的标签也可以进行多分类。一个命令可以派生多种视图。比如,一个视图有日历,待办事项。另一个视图是租借事宜列表。等等。它对 Org 模式的用户没有限制。只有你想不到,没有它做不到。 进化结束了吗? 当然没有。 ### 无应用系统 -我能想到这样一类操作系统,我称之为无应用系统。在下一步的发展中,系统将不需要单域应用程序,即使它们能和 Org-mode 一样出色。计算机直接提供一个处理信息和使用功能的友好用户接口,而不通过文件和程序。甚至连传统的操作系统也不需要。 +我能想到这样一类操作系统,我称之为无应用系统。在下一步的发展中,系统将不需要单一领域的应用程序,即使它们能和 Org 模式一样出色。计算机直接提供一个处理信息和使用功能的友好用户接口,而不通过文件和程序。甚至连传统的操作系统也不需要。 -无应用系统也可能和 [人工智能][21] 联系起来。把它想象成 [2001太空漫游][23] 中的 [HAL 9000][22] 和星际迷航中的 [LCARS][24]一类的东西就可以了。 +无应用系统也可能和 [人工智能][21] 联系起来。把它想象成 [2001 太空漫游][23] 中的 [HAL 9000][22] 和星际迷航中的 [LCARS][24] 一类的东西就可以了。 -从基于应用的,基于供应商的软件文化到无应用系统的转化让人很难相信。 或许,缓慢但却不断发展的开源环境,可以使一个由各种各样组织和人们贡献的真正无应用环境成型。 +从基于应用的、基于供应商的软件文化到无应用系统的转化让人很难相信。 或许,缓慢但却不断发展的开源环境,可以使一个由各种各样组织和人们贡献的真正无应用环境成型。 -信息和提取、操作信息的功能,这是系统应该有的,同时也是我们所需要的。其他的东西仅仅是为了使我们不至于分散注意力。 +信息和提取、操作信息的功能,这是系统应该具有的,同时也是我们所需要的。其他的东西仅仅是为了使我们不至于分散注意力。 -------------------------------------------------------------------------------- @@ -82,7 +78,7 @@ via: http://karl-voit.at/2017/02/10/evolution-of-systems/ 作者:[Karl Voit][a] 译者:[lontow](https://github.com/lontow) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 94765820d50688897dd0b93c4af744a52c3e1bea Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 31 Mar 2018 23:16:01 +0800 Subject: [PATCH 0224/1057] PUB:20170210 Evolutional Steps of Computer Systems.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lontow 首发地址: https://linux.cn/article-9500-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/lontow --- .../20170210 Evolutional Steps of Computer Systems.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20170210 Evolutional Steps of Computer Systems.md (100%) diff --git a/translated/talk/20170210 Evolutional Steps of Computer Systems.md b/published/20170210 Evolutional Steps of Computer Systems.md similarity index 100% rename from translated/talk/20170210 Evolutional Steps of Computer Systems.md rename to published/20170210 Evolutional Steps of Computer Systems.md From 9930f56092a5e9aed384042c2476e95b66a6cd82 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 31 Mar 2018 23:32:01 +0800 Subject: [PATCH 0225/1057] PRF:20180130 Linux ln Command Tutorial for Beginners (5 Examples).md @CYLeft @locez --- ...and Tutorial for Beginners (5 Examples).md | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md b/translated/tech/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md index 8c6f0ba124..f96f8f1a6a 100644 --- a/translated/tech/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md +++ b/translated/tech/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md @@ -1,29 +1,28 @@ -为初学者准备的 Linux ln 命令教程(5 个示例) +为初学者准备的 ln 命令教程(5 个示例) ====== -当我们在命令行上工作时,您可能需要在文件之间创建链接。这时,您可以可以借助一个专用命令,**ln**。本教程中,我们将通过一些简单易理解的例子来讨论此工具的基础知识。在此之前,值得一提的是,本教程所有例子都已在 Ubuntu 16.04 上测试通过。 +当我们在命令行上工作时,您可能需要在文件之间创建链接。这时,您可以可以借助一个专用命令,`ln`。本教程中,我们将通过一些简单易理解的例子来讨论此工具的基础知识。在此之前,值得一提的是,本教程所有例子都已在 Ubuntu 16.04 上测试通过。 ### Linux ln 命令 -正如你现在所了解的,ln 命令能够让您在文件之间创建链接。下面就是 ln 工具的语法(或者使用其他一些可行的语法)。 +正如你现在所了解的,`ln` 命令能够让您在文件之间创建链接。下面就是 `ln` 工具的语法(或者使用其他一些可行的语法)。 ``` -ln [OPTION]... [-T] TARGET LINK_NAME (1st form) -ln [OPTION]... TARGET (2nd form) -ln [OPTION]... TARGET... DIRECTORY (3rd form) -ln [OPTION]... -t DIRECTORY TARGET... (4th form) +ln [OPTION]... [-T] TARGET LINK_NAME (第一种形式) +ln [OPTION]... TARGET (第二种形式) +ln [OPTION]... TARGET... DIRECTORY (第三种形式) +ln [OPTION]... -t DIRECTORY TARGET... (第四种形式) ``` -下面是 ln 工具 man 文档描述的内容: -``` -在第一种形式下,为 TARGET 创建一个叫 LINK_NAME 的链接。在第二种形式下,为 TARGET 在当前目录下创建一个链接( LCTT 译注:创建的为同名链接)。在第三和第四中形式中,在 DIRECTORY 目录下为每一个 TARGET 创建链接。默认创建硬链接,符号链接需要 --symbolic 选项。默认创建的每一个目标(新链接的名字)都不能已经存在。当创建硬链接时,TARGET 文件必须存在。符号链接可以保存任意文本,如果之后解析,相对链接的解析与其父目录有关。 -``` +下面是 `ln` 工具 man 文档描述的内容: + +> 在第一种形式下,为目标位置(TARGET)创建一个叫 LINK_NAME 的链接。在第二种形式下,为目标位置(TARGET)在当前目录下创建一个链接(LCTT 译注:创建的为同名链接)。在第三和第四种形式中,在 DIRECTORY 目录下为每一个目标位置(TARGET)创建链接。默认创建硬链接,符号链接需要 `--symbolic` 选项。默认创建的每一个创建的链接(新链接的名字)都不能已经存在。当创建硬链接时,目标位置(TARGET)文件必须存在;符号链接可以保存任意文本,如果之后解析,相对链接的解析与其父目录有关。 通过下面问答风格的例子,可能会给你更好的理解。但是在此之前,建议您先了解 [硬链接和软链接的区别][1]. ### Q1. 如何使用 ln 命令创建硬链接? -这很简单,你只需要像下面使用 ln 命令: +这很简单,你只需要像下面使用 `ln` 命令: ``` ln [file] [hard-link-to-file] @@ -37,11 +36,11 @@ ln test.txt test_hard_link.txt [![如何使用 ln 命令创建硬链接][2]][3] -如此,您便可以看见一个已经创建好的,名为 test_hard_link.txt 的硬链接。 +如此,您便可以看见一个已经创建好的,名为 `test_hard_link.txt` 的硬链接。 ### Q2. 如何使用 ln 命令创建软/符号链接? -使用 -s 命令行选项 +使用 `-s` 命令行选项: ``` ln -s [file] [soft-link-to-file] @@ -55,39 +54,39 @@ ln -s test.txt test_soft_link.txt [![如何使用 ln 命令创建软/符号链接][4]][5] -test_soft_link.txt 文件就是一个软/符号链接,被天蓝色文本 [标识][6]。 +`test_soft_link.txt` 文件就是一个软/符号链接,以天蓝色文本 [标识][6]。 ### Q3. 如何使用 ln 命令删除既存的同名目标文件? -默认情况下,ln 不允许您在目标目录下创建已存在的链接。 +默认情况下,`ln` 不允许您在目标目录下创建已存在的链接。 [![ln 命令示例][7]][8] -然而,如果一定要这么做,您可以使用 **-f** 命令行选项覆盖此行为。 +然而,如果一定要这么做,您可以使用 `-f` 命令行选项覆盖此行为。 [![如何使用 ln 命令创建软/符号链接][9]][10] -**贴士** : 如果您想在此删除过程中有所交互,您可以使用 **-i** 选项。 +提示:如果您想在此删除过程中有所交互,您可以使用 `-i` 选项。 ### Q4. 如何使用 ln 命令创建现有文件的同名备份? -如果您不想 ln 删除同名的现有文件,您可以为这些文件创建备份。使用 **-b** 即可实现此效果,以这种方式创建的备份文件,会在其文件名结尾处包含一个波浪号(~)。 +如果您不想 `ln` 删除同名的现有文件,您可以为这些文件创建备份。使用 `-b` 即可实现此效果,以这种方式创建的备份文件,会在其文件名结尾处包含一个波浪号(`~`)。 [![如何使用 ln 命令创建现有文件的同名备份][11]][12] ### Q5. 如何在当前目录以外的其它目录创建链接? -使用 **-t** 选项指定一个文件目录(除了当前目录)。比如: +使用 `-t` 选项指定一个文件目录(除了当前目录)。比如: ``` ls test* | xargs ln -s -t /home/himanshu/Desktop/ ``` -上述命令会为所有 test* 文件(当前目录下的 test* 文件)创建链接,并放到桌面目录下。 +上述命令会为(当前目录下的)所有 `test*` 文件创建链接,并放到桌面目录下。 ### 总结 -当然,尤其对于新手来说,**ln** 并不是日常必备命令。但是,这是一个有用的命令,因为你永远不知道它什么时候能够节省你一天的时间。对于这个命令,我们已经讨论了一些实用的选项,如果你已经完成了这些,可以查询 [man 文档][13] 来了解更多详情。 +当然,尤其对于新手来说,`ln` 并不是日常必备命令。但是,这是一个有用的命令,因为你永远不知道它什么时候能够节省你一天的时间。对于这个命令,我们已经讨论了一些实用的选项,如果你已经完成了这些,可以查询 [man 文档][13] 来了解更多详情。 -------------------------------------------------------------------------------- From 8b66196e5f10aac2dd31fcfbeb02cf35da142811 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 31 Mar 2018 23:32:37 +0800 Subject: [PATCH 0226/1057] PUB:20180130 Linux ln Command Tutorial for Beginners (5 Examples).md @CYLeft @locez https://linux.cn/article-9501-1.html --- ...180130 Linux ln Command Tutorial for Beginners (5 Examples).md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md (100%) diff --git a/translated/tech/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md b/published/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md similarity index 100% rename from translated/tech/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md rename to published/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md From 357698330696973a7df5d516a8dc2619555e86ca Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 31 Mar 2018 23:40:29 +0800 Subject: [PATCH 0227/1057] =?UTF-8?q?=E5=BD=92=E6=A1=A3=20201803?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => 201803}/20090203 How the Kernel Manages Your Memory.md | 0 ...w to use yum-cron to automatically update RHEL-CentOS Linux.md | 0 ...reate sar Graphs With kSar To Identifying Linux Bottlenecks.md | 0 ...ly File Permissions On Linux - Unix Web Server DocumentRoot.md | 0 ...140225 How To Safely Generate A Random Number - Quarrelsome.md | 0 .../20150615 Let-s Build A Simple Interpreter. Part 1..md | 0 published/{ => 201803}/20150708 Choosing a Linux Tracer (2015).md | 0 published/{ => 201803}/20160810 How does gdb work.md | 0 .../20170210 Evolutional Steps of Computer Systems.md | 0 ...10 9 Lightweight Linux Applications to Speed Up Your System.md | 0 .../20170921 How to answer questions in a helpful way.md | 0 .../{ => 201803}/20171002 Bash Bypass Alias Linux-Unix Command.md | 0 ...set Linux Desktop To Default Settings With A Single Command.md | 0 ... Stow to manage programs installed from source and dotfiles.md | 0 ...171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md | 0 ...1009 10 layers of Linux container security - Opensource.com.md | 0 ...he Files To -Trash Can- Instead Of Removing Them Completely.md | 0 ...17 What Are the Hidden Files in my Linux Home Directory For.md | 0 published/{ => 201803}/20171102 What is huge pages in Linux.md | 0 ...20171108 How to Use GNOME Shell Extensions [Complete Guide].md | 0 .../{ => 201803}/20171109 Concurrent Servers- Part 4 - libuv.md | 0 ...ure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora).md | 0 ...1115 How to create better documentation with a kanban board.md | 0 .../20171116 Record and Share Terminal Session with Showterm.md | 0 ...nd line fun- Insult the user when typing wrong bash command.md | 0 ... How to organize your passwords using pass password manager.md | 0 .../20171201 Torrents - Everything You Need to Know.md | 0 ...03 3 Essential Questions to Ask at Your Next Tech Interview.md | 0 .../20171207 Concurrent Servers- Part 5 - Redis case study.md | 0 .../20171213 Creating a blog with pelican and Github pages.md | 0 .../{ => 201803}/20171214 6 open source home automation tools.md | 0 .../{ => 201803}/20171214 IPv6 Auto-Configuration in Linux.md | 0 .../20171218 What Are Containers and Why Should You Care-.md | 0 published/{ => 201803}/20171218 Whats CGManager.md | 0 .../{ => 201803}/20171221 Mail transfer agent (MTA) basics.md | 0 published/{ => 201803}/20180102 HTTP errors in WordPress.md | 0 .../20180102 How To Find (Top-10) Largest Files In Linux.md | 0 ...104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md | 0 ...sible- the Automation Framework That Thinks Like a Sysadmin.md | 0 ...to use syslog-ng to collect logs from remote Linux machines.md | 0 .../20180110 Best Linux Screenshot and Screencasting Tools.md | 0 ...110 How to install-update Intel microcode firmware on Linux.md | 0 .../20180111 How to install software applications on Linux.md | 0 ...80111 The Fold Command Tutorial With Examples For Beginners.md | 0 ...A Versatile Free Software for Partition Imaging and Cloning.md | 0 .../{ => 201803}/20180116 Analyzing the Linux boot process.md | 0 .../20180116 SPARTA - Network Penetration Testing GUI Toolkit.md | 0 .../20180117 How To Manage Vim Plugins Using Vundle On Linux.md | 0 ...0117 Linux tee Command Explained for Beginners (6 Examples).md | 0 ...9 5 of the Best Linux Dark Themes that Are Easy on the Eyes.md | 0 .../20180119 How to install Spotify application on Linux.md | 0 ... Magazine-s article, build your own RSS notification system.md | 0 .../20180124 4 cool new projects to try in COPR for January.md | 0 ...20180125 Building a Linux-based HPC system on the Raspberry.md | 0 .../{ => 201803}/20180125 Keep Accurate Time on Linux with NTP.md | 0 ...20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md | 0 ...127 How to install KVM on CentOS 7 - RHEL 7 Headless Server.md | 0 .../20180129 Create your own personal Cloud- Install OwnCloud.md | 0 published/{ => 201803}/20180129 How programmers learn to code.md | 0 published/{ => 201803}/20180129 Parsing HTML with Python.md | 0 .../20180130 Use of du - df commands (with examples).md | 0 published/{ => 201803}/20180131 10 things I love about Vue.md | 0 ...ramming Computer Science Courses You Can Start in February.md | 0 .../{ => 201803}/20180131 An old DOS BBS in a Docker container.md | 0 .../20180131 How to access-view Python help when using vim.md | 0 .../{ => 201803}/20180201 How I coined the term open source.md | 0 ...o Check Your Linux PC for Meltdown or Spectre Vulnerability.md | 0 .../20180201 How to Run Your Own Public Time Server on Linux.md | 0 .../20180202 How do I edit files on the command line.md | 0 .../20180202 How to Manage PGP and SSH Keys with Seahorse.md | 0 .../20180203 3 Ways to Extend the Power of Kubernetes.md | 0 .../20180203 How to print filename with awk on Linux - Unix.md | 0 .../20180204 How to Check if Your Computer Uses UEFI or BIOS.md | 0 ...Get a Loadable Kernel Module for Runtime Integrity Checking.md | 0 .../20180204 Python Hello World and String Manipulation.md | 0 ...e Transfer Utility To Download Only The New Parts Of A File.md | 0 ...205 Block ads on your network with Raspberry Pi and pi-hole.md | 0 ...0205 New Linux User- Try These 8 Great Essential Linux Apps.md | 0 ...207 How To Easily Correct Misspelled Bash Commands In Linux.md | 0 .../{ => 201803}/20180208 Advanced Dnsmasq Tips and Tricks.md | 0 .../{ => 201803}/20180209 Gnome without chrome-gnome-shell.md | 0 ...9 How to setup and configure network bridge on Debian Linux.md | 0 .../{ => 201803}/20180213 Getting started with the RStudio IDE.md | 0 .../20180213 Linux ldd Command Explained with Examples.md | 0 .../20180217 The List Of Useful Bash Keyboard Shortcuts.md | 0 published/{ => 201803}/20180219 How Linux became my job.md | 0 .../20180221 Create a wiki on your Linux desktop with Zim.md | 0 ...180306 Most Useful Linux Commands You Can Run in Windows 10.md | 0 ...0180308 Test Your BASH Skills By Playing Command Line Games.md | 0 .../20180309 How to check your network connections on Linux.md | 0 ...ice - A Tool For Managing Systemd Units From Linux Terminal.md | 0 91 files changed, 0 insertions(+), 0 deletions(-) rename published/{ => 201803}/20090203 How the Kernel Manages Your Memory.md (100%) rename published/{ => 201803}/20090518 How to use yum-cron to automatically update RHEL-CentOS Linux.md (100%) rename published/{ => 201803}/20091215 How To Create sar Graphs With kSar To Identifying Linux Bottlenecks.md (100%) rename published/{ => 201803}/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md (100%) rename published/{ => 201803}/20140225 How To Safely Generate A Random Number - Quarrelsome.md (100%) rename published/{ => 201803}/20150615 Let-s Build A Simple Interpreter. Part 1..md (100%) rename published/{ => 201803}/20150708 Choosing a Linux Tracer (2015).md (100%) rename published/{ => 201803}/20160810 How does gdb work.md (100%) rename published/{ => 201803}/20170210 Evolutional Steps of Computer Systems.md (100%) rename published/{ => 201803}/20170310 9 Lightweight Linux Applications to Speed Up Your System.md (100%) rename published/{ => 201803}/20170921 How to answer questions in a helpful way.md (100%) rename published/{ => 201803}/20171002 Bash Bypass Alias Linux-Unix Command.md (100%) rename published/{ => 201803}/20171002 Reset Linux Desktop To Default Settings With A Single Command.md (100%) rename published/{ => 201803}/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md (100%) rename published/{ => 201803}/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md (100%) rename published/{ => 201803}/20171009 10 layers of Linux container security - Opensource.com.md (100%) rename published/{ => 201803}/20171016 Make -rm- Command To Move The Files To -Trash Can- Instead Of Removing Them Completely.md (100%) rename published/{ => 201803}/20171017 What Are the Hidden Files in my Linux Home Directory For.md (100%) rename published/{ => 201803}/20171102 What is huge pages in Linux.md (100%) rename published/{ => 201803}/20171108 How to Use GNOME Shell Extensions [Complete Guide].md (100%) rename published/{ => 201803}/20171109 Concurrent Servers- Part 4 - libuv.md (100%) rename published/{ => 201803}/20171110 How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora).md (100%) rename published/{ => 201803}/20171115 How to create better documentation with a kanban board.md (100%) rename published/{ => 201803}/20171116 Record and Share Terminal Session with Showterm.md (100%) rename published/{ => 201803}/20171117 Command line fun- Insult the user when typing wrong bash command.md (100%) rename published/{ => 201803}/20171121 How to organize your passwords using pass password manager.md (100%) rename published/{ => 201803}/20171201 Torrents - Everything You Need to Know.md (100%) rename published/{ => 201803}/20171203 3 Essential Questions to Ask at Your Next Tech Interview.md (100%) rename published/{ => 201803}/20171207 Concurrent Servers- Part 5 - Redis case study.md (100%) rename published/{ => 201803}/20171213 Creating a blog with pelican and Github pages.md (100%) rename published/{ => 201803}/20171214 6 open source home automation tools.md (100%) rename published/{ => 201803}/20171214 IPv6 Auto-Configuration in Linux.md (100%) rename published/{ => 201803}/20171218 What Are Containers and Why Should You Care-.md (100%) rename published/{ => 201803}/20171218 Whats CGManager.md (100%) rename published/{ => 201803}/20171221 Mail transfer agent (MTA) basics.md (100%) rename published/{ => 201803}/20180102 HTTP errors in WordPress.md (100%) rename published/{ => 201803}/20180102 How To Find (Top-10) Largest Files In Linux.md (100%) rename published/{ => 201803}/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md (100%) rename published/{ => 201803}/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md (100%) rename published/{ => 201803}/20180109 How to use syslog-ng to collect logs from remote Linux machines.md (100%) rename published/{ => 201803}/20180110 Best Linux Screenshot and Screencasting Tools.md (100%) rename published/{ => 201803}/20180110 How to install-update Intel microcode firmware on Linux.md (100%) rename published/{ => 201803}/20180111 How to install software applications on Linux.md (100%) rename published/{ => 201803}/20180111 The Fold Command Tutorial With Examples For Beginners.md (100%) rename published/{ => 201803}/20180116 A Versatile Free Software for Partition Imaging and Cloning.md (100%) rename published/{ => 201803}/20180116 Analyzing the Linux boot process.md (100%) rename published/{ => 201803}/20180116 SPARTA - Network Penetration Testing GUI Toolkit.md (100%) rename published/{ => 201803}/20180117 How To Manage Vim Plugins Using Vundle On Linux.md (100%) rename published/{ => 201803}/20180117 Linux tee Command Explained for Beginners (6 Examples).md (100%) rename published/{ => 201803}/20180119 5 of the Best Linux Dark Themes that Are Easy on the Eyes.md (100%) rename published/{ => 201803}/20180119 How to install Spotify application on Linux.md (100%) rename published/{ => 201803}/20180123 Never miss a Magazine-s article, build your own RSS notification system.md (100%) rename published/{ => 201803}/20180124 4 cool new projects to try in COPR for January.md (100%) rename published/{ => 201803}/20180125 Building a Linux-based HPC system on the Raspberry.md (100%) rename published/{ => 201803}/20180125 Keep Accurate Time on Linux with NTP.md (100%) rename published/{ => 201803}/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md (100%) rename published/{ => 201803}/20180127 How to install KVM on CentOS 7 - RHEL 7 Headless Server.md (100%) rename published/{ => 201803}/20180129 Create your own personal Cloud- Install OwnCloud.md (100%) rename published/{ => 201803}/20180129 How programmers learn to code.md (100%) rename published/{ => 201803}/20180129 Parsing HTML with Python.md (100%) rename published/{ => 201803}/20180130 Use of du - df commands (with examples).md (100%) rename published/{ => 201803}/20180131 10 things I love about Vue.md (100%) rename published/{ => 201803}/20180131 440 Free Online Programming Computer Science Courses You Can Start in February.md (100%) rename published/{ => 201803}/20180131 An old DOS BBS in a Docker container.md (100%) rename published/{ => 201803}/20180131 How to access-view Python help when using vim.md (100%) rename published/{ => 201803}/20180201 How I coined the term open source.md (100%) rename published/{ => 201803}/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md (100%) rename published/{ => 201803}/20180201 How to Run Your Own Public Time Server on Linux.md (100%) rename published/{ => 201803}/20180202 How do I edit files on the command line.md (100%) rename published/{ => 201803}/20180202 How to Manage PGP and SSH Keys with Seahorse.md (100%) rename published/{ => 201803}/20180203 3 Ways to Extend the Power of Kubernetes.md (100%) rename published/{ => 201803}/20180203 How to print filename with awk on Linux - Unix.md (100%) rename published/{ => 201803}/20180204 How to Check if Your Computer Uses UEFI or BIOS.md (100%) rename published/{ => 201803}/20180204 LKRG- Linux to Get a Loadable Kernel Module for Runtime Integrity Checking.md (100%) rename published/{ => 201803}/20180204 Python Hello World and String Manipulation.md (100%) rename published/{ => 201803}/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md (100%) rename published/{ => 201803}/20180205 Block ads on your network with Raspberry Pi and pi-hole.md (100%) rename published/{ => 201803}/20180205 New Linux User- Try These 8 Great Essential Linux Apps.md (100%) rename published/{ => 201803}/20180207 How To Easily Correct Misspelled Bash Commands In Linux.md (100%) rename published/{ => 201803}/20180208 Advanced Dnsmasq Tips and Tricks.md (100%) rename published/{ => 201803}/20180209 Gnome without chrome-gnome-shell.md (100%) rename published/{ => 201803}/20180209 How to setup and configure network bridge on Debian Linux.md (100%) rename published/{ => 201803}/20180213 Getting started with the RStudio IDE.md (100%) rename published/{ => 201803}/20180213 Linux ldd Command Explained with Examples.md (100%) rename published/{ => 201803}/20180217 The List Of Useful Bash Keyboard Shortcuts.md (100%) rename published/{ => 201803}/20180219 How Linux became my job.md (100%) rename published/{ => 201803}/20180221 Create a wiki on your Linux desktop with Zim.md (100%) rename published/{ => 201803}/20180306 Most Useful Linux Commands You Can Run in Windows 10.md (100%) rename published/{ => 201803}/20180308 Test Your BASH Skills By Playing Command Line Games.md (100%) rename published/{ => 201803}/20180309 How to check your network connections on Linux.md (100%) rename published/{ => 201803}/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md (100%) diff --git a/published/20090203 How the Kernel Manages Your Memory.md b/published/201803/20090203 How the Kernel Manages Your Memory.md similarity index 100% rename from published/20090203 How the Kernel Manages Your Memory.md rename to published/201803/20090203 How the Kernel Manages Your Memory.md diff --git a/published/20090518 How to use yum-cron to automatically update RHEL-CentOS Linux.md b/published/201803/20090518 How to use yum-cron to automatically update RHEL-CentOS Linux.md similarity index 100% rename from published/20090518 How to use yum-cron to automatically update RHEL-CentOS Linux.md rename to published/201803/20090518 How to use yum-cron to automatically update RHEL-CentOS Linux.md diff --git a/published/20091215 How To Create sar Graphs With kSar To Identifying Linux Bottlenecks.md b/published/201803/20091215 How To Create sar Graphs With kSar To Identifying Linux Bottlenecks.md similarity index 100% rename from published/20091215 How To Create sar Graphs With kSar To Identifying Linux Bottlenecks.md rename to published/201803/20091215 How To Create sar Graphs With kSar To Identifying Linux Bottlenecks.md diff --git a/published/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md b/published/201803/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md similarity index 100% rename from published/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md rename to published/201803/20120424 How To Set Readonly File Permissions On Linux - Unix Web Server DocumentRoot.md diff --git a/published/20140225 How To Safely Generate A Random Number - Quarrelsome.md b/published/201803/20140225 How To Safely Generate A Random Number - Quarrelsome.md similarity index 100% rename from published/20140225 How To Safely Generate A Random Number - Quarrelsome.md rename to published/201803/20140225 How To Safely Generate A Random Number - Quarrelsome.md diff --git a/published/20150615 Let-s Build A Simple Interpreter. Part 1..md b/published/201803/20150615 Let-s Build A Simple Interpreter. Part 1..md similarity index 100% rename from published/20150615 Let-s Build A Simple Interpreter. Part 1..md rename to published/201803/20150615 Let-s Build A Simple Interpreter. Part 1..md diff --git a/published/20150708 Choosing a Linux Tracer (2015).md b/published/201803/20150708 Choosing a Linux Tracer (2015).md similarity index 100% rename from published/20150708 Choosing a Linux Tracer (2015).md rename to published/201803/20150708 Choosing a Linux Tracer (2015).md diff --git a/published/20160810 How does gdb work.md b/published/201803/20160810 How does gdb work.md similarity index 100% rename from published/20160810 How does gdb work.md rename to published/201803/20160810 How does gdb work.md diff --git a/published/20170210 Evolutional Steps of Computer Systems.md b/published/201803/20170210 Evolutional Steps of Computer Systems.md similarity index 100% rename from published/20170210 Evolutional Steps of Computer Systems.md rename to published/201803/20170210 Evolutional Steps of Computer Systems.md diff --git a/published/20170310 9 Lightweight Linux Applications to Speed Up Your System.md b/published/201803/20170310 9 Lightweight Linux Applications to Speed Up Your System.md similarity index 100% rename from published/20170310 9 Lightweight Linux Applications to Speed Up Your System.md rename to published/201803/20170310 9 Lightweight Linux Applications to Speed Up Your System.md diff --git a/published/20170921 How to answer questions in a helpful way.md b/published/201803/20170921 How to answer questions in a helpful way.md similarity index 100% rename from published/20170921 How to answer questions in a helpful way.md rename to published/201803/20170921 How to answer questions in a helpful way.md diff --git a/published/20171002 Bash Bypass Alias Linux-Unix Command.md b/published/201803/20171002 Bash Bypass Alias Linux-Unix Command.md similarity index 100% rename from published/20171002 Bash Bypass Alias Linux-Unix Command.md rename to published/201803/20171002 Bash Bypass Alias Linux-Unix Command.md diff --git a/published/20171002 Reset Linux Desktop To Default Settings With A Single Command.md b/published/201803/20171002 Reset Linux Desktop To Default Settings With A Single Command.md similarity index 100% rename from published/20171002 Reset Linux Desktop To Default Settings With A Single Command.md rename to published/201803/20171002 Reset Linux Desktop To Default Settings With A Single Command.md diff --git a/published/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md b/published/201803/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md similarity index 100% rename from published/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md rename to published/201803/20171007 How to use GNU Stow to manage programs installed from source and dotfiles.md diff --git a/published/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md b/published/201803/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md similarity index 100% rename from published/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md rename to published/201803/20171009 10 Free Linux Productivity Apps You Haven-t Heard Of.md diff --git a/published/20171009 10 layers of Linux container security - Opensource.com.md b/published/201803/20171009 10 layers of Linux container security - Opensource.com.md similarity index 100% rename from published/20171009 10 layers of Linux container security - Opensource.com.md rename to published/201803/20171009 10 layers of Linux container security - Opensource.com.md diff --git a/published/20171016 Make -rm- Command To Move The Files To -Trash Can- Instead Of Removing Them Completely.md b/published/201803/20171016 Make -rm- Command To Move The Files To -Trash Can- Instead Of Removing Them Completely.md similarity index 100% rename from published/20171016 Make -rm- Command To Move The Files To -Trash Can- Instead Of Removing Them Completely.md rename to published/201803/20171016 Make -rm- Command To Move The Files To -Trash Can- Instead Of Removing Them Completely.md diff --git a/published/20171017 What Are the Hidden Files in my Linux Home Directory For.md b/published/201803/20171017 What Are the Hidden Files in my Linux Home Directory For.md similarity index 100% rename from published/20171017 What Are the Hidden Files in my Linux Home Directory For.md rename to published/201803/20171017 What Are the Hidden Files in my Linux Home Directory For.md diff --git a/published/20171102 What is huge pages in Linux.md b/published/201803/20171102 What is huge pages in Linux.md similarity index 100% rename from published/20171102 What is huge pages in Linux.md rename to published/201803/20171102 What is huge pages in Linux.md diff --git a/published/20171108 How to Use GNOME Shell Extensions [Complete Guide].md b/published/201803/20171108 How to Use GNOME Shell Extensions [Complete Guide].md similarity index 100% rename from published/20171108 How to Use GNOME Shell Extensions [Complete Guide].md rename to published/201803/20171108 How to Use GNOME Shell Extensions [Complete Guide].md diff --git a/published/20171109 Concurrent Servers- Part 4 - libuv.md b/published/201803/20171109 Concurrent Servers- Part 4 - libuv.md similarity index 100% rename from published/20171109 Concurrent Servers- Part 4 - libuv.md rename to published/201803/20171109 Concurrent Servers- Part 4 - libuv.md diff --git a/published/20171110 How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora).md b/published/201803/20171110 How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora).md similarity index 100% rename from published/20171110 How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora).md rename to published/201803/20171110 How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora).md diff --git a/published/20171115 How to create better documentation with a kanban board.md b/published/201803/20171115 How to create better documentation with a kanban board.md similarity index 100% rename from published/20171115 How to create better documentation with a kanban board.md rename to published/201803/20171115 How to create better documentation with a kanban board.md diff --git a/published/20171116 Record and Share Terminal Session with Showterm.md b/published/201803/20171116 Record and Share Terminal Session with Showterm.md similarity index 100% rename from published/20171116 Record and Share Terminal Session with Showterm.md rename to published/201803/20171116 Record and Share Terminal Session with Showterm.md diff --git a/published/20171117 Command line fun- Insult the user when typing wrong bash command.md b/published/201803/20171117 Command line fun- Insult the user when typing wrong bash command.md similarity index 100% rename from published/20171117 Command line fun- Insult the user when typing wrong bash command.md rename to published/201803/20171117 Command line fun- Insult the user when typing wrong bash command.md diff --git a/published/20171121 How to organize your passwords using pass password manager.md b/published/201803/20171121 How to organize your passwords using pass password manager.md similarity index 100% rename from published/20171121 How to organize your passwords using pass password manager.md rename to published/201803/20171121 How to organize your passwords using pass password manager.md diff --git a/published/20171201 Torrents - Everything You Need to Know.md b/published/201803/20171201 Torrents - Everything You Need to Know.md similarity index 100% rename from published/20171201 Torrents - Everything You Need to Know.md rename to published/201803/20171201 Torrents - Everything You Need to Know.md diff --git a/published/20171203 3 Essential Questions to Ask at Your Next Tech Interview.md b/published/201803/20171203 3 Essential Questions to Ask at Your Next Tech Interview.md similarity index 100% rename from published/20171203 3 Essential Questions to Ask at Your Next Tech Interview.md rename to published/201803/20171203 3 Essential Questions to Ask at Your Next Tech Interview.md diff --git a/published/20171207 Concurrent Servers- Part 5 - Redis case study.md b/published/201803/20171207 Concurrent Servers- Part 5 - Redis case study.md similarity index 100% rename from published/20171207 Concurrent Servers- Part 5 - Redis case study.md rename to published/201803/20171207 Concurrent Servers- Part 5 - Redis case study.md diff --git a/published/20171213 Creating a blog with pelican and Github pages.md b/published/201803/20171213 Creating a blog with pelican and Github pages.md similarity index 100% rename from published/20171213 Creating a blog with pelican and Github pages.md rename to published/201803/20171213 Creating a blog with pelican and Github pages.md diff --git a/published/20171214 6 open source home automation tools.md b/published/201803/20171214 6 open source home automation tools.md similarity index 100% rename from published/20171214 6 open source home automation tools.md rename to published/201803/20171214 6 open source home automation tools.md diff --git a/published/20171214 IPv6 Auto-Configuration in Linux.md b/published/201803/20171214 IPv6 Auto-Configuration in Linux.md similarity index 100% rename from published/20171214 IPv6 Auto-Configuration in Linux.md rename to published/201803/20171214 IPv6 Auto-Configuration in Linux.md diff --git a/published/20171218 What Are Containers and Why Should You Care-.md b/published/201803/20171218 What Are Containers and Why Should You Care-.md similarity index 100% rename from published/20171218 What Are Containers and Why Should You Care-.md rename to published/201803/20171218 What Are Containers and Why Should You Care-.md diff --git a/published/20171218 Whats CGManager.md b/published/201803/20171218 Whats CGManager.md similarity index 100% rename from published/20171218 Whats CGManager.md rename to published/201803/20171218 Whats CGManager.md diff --git a/published/20171221 Mail transfer agent (MTA) basics.md b/published/201803/20171221 Mail transfer agent (MTA) basics.md similarity index 100% rename from published/20171221 Mail transfer agent (MTA) basics.md rename to published/201803/20171221 Mail transfer agent (MTA) basics.md diff --git a/published/20180102 HTTP errors in WordPress.md b/published/201803/20180102 HTTP errors in WordPress.md similarity index 100% rename from published/20180102 HTTP errors in WordPress.md rename to published/201803/20180102 HTTP errors in WordPress.md diff --git a/published/20180102 How To Find (Top-10) Largest Files In Linux.md b/published/201803/20180102 How To Find (Top-10) Largest Files In Linux.md similarity index 100% rename from published/20180102 How To Find (Top-10) Largest Files In Linux.md rename to published/201803/20180102 How To Find (Top-10) Largest Files In Linux.md diff --git a/published/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md b/published/201803/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md similarity index 100% rename from published/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md rename to published/201803/20180104 Tlog - A Tool to Record - Play Terminal IO and Sessions.md diff --git a/published/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md b/published/201803/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md similarity index 100% rename from published/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md rename to published/201803/20180105 Ansible- the Automation Framework That Thinks Like a Sysadmin.md diff --git a/published/20180109 How to use syslog-ng to collect logs from remote Linux machines.md b/published/201803/20180109 How to use syslog-ng to collect logs from remote Linux machines.md similarity index 100% rename from published/20180109 How to use syslog-ng to collect logs from remote Linux machines.md rename to published/201803/20180109 How to use syslog-ng to collect logs from remote Linux machines.md diff --git a/published/20180110 Best Linux Screenshot and Screencasting Tools.md b/published/201803/20180110 Best Linux Screenshot and Screencasting Tools.md similarity index 100% rename from published/20180110 Best Linux Screenshot and Screencasting Tools.md rename to published/201803/20180110 Best Linux Screenshot and Screencasting Tools.md diff --git a/published/20180110 How to install-update Intel microcode firmware on Linux.md b/published/201803/20180110 How to install-update Intel microcode firmware on Linux.md similarity index 100% rename from published/20180110 How to install-update Intel microcode firmware on Linux.md rename to published/201803/20180110 How to install-update Intel microcode firmware on Linux.md diff --git a/published/20180111 How to install software applications on Linux.md b/published/201803/20180111 How to install software applications on Linux.md similarity index 100% rename from published/20180111 How to install software applications on Linux.md rename to published/201803/20180111 How to install software applications on Linux.md diff --git a/published/20180111 The Fold Command Tutorial With Examples For Beginners.md b/published/201803/20180111 The Fold Command Tutorial With Examples For Beginners.md similarity index 100% rename from published/20180111 The Fold Command Tutorial With Examples For Beginners.md rename to published/201803/20180111 The Fold Command Tutorial With Examples For Beginners.md diff --git a/published/20180116 A Versatile Free Software for Partition Imaging and Cloning.md b/published/201803/20180116 A Versatile Free Software for Partition Imaging and Cloning.md similarity index 100% rename from published/20180116 A Versatile Free Software for Partition Imaging and Cloning.md rename to published/201803/20180116 A Versatile Free Software for Partition Imaging and Cloning.md diff --git a/published/20180116 Analyzing the Linux boot process.md b/published/201803/20180116 Analyzing the Linux boot process.md similarity index 100% rename from published/20180116 Analyzing the Linux boot process.md rename to published/201803/20180116 Analyzing the Linux boot process.md diff --git a/published/20180116 SPARTA - Network Penetration Testing GUI Toolkit.md b/published/201803/20180116 SPARTA - Network Penetration Testing GUI Toolkit.md similarity index 100% rename from published/20180116 SPARTA - Network Penetration Testing GUI Toolkit.md rename to published/201803/20180116 SPARTA - Network Penetration Testing GUI Toolkit.md diff --git a/published/20180117 How To Manage Vim Plugins Using Vundle On Linux.md b/published/201803/20180117 How To Manage Vim Plugins Using Vundle On Linux.md similarity index 100% rename from published/20180117 How To Manage Vim Plugins Using Vundle On Linux.md rename to published/201803/20180117 How To Manage Vim Plugins Using Vundle On Linux.md diff --git a/published/20180117 Linux tee Command Explained for Beginners (6 Examples).md b/published/201803/20180117 Linux tee Command Explained for Beginners (6 Examples).md similarity index 100% rename from published/20180117 Linux tee Command Explained for Beginners (6 Examples).md rename to published/201803/20180117 Linux tee Command Explained for Beginners (6 Examples).md diff --git a/published/20180119 5 of the Best Linux Dark Themes that Are Easy on the Eyes.md b/published/201803/20180119 5 of the Best Linux Dark Themes that Are Easy on the Eyes.md similarity index 100% rename from published/20180119 5 of the Best Linux Dark Themes that Are Easy on the Eyes.md rename to published/201803/20180119 5 of the Best Linux Dark Themes that Are Easy on the Eyes.md diff --git a/published/20180119 How to install Spotify application on Linux.md b/published/201803/20180119 How to install Spotify application on Linux.md similarity index 100% rename from published/20180119 How to install Spotify application on Linux.md rename to published/201803/20180119 How to install Spotify application on Linux.md diff --git a/published/20180123 Never miss a Magazine-s article, build your own RSS notification system.md b/published/201803/20180123 Never miss a Magazine-s article, build your own RSS notification system.md similarity index 100% rename from published/20180123 Never miss a Magazine-s article, build your own RSS notification system.md rename to published/201803/20180123 Never miss a Magazine-s article, build your own RSS notification system.md diff --git a/published/20180124 4 cool new projects to try in COPR for January.md b/published/201803/20180124 4 cool new projects to try in COPR for January.md similarity index 100% rename from published/20180124 4 cool new projects to try in COPR for January.md rename to published/201803/20180124 4 cool new projects to try in COPR for January.md diff --git a/published/20180125 Building a Linux-based HPC system on the Raspberry.md b/published/201803/20180125 Building a Linux-based HPC system on the Raspberry.md similarity index 100% rename from published/20180125 Building a Linux-based HPC system on the Raspberry.md rename to published/201803/20180125 Building a Linux-based HPC system on the Raspberry.md diff --git a/published/20180125 Keep Accurate Time on Linux with NTP.md b/published/201803/20180125 Keep Accurate Time on Linux with NTP.md similarity index 100% rename from published/20180125 Keep Accurate Time on Linux with NTP.md rename to published/201803/20180125 Keep Accurate Time on Linux with NTP.md diff --git a/published/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md b/published/201803/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md similarity index 100% rename from published/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md rename to published/201803/20180126 How to Make a Minecraft Server - ThisHosting.Rocks.md diff --git a/published/20180127 How to install KVM on CentOS 7 - RHEL 7 Headless Server.md b/published/201803/20180127 How to install KVM on CentOS 7 - RHEL 7 Headless Server.md similarity index 100% rename from published/20180127 How to install KVM on CentOS 7 - RHEL 7 Headless Server.md rename to published/201803/20180127 How to install KVM on CentOS 7 - RHEL 7 Headless Server.md diff --git a/published/20180129 Create your own personal Cloud- Install OwnCloud.md b/published/201803/20180129 Create your own personal Cloud- Install OwnCloud.md similarity index 100% rename from published/20180129 Create your own personal Cloud- Install OwnCloud.md rename to published/201803/20180129 Create your own personal Cloud- Install OwnCloud.md diff --git a/published/20180129 How programmers learn to code.md b/published/201803/20180129 How programmers learn to code.md similarity index 100% rename from published/20180129 How programmers learn to code.md rename to published/201803/20180129 How programmers learn to code.md diff --git a/published/20180129 Parsing HTML with Python.md b/published/201803/20180129 Parsing HTML with Python.md similarity index 100% rename from published/20180129 Parsing HTML with Python.md rename to published/201803/20180129 Parsing HTML with Python.md diff --git a/published/20180130 Use of du - df commands (with examples).md b/published/201803/20180130 Use of du - df commands (with examples).md similarity index 100% rename from published/20180130 Use of du - df commands (with examples).md rename to published/201803/20180130 Use of du - df commands (with examples).md diff --git a/published/20180131 10 things I love about Vue.md b/published/201803/20180131 10 things I love about Vue.md similarity index 100% rename from published/20180131 10 things I love about Vue.md rename to published/201803/20180131 10 things I love about Vue.md diff --git a/published/20180131 440 Free Online Programming Computer Science Courses You Can Start in February.md b/published/201803/20180131 440 Free Online Programming Computer Science Courses You Can Start in February.md similarity index 100% rename from published/20180131 440 Free Online Programming Computer Science Courses You Can Start in February.md rename to published/201803/20180131 440 Free Online Programming Computer Science Courses You Can Start in February.md diff --git a/published/20180131 An old DOS BBS in a Docker container.md b/published/201803/20180131 An old DOS BBS in a Docker container.md similarity index 100% rename from published/20180131 An old DOS BBS in a Docker container.md rename to published/201803/20180131 An old DOS BBS in a Docker container.md diff --git a/published/20180131 How to access-view Python help when using vim.md b/published/201803/20180131 How to access-view Python help when using vim.md similarity index 100% rename from published/20180131 How to access-view Python help when using vim.md rename to published/201803/20180131 How to access-view Python help when using vim.md diff --git a/published/20180201 How I coined the term open source.md b/published/201803/20180201 How I coined the term open source.md similarity index 100% rename from published/20180201 How I coined the term open source.md rename to published/201803/20180201 How I coined the term open source.md diff --git a/published/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md b/published/201803/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md similarity index 100% rename from published/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md rename to published/201803/20180201 How to Check Your Linux PC for Meltdown or Spectre Vulnerability.md diff --git a/published/20180201 How to Run Your Own Public Time Server on Linux.md b/published/201803/20180201 How to Run Your Own Public Time Server on Linux.md similarity index 100% rename from published/20180201 How to Run Your Own Public Time Server on Linux.md rename to published/201803/20180201 How to Run Your Own Public Time Server on Linux.md diff --git a/published/20180202 How do I edit files on the command line.md b/published/201803/20180202 How do I edit files on the command line.md similarity index 100% rename from published/20180202 How do I edit files on the command line.md rename to published/201803/20180202 How do I edit files on the command line.md diff --git a/published/20180202 How to Manage PGP and SSH Keys with Seahorse.md b/published/201803/20180202 How to Manage PGP and SSH Keys with Seahorse.md similarity index 100% rename from published/20180202 How to Manage PGP and SSH Keys with Seahorse.md rename to published/201803/20180202 How to Manage PGP and SSH Keys with Seahorse.md diff --git a/published/20180203 3 Ways to Extend the Power of Kubernetes.md b/published/201803/20180203 3 Ways to Extend the Power of Kubernetes.md similarity index 100% rename from published/20180203 3 Ways to Extend the Power of Kubernetes.md rename to published/201803/20180203 3 Ways to Extend the Power of Kubernetes.md diff --git a/published/20180203 How to print filename with awk on Linux - Unix.md b/published/201803/20180203 How to print filename with awk on Linux - Unix.md similarity index 100% rename from published/20180203 How to print filename with awk on Linux - Unix.md rename to published/201803/20180203 How to print filename with awk on Linux - Unix.md diff --git a/published/20180204 How to Check if Your Computer Uses UEFI or BIOS.md b/published/201803/20180204 How to Check if Your Computer Uses UEFI or BIOS.md similarity index 100% rename from published/20180204 How to Check if Your Computer Uses UEFI or BIOS.md rename to published/201803/20180204 How to Check if Your Computer Uses UEFI or BIOS.md diff --git a/published/20180204 LKRG- Linux to Get a Loadable Kernel Module for Runtime Integrity Checking.md b/published/201803/20180204 LKRG- Linux to Get a Loadable Kernel Module for Runtime Integrity Checking.md similarity index 100% rename from published/20180204 LKRG- Linux to Get a Loadable Kernel Module for Runtime Integrity Checking.md rename to published/201803/20180204 LKRG- Linux to Get a Loadable Kernel Module for Runtime Integrity Checking.md diff --git a/published/20180204 Python Hello World and String Manipulation.md b/published/201803/20180204 Python Hello World and String Manipulation.md similarity index 100% rename from published/20180204 Python Hello World and String Manipulation.md rename to published/201803/20180204 Python Hello World and String Manipulation.md diff --git a/published/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md b/published/201803/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md similarity index 100% rename from published/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md rename to published/201803/20180205 A File Transfer Utility To Download Only The New Parts Of A File.md diff --git a/published/20180205 Block ads on your network with Raspberry Pi and pi-hole.md b/published/201803/20180205 Block ads on your network with Raspberry Pi and pi-hole.md similarity index 100% rename from published/20180205 Block ads on your network with Raspberry Pi and pi-hole.md rename to published/201803/20180205 Block ads on your network with Raspberry Pi and pi-hole.md diff --git a/published/20180205 New Linux User- Try These 8 Great Essential Linux Apps.md b/published/201803/20180205 New Linux User- Try These 8 Great Essential Linux Apps.md similarity index 100% rename from published/20180205 New Linux User- Try These 8 Great Essential Linux Apps.md rename to published/201803/20180205 New Linux User- Try These 8 Great Essential Linux Apps.md diff --git a/published/20180207 How To Easily Correct Misspelled Bash Commands In Linux.md b/published/201803/20180207 How To Easily Correct Misspelled Bash Commands In Linux.md similarity index 100% rename from published/20180207 How To Easily Correct Misspelled Bash Commands In Linux.md rename to published/201803/20180207 How To Easily Correct Misspelled Bash Commands In Linux.md diff --git a/published/20180208 Advanced Dnsmasq Tips and Tricks.md b/published/201803/20180208 Advanced Dnsmasq Tips and Tricks.md similarity index 100% rename from published/20180208 Advanced Dnsmasq Tips and Tricks.md rename to published/201803/20180208 Advanced Dnsmasq Tips and Tricks.md diff --git a/published/20180209 Gnome without chrome-gnome-shell.md b/published/201803/20180209 Gnome without chrome-gnome-shell.md similarity index 100% rename from published/20180209 Gnome without chrome-gnome-shell.md rename to published/201803/20180209 Gnome without chrome-gnome-shell.md diff --git a/published/20180209 How to setup and configure network bridge on Debian Linux.md b/published/201803/20180209 How to setup and configure network bridge on Debian Linux.md similarity index 100% rename from published/20180209 How to setup and configure network bridge on Debian Linux.md rename to published/201803/20180209 How to setup and configure network bridge on Debian Linux.md diff --git a/published/20180213 Getting started with the RStudio IDE.md b/published/201803/20180213 Getting started with the RStudio IDE.md similarity index 100% rename from published/20180213 Getting started with the RStudio IDE.md rename to published/201803/20180213 Getting started with the RStudio IDE.md diff --git a/published/20180213 Linux ldd Command Explained with Examples.md b/published/201803/20180213 Linux ldd Command Explained with Examples.md similarity index 100% rename from published/20180213 Linux ldd Command Explained with Examples.md rename to published/201803/20180213 Linux ldd Command Explained with Examples.md diff --git a/published/20180217 The List Of Useful Bash Keyboard Shortcuts.md b/published/201803/20180217 The List Of Useful Bash Keyboard Shortcuts.md similarity index 100% rename from published/20180217 The List Of Useful Bash Keyboard Shortcuts.md rename to published/201803/20180217 The List Of Useful Bash Keyboard Shortcuts.md diff --git a/published/20180219 How Linux became my job.md b/published/201803/20180219 How Linux became my job.md similarity index 100% rename from published/20180219 How Linux became my job.md rename to published/201803/20180219 How Linux became my job.md diff --git a/published/20180221 Create a wiki on your Linux desktop with Zim.md b/published/201803/20180221 Create a wiki on your Linux desktop with Zim.md similarity index 100% rename from published/20180221 Create a wiki on your Linux desktop with Zim.md rename to published/201803/20180221 Create a wiki on your Linux desktop with Zim.md diff --git a/published/20180306 Most Useful Linux Commands You Can Run in Windows 10.md b/published/201803/20180306 Most Useful Linux Commands You Can Run in Windows 10.md similarity index 100% rename from published/20180306 Most Useful Linux Commands You Can Run in Windows 10.md rename to published/201803/20180306 Most Useful Linux Commands You Can Run in Windows 10.md diff --git a/published/20180308 Test Your BASH Skills By Playing Command Line Games.md b/published/201803/20180308 Test Your BASH Skills By Playing Command Line Games.md similarity index 100% rename from published/20180308 Test Your BASH Skills By Playing Command Line Games.md rename to published/201803/20180308 Test Your BASH Skills By Playing Command Line Games.md diff --git a/published/20180309 How to check your network connections on Linux.md b/published/201803/20180309 How to check your network connections on Linux.md similarity index 100% rename from published/20180309 How to check your network connections on Linux.md rename to published/201803/20180309 How to check your network connections on Linux.md diff --git a/published/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md b/published/201803/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md similarity index 100% rename from published/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md rename to published/201803/20180322 chkservice - A Tool For Managing Systemd Units From Linux Terminal.md From 4ee56d7c07e8756bfbc6089b33bac9c248a4ee1f Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 1 Apr 2018 09:24:47 +0800 Subject: [PATCH 0228/1057] PRF:20171228 Testing Ansible Playbooks With Vagrant.md @lujun9972 --- ... Testing Ansible Playbooks With Vagrant.md | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/translated/tech/20171228 Testing Ansible Playbooks With Vagrant.md b/translated/tech/20171228 Testing Ansible Playbooks With Vagrant.md index 373e7aa41b..e05aa98499 100644 --- a/translated/tech/20171228 Testing Ansible Playbooks With Vagrant.md +++ b/translated/tech/20171228 Testing Ansible Playbooks With Vagrant.md @@ -1,33 +1,34 @@ -使用 Vagrant 测试 Ansible Playbooks +使用 Vagrant 测试 Ansible 剧本 ====== -我使用 Ansible 来自动部署站点 ([LinuxJobs.fr][1],[Journal du hacker][2]) 与应用 ([Feed2toot][3],[Feed2tweet][4])。在本文中将会讲述我是如何配置以实现在本地测试 ansbile playbook 的。 -![ansible](https://carlchenet.com/wp-content/uploads/2017/12/ansible-300x300.png) +我使用 Ansible 来自动部署站点 ([LinuxJobs.fr][1]、[Journal du hacker][2]) 与应用 ([Feed2toot][3]、[Feed2tweet][4])。在本文中将会讲述我是如何配置以实现在本地测试 ansbile 剧本playbook的。 -### 为何要测试 Ansible Playbooks +![ansible](https://carlchenet.com/wp-content/uploads/2017/12/ansible-300x300.png) -我需要一种简单而迅速的方法来在我的本地笔记本上测试 Ansible Playbook 的部署情况,尤其在刚开始写一个新 Playbook 的时候,因为直接部署到生产服务器上不仅特别慢而且风险还很大。 +### 为何要测试 Ansible 剧本 -我使用 [Vagrant][6] 来将 Playbook 部署到 [VirtualBox][5] 虚拟机上而不是部署到远程服务器。这使得修改的结果很快就能看到,以实现快速迭代和修正。 +我需要一种简单而迅速的方法来在我的本地笔记本上测试 Ansible 剧本的部署情况,尤其在刚开始写一个新剧本的时候,因为直接部署到生产服务器上不仅特别慢而且风险还很大。 -责任声明:我并不是专业程序员。我只是描述一种我觉得适合我的,即简单又有效的用来测试 Ansible Playbook 的解决方案,但可能还有其他更好的方法。 +我使用 [Vagrant][6] 来将剧本部署到 [VirtualBox][5] 虚拟机上而不是部署到远程服务器。这使得修改的结果很快就能看到,以实现快速迭代和修正。 + +责任声明:我并不是专业程序员。我只是描述一种我觉得适合我的,即简单又有效的用来测试 Ansible 剧本的解决方案,但可能还有其他更好的方法。 ### 我的流程 - 1。开始写新的 Ansible Playbook - 2。启动一台新的虚拟机 (VM) 并使用 Vagrantt 将 playbook 部署到这台虚拟机中 - 3。修复 playbook 或应用中的错误 - 4。重新运行虚拟机中的部署 - 5。如果还有问题,回到第三步。否则销毁这台虚拟机,重新创建新虚拟机然后最后测试一次全新部署 - 6。若没有问题出现,则给你的 Ansible Playbook 版本加上标签,可以在生产环境上发布产品了 + 1. 开始写新的 Ansible 剧本 + 2. 启动一台新的虚拟机(VM)并使用 Vagrantt 将剧本部署到这台虚拟机中 + 3. 修复剧本或应用中的错误 + 4. 重新在虚拟机上部署 + 5. 如果还有问题,回到第三步。否则销毁这台虚拟机,重新创建新虚拟机然后测试一次全新部署 + 6. 若没有问题出现,则标记你的 Ansible 剧本版本,可以在生产环境上发布产品了 ### 你需要哪些东西 -首先,你需要 Virtualbox。若你使用的是 [Debian][7] 发行版,[这个链接 ][8] 描述了安装的方法,可以从 Debian 仓库中安装,也可以通过官网来安装。 +首先,你需要 Virtualbox。若你使用的是 [Debian][7] 发行版,[这个链接][8] 描述了安装的方法,可以从 Debian 仓库中安装,也可以通过官网来安装。 [![][9]][5] -其次,你需要 Vagrant。为什么要 Vagrant?因为它是介于开发环境和虚拟机之间的中间件,它允许通过编程的方式重复操作,而且可以很方便地将你的发布与虚拟机连接起来。通过下面命令可以安装 Vagrant: +其次,你需要 Vagrant。为什么要 Vagrant?因为它是介于开发环境和虚拟机之间的中间件,它允许通过编程的方式重复操作,而且可以很方便地将你的部署环境与虚拟机连接起来。通过下面命令可以安装 Vagrant: ``` # apt install vagrant ``` @@ -36,71 +37,72 @@ ### 设置 Vagrant -Vagrant 的一切信息都存放在 Vagrantfile 文件中。这是我的内容: +Vagrant 的一切信息都存放在 `Vagrantfile` 文件中。这是我的内容: + ``` Vagrant.require_version ">= 2.0.0" Vagrant.configure(1) do |config| config.vm.box = "debian/stretch64" - config.vm.provision "shell",inline:"apt install --yes git python3-pip" + config.vm.provision "shell", inline: "apt install --yes git python3-pip" config.vm.provision "ansible" do |ansible| - ansible.verbose = "v" - ansible.playbook = "site.yml" - ansible.vault_password_file = "vault_password_file" + ansible.verbose = "v" + ansible.playbook = "site.yml" + ansible.vault_password_file = "vault_password_file" end end - ``` - 1。第一行指明了需要用哪个版本的 Vagrant 来执行 Vagrantfile。 - 2。文件中的第一个循环,你要定义为多少台虚拟机执行下面的操作(这里为 1)。 - 3。第三行指定了用来创建虚拟机的官方 Vagrant 镜像。 - 4。第四行非常重要:有一些需要的应用没有安装到虚拟机中。这里我们用 apt 安装 git 和 python3-pip。 - 5。下一行指明了 Ansible 配置开始的地方 - 6。第六行说明我们想要 Ansible 输出详细信息。 - 7。第 7 行,我们定义了 Ansible Playbook 的入口。 - 8。第八行,若你使用 Ansible Vault 加密了一些文件,在这里指定这些文件。 + 1. 第一行指明了需要用哪个版本的 Vagrant 来执行 `Vagrantfile`。 + 2. 文件中的第一个循环,你要定义为多少台虚拟机执行下面的操作(这里为 `1`)。 + 3. 第三行指定了用来创建虚拟机的官方 Vagrant 镜像。 + 4. 第四行非常重要:有一些需要的应用没有安装到虚拟机中。这里我们用 `apt` 安装 `git` 和 `python3-pip`。 + 5. 下一行指明了 Ansible 配置开始的地方 + 6. 第六行说明我们想要 Ansible 输出详细信息。 + 7. 第七行,我们定义了 Ansible 剧本的入口。 + 8. 第八行,若你使用 Ansible Vault 加密了一些文件,在这里指定这些文件。 当 Vagrant 启动 Ansible 时,类似于执行这样的操作: + ``` $  ansible-playbook --inventory-file=/home/me/ansible/test-ansible-playbook/.vagrant/provisioners/ansible/inventory -v --vault-password-file=vault_password_file site.yml ``` ### 执行 Vagrant -写好 Vagrantfile 后,就可以启动虚拟机了。只需要简单地运行下面命令: +写好 `Vagrantfile` 后,就可以启动虚拟机了。只需要简单地运行下面命令: + ``` $ vagrant up ``` -这个操作会很慢,因为它会启动虚拟机,安装 Vagrantfile 中定义的附加软件,最用应用你的 Playbook。你不要太频繁地使用这条命令。 +这个操作会很慢,因为它会启动虚拟机,安装 `Vagrantfile` 中定义的附加软件,最终应用你的剧本。你不要太频繁地使用这条命令。 Ok,现在你可以快速迭代了。在做出修改后,可以通过下面命令来快速测试你的部署: + ``` $ vagrant provision ``` -Ansible Playbook 搞定后,通常要经过多次迭代(至少我是这样的),你应该一个全新安装的虚拟机上再测试一次,因为你在迭代的过程中可能会对虚拟机造成修改从而引发意料之外的结果。 +Ansible 剧本搞定后,通常要经过多次迭代(至少我是这样的),你应该一个全新安装的虚拟机上再测试一次,因为你在迭代的过程中可能会对虚拟机造成修改从而引发意料之外的结果。 使用下面命令进行全新测试: + ``` $ vagrant destroy && vagrant up ``` -这又是一个很慢的操作。你应该十分肯定 Ansible Playbook 差不多完成了的情况下才这样做。在全新虚拟机上测试部署之后,就可以发布到生产上去了。至少准备要充分不少了吧:p +这又是一个很慢的操作。你应该在 Ansible 剧本差不多完成了的情况下才这样做。在全新虚拟机上测试部署之后,就可以发布到生产上去了。至少准备要充分不少了吧 :p ### 有什么改进意见?请告诉我 -本文中描述的配置对我自己来说很有用。我可以做到快速迭代(尤其在编写新的 playbook 的时候),除了 playbook 外,对我的最新应用,尚未准备好部署到生产环境上的应用也很有帮助。直接部署到远程服务器上对我的生产服务来说不仅缓慢而且很危险。 - -我本也可以使用持续集成 (CI) 服务器,但这不是本文的主题。如前所述,本文的目的是在编写新的 Ansible Playbook 之初尽可能的快速迭代。 - -在编写 Ansible Playbook 之初就提交,推送到你的 Git 仓库然后等待 CI 测试的执行结果,这有点太过了,因为这个时期的错误总是很多,你需要一一个地去调试。我觉得 CI 在编写 Ansible Playbook 的后期会有用的多,尤其当多个人同时对它进行修改而且你有一整套代码质量规范要遵守的时候。不过,这只是我自己的观念,还有带讨论,再重申一遍,我不是个专业的程序员。 - -如果你有更好的测试 Ansible Playbook 的方案或者能对这里描述的方法做出一些改进,请告诉我。你可以把它写到留言框中或者通过社交网络联系我,我会很高兴的。 +本文中描述的配置对我自己来说很有用。我可以做到快速迭代(尤其在编写新的剧本的时候),除了剧本外,对我的最新应用,尚未准备好部署到生产环境上的应用也很有帮助。直接部署到远程服务器上对我的生产服务来说不仅缓慢而且很危险。 +我本也可以使用持续集成(CI)服务器,但这不是本文的主题。如前所述,本文的目的是在编写新的 Ansible 剧本之初尽可能的快速迭代。 +在编写 Ansible 剧本之初就提交,推送到你的 Git 仓库然后等待 CI 测试的执行结果,这有点太过了,因为这个时期的错误总是很多,你需要一一个地去调试。我觉得 CI 在编写 Ansible 剧本的后期会有用的多,尤其当多个人同时对它进行修改而且你有一整套代码质量规范要遵守的时候。不过,这只是我自己的观念,还有待讨论,再重申一遍,我不是个专业的程序员。 +如果你有更好的测试 Ansible 剧本的方案或者能对这里描述的方法做出一些改进,请告诉我。你可以把它写到留言框中或者通过社交网络联系我,我会很高兴的。 -------------------------------------------------------------------------------- @@ -108,7 +110,7 @@ via: https://carlchenet.com/testing-ansible-playbooks-with-vagrant/ 作者:[Carl Chenet][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 6ffcf0906e70afb769579653bc9bfece854b496b Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 1 Apr 2018 09:25:11 +0800 Subject: [PATCH 0229/1057] PUB:20171228 Testing Ansible Playbooks With Vagrant.md @lujun9972 https://linux.cn/article-9502-1.html --- .../20171228 Testing Ansible Playbooks With Vagrant.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171228 Testing Ansible Playbooks With Vagrant.md (100%) diff --git a/translated/tech/20171228 Testing Ansible Playbooks With Vagrant.md b/published/20171228 Testing Ansible Playbooks With Vagrant.md similarity index 100% rename from translated/tech/20171228 Testing Ansible Playbooks With Vagrant.md rename to published/20171228 Testing Ansible Playbooks With Vagrant.md From edf8a57186347e579e8739298bbae3ede5c83e28 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 1 Apr 2018 12:39:40 +0800 Subject: [PATCH 0230/1057] PRF:20171113 The big break in computer languages.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @name1e5s 用心了,翻译的棒极了! --- ...113 The big break in computer languages.md | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/translated/tech/20171113 The big break in computer languages.md b/translated/tech/20171113 The big break in computer languages.md index c8d2f9a07a..720100a600 100644 --- a/translated/tech/20171113 The big break in computer languages.md +++ b/translated/tech/20171113 The big break in computer languages.md @@ -1,91 +1,90 @@ 计算机语言的巨变 ==================================================== +我的上一篇博文《[与 C 语言长别离][3]》引来了我的老朋友,一位 C++ 专家的评论。在评论里,他推荐把 C++ 作为 C 的替代品。这是不可能发生的,如果 C++ 代替 C 是趋势的话,那么 Go 和 Rust 也就不会出现了。 -我的上一篇博文([与 C 的长久别离][3])引来了我的老朋友,一位 C++ 专家的评论。在评论里,他推荐把 C++ 作为 C 的替代品。这是不可能发生的,如果 C ++ 代替 C 是趋势的话,那么 Go 和 Rust 也就不会出现了。 +![](https://static1.squarespace.com/static/586bd48d03596e5605450cee/t/5880d61b29687f4fd5a5712d/1484838431523/) -但是我不能只给我的读者一个空洞的看法。所以,在这篇文章中,我来讲述一下为什么我不再碰 C++ 的故事。这是关于计算机语言设计经济学专题文章的起始点。这篇文章会讨论为什么一些真心不好的决策会被做出来,然后进入语言的基础设计之中,以及我们该如何修正这些问题。 +但是我不能只给我的读者一个光秃秃的看法(LCTT 译注:此处是双关语)。所以,在这篇文章中,我来讲述一下为什么我不再碰 C++ 的故事。这是关于计算机语言设计经济学专题文章的起始点。这篇文章会讨论为什么一些真心不好的决策会被做出来,然后进入语言的基础设计之中,以及我们该如何修正这些问题。 -在这篇文章中,我会一点一点的指出人们(当然也包括我)自从 20 世纪 80 年代以来就存在的关于未来的编程语言的预见失误。直到最近我们才找到了证明我们错了的证据。 +在这篇文章中,我会一点一点的指出人们(当然也包括我)自从 20 世纪 80 年代以来就存在的关于未来的编程语言的预见失误。直到最近,我们才找到了证明我们错了的证据。 -我第一次学习 C++ 是因为我需要使用 GNU eqn 输出 MathXML,而 eqn 是使用 C++ 写的。那个项目不错。在那之后,21世纪初,我在韦诺之战那边当了多年的高级开发工程师,并且与 C++ 相处甚欢。 +我记得我第一次学习 C++ 是因为我需要使用 GNU eqn 输出 MathXML,而 eqn 是使用 C++ 写的。那个项目不错。在那之后,21 世纪初,我在韦诺之战Battle For Wesnoth那边当了多年的资深开发人生,并且与 C++ 相处甚欢。 -在那之后啊,有一天我们发现一个不小心被我们授予特权的人已经把游戏的 AI 核心搞崩掉了。显然,在团队中只有我是不那么害怕查看代码的。最终,我把一切都恢复正常了 —— 我折腾了整整两周。再那之后,我就发誓我再也不靠近 C++ 了。 +在那之后啊,有一天我们发现一个不小心被我们授予提交权限的人已经把游戏的 AI 核心搞崩掉了。显然,在团队中只有我是不那么害怕查看代码的。最终,我把一切都恢复正常了 —— 我折腾了整整两周。再那之后,我就发誓我再也不靠近 C++ 了。 -在那次经历过后,我发现这个语言的问题就是它在尝试使得本来就复杂的东西更加复杂,来属兔补上因为基础概念的缺失造成的漏洞。对于裸指针,他说“别这样做”,这没有问题。对于小规模的个人项目(比如我的魔改版 eqn),遵守这些规定没有问题。 +在那次经历过后,我发现这个语言的问题就是它在尝试使得本来就复杂的东西更加复杂,来粗陋补上因为基础概念的缺失造成的漏洞。对于裸指针这样东西,它说“别这样做”,这没有问题。对于小规模的个人项目(比如我的魔改版 eqn),遵守这些规定没有问题。 -但是对于大型项目,或者开发者水平不同的多人项目(这是我经常要处理的情况)就不能这样。随着时间的推移以及代码行数的增加,有的人就会捅篓子。当别人指出有 BUG 时,因为诸如 STL 之类的东西给你增加了一层复杂度,你处理这种问题所需要的精力就比处理同等规模的 C 语言的问题就要难上很多。我在韦诺之战时,我就知道了,处理这种问题真的相当棘手。 +但是对于大型项目,或者开发者水平参差不齐的多人项目(这是我经常要处理的情况)就不能这样。随着时间的推移以及代码行数的增加,有的人就会捅篓子。当别人指出有 BUG 时,因为诸如 STL 之类的东西给你增加了一层复杂度,你处理这种问题所需要的精力就比处理同等规模的 C 语言的问题就要难上很多。我在韦诺之战时,我就知道了,处理这种问题真的相当棘手。 -我给 Stell Heller(我的老朋友 ,C++ 的支持者)写代码时不会发生的问题在我与非 Heller 们合作时就被放大了,我和他们合作的结局可能就是我得给他们擦屁股。所以我就不用 C++ ,我觉得不值得为了其花时间。 C 是有缺陷的,但是 C 有 C++ 没有的优点 —— 如果你能在脑内模拟出硬件,那么你就能很简单的看出程序是怎么运行的。如果 C++ 真的能解决 C 的问题(也就是说,C++ 是类型安全以及内存安全的),那么失去其透明性也是值得的。但是,C++ 并没有这样。 +我给 Stell Heller(我的老朋友,C++ 的支持者)写代码时不会发生的问题在我与非 Heller 们合作时就被放大了,我和他们合作的结局可能就是我得给他们擦屁股。所以我就不用 C++ ,我觉得不值得为了其花时间。 C 是有缺陷的,但是 C 有 C++ 没有的优点 —— 如果你能在脑内模拟出硬件,那么你就能很简单的看出程序是怎么运行的。如果 C++ 真的能解决 C 的问题(也就是说,C++ 是类型安全以及内存安全的),那么失去其透明性也是值得的。但是,C++ 并没有这样。 -我们判断 C++ 做的还不够的方法之一是想象一个 C++ 已经搞得不错的世界。在那个世界里,老旧的 C 语言项目会被迁移到 C++ 上来。主流的操作系统内核会是 C++ 写就,而现存的内核实现,比如 Linux 会渐渐升级成那样。在现实世界,这些都没有发生。C++ 不仅没有打消语言设计者设想像 D,Go 以及 Rust 那样的新语言的想法,他甚至都没有取代他的前辈。不改变 C++ 的核心思想,他就没有未来,也因此,C++ 的抽象泄露也不会消失。 +我们判断 C++ 做的还不够的方法之一是想象一个 C++ 已经搞得不错的世界。在那个世界里,老旧的 C 语言项目会被迁移到 C++ 上来。主流的操作系统内核会是 C++ 写就,而现存的内核实现,比如 Linux 会渐渐升级成那样。在现实世界,这些都没有发生。C++ 不仅没有打消语言设计者设想像 D、Go 以及 Rust 那样的新语言的想法,它甚至都没有取代它的前辈。不改变 C++ 的核心思想,它就没有未来,也因此,C++ 的抽象泄露leaky abstraction也不会消失。 -既然我刚刚提到了 D 语言,那我就说说为什么我不把 D 视为一个够格的 C 语言竞争者的原因吧.尽管他比 Rust 早出现了八年 -- 和 Rust 相比是九年 -- Walter Bright 早在那时就有了构建那样一个语言的想法.但是在 2001 年,以 Python 和 Perl 为首的语言的出现已经确定了,专有语言能和开源语言抗衡的时代已经过去.官方 D 语言库/运行时和 Tangle 的无谓纷争也打击了其发展.它从未修正这些错误。 +既然我刚刚提到了 D 语言,那我就说说为什么我不把 D 视为一个够格的 C 语言竞争者的原因吧。尽管它比 Rust 早出现了八年(和 Rust 相比是九年)Walter Bright 早在那时就有了构建那样一个语言的想法。但是在 2001 年,以 Python 和 Perl 为首的语言的出现已经确定了,专有语言能和开源语言抗衡的时代已经过去。官方 D 语言库/运行时和 Tangle 的无谓纷争也打击了其发展。它从未修正这些错误。 -然后就是 Go 语言(我本来想说“以及 Rust”。但是如前文所述,我认为 Rust 还需要几年时间才能有竞争力)。它 _的确是_ 类型安全以及内存安全的(好吧,是在大多数时候是这样,但是如果你要使用接口的话就不是如此了,但是自找麻烦可不是正常人的做法)。我的一位好友,Mark Atwood,曾指出过 Go 语言是脾气暴躁的老头子因为愤怒创造出的语言,主要是 _C 语言的作者之一_(Ken Thompson) 因为 C++ 的混乱臃肿造成的愤怒,我深以为然。 +然后就是 Go 语言(我本来想说“以及 Rust”。但是如前文所述,我认为 Rust 还需要几年时间才能有竞争力)。它_的确是_类型安全以及内存安全的(好吧,是在大多数时候是这样,但是如果你要使用接口的话就不是如此了,但是自找麻烦可不是正常人的做法)。我的一位好友,Mark Atwood,曾指出过 Go 语言是脾气暴躁的老头子因为愤怒而创造出的语言,主要是 _C 语言的作者之一_(Ken Thompson) 因为 C++ 的混乱臃肿造成的愤怒,我深以为然。 -我能理解 Ken 恼火的原因。这几十年来我就一直认为 C++ 搞错了需要解决的问题。C 语言的后继者有两条路可走。其一就是 C++ 那样,接受 C 的抽象泄漏,裸指针等等,以保证兼容性。然后以此为基础,构建一个最先进的语言。还有一条道路,就是从根源上解决问题 —— _修正_ C语言的抽象泄露。这一来就会破环其兼容性,但是也会杜绝 C/C++ 现有的问题。 +我能理解 Ken 恼火的原因。这几十年来我就一直认为 C++ 搞错了需要解决的问题。C 语言的后继者有两条路可走。其一就是 C++ 那样,接受 C 的抽象泄漏、裸指针等等,以保证兼容性。然后以此为基础,构建一个最先进的语言。还有一条道路,就是从根源上解决问题 —— _修正_ C语言的抽象泄露。这一来就会破环其兼容性,但是也会杜绝 C/C++ 现有的问题。 -对于第二条道路,第一次严谨的尝试就是 1995 年出现的 Java。Java 搞得不错,但是在语言解释器上构建这门语言使其不适合系统编程。这就在系统编程那留下一个巨大的漏洞,在 Go 以及 Rust 出现之前的 15 年里,都没有语言来填补这个空白。这也就是我的GPSD和NTPsec等软件在2017年仍然主要用C写成的原因,尽管C的问题也很多。 +对于第二条道路,第一次严谨的尝试就是 1995 年出现的 Java。Java 搞得不错,但是在语言解释器上构建这门语言使其不适合系统编程。这就在系统编程那留下一个巨大的洞,在 Go 以及 Rust 出现之前的 15 年里,都没有语言来填补这个空白。这也就是我的 GPSD 和 NTPsec 等软件在 2017 年仍然主要用 C 写成的原因,尽管 C 的问题也很多。 -程序员的现状很差。尽管由于缺少足够多样化的选择,我们很难认识到 C/C++ 做的不够好的地方。我们都认为在软件里面出现缺陷以及基于安全方面考虑的妥协是理所当然的,而不是想想这其中多少是真的由于语言的设计问题导致的,就像缓存区溢出漏洞一样。 +在许多方面这都是很糟糕的情况。尽管由于缺少足够多样化的选择,我们很难认识到 C/C++ 做的不够好的地方。我们都认为在软件里面出现缺陷以及基于安全方面考虑的妥协是理所当然的,而不是想想这其中多少是真的由于语言的设计问题导致的,就像缓存区溢出漏洞一样。 -所以,为什么我们花了这么长时间才开始解决这个问题?从 C(1972) 面世到 Go(2009) 出现,这其中隔了 37 年;Rust也是在其仅仅一年之前出现。我想根本原因还是经济。 +所以,为什么我们花了这么长时间才开始解决这个问题?从 C 1972 年面世到 Go 2009 年出现,这其中隔了 37 年;Rust 也是在其仅仅一年之前出现。我想根本原因还是经济。 -从最早的计算机语言开始,人们就已经知道,每种语言的设计都体现了程序员时间与机器资源的相对价值。在机器这端,就是汇编语言,以及之后的 C 语言,这些语言以牺牲开发人员的时间为代价来提高性能。 另一方面,像 Lisp 和(之后的)Python 这样的语言则试图自动处理尽可能多的细节,但这是以牺牲机器性能为代价的。 +从最早的计算机语言开始,人们就已经知道,每种语言的设计都体现了程序员时间与机器资源的相对价值的权衡。在机器这端,就是汇编语言,以及之后的 C 语言,这些语言以牺牲开发人员的时间为代价来提高性能。 另一方面,像 Lisp 和(之后的)Python 这样的语言则试图自动处理尽可能多的细节,但这是以牺牲机器性能为代价的。 广义地说,这两端的语言的最重要的区别就是有没有自动内存管理。这与经验一致,内存管理缺陷是以机器为中心的语言中最常见的一类缺陷,程序员需要手动管理资源。 -当一个语言对于程序员和机器的价值的理念与软件开发的某些领域的理念一致时,这个语言就是在经济上可行的。语言设计者通过设计一个适合处理现在或者不远的将来出现的情况的语言,而不是使用现有的语言来解决他们遇到的问题。 +当相对价值断言与软件开发在某个特定领域的实际成本动因相匹配时,这个语言就是在经济上可行的。语言设计者通过设计一个适合处理现在或者不远的将来出现的情况的语言,而不是使用现有的语言来解决他们遇到的问题。 -今年来,时兴的编程语言已经渐渐从需要手动管理内存的语言变为带有自动内存管理以及垃圾回收(GC)机制的语言。这种变化对应了摩尔定律导致的计算机硬件成本的降低,使得程序员的时间与之前相比更加的宝贵。但是,除了程序员的时间以及机器效率的变化之外,至少还有两个维度与这种变化相关。 +随着时间的推移,时兴的编程语言已经渐渐从需要手动管理内存的语言变为带有自动内存管理以及垃圾回收(GC)机制的语言。这种变化对应了摩尔定律导致的计算机硬件成本的降低,使得程序员的时间与之前相比更加的宝贵。但是,除了程序员的时间以及机器效率的变化之外,至少还有两个维度与这种变化相关。 -其一就是距离底层硬件的距离。底层软件(内核与服务代码)的低效率会被成倍地扩大。因此我们可以发现,以机器为中心的语言像底层推进而以程序员为中心的语言向着高级发展。因为大多数情况下面向用户的语言仅仅需要以人类的反应速度(0.1秒)做出回应即可。 +其一就是距离底层硬件的距离。底层软件(内核与服务代码)的低效率会被成倍地扩大。因此我们可以发现,以机器为中心的语言向底层推进,而以程序员为中心的语言向着高级发展。因为大多数情况下面向用户的语言仅仅需要以人类的反应速度(0.1 秒)做出回应即可。 -另一个维度就是项目的规模。由于程序员抽象出的问题的漏洞以及自身的疏忽,任何语言都会有预期的每千行代码的出错率。这个比率在以机器为中心的语言上很高,而在程序员为中心的带有 GC 的语言里就大大降低。随着项目规模的增大,带有 GC 语言作为一个防止出错率不堪入目的策略就显得愈发重要起来。 +另一个维度就是项目的规模。由于程序员抽象发生的问题的漏洞以及自身的疏忽,任何语言都会有可预期的每千行代码的出错率。这个比率在以机器为中心的语言上很高,而在程序员为中心的带有 GC 的语言里就大大降低。随着项目规模的增大,带有 GC 的语言作为一个防止出错率不堪入目的策略就显得愈发重要起来。 当我们使用这三种维度来看当今的编程语言的形势 —— C 语言在底层,蓬勃发展的带有 GC 的语言在上层,我们会发现这基本上很合理。但是还有一些看似不合理的是 —— C 语言的应用不合理地广泛。 -我为什么这么说?想想那些经典的 Unix 命令行工具吧。这些通常都是可以使用带有完整的POSIX绑定的脚本语言写出的小程序。那样重新编码的程序调试维护拓展起来都会更加简单。 +我为什么这么说?想想那些经典的 Unix 命令行工具吧。那些小程序通常都可以使用带有完整的 POSIX 支持的脚本语言快速实现出来。重新编码那些程序将使得它们调试、维护和拓展起来都会更加简单。 -但是为什么还是使用 C (或者某些像 eqn 的项目,使用 C++)?因为有转型成本。就算是把相当小相当简单的语言使用新的语言重写并且确认你已经忠实地保留了所有非错误行为都是相当困难的。笼统地说,在任何一个领域的应用编程或者系统编程在语言的权衡过去之后,都可以使用一种哪怕是过时的语言。 +但是为什么还是使用 C (或者某些像 eqn 的项目,使用 C++)?因为有转换成本。就算是把相当小、相当简单的程序使用新的语言重写并且确认你已经忠实地保留了所有非错误行为都是相当困难的。笼统地说,在任何一个领域的应用编程或者系统编程在一种语言的权衡过时之后,仍然坚持使用它。 -这就是我和其他预测者犯的大错。 我们认为,降低机器资源成本(增加程序员时间的相对成本)本身就足以取代C语言(以及没有 GC 的语言)。 在这个过程中,我们有一部分或者甚至一大部分都是错误的 - 自20世纪90年代初以来,脚本语言,Java 以及像 Node.js 这样的东西的兴起显然都是这样兴起的的。 +这就是我和其他预测者犯的大错。 我们认为,降低机器资源成本(增加程序员时间的相对成本)本身就足以取代 C 语言(以及没有 GC 的语言)。 在这个过程中,我们有一部分或者甚至一大部分都是错误的 —— 自 20 世纪 90 年代初以来,脚本语言、Java 以及像 Node.js 这样的东西的兴起显然都是这样兴起的。 -但是,竞争系统编程语言的新浪潮并非如此。 Rust和Go都明确地回应了_增加项目规模_ 这一需求。 脚本语言是先是作为编写小程序的有效途径,并逐渐扩大规模,而Rust和Go从一开始就定位为减少_大型项目_中的缺陷率。 比如 Google 的搜索服务和 Facebook 的实时聊天多服务。 +但是,竞争系统编程语言的新浪潮并非如此。 Rust 和 Go 都明确地回应了_增加项目规模_ 这一需求。 脚本语言是先是作为编写小程序的有效途径,并逐渐扩大规模,而 Rust 和 Go 从一开始就定位为减少_大型项目_中的缺陷率。 比如 Google 的搜索服务和 Facebook 的实时聊天复用。 -我认为这就是对 "为什么不再早点儿" 这个问题的回答。Rust 和 Go 实际上并不算晚,他们相对迅速地回应了一个直到最近才被发现低估的成本问题。 +我认为这就是对 “为什么不再早点儿” 这个问题的回答。Rust 和 Go 实际上并不算晚,它们相对迅速地回应了一个直到最近才被发现低估的成本动因问题。 -好,说了这么多理论上的问题。按照这些理论我们能预言什么?它高偶素我们在 C 之后会出现什么? +好,说了这么多理论上的问题。按照这些理论我们能预言什么?它告诉我们在 C 之后会出现什么? -推动 GC 语言发展的趋势还没有扭转,也不要期待其扭转。这是大势所趋。因此:最终我们将拥有具有足够低延迟的 GC 技术,可用于内核和底层固件,这些技术将以语言实现方式被提供。 这些才是真正结束C长期统治的语言应有的特性。 +推动 GC 语言发展的趋势还没有扭转,也不要期待其扭转。这是大势所趋。因此:最终我们*将*拥有具有足够低延迟的 GC 技术,可用于内核和底层固件,这些技术将以语言实现方式被提供。 这些才是真正结束 C 长期统治的语言应有的特性。 -我们能从 Go 语言开发团队的工作文件中发现端倪,他们正朝着这个方向前进 - 参考关于并发GC 的学术研究,从来没有停止研究。 如果 Go 语言自己没有选择这么做,其他的语言设计师也会这样。 但我认为他们会这么做 - 谷歌推动他们的项目的能力是显而易见的(我们从 “Android 的发展”就能看出来)。 +我们能从 Go 语言开发团队的工作文件中发现端倪,他们正朝着这个方向前进 —— 可参见关于并发 GC 的学术研究 —— 从未停止研究。 如果 Go 语言自己没有选择这么做,其他的语言设计师也会这样。 但我认为他们会这么做 —— 谷歌推动他们的项目的能力是显而易见的(我们从 “Android 的发展”就能看出来)。 在我们拥有那么理想的 GC 之前,我把能替换 C 语言的赌注押在 Go 语言上。因为其 GC 的开销是可以接受的 —— 也就是说不只是应用,甚至是大部分内核外的服务都可以使用。原因很简单: C 的出错率无药可医,转化成本还很高。 -上周我尝试将 C 语言项目转化到 Go 语言上,我发现了两件事。其一就是这话很简单, C 的语言和 Go 对应的很好。还有就是写出的代码相当简单。因为 GC 的存在以及把集合视为首要的我数据结构,人人都要注意到这一点。但是我意识到我写的代码比我期望的多了不少,比例约为 2:1 —— 和 C 转 Python 类似。 +上周我尝试将 C 语言项目转化到 Go 语言上,我发现了两件事。其一就是这活很简单, C 的语言和 Go 对应的很好。还有就是写出的代码相当简单。由于 GC 的存在以及把集合视为首要的数据结构,人们会预期代码减少,但是我意识到我写的代码比我最初期望的减少的更多,比例约为 2:1 —— 和 C 转 Python 类似。 -抱歉呐,Rust 粉们。你们在内核以及底层固件上有着美好的未来。但是你们在别的领域被 Go 压的很惨。没有 GC ,再加上难以从 C 语言转化过来,还有就是有一部分 API 还是不够完善。(我的 select(2) 又哪去了啊?)。 +抱歉呐,Rust 粉们。你们在内核以及底层固件上有着美好的未来,但是你们在别的 C 领域被 Go 压的很惨。没有 GC ,再加上难以从 C 语言转化过来,还有就是 API 的标准部分还是不够完善。(我的 `select(2)` 又哪去了啊?)。 对你们来说,唯一的安慰就是,C++ 粉比你们更糟糕 —— 如果这算是安慰的话。至少 Rust 还可以在 Go 顾及不到的 C 领域内大展宏图。C++ 可不能。 -本文由 [Eric Raymond][5] 发布在 [Software][4] 栏。[收藏链接][6]。 - -------------------------------------------------------------------------------- via: http://esr.ibiblio.org/?p=7724 作者:[Eric Raymond][a] 译者:[name1e5s](https://github.com/name1e5s) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:http://esr.ibiblio.org/?author=2 [1]:http://esr.ibiblio.org/?author=2 [2]:http://esr.ibiblio.org/?p=7724 -[3]:http://esr.ibiblio.org/?p=7711 +[3]:https://linux.cn/article-9268-1.html [4]:http://esr.ibiblio.org/?cat=13 [5]:http://esr.ibiblio.org/?author=2 [6]:http://esr.ibiblio.org/?p=7724 From 741d8d26b2a705481064b0f16e5049f49883fec2 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 1 Apr 2018 12:40:11 +0800 Subject: [PATCH 0231/1057] PUB:20171113 The big break in computer languages.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @name1e5s 明天发布到 https://linux.cn/article-9503-1.html --- .../20171113 The big break in computer languages.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171113 The big break in computer languages.md (100%) diff --git a/translated/tech/20171113 The big break in computer languages.md b/published/20171113 The big break in computer languages.md similarity index 100% rename from translated/tech/20171113 The big break in computer languages.md rename to published/20171113 The big break in computer languages.md From 91f16966c046a4304e8a243e0b5aa18eaec6cb4d Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sun, 1 Apr 2018 14:00:12 +0800 Subject: [PATCH 0232/1057] Update 20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md Translating by kennethXia --- ...o add network bridge with nmcli (NetworkManager) on Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md index bf7772ef1a..7fbfec4573 100644 --- a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md +++ b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md @@ -1,3 +1,5 @@ +Translating by kennethXia + How to add network bridge with nmcli (NetworkManager) on Linux ====== From 7251ee586675227e712a98a3c70f283912d94f07 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sun, 1 Apr 2018 16:22:53 +0800 Subject: [PATCH 0233/1057] Update 20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md --- ...ge with nmcli (NetworkManager) on Linux.md | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md index 7fbfec4573..bb8be19602 100644 --- a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md +++ b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md @@ -1,51 +1,51 @@ Translating by kennethXia -How to add network bridge with nmcli (NetworkManager) on Linux +如何在Linux里使用nmcli (NetworkManager) 添加网桥 ====== -I am using Debian Linux 9 "stretch" on the desktop. I would like to create network bridge with NetworkManager. But, I am unable to find the option to add br0. How can I create or add network bridge with nmcli for NetworkManager on Linux? +我正在电脑上使用Debian Linux 9 “stretch”。 我想用NetworkManager 来建网桥。但是根本就没有添加br0的选项。我该如何在Linux里使用nmcli 来为 NetworkManager 创建或者添加网桥呢? -A bridge is nothing but a device which joins two local networks into one network. It works at the data link layer, i.e., layer 2 of the OSI model. Network bridge often used with virtualization and other software. Disabling NetworkManager for a simple bridge especially on Linux Laptop/desktop doesn't make any sense. The nmcli tool can create Persistent bridge configuration without editing any files. **This page shows how to create a bridge interface using the Network Manager command line tool called nmcli**. +网桥没什么特别的,只是把两个网络连在一起。它工作在数据链路层,例如OSI模型的第二层。网桥经常被虚拟机和别的一些软件使用。为了使用网桥而关闭桌面Linux上的NetworkManager 显然是不明智的。nmcli可以创建一个永久的网桥而不编辑任何文件。**本文将展示如何使用NetworkManager 的命令行工具nmcli来创建网桥。** -### How to create/add network bridge with nmcli +### 如何使用nmcli来创建/添加网桥 -The procedure to add a bridge interface on Linux is as follows when you want to use Network Manager: +使用NetworkManager 在Linux上添加网桥接口的步骤如下: -1. Open the Terminal app -2. Get info about the current connection: +1. 打开terminal +2. 获取当前连接状态: ``` nmcli con show ``` -3. Add a new bridge: +3. 添加新的网桥: ``` nmcli con add type bridge ifname br0 ``` -4. Create a slave interface: +4. 创建子网卡: ``` nmcli con add type bridge-slave ifname eno1 master br0 ``` -5. Turn on br0: +5. br0上线: ``` nmcli con up br0 ``` -Let us see how to create a bridge, named br0 in details. +让我们从细节层面看看如何创建一个叫br0的网桥。 -### Get current network config +### 获取当前网络配置 -You can view connection from the Network Manager GUI in settings: +你可以通过NetworkManager的图像界面来了解本机的网络连接: [![Getting Network Info on Linux][1]][1] -Another option is to type the following command: +也可以使用如下命令行来查看: ``` $ nmcli con show $ nmcli connection show --active ``` [![View the connections with nmcli][2]][2] -I have a "Wired connection 1" which uses the eno1 Ethernet interface. My system has a VPN interface too. I am going to setup a bridge interface named br0 and add, (or enslave) an interface to eno1. +我有一个使用eno1网卡的“有线连接”。我的系统还有一个VPN接口。我将要创建一个名为br0的网桥,并连接一个网卡到eno1. -### How to create a bridge, named br0 +### 如何创建一个名为br0的网桥 ``` $ sudo nmcli con add ifname br0 type bridge con-name br0 @@ -53,13 +53,13 @@ $ sudo nmcli con add type bridge-slave ifname eno1 master br0 $ nmcli connection show ``` [![Create bridge interface using nmcli on Linux][3]][3] -You can disable STP too: +你也可以禁用STP: ``` $ sudo nmcli con modify br0 bridge.stp no $ nmcli con show $ nmcli -f bridge con show br0 ``` -The last command shows the bridge settings including disabled STP: +最后一条命令展示了禁用STP后的网桥参数: ``` bridge.mac-address: -- bridge.stp: no @@ -72,26 +72,26 @@ bridge.multicast-snooping: yes ``` -### How to turn on bridge interface +### 如何打开网桥 -You must turn off "Wired connection 1" and turn on br0: +你必须先关闭"Wired connection 1" ,然后打开br0: ``` $ sudo nmcli con down "Wired connection 1" $ sudo nmcli con up br0 $ nmcli con show ``` -Use [ip command][4] to view the IP settings: +使用 [ip command][4] 来查看IP地址: ``` $ ip a s $ ip a s br0 ``` [![Build a network bridge with nmcli on Linux][5]][5] -### Optional: How to use br0 with KVM +### 附录: 如何在KVM上使用br0 -Now you can connect VMs (virtual machine) created with KVM/VirtualBox/VMware workstation to a network directly without using NAT. Create a file named br0.xml for KVM using vi command or [cat command][6]: +现在你可以使用KVM/VirtualBox/VMware workstation创建的VM(虚拟机)来直接连接网络而非通过NAT。使用vi或者cat命令[cat command][6]为虚拟机创建一个名为br0.xml的文件: `$ cat /tmp/br0.xml` -Append the following code: +添加以下代码: ``` br0 @@ -100,14 +100,14 @@ Append the following code: ``` -Run virsh command as follows: +如下所示运行virsh命令: ``` # virsh net-define /tmp/br0.xml # virsh net-start br0 # virsh net-autostart br0 # virsh net-list --all ``` -Sample outputs: +输出样例: ``` Name State Autostart Persistent ---------------------------------------------------------- @@ -116,22 +116,22 @@ Sample outputs: ``` -For more info read the following man page: +阅读man页面获取更多信息: ``` $ man ip $ man nmcli ``` -### about the author +### 关于作者 -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][7], [Facebook][8], [Google+][9]. +作者是nixCraft的创建者,老练的系统管理员和一个Linux/Unix shell脚本编程培训师。他为全球客户和各种公司工作,包括IT,教育,国防,空间研究以及非营利组织。 他的联系方式[Twitter][7], [Facebook][8], [Google+][9]. -------------------------------------------------------------------------------- via: https://www.cyberciti.biz/faq/how-to-add-network-bridge-with-nmcli-networkmanager-on-linux/ 作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) +译者:[kennethXia](https://github.com/kennethXia) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From aa78ae6313c97f924da60b126f7201a04e229172 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sun, 1 Apr 2018 16:33:06 +0800 Subject: [PATCH 0234/1057] Update 20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md --- ...rk bridge with nmcli (NetworkManager) on Linux.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md index bb8be19602..9d3703d22f 100644 --- a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md +++ b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md @@ -26,7 +26,7 @@ nmcli con add type bridge ifname br0 ``` nmcli con add type bridge-slave ifname eno1 master br0 ``` -5. br0上线: +5. 打开br0: ``` nmcli con up br0 ``` @@ -35,7 +35,7 @@ nmcli con up br0 ### 获取当前网络配置 -你可以通过NetworkManager的图像界面来了解本机的网络连接: +你可以通过NetworkManager的GUI来了解本机的网络连接: [![Getting Network Info on Linux][1]][1] 也可以使用如下命令行来查看: ``` @@ -43,7 +43,8 @@ $ nmcli con show $ nmcli connection show --active ``` [![View the connections with nmcli][2]][2] -我有一个使用eno1网卡的“有线连接”。我的系统还有一个VPN接口。我将要创建一个名为br0的网桥,并连接一个网卡到eno1. + +我有一个使用eno1网卡的“有线连接”。我的系统还有一个VPN接口。我将要创建一个名为br0的网桥,并连接到eno1. ### 如何创建一个名为br0的网桥 @@ -53,6 +54,7 @@ $ sudo nmcli con add type bridge-slave ifname eno1 master br0 $ nmcli connection show ``` [![Create bridge interface using nmcli on Linux][3]][3] + 你也可以禁用STP: ``` $ sudo nmcli con modify br0 bridge.stp no @@ -80,7 +82,7 @@ $ sudo nmcli con down "Wired connection 1" $ sudo nmcli con up br0 $ nmcli con show ``` -使用 [ip command][4] 来查看IP地址: +使用 [ip 命令][4] 来查看IP地址: ``` $ ip a s $ ip a s br0 @@ -107,7 +109,7 @@ $ ip a s br0 # virsh net-autostart br0 # virsh net-list --all ``` -输出样例: +输出: ``` Name State Autostart Persistent ---------------------------------------------------------- From ab2a8c13c25e7c611c701031e6f6d1f30aac4800 Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 1 Apr 2018 16:48:18 +0800 Subject: [PATCH 0235/1057] Update 20180318 How To Manage Disk Partitions Using Parted Command.md --- ...0180318 How To Manage Disk Partitions Using Parted Command.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md b/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md index 141e86cc1d..2a5e647e28 100644 --- a/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md +++ b/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md @@ -1,5 +1,6 @@ How To Manage Disk Partitions Using Parted Command ====== +Translating by zyk2290 We all knows disk partitions is one of the important task for Linux administrator. They can not survive without knowing this. In worst cases, at least once in a week they would get this request from dependent team but in big environment admins used to get this request very often. From a51f65f4504d134d72ee0445eb137dadc1d3d601 Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 1 Apr 2018 16:48:52 +0800 Subject: [PATCH 0236/1057] Update 20180318 How To Manage Disk Partitions Using Parted Command.md --- ...0180318 How To Manage Disk Partitions Using Parted Command.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md b/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md index 2a5e647e28..804a31fa52 100644 --- a/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md +++ b/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md @@ -1,6 +1,7 @@ How To Manage Disk Partitions Using Parted Command ====== Translating by zyk2290 + We all knows disk partitions is one of the important task for Linux administrator. They can not survive without knowing this. In worst cases, at least once in a week they would get this request from dependent team but in big environment admins used to get this request very often. From d4454623162a408b7800db711982aab0e7013fa1 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sun, 1 Apr 2018 16:59:32 +0800 Subject: [PATCH 0237/1057] Update 20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md --- ... add network bridge with nmcli (NetworkManager) on Linux.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md index 9d3703d22f..3836598a93 100644 --- a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md +++ b/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md @@ -37,6 +37,7 @@ nmcli con up br0 你可以通过NetworkManager的GUI来了解本机的网络连接: [![Getting Network Info on Linux][1]][1] + 也可以使用如下命令行来查看: ``` $ nmcli con show @@ -82,7 +83,7 @@ $ sudo nmcli con down "Wired connection 1" $ sudo nmcli con up br0 $ nmcli con show ``` -使用 [ip 命令][4] 来查看IP地址: +使用 [ip 命令][4] 来查看IP信息: ``` $ ip a s $ ip a s br0 From 4ad74d50a0e365b3733317f6f81ffa9f7a3c91c2 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 17:59:50 +0800 Subject: [PATCH 0238/1057] Translated by pygmalion666 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts” 翻译完成,请校对。 --- ... Spice To Your UNIX-Linux Shell Scripts.md | 275 ++++++++++-------- 1 file changed, 150 insertions(+), 125 deletions(-) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index 3735494dee..7d9e374c3e 100644 --- a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -1,36 +1,40 @@ -# 10 个给 UNIX-Linux Shell 脚本增加趣味的工具 - +# 10 个增加 UNIX/Linux Shell 脚本趣味的工具 ====== -There are some misconceptions that shell scripts are only for a CLI environment. You can efficiently use various tools to write GUI and network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxes, progress bars, etc.). You can always control the final output, cursor position on the screen, various output effects, and more. With the following tools, you can build powerful, interactive, user-friendly UNIX / Linux bash shell scripts. +有些误解认为 Shell 脚本仅用于 CLI 环境。实际上在 KDE 或 Gnome 桌面下,你可以有效的使用各种工具编写 GUI 或者网络(socket)脚本。Shell 脚本可以使用一些 GUI 组件(菜单、警告框、进度条等),你可以控制终端输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户友好的 UNIX/Linux bash 脚本。 -有些误解认为 shell 脚本仅适用于命令行环境。你可以在 KDE 或者 Gnome 桌面下有效的使用各种工具编写 GUI 或者网络(socket)脚本。shell 脚本可以利用一些 GUI 的组件(菜单、警告框、状态栏等等)。你可以一直控制屏幕最终输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户有好的 UNIX / Linux bash 脚本。 +制作 GUI 应用不是一项昂贵的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 -Creating GUI application is not an expensive task but a task that takes time and patience. Luckily, both UNIX and Linux ships with plenty of tools to write beautiful GUI scripts. The following tools are tested on FreeBSD and Linux operating systems but should work under other UNIX like operating systems. +### 1. notify-send 命令 -制作 GUI 应用不是一个昂贵任务,但是需要时间和耐心。幸运的是,UNIX 和 Linux 都附带有大量写漂亮 GUI 脚本的工具。以下工具在 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 +notify-send 命令允许你使用通知守护进程发送桌面通知给用户。这种避免侵入用户的方式,对于通知桌面用户一个事件或显示一些信息是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt 命令][1] 或 [apt-get 命令][2] 安装的包: -## 1. notify-send 命令 +```bash +sudo apt-get install libnotify-bin +``` -The notify-send command allows you to send desktop notifications to the user via a notification daemon from the command line. This is useful to inform the desktop user about an event or display some form of information without getting in the user's way. You need to install the following package on a Debian/Ubuntu Linux using [apt command][1]/[apt-get command][2]: +CentOS/RHEL 用户使用下面的 [yum 命令][3]: -notify-send 命令允许你通过通知守护进程发送桌面通知给用户。这种通知桌面用户一个事件或者显示一些信息,而避免侵入用户的方式是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt][1] 或 [apt-get][2] 命令安装下面的包: +```bash +sudo yum install libnotify +``` -`$ sudo apt-get install libnotify-bin` -CentOS/RHEL user try the following [yum command][3]: -`$ sudo yum install libnotify` -Fedora Linux user type the following dnf command: +Fedora Linux 用户使用下面的 dnf 命令: + +```bash `$ sudo dnf install libnotify` In this example, send simple desktop notification from the command line, enter: -``` ### send some notification ## notify-send "rsnapshot done :)" ``` -Sample outputs: +示例输出: + ![Fig:01: notify-send in action ][4] -Here is another code with additional options: -``` + +下面是另一个附加选项的代码: + +```bash .... alert=18000 live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g') @@ -38,119 +42,122 @@ live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5} ... ``` -Sample outputs: +示例输出: + ![Fig.02: notify-send with timeouts and other options][5] -Where, - * -t 5000: Specifies the timeout in milliseconds ( 5000 milliseconds = 5 seconds) - * -u low : Set the urgency level (i.e. low, normal, or critical). - * -i gtk-dialog-info : Set an icon filename or stock icon to display (you can set path as -i /path/to/your-icon.png). +这里: + * -t 5000: 指定超时时间(毫秒) (5000 毫秒 = 5 秒) + * -u low : 设置紧急等级 (如:低、普通、紧急) + * -i gtk-dialog-info : 设置要显示的图标名称或者指定的图标(你可以设置路径为:-i /path/to/your-icon.png) +关于更多使用 notify-send 功能的信息,请参考 notify-send 手册。在命令行下输入 `man notify-send` 即可看见: -For more information on use of the notify-send utility, please refer to the notify-send man page, viewable by typing man notify-send from the command line: -``` +```bash man notify-send ``` -### #2: tput Command +### #2:tput 命令 -The tput command is used to set terminal features. With tput you can set: +tput 命令用于设置终端特性。通过 tput 你可以设置: - * Move the cursor around the screen. - * Get information about terminal. - * Set colors (background and foreground). - * Set bold mode. - * Set reverse mode and much more. + * 在屏幕上移动光标。 + * 获取终端信息。 + * 设置颜色(背景和前景)。 + * 设置加粗模式。 + * 设置反向模式等等。 +下面有一段示例代码: - -Here is a sample code: -``` +```bash #!/bin/bash - + # clear the screen tput clear - + # Move cursor to screen location X,Y (top left is 0,0) tput cup 3 15 - + # Set a foreground colour using ANSI escape tput setaf 3 echo "XYX Corp LTD." tput sgr0 - + tput cup 5 17 # Set reverse video mode tput rev echo "M A I N - M E N U" tput sgr0 - + tput cup 7 15 echo "1. User Management" - + tput cup 8 15 echo "2. Service Management" - + tput cup 9 15 echo "3. Process Management" - + tput cup 10 15 echo "4. Backup" - + # Set bold mode tput bold tput cup 12 15 read -p "Enter your choice [1-4] " choice - + tput clear tput sgr0 tput rc ``` +示例输出: -Sample outputs: ![Fig.03: tput in action][6] -For more detail concerning the tput command, see the following man page: -``` + +关于 tput 命令的详细信息,参见手册: + +```bash man 5 terminfo man tput ``` -### #3: setleds Command +### #3:setleds 命令 -The setleds command allows you to set the keyboard leds. In this example, set NumLock on: -``` +setleds 命令允许你设置键盘灯。下面是打开数字键灯的示例: + +```bash setleds -D +num ``` -To turn it off NumLock, enter: -``` +关闭数字键灯,输入: + +```bash setleds -D -num ``` - * -caps : Clear CapsLock. - * +caps : Set CapsLock. - * -scroll : Clear ScrollLock. - * +scroll : Set ScrollLock. + * -caps:关闭大小写锁定 + * +caps:打开大小写锁定 + * -scroll:关闭滚动锁定 + * +scroll:打开滚动锁定 +查看 setleds 手册可看见更多信息和选项: - -See setleds command man page for more information and options: `man setleds` -### #4: zenity Command +### #4:zenity 命令 -The [zenity commadn will display GTK+ dialogs box][7], and return the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts. Here is a sample GUI client for the whois directory service for given domain name: +[zenity 命令显示 GTK+ 对话框][7],并且返回用户输入。它允许你使用各种 Shell 脚本向用户展示或请求信息。下面是 whois 指定域名目录服务的 GUI 客户端示例。 -```shell +```bash #!/bin/bash # Get domain name _zenity="/usr/bin/zenity" _out="/tmp/whois.output.$$" domain=$(${_zenity} --title "Enter domain" \ - --entry --text "Enter the domain you would like to see whois info" ) - + --entry --text "Enter the domain you would like to see whois info" ) + if [ $? -eq 0 ] then # Display a progress dialog while searching whois database @@ -170,30 +177,36 @@ else fi ``` -Sample outputs: +示例输出: + ![Fig.04: zenity in Action][8] -See the zenity man page for more information and all other supports GTK+ widgets: -``` + +参见手册获取更多 zenity 信息以及其他支持 GTK+ 的组件: + +```bash zenity --help man zenity ``` -### #5: kdialog Command +### #5:kdialog 命令 -kdialog is just like zenity but it is designed for KDE desktop / qt apps. You can display dialogs using kdialog. The following will display message on screen: -``` +kdialog 命令与 zenity 类似,但它是为 KDE 桌面和 QT 应用设计。你可以使用 kdialog 展示对话框。下面示例将在屏幕上显示信息: + +```bash kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not found." ``` -Sample outputs: +示例输出: + ![Fig.05: Suppressing the display of a dialog ][9] -See [shell scripting with KDE Dialogs][10] tutorial for more information. +参见 《[KDE 对话框 Shell 脚本编程][10]》 教程获取更多信息。 -### #6: Dialog +### #6:Dialog -[Dialog is an application used in shell scripts][11] which displays text user interface widgets. It uses the curses or ncurses library. Here is a sample code: -``` +[Dialog 是一个使用 Shell 脚本的应用][11],显示用户界面组件的文本。它使用 curses 或者 ncurses 库。下面是一个示例代码: + +```bash #!/bin/bash dialog --title "Delete file" \ --backtitle "Linux Shell Script Tutorial Example" \ @@ -211,70 +224,77 @@ case $response in esac ``` -See the dialog man page for details: +参见 dialog 手册获取详细信息: `man dialog` -#### A Note About Other User Interface Widgets Tools +### 关于其他用户界面工具的注意事项 -UNIX and Linux comes with lots of other tools to display and control apps from the command line, and shell scripts can make use of some of the KDE / Gnome / X widget set: +UNIX、Linux 提供了大量其他工具来显示和控制命令行中的应用程序,shell 脚本可以使用一些 KDE、Gnome、X 组件集: - * **gmessage** - a GTK-based xmessage clone. - * **xmessage** - display a message or query in a window (X-based /bin/echo) - * **whiptail** - display dialog boxes from shell scripts - * **python-dialog** - Python module for making simple Text/Console-mode user interfaces + * **gmessage** - 基于 GTK xmessage 的克隆. + * **xmessage** - 在窗口中显示或查询消息(X-based /bin/echo) + * **whiptail** - 显示来自 shell 脚本的对话框 + * **python-dialog** - 用于制作简单文本或控制台模式用户界面的 Python 模块 +### #7:logger 命令 +logger 命令将信息写到系统日志文件,如: /var/log/messages。它为系统日志模块 syslog 提供了一个 shell 命令行接口: -### #7: logger command - -The logger command writes entries in the system log file such as /var/log/messages. It provides a shell command interface to the syslog system log module: -``` +```bash logger "MySQL database backup failed." tail -f /var/log/messages logger -t mysqld -p daemon.error "Database Server failed" tail -f /var/log/syslog ``` -Sample outputs: -``` +示例输出: + +```bash Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature/speed normal Apr 20 00:12:20 vivek-desktop mysqld: Database Server failed ``` -See howto [write message to a syslog / log file][12] for more information. Alternatively, you can see the logger man page for details: +参见 《[如何写消息到 syslog 或 日志文件][12]》 获得更多信息。此外,你也可以查看 logger 手册获取详细信息: + `man logger` -### #8: setterm Command +### #8:setterm 命令 -The setterm command can set various terminal attributes. In this example, force screen to turn black in 15 minutes. Monitor standby will occur at 60 minutes: -``` +setterm 命令可设置不同的终端属性。下面的示例代码会强制屏幕在 15分钟后变黑,监视器则待机 60 分钟。 + +```bash setterm -blank 15 -powersave powerdown -powerdown 60 ``` -In this example show underlined text for xterm window: -``` +下面的例子将 xterm 窗口中的文本带有下划线展示: + +```bash setterm -underline on; echo "Add Your Important Message Here" setterm -underline off ``` -Another useful option is to turn on or off cursor: -``` +另一个有用的选项是打开或关闭光标: + +```bash setterm -cursor off ``` -Turn it on: -``` +打开光标: + +```bash setterm -cursor on ``` -See the setterm command man page for details: +参见 setterm 命令手册获取详细信息: + `man setterm` -### #9: smbclient: Sending Messages To MS-Windows Workstations +### #9:smbclient:给 MS-Windows 工作站发送消息 -The smbclient command can talk to an SMB/CIFS server. It can send a message to selected users or all users on MS-Windows systems: -``` +smbclient 命令可以与 SMB/CIFS 服务器通讯。它可以向 MS-Windows 系统上选定或全部用户发送消息。 + +```bash smbclient -M WinXPPro </dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 open" || echo "TCP port 25 close" ``` -You can use [bash loop and find out open ports][14] with the snippets: -``` +下面的代码片段,你可以利用 [bash 循环找出已打开的端口][14]: + +```bash echo "Scanning TCP ports..." for p in {1..1023} do @@ -315,9 +337,9 @@ do done ``` +示例输出: -Sample outputs: -``` +```bash Scanning TCP ports... 22 open 53 open @@ -327,17 +349,18 @@ Scanning TCP ports... 631 open ``` -In this example, your bash script act as an HTTP client: -``` +下面的示例中,你的 bash 脚本将像 HTTP 客户端一样工作: + +```bash #!/bin/bash exec 3<> /dev/tcp/${1:-www.cyberciti.biz}/80 - + printf "GET / HTTP/1.0\r\n" >&3 printf "Accept: text/html, text/plain\r\n" >&3 printf "Accept-Language: en\r\n" >&3 printf "User-Agent: nixCraft_BashScript v.%s\r\n" "${BASH_VERSION}" >&3 printf "\r\n" >&3 - + while read LINE <&3 do # do something on $LINE @@ -347,26 +370,28 @@ do done ``` -See the bash man page for more information: +参见 bash 手册获取更多信息: + `man bash` -### A Note About GUI Tools and Cronjob +### 关于 GUI 工具和 Cronjob 的注意事项 + +如果你 [使用 crontab][15] 来启动你的脚本,你需要使用 `export DISPLAY=[用户机器]:0` 命令请求本地显示或输出服务。举个例子,使用 zenity 工具调用 /home/vivek/scripts/monitor.stock.sh: -You need to request local display/input service using export DISPLAY=[user's machine]:0 command if you are [using cronjob][15] to call your scripts. For example, call /home/vivek/scripts/monitor.stock.sh as follows which uses zenity tool: `@hourly DISPLAY=:0.0 /home/vivek/scripts/monitor.stock.sh` -Have a favorite UNIX tool to spice up shell script? Share it in the comments below. +你有喜欢的可以增加 shell 脚本趣味的 UNIX 工具么?请在下面的评论区分享它吧。 -### about the author +### 关于作者 -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][16], [Facebook][17], [Google+][18]. +本文作者是 nixCraft 创始人、一个老练的系统管理员、Linux 操作系统和 UNIX shell 编程培训师。他服务来自全球的客户和不同的行业,包括 IT 、教育、防务和空间探索、还有非营利组织。你可以在 [Twitter][16],[Facebook][17],[Google+][18] 上面关注他。 -------------------------------------------------------------------------------- via: https://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html 作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/pygmalion666) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 53aa2fd3d41c239d063d318e20198d215d7d12aa Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 18:03:49 +0800 Subject: [PATCH 0239/1057] Updated by pygmalion666 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正 shell 大小写 --- ... Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index 7d9e374c3e..03c2a345e2 100644 --- a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -1,7 +1,7 @@ # 10 个增加 UNIX/Linux Shell 脚本趣味的工具 ====== -有些误解认为 Shell 脚本仅用于 CLI 环境。实际上在 KDE 或 Gnome 桌面下,你可以有效的使用各种工具编写 GUI 或者网络(socket)脚本。Shell 脚本可以使用一些 GUI 组件(菜单、警告框、进度条等),你可以控制终端输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户友好的 UNIX/Linux bash 脚本。 +有些误解认为 shell 脚本仅用于 CLI 环境。实际上在 KDE 或 Gnome 桌面下,你可以有效的使用各种工具编写 GUI 或者网络(socket)脚本。shell 脚本可以使用一些 GUI 组件(菜单、警告框、进度条等),你可以控制终端输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户友好的 UNIX/Linux bash 脚本。 制作 GUI 应用不是一项昂贵的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 From f966a3cec90dc71212ff1d7292fd2393a331b0a6 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 18:07:08 +0800 Subject: [PATCH 0240/1057] Update by pygmalion666 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修正 H3 标题 --- ... Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index 03c2a345e2..bed5385d90 100644 --- a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -5,7 +5,7 @@ 制作 GUI 应用不是一项昂贵的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 -### 1. notify-send 命令 +### 1#:notify-send 命令 notify-send 命令允许你使用通知守护进程发送桌面通知给用户。这种避免侵入用户的方式,对于通知桌面用户一个事件或显示一些信息是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt 命令][1] 或 [apt-get 命令][2] 安装的包: From 86900eec8d91ac123a371765dc57ba43aef11fe1 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 18:12:11 +0800 Subject: [PATCH 0241/1057] Delete source: 20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 删除原始文档 --- ... Spice To Your UNIX-Linux Shell Scripts.md | 384 ------------------ 1 file changed, 384 deletions(-) delete mode 100644 sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md diff --git a/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md deleted file mode 100644 index 138215d9ec..0000000000 --- a/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ /dev/null @@ -1,384 +0,0 @@ -【Pgmalion666 Translating】 -10 Tools To Add Some Spice To Your UNIX/Linux Shell Scripts -====== -There are some misconceptions that shell scripts are only for a CLI environment. You can efficiently use various tools to write GUI and network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxes, progress bars, etc.). You can always control the final output, cursor position on the screen, various output effects, and more. With the following tools, you can build powerful, interactive, user-friendly UNIX / Linux bash shell scripts. - -Creating GUI application is not an expensive task but a task that takes time and patience. Luckily, both UNIX and Linux ships with plenty of tools to write beautiful GUI scripts. The following tools are tested on FreeBSD and Linux operating systems but should work under other UNIX like operating systems. - -### 1. notify-send Command - -The notify-send command allows you to send desktop notifications to the user via a notification daemon from the command line. This is useful to inform the desktop user about an event or display some form of information without getting in the user's way. You need to install the following package on a Debian/Ubuntu Linux using [apt command][1]/[apt-get command][2]: -`$ sudo apt-get install libnotify-bin` -CentOS/RHEL user try the following [yum command][3]: -`$ sudo yum install libnotify` -Fedora Linux user type the following dnf command: -`$ sudo dnf install libnotify` -In this example, send simple desktop notification from the command line, enter: -``` -### send some notification ## -notify-send "rsnapshot done :)" -``` - -Sample outputs: -![Fig:01: notify-send in action ][4] -Here is another code with additional options: -``` -.... -alert=18000 -live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g') -[ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i "BSE Sensex touched 18k"; notify_counter=1; } -... -``` - -Sample outputs: -![Fig.02: notify-send with timeouts and other options][5] -Where, - - * -t 5000: Specifies the timeout in milliseconds ( 5000 milliseconds = 5 seconds) - * -u low : Set the urgency level (i.e. low, normal, or critical). - * -i gtk-dialog-info : Set an icon filename or stock icon to display (you can set path as -i /path/to/your-icon.png). - - - -For more information on use of the notify-send utility, please refer to the notify-send man page, viewable by typing man notify-send from the command line: -``` -man notify-send -``` - -### #2: tput Command - -The tput command is used to set terminal features. With tput you can set: - - * Move the cursor around the screen. - * Get information about terminal. - * Set colors (background and foreground). - * Set bold mode. - * Set reverse mode and much more. - - - -Here is a sample code: -``` -#!/bin/bash - -# clear the screen -tput clear - -# Move cursor to screen location X,Y (top left is 0,0) -tput cup 3 15 - -# Set a foreground colour using ANSI escape -tput setaf 3 -echo "XYX Corp LTD." -tput sgr0 - -tput cup 5 17 -# Set reverse video mode -tput rev -echo "M A I N - M E N U" -tput sgr0 - -tput cup 7 15 -echo "1. User Management" - -tput cup 8 15 -echo "2. Service Management" - -tput cup 9 15 -echo "3. Process Management" - -tput cup 10 15 -echo "4. Backup" - -# Set bold mode -tput bold -tput cup 12 15 -read -p "Enter your choice [1-4] " choice - -tput clear -tput sgr0 -tput rc -``` - - -Sample outputs: -![Fig.03: tput in action][6] -For more detail concerning the tput command, see the following man page: -``` -man 5 terminfo -man tput -``` - -### #3: setleds Command - -The setleds command allows you to set the keyboard leds. In this example, set NumLock on: -``` -setleds -D +num -``` - -To turn it off NumLock, enter: -``` -setleds -D -num -``` - - * -caps : Clear CapsLock. - * +caps : Set CapsLock. - * -scroll : Clear ScrollLock. - * +scroll : Set ScrollLock. - - - -See setleds command man page for more information and options: -`man setleds` - -### #4: zenity Command - -The [zenity commadn will display GTK+ dialogs box][7], and return the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts. Here is a sample GUI client for the whois directory service for given domain name: - -```shell -#!/bin/bash -# Get domain name -_zenity="/usr/bin/zenity" -_out="/tmp/whois.output.$$" -domain=$(${_zenity} --title "Enter domain" \ - --entry --text "Enter the domain you would like to see whois info" ) - -if [ $? -eq 0 ] -then - # Display a progress dialog while searching whois database - whois $domain | tee >(${_zenity} --width=200 --height=100 \ - --title="whois" --progress \ - --pulsate --text="Searching domain info..." \ - --auto-kill --auto-close \ - --percentage=10) >${_out} - - # Display back output - ${_zenity} --width=800 --height=600 \ - --title "Whois info for $domain" \ - --text-info --filename="${_out}" -else - ${_zenity} --error \ - --text="No input provided" -fi -``` - -Sample outputs: -![Fig.04: zenity in Action][8] -See the zenity man page for more information and all other supports GTK+ widgets: -``` -zenity --help -man zenity -``` - -### #5: kdialog Command - -kdialog is just like zenity but it is designed for KDE desktop / qt apps. You can display dialogs using kdialog. The following will display message on screen: -``` -kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not found." -``` - -Sample outputs: -![Fig.05: Suppressing the display of a dialog ][9] - -See [shell scripting with KDE Dialogs][10] tutorial for more information. - -### #6: Dialog - -[Dialog is an application used in shell scripts][11] which displays text user interface widgets. It uses the curses or ncurses library. Here is a sample code: -``` -#!/bin/bash -dialog --title "Delete file" \ ---backtitle "Linux Shell Script Tutorial Example" \ ---yesno "Are you sure you want to permanently delete \"/tmp/foo.txt\"?" 7 60 - -# Get exit status -# 0 means user hit [yes] button. -# 1 means user hit [no] button. -# 255 means user hit [Esc] key. -response=$? -case $response in - 0) echo "File deleted.";; - 1) echo "File not deleted.";; - 255) echo "[ESC] key pressed.";; -esac -``` - -See the dialog man page for details: -`man dialog` - -#### A Note About Other User Interface Widgets Tools - -UNIX and Linux comes with lots of other tools to display and control apps from the command line, and shell scripts can make use of some of the KDE / Gnome / X widget set: - - * **gmessage** - a GTK-based xmessage clone. - * **xmessage** - display a message or query in a window (X-based /bin/echo) - * **whiptail** - display dialog boxes from shell scripts - * **python-dialog** - Python module for making simple Text/Console-mode user interfaces - - - -### #7: logger command - -The logger command writes entries in the system log file such as /var/log/messages. It provides a shell command interface to the syslog system log module: -``` -logger "MySQL database backup failed." -tail -f /var/log/messages -logger -t mysqld -p daemon.error "Database Server failed" -tail -f /var/log/syslog -``` - -Sample outputs: -``` -Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature/speed normal -Apr 20 00:12:20 vivek-desktop mysqld: Database Server failed -``` - -See howto [write message to a syslog / log file][12] for more information. Alternatively, you can see the logger man page for details: -`man logger` - -### #8: setterm Command - -The setterm command can set various terminal attributes. In this example, force screen to turn black in 15 minutes. Monitor standby will occur at 60 minutes: -``` -setterm -blank 15 -powersave powerdown -powerdown 60 -``` - -In this example show underlined text for xterm window: -``` -setterm -underline on; -echo "Add Your Important Message Here" -setterm -underline off -``` - -Another useful option is to turn on or off cursor: -``` -setterm -cursor off -``` - -Turn it on: -``` -setterm -cursor on -``` - -See the setterm command man page for details: -`man setterm` - -### #9: smbclient: Sending Messages To MS-Windows Workstations - -The smbclient command can talk to an SMB/CIFS server. It can send a message to selected users or all users on MS-Windows systems: -``` -smbclient -M WinXPPro </dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 open" || echo "TCP port 25 close" -``` - -You can use [bash loop and find out open ports][14] with the snippets: -``` -echo "Scanning TCP ports..." -for p in {1..1023} -do - (echo >/dev/tcp/localhost/$p) >/dev/null 2>&1 && echo "$p open" -done -``` - - -Sample outputs: -``` -Scanning TCP ports... -22 open -53 open -80 open -139 open -445 open -631 open -``` - -In this example, your bash script act as an HTTP client: -``` -#!/bin/bash -exec 3<> /dev/tcp/${1:-www.cyberciti.biz}/80 - -printf "GET / HTTP/1.0\r\n" >&3 -printf "Accept: text/html, text/plain\r\n" >&3 -printf "Accept-Language: en\r\n" >&3 -printf "User-Agent: nixCraft_BashScript v.%s\r\n" "${BASH_VERSION}" >&3 -printf "\r\n" >&3 - -while read LINE <&3 -do - # do something on $LINE - # or send $LINE to grep or awk for grabbing data - # or simply display back data with echo command - echo $LINE -done -``` - -See the bash man page for more information: -`man bash` - -### A Note About GUI Tools and Cronjob - -You need to request local display/input service using export DISPLAY=[user's machine]:0 command if you are [using cronjob][15] to call your scripts. For example, call /home/vivek/scripts/monitor.stock.sh as follows which uses zenity tool: -`@hourly DISPLAY=:0.0 /home/vivek/scripts/monitor.stock.sh` - -Have a favorite UNIX tool to spice up shell script? Share it in the comments below. - -### about the author - -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][16], [Facebook][17], [Google+][18]. - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html - -作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz -[1]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) -[2]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) -[3]:https://www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/ (See Linux/Unix yum command examples for more info) -[4]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send.png (notify-send: Shell Script Get Or Send Desktop Notifications ) -[5]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send-with-icons-timeout.png (Linux / UNIX: Display Notifications From Your Shell Scripts With notify-send) -[6]:https://www.cyberciti.biz/media/new/tips/2010/04/tput-options.png (Linux / UNIX Script Colours and Cursor Movement With tput) -[7]:https://bash.cyberciti.biz/guide/Zenity:_Shell_Scripting_with_Gnome -[8]:https://www.cyberciti.biz/media/new/tips/2010/04/zenity-outputs.png (zenity: Linux / UNIX display Dialogs Boxes From The Shell Scripts) -[9]:https://www.cyberciti.biz/media/new/tips/2010/04/KDialog.png (Kdialog: Suppressing the display of a dialog ) -[10]:http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs -[11]:https://bash.cyberciti.biz/guide/Bash_display_dialog_boxes -[12]:https://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html -[13]:https://www.cyberciti.biz/tips/freebsd-sending-a-message-to-windows-workstation.html -[14]:https://www.cyberciti.biz/faq/bash-for-loop/ -[15]:https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/ -[16]:https://twitter.com/nixcraft -[17]:https://facebook.com/nixcraft -[18]:https://plus.google.com/+CybercitiBiz From ff62acdc404c1a31b442894dbe1df345dd3eceba Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 1 Apr 2018 19:21:01 +0800 Subject: [PATCH 0242/1057] PRF:20180109 Linux size Command Tutorial for Beginners (6 Examples).md @lujun9972 --- ...and Tutorial for Beginners (6 Examples).md | 76 +++++++++---------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/translated/tech/20180109 Linux size Command Tutorial for Beginners (6 Examples).md b/translated/tech/20180109 Linux size Command Tutorial for Beginners (6 Examples).md index 3681dfa3c6..fae2306150 100644 --- a/translated/tech/20180109 Linux size Command Tutorial for Beginners (6 Examples).md +++ b/translated/tech/20180109 Linux size Command Tutorial for Beginners (6 Examples).md @@ -1,13 +1,14 @@ 六个例子带你入门 size 命令 ====== -正如你所知道的那样,Linux 中的目标文件或着说可执行文件由多个段组成(比如 txt 和 data)。若你想知道每个段的大小,那么确实存在这么一个命令行工具 - 那就是 `size`。在本教程中,我们将会用几个简单易懂的案例来讲解该工具的基本用法。 +正如你所知道的那样,Linux 中的目标文件或着说可执行文件由多个段组成(比如文本段和数据段)。若你想知道每个段的大小,那么确实存在这么一个命令行工具 —— 那就是 `size`。在本教程中,我们将会用几个简单易懂的案例来讲解该工具的基本用法。 -在我们开始前,有必要先声明一下,本文的所有案例都在 Ubuntu 16.04LTS 中测试过了 .04LTS。 +在我们开始前,有必要先声明一下,本文的所有案例都在 Ubuntu 16.04 LTS 中测试过了。 -## Linux size 命令 +### Linux size 命令 + +`size` 命令基本上就是输出指定输入文件各段及其总和的大小。下面是该命令的语法: -size 命令基本上就是输出指定木比奥文件各段及其总和的大小。下面是该命令的语法: ``` size [-A|-B|--format=compatibility]             [--help] @@ -19,17 +20,16 @@ size [-A|-B|--format=compatibility] ``` man 页是这样描述它的: -``` -GNU的size程序列出参数列表objfile中,各目标文件(object)或存档库文件(archive)的段节(section)大小 — 以及总大小.默认情况下,对每目标文件或存档库中的每个模块都会产生一行输出. -objfile... 是待检查的目标文件(object). 如果没有指定, 则默认为文件 "a.out". -``` +> GNU 的 `size` 程序列出参数列表中各目标文件或存档库文件的段大小 — 以及总大小。默认情况下,对每个目标文件或存档库中的每个模块都会产生一行输出。 +> +> `objfile...` 是待检查的目标文件。如果没有指定,则默认为文件 `a.out`。 -下面是一些问答方式的案例,希望能让你对 size 命令有所了解。 +下面是一些问答方式的案例,希望能让你对 `size` 命令有所了解。 -## Q1。如何使用 size 命令? +### Q1、如何使用 size 命令? -size 的基本用法很简单。你只需要将目标文件/可执行文件名称作为输入就行了。下面是一个例子: +`size` 的基本用法很简单。你只需要将目标文件/可执行文件名称作为输入就行了。下面是一个例子: ``` size apl @@ -39,11 +39,11 @@ size apl [![How to use size command][1]][2] -前三部分的内容是 text,data,和 bss 段及其相应的大小。然后是十进制格式和十六进制格式的总大小。最后是文件名。 +前三部分的内容是文本段、数据段和 bss 段及其相应的大小。然后是十进制格式和十六进制格式的总大小。最后是文件名。 -## Q2。如何切换不同的输出格式? +### Q2、如何切换不同的输出格式? -根据 man 页的说法,size 的默认输出格式类似于 Berkeley 的格式。然而,如果你想的话,你也可以使用 System V 规范。要做到这一点,你可以使用 `--format` 选项加上 `SysV` 值。 +根据 man 页的说法,`size` 的默认输出格式类似于 Berkeley 的格式。然而,如果你想的话,你也可以使用 System V 规范。要做到这一点,你可以使用 `--format` 选项加上 `SysV` 值。 ``` size apl --format=SysV @@ -53,25 +53,27 @@ size apl --format=SysV [![How to switch between different output formats][3]][4] -## Q3。如何切换使用其他的单位? +### Q3、如何切换使用其他的单位? 默认情况下,段的大小是以十进制的方式来展示。然而,如果你想的话,也可以使用八进制或十六进制来表示。对应的命令行参数分别为 `o` 和 `-x`。 [![How to switch between different size units][5]][6] 关于这些参数,man 页是这么说的: -``` --d --o --x ---radix=number -使用这几个选项,你可以让各个段节的大小以十进制(`-d',或`--radix 10');八进制(`-o',或`--radix 8');或十六进制(`-x',或`--radix 16')数字的格式显示.`--radix number' 只支持三个数值参数 (8, 10, 16).总共大小以两种进制给出; `-d'或`-x'的十进制和十六进制输出,或`-o'的 八进制和 十六进制 输出. -``` +> -d -## Q4。如何让 size 命令显示所有对象文件的总大小? +> -o -如果你用 size 一次性查找多个文件的段大小,则通过使用 `-t` 选项还可以让它显示各列值的总和。 +> -x + +> --radix=number + +> 使用这几个选项,你可以让各个段的大小以十进制(`-d` 或 `--radix 10`)、八进制(`-o` 或 `--radix 8`);或十六进制(`-x` 或 `--radix 16`)数字的格式显示。`--radix number` 只支持三个数值参数(8、 10、 16)。总共大小以两种进制给出; `-d` 或 `-x` 的十进制和十六进制输出,或 `-o` 的八进制和十六进制输出。 + +### Q4、如何让 size 命令显示所有对象文件的总大小? + +如果你用 `size` 一次性查找多个文件的段大小,则通过使用 `-t` 选项还可以让它显示各列值的总和。 ``` size -t [file1] [file2] ... @@ -83,35 +85,29 @@ size -t [file1] [file2] ... `-t` 选项让它多加了最后那一行。 -## Q5。如何让 size 输出每个文件中公共符号的总大小? +### Q5、如何让 size 输出每个文件中公共符号的总大小? -若你为 size 提供多个输入文件作为参数,而且想让它显示每个文件中公共符号(指 common segment 中的 symbol) 的大小,则你可以带上 `--common` 选项。 +若你为 `size` 提供多个输入文件作为参数,而且想让它显示每个文件中公共符号(指 common segment 中的 symbol)的大小,则你可以带上 `--common` 选项。 ``` size --common [file1] [file2] ... ``` -另外需要指出的是,当使用 Berkeley 格式时,和谐公共符号的大小被纳入了 bss 大小中。 +另外需要指出的是,当使用 Berkeley 格式时,这些公共符号的大小被纳入了 bss 大小中。 -## Q6。还有什么其他的选项? +### Q6、还有什么其他的选项? -除了刚才提到的那些选项外,size 还有一些一般性的命令行选项,比如 `v` (显示版本信息) 和 `-h` (可选参数和选项的 summary) +除了刚才提到的那些选项外,`size` 还有一些一般性的命令行选项,比如 `v` (显示版本信息)和 `-h` (可选参数和选项的汇总)。 [![What are the other available command line options][9]][10] -除此之外,你也可以使用 `@file` 选项来让 size 从文件中读取命令行选项。下面是详细的相关说明: -``` -读出来的选项会插入并替代原来的@file选项。若文件不存在或着无法读取,则该选项不会被删除,而是会以字面意义来解释该选项。 +除此之外,你也可以使用 `@file` 选项来让 `size` 从文件中读取命令行选项。下面是详细的相关说明: -文件中的选项以空格分隔。当选项中要包含空格时需要用单引号或双引号将整个选项包起来。 -通过在字符前面添加一个反斜杠可以将任何字符(包括反斜杠本身)纳入到选项中。 -文件本身也能包含其他的@file选项;任何这样的选项都会被递归处理。 -``` +> 读出来的选项会插入并替代原来的 `@file` 选项。若文件不存在或着无法读取,则该选项不会被替换,而是会以字面意义来解释该选项。文件中的选项以空格分隔。当选项中要包含空格时需要用单引号或双引号将整个选项包起来。通过在字符前面添加一个反斜杠可以将任何字符(包括反斜杠本身)纳入到选项中。文件本身也能包含其他的 `@file` 选项;任何这样的选项都会被递归处理。 -## 结论 - -很明显,size 命令并不适用于所有人。它的目标群体是那些需要处理 Linux 中目标文件/可执行文件结构的人。因此,如果你刚好是目标受众,那么多试试我们这里提到的那些选项,你应该做好每天都使用这个工具的准备。想了解关于 size 的更多信息,请阅读它的 [man 页 ][11]。 +### 结论 +很明显,`size` 命令并不适用于所有人。它的目标群体是那些需要处理 Linux 中目标文件/可执行文件结构的人。因此,如果你刚好是目标受众,那么多试试我们这里提到的那些选项,你应该做好每天都使用这个工具的准备。想了解关于 `size` 的更多信息,请阅读它的 [man 页 ][11]。 -------------------------------------------------------------------------------- @@ -119,7 +115,7 @@ via: https://www.howtoforge.com/linux-size-command/ 作者:[Himanshu Arora][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 091530d9e72c5d08f37d75f3ac139094392b3402 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 1 Apr 2018 19:21:30 +0800 Subject: [PATCH 0243/1057] PUB:20180109 Linux size Command Tutorial for Beginners (6 Examples).md @lujun9972 https://linux.cn/article-9504-1.html --- ...0109 Linux size Command Tutorial for Beginners (6 Examples).md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180109 Linux size Command Tutorial for Beginners (6 Examples).md (100%) diff --git a/translated/tech/20180109 Linux size Command Tutorial for Beginners (6 Examples).md b/published/20180109 Linux size Command Tutorial for Beginners (6 Examples).md similarity index 100% rename from translated/tech/20180109 Linux size Command Tutorial for Beginners (6 Examples).md rename to published/20180109 Linux size Command Tutorial for Beginners (6 Examples).md From bcf01ecaeca3c96be73483be58d5ab3df0a4582e Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 2 Apr 2018 08:56:35 +0800 Subject: [PATCH 0244/1057] translated --- ...Supports Virtualization Technology (VT).md | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) rename {sources => translated}/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md (53%) diff --git a/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md b/translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md similarity index 53% rename from sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md rename to translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md index bf313627df..5f494db6b8 100644 --- a/sources/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md +++ b/translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md @@ -1,35 +1,33 @@ -translating---geekpi - -How To Find If A CPU Supports Virtualization Technology (VT) +如何知道 CPU 是否支持虚拟化技术 (VT) ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/Virtualization-Technology-720x340.png) -We already knew how to [**check if your Linux OS is 32 bit or 64 bit**][1] and how to [**find if your Linux system is physical or virtual machine**][2]. Today, we are going to learn yet another useful topic – how to find if a CPU supports virtualization technology (VT) or not? This should be first thing you might want to verify before installing virtualization applications such as VirtualBox or VMWare workstation to run virtual machines on your Linux system. Now let us go and find out if your computer supports VT or not. Trust me, it is really easy! +我们已经知道如何[**检查你的 Linux 操作系统是 32 位还是 64 位**] [1]以及如何[**知道你的 Linux 系统是物理机还是虚拟机**] [2]。今天,我们将学习另一个有用的话题 - 如何知道 CPU 是否支持虚拟化技术 (VT)?在安装虚拟化程序(如 VirtualBox 或 VMWare workstation)以在 Linux 系统上运行虚拟机之前,你应该首先验证这一点。现在让我们来看看你的电脑是否支持 VT。相信我,这真的很简单! -### Find If A CPU Supports Virtualization Technology (VT) +### 了解 CPU 是否支持虚拟化技术 (VT) -We can check if the CPU supports VT in several methods. Here I present you four methods. +我们可以通过几种方法检查 CPU 是否支持 VT。在这里我向你展示四种方法。 -#### Method 1: Using “egrep” command +#### 方法 1:使用 “egrep” 命令 -**Egrep** is one of the variant of [**Grep**][3] command which is used to search text files with regular expressions. For the purpose of this guide, we are going to grep **/cpu/procinfo/** file to find out if the CPU supports VT or not. +**egrep** 是 [**grep**][3] 命令的变体之一,用于使用正则表达式搜索文本文件。为了本指南的目的,我们将grep **/cpu/procinfo/** 文件来确定 CPU 是否支持 VT。 -To find out if your CPU supports VT using egrep command, run: +要使用 egrep 命令查明你的CPU是否支持VT,请运行: ``` $ egrep "(svm|vmx)" /proc/cpuinfo ``` -**Sample output:** +**示例输出** -You will get either **“vmx”** (Intel-VT technology) or **“svm”** (AMD-V support) in the output. +你将在输出中看到 **“vmx”**(Intel-VT 技术)或 **“svm”** (AMD-V 支持)。 ``` flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx lahf_lm epb pti tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts [...] ``` -Since the output is very long, you may find it hard to find the words “vmx” or “svm” in the output. No worries! You can distinguish those terms with colors like below. +由于输出很长,你可能会发现很难在输出中找到 “vmx” 或 “svm”。别担心!你可以像下面那样用颜色来区分这些术语。 ``` $ egrep --color -i "svm|vmx" /proc/cpuinfo @@ -37,21 +35,21 @@ $ egrep --color -i "svm|vmx" /proc/cpuinfo ![][5] -If you don’t get any output, it means that your system doesn’t support virtualization. +如果你没有看到任何输出,这意味着你的系统不支持虚拟化。 -Please note that these CPU flags (vmx or svm) in the cpuinfo means that your system will support VT. In some CPU models, the VT support might be disabled in the BIOS, by default. In such cases, you should check your BIOS settings to enable VT support. +请注意,cpuinfo 中的这些 CPU 标志(vmx 或 svm)表示你的系统支持 VT。在某些 CPU 型号中,默认情况下,可能会在 BIOS 中禁用 VT 支持。在这种情况下,你应该检查 BIOS 设置以启用 VT 支持。 -For more details about grep/egrep command, refer the man pages. +有关 grep/egrep 命令的更多详细信息,请参阅手册页。 ``` $ man grep ``` -#### Method 2 – Using “lscpu” command +#### 方法 2: 使用 “lscpu” 命令 -The “lscpu” command is used to display the information about your CPU architecture. It gathers information from sysfs, /proc/cpuinfo file and displays the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes of your host system. +“lscpu” 命令用于显示有关 CPU 架构的信息。它从 sysfs、/proc/cpuinfo 收集信息,并显示主机系统的 CPU、线程、内核、套接字和非统一内存访问 (NUMA) 节点的数量。 -To find out if the VT support is enabled or not, simply run: +要确定是否启用 VT 支持,只需运行: ``` $ lscpu @@ -59,55 +57,55 @@ $ lscpu ![][6] -For more details, check the man pages. +有关更多详细信息,请查看手册页。 ``` $ man lscpu ``` -#### Method 3 – Using “Cpu-checker” utility +#### 方法 3:使用 “Cpu-checker” 工具 -**Cpu-checker** is yet another useful utility to test your CPU for virtualization support. As far as I searched on the web, this utility is available for only Ubuntu-based systems. To install it, run: +**Cpu-checker** 是另一个有用的工具,用于测试你的 CPU 是否支持虚拟化。就我在网上搜索得到的,该程序仅适用于基于 Ubuntu 的系统。要安装它,请运行: ``` $ sudo apt-get install cpu-checker ``` -Once cpu-checker package is installed, run the following command to check whether VT support is enable or not: +安装 cpu-checker 包之后,运行以下命令来检查是否启用 VT 支持: ``` $ sudo kvm-ok ``` -If your CPU supports VT, you will get the following output: +如果您的 CPU 支持 VT,你将得到以下输出: ``` INFO: /dev/kvm exists KVM acceleration can be used ``` -If your CPU doesn’t support VT, you will see an output something like below. +如果你的 CPU 不支持 VT,你会看到如下的输出。 ``` INFO: Your CPU does not support KVM extensions KVM acceleration can NOT be used ``` -#### Method 4 – Using “virt-host-validate ” tool +#### 方法 4:使用 “virt-host-validate” 工具 -This tool is specifically for RHEL based distros like CentOS and Scientific Linux. The **libvirt-client** package provides **virt-host-validate** binary. So you need to install “libvert-client” package to use this tool. +该工具专门用于基于 RHEL 的发行版,如 CentOS 和 Scientific Linux。 **libvirt-client** 包提供 **virt-host-validate** 二进制文件。所以你需要安装 “libvert-client” 包来使用这个工具。 ``` $ sudo yum install libvirt-client ``` -Now, run “virt-host-validate” command to find if VT is enabled or not in your RHEL-based systems. +现在,运行 “virt-host-validate” 命令来确定基于 RHEL 的系统中是否启用了 VT。 ``` $ sudo virt-host-validate ``` -If you get **pass** for all results, your system supports VT. +如果所有的结果是 **pass**,那么你的系统支持 VT。 ``` QEMU: Checking for hardware virtualization : PASS QEMU: Checking if device /dev/vhost-net exists : PASS @@ -147,16 +145,16 @@ If you get **pass** for all results, your system supports VT. ``` -If your system doesn’t support VT, you will see an output like below. +如果你的系统不支持 VT,你会看到下面的输出。 ``` QEMU: Checking for hardware virtualization : FAIL (Only emulated CPUs are available, performance will be significantly limited) [...] ``` -And, that’s all for now folks. In this guide, we have discussed various methods to find if a CPU supports VT or not. As you can see, it was very easy. Hope this was useful. More good stuffs to come. Stay tuned! +就是这样了。在本文中,我们讨论了确定 CPU 是否支持 VT 的不同方法。如你所见,这很简单。希望这个有用。还有更多好的东西。敬请关注! -Cheers! +干杯! -------------------------------------------------------------------------------- @@ -164,7 +162,7 @@ Cheers! via: https://www.ostechnix.com/how-to-find-if-a-cpu-supports-virtualization-technology-vt/ 作者:[SK][a] -译者:[译者ID](https://github.com/译者ID) +译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e8af88bce285b4e7f863cdc1f1c37e6873fb9f2d Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 2 Apr 2018 09:00:56 +0800 Subject: [PATCH 0245/1057] translating --- sources/tech/20180328 How To Use Instagram In Terminal.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180328 How To Use Instagram In Terminal.md b/sources/tech/20180328 How To Use Instagram In Terminal.md index bfa1149c15..a1dc7102c7 100644 --- a/sources/tech/20180328 How To Use Instagram In Terminal.md +++ b/sources/tech/20180328 How To Use Instagram In Terminal.md @@ -1,3 +1,5 @@ +translating---geekpi + How To Use Instagram In Terminal ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-720x340.png) From 17e2e117f1ce57b922cc38621a149495d795a400 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 2 Apr 2018 09:40:53 +0800 Subject: [PATCH 0246/1057] PRF:20171014 Proxy Models in Container Environments.md @geekpi --- ... Proxy Models in Container Environments.md | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/translated/tech/20171014 Proxy Models in Container Environments.md b/translated/tech/20171014 Proxy Models in Container Environments.md index 4e5b329d68..3592ce567e 100644 --- a/translated/tech/20171014 Proxy Models in Container Environments.md +++ b/translated/tech/20171014 Proxy Models in Container Environments.md @@ -1,41 +1,43 @@ 容器环境中的代理模型 ============================================================ -### 我们大多数人都熟悉代理如何工作,但在基于容器的环境中有什么不同?看看有什么改变。 +> 我们大多数人都熟悉代理如何工作,但在基于容器的环境中有什么不同?让我们来看看有什么改变。 -内联,side-arm,反向和前向。这些曾经是我们用来描述网络代理架构布局的术语。 +内联、侧臂side-arm、反向和前向。这些曾经是我们用来描述网络代理架构布局的术语。 如今,容器使用一些相同的术语,但它们正在引入新的东西。这对我是个机会来阐述我最爱的所有主题:代理。 -云的主要驱动之一(我们曾经有过成果控制的白日梦)就是可扩展性。在过去五年中,扩展在各种调查中面临着敏捷性的挑战(有时甚至获胜),因为这是机构在云计算环境中部署应用的最大追求。 +云的主要驱动之一(我们曾经有过成本控制的白日梦)就是可扩展性。在过去五年中,扩展在各种调查中面临着敏捷性的挑战(有时甚至获胜),因为这是机构在云计算环境中部署应用的最大追求。 -这在一定程度上是因为在数字经济 (我们现在运营的) 中,应用已经成为数字等同于实体店的“开放/关闭”的标志和数字客户援助的体现。缓慢、无响应的应用程序等同于把灯关闭或者商店人员不足。 +这在一定程度上是因为在(我们现在运营的)数字经济中,应用已经成为像实体店的“营业/休息”的标牌和导购一样的东西。缓慢、无响应的应用如同商店关灯或缺少营业人员一样。 -应用程序需要可用且响应满足需求。扩展是实现这一业务目标的技术响应。云不仅提供了扩展的能力,而且还提供了_自动_扩展的能力。要做到这一点,需要一个负载均衡器。因为这就是我们扩展应用程序的方式 - 使用代理负载均衡流量/请求。 + [![](https://devcentral.f5.com/Portals/0/Users/038/38/38/unavailable_is_closed_thumb.png?ver=2017-09-12-082119-957)][4] + +应用需要随时可用且能够满足需求。扩展是实现这一业务目标的技术响应。云不仅提供了扩展的能力,而且还提供了_自动_扩展的能力。要做到这一点,需要一个负载均衡器。因为这就是我们扩展应用程序的方式 :使用代理来负载均衡流量/请求。 -容器在扩展上与预期没有什么不同。容器必须进行扩展 - 并自动扩展 - 这意味着使用负载均衡器(代理)。 +容器在扩展上与预期没有什么不同。容器必须进行扩展(并自动扩展)这意味着使用负载均衡器(代理)。 -如果你使用的是本机,则你正在基于 TCP/UDP 进行基本的负载平衡。一般来说,基于容器的代理实现在 HTTP 或其他应用层协议中不流畅,除了一般的旧的负载均衡([POLB][1])之外,不提供其他功能。这通常足够好,因为容器扩展是在一个克隆的水平预置环境中进行的 - 要扩展一个应用程序,添加另一个副本并在其上分发请求。在入口处(在[入口控制器][2]和 API 网关中)可以找到第 7 层(HTTP)路由功能,并且可以使用尽可能多(或更多)的应用程序路由来扩展应用程序。 +如果你使用的是原有的代理机制,那就是采用基于 TCP/UDP 进行基本的负载平衡。一般来说,基于容器的代理的实现在 HTTP 或其他应用层协议中并不流畅,并不能在旧式的负载均衡([POLB][1])之外提供其他功能。这通常足够了,因为容器扩展是在一个克隆的、假定水平扩展的环境中进行的:要扩展一个应用程序,就添加另一个副本并在其上分发请求。在入口处(在[入口控制器][2]和 API 网关中)可以找到第 7 层(HTTP)路由功能,并且可以使用尽可能多(或更多)的应用路由来扩展应用程序。 -然而,在某些情况下,这还不够。如果你希望(或需要)更多以应用程序为中心的扩展或插入其他服务的能力,那么你将获得更健壮的产品,可提供可编程性或以应用程序为中心的可伸缩性,或者两者兼而有之。 +然而,在某些情况下,这还不够。如果你希望(或需要)更多以应用程序为中心的扩展或插入其他服务的能力,那么你就可以获得更健壮的产品,可提供可编程性或以应用程序为中心的可伸缩性,或者两者兼而有之。 -这意味着[插入代理][3]。你正在使用的容器编排环境在很大程度上决定了代理的部署模型,无论它是反向代理还是前向代理。为了让事情有趣,还有第三个模型 - sidecar - 这是由新兴的服务网格实现支持的可扩展性的基础。 +这意味着[插入代理][3]。你正在使用的容器编排环境在很大程度上决定了代理的部署模型,无论它是反向代理还是前向代理。更有趣的是,还有第三个模型挎斗模式 ,这是由新兴的服务网格实现支持的可扩展性的基础。 ### 反向代理 - [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/unavailable_is_closed_thumb.png?ver=2017-09-12-082119-957 "Image title")][4] +![](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-app_reverse_proxy.jpg) -反向代理最接近于传统模型,在这种模型中,虚拟服务器接受所有传入请求,并将其分发到资源池(服务器中心,集群)中。 +反向代理最接近于传统模型,在这种模型中,虚拟服务器接受所有传入请求,并将其分发到资源池(服务器中心、集群)中。 -每个“应用程序”有一个代理。任何想要连接到应用程序的客户端连接到代理,代理然后选择并转发请求到适当的实例。如果绿色应用想要与蓝色应用通信,它会向蓝色代理发送请求,蓝色代理会确定蓝色应用的两个实例中的哪一个应该响应该请求。 +每个“应用程序”有一个代理。任何想要连接到应用程序的客户端都连接到代理,代理然后选择并转发请求到适当的实例。如果绿色应用想要与蓝色应用通信,它会向蓝色代理发送请求,蓝色代理会确定蓝色应用的两个实例中的哪一个应该响应该请求。 在这个模型中,代理只关心它正在管理的应用程序。蓝色代理不关心与橙色代理关联的实例,反之亦然。 ### 前向代理 - [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-node_forward_proxy_thumb.jpg?ver=2017-09-14-072422-213)][5] + [![](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-node_forward_proxy.jpg?ver=2017-09-14-072422-213)][5] -这种模式更接近传统出站防火墙的模式。 +这种模式更接近传统的出站防火墙的模式。 在这个模型中,每个容器 **节点** 都有一个关联的代理。如果客户端想要连接到特定的应用程序或服务,它将连接到正在运行的客户端所在的容器节点的本地代理。代理然后选择一个适当的应用实例,并转发客户端的请求。 @@ -43,31 +45,31 @@ 在这个模型中,每个代理必须知道每个应用,以确保它可以将请求转发给适当的实例。 -### sidecar 代理 +### 挎斗代理 - [![Image title](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-pod_sidecar_proxy_thumb.jpg?ver=2017-09-14-072425-620)][6] + [![](https://devcentral.f5.com/Portals/0/Users/038/38/38/per-pod_sidecar_proxy.jpg?ver=2017-09-14-072425-620)][6] 这种模型也被称为服务网格路由。在这个模型中,每个**容器**都有自己的代理。 -如果客户想要连接到一个应用,它将连接到 sidecar 代理,它会选择一个合适的应用程序实例并转发客户端的请求。此行为与_前向代理_模型相同。 +如果客户想要连接到一个应用,它将连接到挎斗代理,它会选择一个合适的应用程序实例并转发客户端的请求。此行为与_前向代理_模型相同。 -sidecar 和前向代理之间的区别在于,sidecar 代理不需要修改容器编排环境。例如,为了插入一个前向代理到 k8s,你需要代理_和_一个 kube-proxy 的替代。sidecar 代理不需要此修改,因为应用会自动连接到 “sidecar” 代理而不是通过代理路由。 +挎斗代理和前向代理之间的区别在于,挎斗代理不需要修改容器编排环境。例如,为了插入一个前向代理到 k8s,你需要代理_和_一个 kube-proxy 的替代。挎斗代理不需要这种修改,因为应用会自动连接到 “挎斗” 代理而不是通过代理路由。 ### 总结 -每种模式都有其优点和缺点。三者共同依赖环境数据(远程监控和配置变化),以及融入生态系统的需求。有些模型是根据你选择的环境预先确定的,因此需要仔细考虑将来的需求 - 服务插入、安全性、网络复杂性 - 在建立模型之前需要进行评估。 +每种模式都有其优点和缺点。三者共同依赖环境数据(远程监控和配置变化),以及融入生态系统的需求。有些模型是根据你选择的环境预先确定的,因此需要仔细考虑将来的需求(服务插入、安全性、网络复杂性)在建立模型之前需要进行评估。 在容器及其在企业中的发展方面,我们还处于早期阶段。随着它们继续延伸到生产环境中,了解容器化环境发布的应用程序的需求以及它们在代理模型实现上的差异是非常重要的。 -我是急性写下这篇文章的。现在就这么多。 +这篇文章是匆匆写就的。现在就这么多。 -------------------------------------------------------------------------------- via: https://dzone.com/articles/proxy-models-in-container-environments -作者:[Lori MacVittie ][a] +作者:[Lori MacVittie][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 bbae68a7bb56dc41c4582f1e2a7033c31ce634d0 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 2 Apr 2018 09:41:32 +0800 Subject: [PATCH 0247/1057] PUB:20171014 Proxy Models in Container Environments.md @geekpi --- .../20171014 Proxy Models in Container Environments.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171014 Proxy Models in Container Environments.md (100%) diff --git a/translated/tech/20171014 Proxy Models in Container Environments.md b/published/20171014 Proxy Models in Container Environments.md similarity index 100% rename from translated/tech/20171014 Proxy Models in Container Environments.md rename to published/20171014 Proxy Models in Container Environments.md From 317ad8c0e70b6aba220efade61b2e688ce355ff7 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 2 Apr 2018 10:14:38 +0800 Subject: [PATCH 0248/1057] PRF:20180222 How to configure an Apache web server.md @amwps290 --- ...2 How to configure an Apache web server.md | 134 +++++------------- 1 file changed, 37 insertions(+), 97 deletions(-) diff --git a/translated/tech/20180222 How to configure an Apache web server.md b/translated/tech/20180222 How to configure an Apache web server.md index a6c0d2cd73..20f0e7d5c8 100644 --- a/translated/tech/20180222 How to configure an Apache web server.md +++ b/translated/tech/20180222 How to configure an Apache web server.md @@ -1,23 +1,25 @@ -# 配置 Apache Web 服务器 +如何配置 Apache Web 服务器 +========== + +> 学习如何在 Apache 上托管你自己的网站,这是一个可靠、流行且易于配置的 Web 服务器。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) -我自己的网站已经有很多年了。自从 20 多年前从 OS/2 切换到 Linux 以来,我已经将 [Apache][1] 作为我的服务器软件。Apache 是可靠的、众所周知的,并且基本的安装配置也很容易。对于更复杂的设置(比如多个网站)并不是那么困难。 +我托管自己的网站已经有很多年了。自从 20 多年前从 OS/2 切换到 Linux 以来,我一直将 [Apache][1] 作为我的服务器软件。Apache 是可靠、流行的,且基本的安装配置也很容易。对于更复杂的设置(比如多个网站)也并不是那么困难。 Apache Web 服务器的安装和配置必须以 root 身份执行。 防火墙的配置也需要以 root 身份执行。 使用浏览器查看安装配置的结果应该以非 root 用户的身份完成。 (我在我的虚拟主机上使用 `student` 这个用户。) ### 安装 -注意:我使用的实验环境是安装有 Fedora 27 的虚拟机,Apache 版本为 2.4.29。 如果您使用的是不同的发行版或不同版本的Fedora,您的命令以及配置文件的位置和内容可能会有所不同。 但是,您需要修改的配置行是相同的。 +注意:我使用的实验环境是安装有 Fedora 27 的虚拟机,Apache 版本为 2.4.29。 如果您使用的是不同的发行版或不同版本的 Fedora,您的命令以及配置文件的位置和内容可能会有所不同。 但是,您需要修改的配置行是相同的。 Apache Web 服务器非常容易安装。 在我的 CentOS 6.x 服务器上,它只需要一个简单的 `yum` 命令。 它会安装所有必要的依赖(如果需要的话)。 我在我的 Fedora 虚拟机上使用了下面的 `dnf` 命令。 除了命令本身的名称之外, `dnf` 和 `yum` 的语法是相同的。 ``` dnf -y install httpd - ``` -VM (虚拟机) 非常容易安装,我正在使用它作为编写书籍的测试平台。 即使在这个系统上,在一分钟内只安装了六个依赖项。 +这个虚拟机是个非常基础的桌面环境,我正在使用它作为编写书籍的测试平台。 即使在这个系统上,也只安装了六个依赖项,用了一分钟。 Apache 的所有配置文件都位于 `/etc/httpd/conf` 和 `/etc/httpd/conf.d` 。网站的数据默认位于 `/var/www`,但如果你愿意,你可以改变它。 @@ -25,203 +27,141 @@ Apache 的所有配置文件都位于 `/etc/httpd/conf` 和 `/etc/httpd/conf.d` Apache 主要的配置文件是 `/etc/httpd/conf/httpd.conf` 。 它包含许多在基本安装中不需要更改的配置。 实际上,只需对此文件进行一些更改即可启动并运行一个简单的网站。 该文件非常大,因此,我不会将这篇文章与大量不必要的东西混淆起来,而只会显示那些需要更改的指令。 -首先,花点时间熟悉一下 `httpd.conf` 文件。我喜欢 Red Hat 的一个原因是它的配置文件注释非常的详细。 `httpd.conf` 文件也不例外,因为它有很好的注释。 使用这些注释来了解文件的配置。 +首先,花点时间熟悉一下 `httpd.conf` 文件。我喜欢 Red Hat 的一个原因是它的配置文件注释非常的详细。 `httpd.conf` 文件也不例外,因为它有很好的注释。可以使用这些注释来了解文件的配置。 -第一个要修改的是 `Listen` 配置项,它定义了 Apache 要监听页面请求的 IP 地址和端口。 现在,你只需要使这个网站可以从本地访问,所以使用 `localhost` 地址。 完成后,该行应该看起来像这样:( LCTT 注:localhost 既是 127.0.0.1,80 是端口) +第一个要修改的是 `Listen` 配置项,它定义了 Apache 要监听页面请求的 IP 地址和端口。 现在,你只需要使这个网站可以从本地访问,所以使用 `localhost` 地址。 完成后,该行应该看起来像这样:( LCTT 译注:`localhost` 的 IP 地址是 `127.0.0.1`,`80` 是端口) ``` Listen 127.0.0.1:80 - ``` -通过将此配置项设置为`localhost`的 IP 地址,Apache 将只侦听来自本地主机的连接。 如果您希望 Web 服务器侦听来自远程主机的连接,则可以使用主机的外部 IP 地址。 +通过将此配置项设置为 `localhost`的 IP 地址,Apache 将只侦听来自本地主机的连接。 如果您希望 Web 服务器侦听来自远程主机的连接,则可以使用主机的外部 IP 地址。 `DocumentRoot` 配置项指定组成网站页面的 HTML 文件的位置。 该配置项不需要更改,因为它已经指向标准位置。 该行应该看起来像这样: ``` DocumentRoot "/var/www/html" - ``` -Apache 安装包创建 `/var /www` 目录。 如果您想更改存储网站文件的位置,则使用此配置项来完成此操作。 例如,您可能想要为 `www` 子目录使用不同的名称,以更明确地识别网站。 这可能是这样的: +Apache 安装包会创建 `/var/www` 目录。 如果您想更改存储网站文件的位置,则使用此配置项来完成此操作。 例如,您可能想要为 `www` 目录使用不同的名称,以更明确地识别网站。 这可以是这样的: ``` DocumentRoot "/var/mywebsite/html" - ``` 这些是创建一个简单网站需要唯一修改的 Apache 配置项。 对于这个小练习,只对 `httpd.conf` 文件(`Listen` 配置项)进行了一些修改。 其它的配置项对于一个简单的 Web 服务器暂时无需配置。 -另一个需要改变的地方是:在我们的防火墙中打开端口 80。 我使用 [iptables][2] 作为我的防火墙,因此我更改 `/etc/ sysconfig/iptables` 文件以添加允许使用 HTTP 协议。 整个文件看起来像这样: +另一个需要改变的地方是:在我们的防火墙中打开端口 80。 我使用 [iptables][2] 作为我的防火墙,因此我更改 `/etc/sysconfig/iptables` 文件以添加允许使用 HTTP 协议。 整个文件看起来像这样: ``` # sample configuration for iptables service - # you can edit this manually or use system-config-firewall - # please do not ask us to add additional ports/services to this default configuration - *filter - :INPUT ACCEPT [0:0] - :FORWARD ACCEPT [0:0] - :OUTPUT ACCEPT [0:0] - -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT - -A INPUT -p icmp -j ACCEPT - -A INPUT -i lo -j ACCEPT - -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT - -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT - -A INPUT -j REJECT --reject-with icmp-host-prohibited - -A FORWARD -j REJECT --reject-with icmp-host-prohibited - COMMIT - ``` -我在文件的倒数第三行上添加了一个新行,它允许在端口 80 上输入流量。现在我重新加载 iptables 配置文件。 +我在文件的倒数第三行上添加了一个新行,它允许在端口 `80` 上输入流量。现在我重新加载 iptables 配置文件。 ``` [root@testvm1 ~]# cd /etc/sysconfig/ ; iptables-restore iptables - ``` ### 创建 index.html 文件 -`index.html` 文件是你使用域名访问网站而不是访问特定网页时的默认文件。在 `/var/www/html `中,创建一个名字为 `index.html` 的文件,在其中添加 `Hello World` 。你不需要添加任何的 HTML 标志去完成这项工作。web 服务器的唯一任务是提供文本数据流,服务器不知道日期是什么,也不知道如何呈现数据流。它只是将数据流传输给请求主机。 +`index.html` 文件是你使用域名访问网站而不是访问特定网页时的默认文件。在 `/var/www/html`中,创建一个名字为 `index.html` 的文件,在其中添加字符串 `Hello World` 。你不需要添加任何的 HTML 标志去完成这项工作。web 服务器的唯一任务是提供文本数据流,服务器不知道数据是什么,也不知道如何呈现它。它只是将数据流传输给请求主机。 保存文件后,将所有权设置为 `apache.apache` 。 ``` [root@testvm1 html]# chown apache.apache index.html - ``` ### 启动 Apache -Apache 很容易启动。 当前版本的 Fedora 使用 `systemd` 。 运行以下命令启动它,然后检查服务器的状态:(LCTT 注:systemctl 是一个 systemd 工具) +Apache 很容易启动。 当前版本的 Fedora 使用 systemd 。 运行以下命令启动它,然后检查服务器的状态:(LCTT 译注:`systemctl` 是一个 systemd 工具) ``` [root@testvm1 ~]# systemctl start httpd - [root@testvm1 ~]# systemctl status httpd - ● httpd.service - The Apache HTTP Server - -   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) - -   Active: active (running) since Thu 2018-02-08 13:18:54 EST; 5s ago - -     Docs: man:httpd.service(8) - - Main PID: 27107 (httpd) - -   Status: "Processing requests..." - -    Tasks: 213 (limit: 4915) - -   CGroup: /system.slice/httpd.service - -           ├─27107 /usr/sbin/httpd -DFOREGROUND - -           ├─27108 /usr/sbin/httpd -DFOREGROUND - -           ├─27109 /usr/sbin/httpd -DFOREGROUND - -           ├─27110 /usr/sbin/httpd -DFOREGROUND - -           └─27111 /usr/sbin/httpd -DFOREGROUND - - + Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) + Active: active (running) since Thu 2018-02-08 13:18:54 EST; 5s ago + Docs: man:httpd.service(8) + Main PID: 27107 (httpd) + Status: "Processing requests..." + Tasks: 213 (limit: 4915) + CGroup: /system.slice/httpd.service + ├─27107 /usr/sbin/httpd -DFOREGROUND + ├─27108 /usr/sbin/httpd -DFOREGROUND + ├─27109 /usr/sbin/httpd -DFOREGROUND + ├─27110 /usr/sbin/httpd -DFOREGROUND + └─27111 /usr/sbin/httpd -DFOREGROUND Feb 08 13:18:54 testvm1 systemd[1]: Starting The Apache HTTP Server... - Feb 08 13:18:54 testvm1 systemd[1]: Started The Apache HTTP Server. - ``` -您的服务器上的命令可能不同。在使用 SystemV 启动脚本的Linux系统上,命令如下: +您的服务器上的命令可能不同。在使用 SystemV 启动脚本的 Linux 系统上,命令如下: ``` [root@testvm1 ~]# service httpd start - Starting httpd: [Fri Feb 09 08:18:07 2018]          [  OK  ] - [root@testvm1 ~]# service httpd status - httpd (pid  14649) is running... - ``` -如果您的主机上有像 Firefox 或 Chrome 这样的浏览器,您可以在浏览器的 URL 行上使用 URL `localhost` 来显示您的 web 页面,尽管它很简单。您还可以使用像 [Lynx][3] 这样的文本模式 web 浏览器来查看 web 页面。首先,安装 Lynx (如果它还没有被安装)。 +如果您的主机上有像 Firefox 或 Chrome 这样的浏览器,您可以在浏览器的 URL 行上使用 URL `localhost` 来显示您的 web 页面,尽管看起来很简单。您还可以使用像 [Lynx][3] 这样的文本模式 web 浏览器来查看 web 页面。首先,安装 Lynx (如果它还没有被安装)。 ``` [root@testvm1 ~]# dnf -y install lynx - ``` 然后使用下面的命令来显示网页。 ``` [root@testvm1 ~]# lynx localhost - ``` 结果在我的终端中是这样的。我已经删除了页面上的很多空白。 ``` -  Hello World - - + Hello World - - - Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. - -  Arrow keys: Up and Down to move.  Right to follow a link; Left to go back. - - H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list - -``` + Arrow keys: Up and Down to move. Right to follow a link; Left to go back. + H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list``` 接下来,编辑您的 `index.html` 文件并添加一些 HTML 标记,使其看起来像这样: ```

Hello World

- ``` -现在刷新浏览器。对于 Lynx,使用组合键 Ctrl + R 。 结果看起来有点不同。如果你的终端支持彩色的话文本是彩色显示的,Lynx 会显示标题,现在它处于居中状态。 在 GUI 浏览器中,文本将以大字体显示。 +现在刷新浏览器。对于 Lynx,使用组合键 `Ctrl + R` 。 结果看起来有点不同。如果你的终端支持彩色的话文本是彩色显示的,Lynx 会显示标题,现在它处于居中状态。 在 GUI 浏览器中,文本将以大字体显示。 ``` -                                   Hello World - - + Hello World - - - Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. - -  Arrow keys: Up and Down to move.  Right to follow a link; Left to go back. - - H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list - + Arrow keys: Up and Down to move. Right to follow a link; Left to go back. + H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list ``` ### 后记 @@ -236,7 +176,7 @@ via: https://opensource.com/article/18/2/how-configure-apache-web-server 作者:[David Both][a] 译者:[amwps290](https://github.com/amwps290) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 16cc715001559f1726b119fd182a0e53a1fc628b Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 2 Apr 2018 10:15:06 +0800 Subject: [PATCH 0249/1057] PUB:20180222 How to configure an Apache web server.md @amwps290 https://linux.cn/article-9506-1.html --- .../20180222 How to configure an Apache web server.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180222 How to configure an Apache web server.md (100%) diff --git a/translated/tech/20180222 How to configure an Apache web server.md b/published/20180222 How to configure an Apache web server.md similarity index 100% rename from translated/tech/20180222 How to configure an Apache web server.md rename to published/20180222 How to configure an Apache web server.md From e1c62a1d5485d74ac6f8784884965d925698751e Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 2 Apr 2018 10:20:04 +0800 Subject: [PATCH 0250/1057] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- published/20180222 How to configure an Apache web server.md | 1 + 1 file changed, 1 insertion(+) diff --git a/published/20180222 How to configure an Apache web server.md b/published/20180222 How to configure an Apache web server.md index 20f0e7d5c8..dd8d68cf2b 100644 --- a/published/20180222 How to configure an Apache web server.md +++ b/published/20180222 How to configure an Apache web server.md @@ -144,6 +144,7 @@ httpd (pid  14649) is running... Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. Arrow keys: Up and Down to move. Right to follow a link; Left to go back. H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list``` +``` 接下来,编辑您的 `index.html` 文件并添加一些 HTML 标记,使其看起来像这样: From ff92e7ea7025b1256b36a552a16a3aecdec82b24 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 2 Apr 2018 13:09:48 +0800 Subject: [PATCH 0251/1057] Translated by qhwdw --- ...ve into BPF a list of reading material.md} | 207 ++++++++++-------- 1 file changed, 121 insertions(+), 86 deletions(-) rename translated/tech/{20171102 Dive into BPF a list of reading material.md => 20180308 Dive into BPF a list of reading material.md} (64%) diff --git a/translated/tech/20171102 Dive into BPF a list of reading material.md b/translated/tech/20180308 Dive into BPF a list of reading material.md similarity index 64% rename from translated/tech/20171102 Dive into BPF a list of reading material.md rename to translated/tech/20180308 Dive into BPF a list of reading material.md index 91f907436c..a2b3754d5d 100644 --- a/translated/tech/20171102 Dive into BPF a list of reading material.md +++ b/translated/tech/20180308 Dive into BPF a list of reading material.md @@ -63,23 +63,23 @@ # 什么是 BPF? -BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第一个字母的组合,最初构想于 1992 年,是为了提供一种过滤包的方法,以避免从内核到用户空间的无用的数据包副本。它最初是由从用户空间注入到内核的一个简单的字节码构成,它在哪里通过一个校验器进行检查 — 以避免内核崩溃或者安全问题 — 并附加到一个套接字上,然后运行在每个接收到的包上。几年后它被移植到 Linux 上,并且应用于一小部分应用程序上(例如,tcpdump)。简化的语言以及存在于内核中的即时编译器(JIT),使 BPF 成为一个性能卓越的工具。 +BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第一个字母的组合,在 1992 年提出最初的设想,它的目的是为了提供一种过滤包的方法,并且要避免这种从内核空间到用户空间的没用的数据包复制行为。它最初是由从用户空间注入到内核的一个简单的字节码构成,它在那个位置利用一个校验器进行检查 —— 以避免内核崩溃或者安全问题 —— 并附加到一个套接字上,接着在每个接收到的包上运行。几年后它被移植到 Linux 上,并且应用于一小部分应用程序上(例如,tcpdump)。简化的语言以及存在于内核中的即时编译器(JIT),使 BPF 成为一个性能卓越的工具。 -然后,在 2013 年,Alexei Starovoitov 对 BPF 进行彻底地改造,并增加了新的功能,改善了它的性能。这个新版本被命名为 eBPF (意思是 “extended BPF”),同时将以前的变成 cBPF(意思是 “classic” BPF)。出现了如映射(maps)和 tail 调用(calls)。JIT 编译器被重写了。新的语言比 cBPF 更接近于原生机器语言。并且,在内核中创建了新的附加点。 +然后,在 2013 年,Alexei Starovoitov 对 BPF 进行彻底地改造,并增加了新的功能,改善了它的性能。这个新版本被命名为 eBPF (意思是 “extended BPF”),与此同时,将以前的 BPF 变成 cBPF(意思是 “classic” BPF)。新版本出现了如映射和尾调用这样的新特性,并且 JIT 编译器也被重写了。新的语言比 cBPF 更接近于原生机器语言。并且,在内核中创建了新的附加点。 -感谢那些新的钩子,eBPF 程序才可以被设计用于各种各样的使用案例,它分为两个应用领域。其中一个应用领域是内核跟踪和事件监控。BPF 程序可以被附加到 kprobes,并且它与其它跟踪模式相比,有很多的优点(有时也有一些缺点)。 +感谢那些新的钩子,eBPF 程序才可以被设计用于各种各样的使用案例,它分为两个应用领域。其中一个应用领域是内核跟踪和事件监控。BPF 程序可以被附加到探针,而且它与其它跟踪模式相比,有很多的优点(有时也有一些缺点)。 -其它的应用领域是网络程序。除了套接字过滤器,eBPF 程序可以附加到 tc(Linux 流量控制工具) ingress 或者 egress 接口,并且用一种高效的方式去执行各种包处理任务。它在这个领域打开了一个新的思路。 +另外一个应用领域是网络编程。除了套接字过滤器外,eBPF 程序还可以附加到 tc(Linux 流量控制工具)的入站或者出站接口上,以一种很高效的方式去执行各种包处理任务。这种使用方式在这个领域开创了一个新的天地。 -并且 eBPF 的性能通过为 IO Visor 项目开发的技术进一步得到提升:也为 XDP(“eXpress Data Path”)增加了新的钩子,它是不久前增加到内核中的一种新的快速路径。XDP 与 Linux 栈一起工作,并且依赖 BPF 去执行更快的包处理。 +并且 eBPF 通过使用为 IO Visor 项目开发的技术,使它的性能进一步得到提升:也为 XDP(“eXpress Data Path”)添加了新的钩子,XDP 是不久前添加到内核中的一种新式快速路径。XDP 与 Linux 栈组合,然后使用 BPF ,使包处理的速度更快。 -甚至一些项目,如 P4、Open vSwitch、[考虑][155] 或者开始去接近(approach)BPF。其它的一些,如 CETH、Cilium,则是完全基于它的。BPF 是如此流行,因此,我们可以预计到不久后,将围绕它有很多工具和项目出现 … +甚至一些项目,如 P4、Open vSwitch,[考虑][155] 或者开始去接洽使用 BPF。其它的一些,如 CETH、Cilium,则是完全基于它的。BPF 是如此流行,因此,我们可以预计,不久之后,将围绕它有更多工具和项目出现 … # 深入理解字节码 -就像我一样:我的一些工作(包括 [BEBA][156])是非常依赖 eBPF 的,并且在这个网站上以后的几篇文章将关注于这个主题。从逻辑上说,在这篇文章中我在深入到细节之前,希望以某种方式去介绍 BPF — 我的意思是,一个真正的介绍,更多的在 BPF 上开发的功能,它在开始节已经提供了一些简短的摘要:什么是 BPF 映射? Tail 调用?内部结构是什么样子?等等。但是,在这个网站上已经有很多这个主题的介绍了,并且,我也不希望去创建 “另一个 BPF 介绍” 的重复的文章。 +就像我一样:我的一些工作(包括 [BEBA][156])是非常依赖 eBPF 的,并且在这个网站上以后的几篇文章将关注于这个主题。这篇文章的基本逻辑是,在深入到细节之前,我希望以某种方式去介绍 BPF —— 我的意思是,更多地介绍在 BPF 上开发的新功能,它在开始节已经提供了一些简短的概述:什么是 BPF 映射?尾调用?内部结构是什么样子?等等。但是,在这个网站上已经有很多这个主题的介绍了,而且,我也不希望去写另一篇 “BPF 介绍” 的重复文章。 -毕竟,我花费了很多的时间去阅读和学习关于 BPF 的知识,并且,也是这么做的,因此,在这里我们将要做的是,我收集了非常多的关于 BPF 的阅读材料:介绍、文档、也有教程或者示例。这里有很多的材料可以去阅读,但是,为了去阅读它,首先要去 _找到_ 它。因此,为了能够帮助更多想去学习和使用 BPF 的人,现在的这篇文章是介绍了一个资源列表。这里有各种阅读材料,它可以帮你深入理解内核字节码的机制。 +毕竟,我花费了很多的时间去阅读和学习关于 BPF 的知识,因此,在这里我们将要做什么呢,我收集了非常多的关于 BPF 的阅读材料:介绍、文档、也有教程或者示例。这里有很多的材料可以去阅读,但是,为了去阅读它,首先要去 _找到_ 它。因此,为了能够帮助更多想去学习和使用 BPF 的人,现在的这篇文章是介绍了一个资源清单。这里有各种阅读材料,它可以帮你深入理解内核字节码的机制。 # 资源 @@ -93,10 +93,13 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 关于 eBPF 的简介: +* [*全面介绍 eBPF*][193](Matt Flemming,on LWN.net,December 2017): +一篇写的很好的,并且易于理解的,介绍 eBPF 子系统组件的概述文章。 + * [_利用 BPF 和 XDP 实现可编程的内核网络数据路径_][53]  (Daniel Borkmann, OSSNA17, Los Angeles, September 2017): 快速理解所有的关于 eBPF 和 XDP 的基础概念的许多文章中的一篇(大多数是关于网络处理的) -* [BSD 包过滤器][54] (Suchakra Sharma, June 2017):  +* [*BSD 包过滤器*][54] (Suchakra Sharma, June 2017):  一篇非常好的介绍文章,大多数是关于跟踪方面的。 * [_BPF:跟踪及更多_][55]  (Brendan Gregg, January 2017): @@ -119,7 +122,7 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 **BPF 内部结构**: -* Daniel Borkmann 正在做的一项令人称奇的工作,它用于去展现 eBPF 的 **内部结构**,特别是通过几次关于 **eBPF 用于 tc ** 的演讲和论文。 +* Daniel Borkmann 正在做的一项令人称奇的工作,它用于去展现 eBPF 的 **内部结构**,尤其是,它的关于 **eBPF 用于 tc ** 的几次演讲和论文。 * [_使用 tc 的 cls_bpf 的高级可编程和它的最新更新_][30]  (netdev 1.2, Tokyo, October 2016): Daniel 介绍了 eBPF 的细节,它使用了隧道和封装、直接包访问、和其它特性。 @@ -134,7 +137,7 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 这些介绍可能是理解 eBPF 内部机制设计与实现的最佳文档资源之一。 -[**IO Visor 博客**][157] 有一些关于 BPF 感兴趣的技术文章。它们中的一些包含了许多营销讨论。 +[***IO Visor 博客***][157] 有一些关于 BPF 感兴趣的技术文章。它们中的一些包含了许多营销讨论。 **内核跟踪**:总结了所有的已有的方法,包括 BPF: @@ -144,7 +147,7 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 * [_Linux 内核跟踪_][63]  (Viller Hsiao, July 2016): Systemtap、Kernelshark、trace-cmd、LTTng、perf-tool、ftrace、hist-trigger、perf、function tracer、tracepoint、kprobe/uprobe … -关于 **事件跟踪和监视**,Brendan Gregg 使用 eBPF 的一些心得,它使用 eBPFR 的一些案例,他做的非常出色。如果你正在做一些内核跟踪方面的工作,你应该去看一下他的关于 eBPF 和火焰图相关的博客文章。其中的大多数都可以 [从这篇文章中][158] 访问,或者浏览他的博客。 +关于 **事件跟踪和监视**,Brendan Gregg 使用 eBPF 的一些心得,它使用 eBPFR 的一些案例,他做的非常出色。如果你正在做一些内核跟踪方面的工作,你应该去看一下他的关于 eBPF 和火焰图相关的博客文章。其中的大多数都可以 *[从这篇文章中][158]* 访问,或者浏览他的博客。 介绍 BPF,也介绍 **Linux 网络的一般概念**: @@ -154,24 +157,30 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 **硬件 offload**(译者注:offload 是指原本由软件来处理的一些操作交由硬件来完成,以提升吞吐量,降低 CPU 负荷。): -* eBPF 与 tc 或者 XDP 一起支持硬件 offload,开始于 Linux 内核版本 4.9,并且由 Netronome 提出的。这里是关于这个特性的介绍:[eBPF/XDP hardware offload to SmartNICs][147] (Jakub Kicinski 和 Nic Viljoen, netdev 1.2, Tokyo, October 2016) +* eBPF 与 tc 或者 XDP 一起支持硬件 offload,开始于 Linux 内核版本 4.9,并且由 Netronome 提出的。这里是关于这个特性的介绍:[*eBPF/XDP hardware offload to SmartNICs*][147] (Jakub Kicinski 和 Nic Viljoen, netdev 1.2, Tokyo, October 2016) + +* 年后出现的更新版: +[*综合的关于 XDP offload 处理边界的案例*][194](Jakub Kicinski 和 Nic Viljoen,netdev 2.2 ,Seoul,November 2017) + +* 我现在有一个简短的,但是在 2018 年的 FOSDEM 上有一个更新版: +[*XDP 硬件 Offload 的挑战*][195](Quentin Monnet,FOSDEM 2018,Brussels,February 2018) 关于 **cBPF**: * [_BSD 包过滤器:一个用户级包捕获的新架构_][66] (Steven McCanne 和 Van Jacobson, 1992): 它是关于(classic)BPF 的最早的论文。 -* [关于 BPF 的 FreeBSD 手册][67] 是理解 cBPF 程序的可用资源。 +* *[关于 BPF 的 FreeBSD 手册][67]* 是理解 cBPF 程序的可用资源。 -* 关于 cBPF,Daniel Borkmann 实现的至少两个演示,[一是,在 2013 年 mmap 中,BPF 和 Netsniff-NG][68],以及 [在 2014 中关于 tc 和 cls_bpf 的的一个非常完整的演示][69]。 +* 关于 cBPF,Daniel Borkmann 实现的至少两个演示,[*一是,在 2013 年 mmap 中,BPF 和 Netsniff-NG*][68],以及 *[在 2014 中关于 tc 和 cls_bpf 的的一个非常完整的演示][69]*。 -* 在 Cloudflare 的博客上,Marek Majkowski 提出的它的 [BPF 字节码与 **iptables** 的 `xt_bpf` 模块一起的应用][70]。值得一提的是,从 Linux 内核 4.10 开始,eBPF 也是通过这个模块支持的。(虽然,我并不知道关于这件事的任何讨论或者文章) +* 在 Cloudflare 的博客上,Marek Majkowski 提出的它的 *[BPF 字节码与 **iptables** 的 `xt_bpf` 模块一起的应用][70]*。值得一提的是,从 Linux 内核 4.10 开始,eBPF 也是通过这个模块支持的。(虽然,我并不知道关于这件事的任何讨论或者文章) -* [Libpcap 过滤器语法][71] +* [*Libpcap 过滤器语法*][71] ### 关于 XDP -* 在 IO Visor 网站上的 [XDP 概述][72]。 +* 在 IO Visor 网站上的 *[XDP 概述][72]*。 * [_eXpress Data Path (XDP)_][73]  (Tom Herbert, Alexei Starovoitov, March 2016): 这是第一个关于 XDP 的演示。 @@ -214,7 +223,7 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 ### 关于 基于 eBPF 或者 eBPF 相关的其它组件 -* [_在边缘上的 P4_][77]  (John Fastabend, May 2016): +* [_在边界上的 P4_][77]  (John Fastabend, May 2016): 提出了使用 **P4**,一个包处理的描述语言,使用 BPF 去创建一个高性能的可编程交换机。 * 如果你喜欢音频的介绍,这里有一个相关的 [OvS Orbit 片断(#11),叫做 _在边缘上的 **P4**_][78],日期是 2016 年 8 月。OvS Orbit 是对 Ben Pfaff 的访谈,它是 Open vSwitch 的其中一个核心维护者。在这个场景中,John Fastabend 是被访谈者。 @@ -233,34 +242,40 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 在不同的演示中重复了大量的内容;如果有疑问,就选最近的一个。Daniel Borkmann 作为 Google 开源博客的特邀作者,也写了 [Cilium 简介][80]。 -* 这里也有一个关于 **Cilium** 的播客节目:一个 [OvS Orbit episode (#4)][81],它是 Ben Pfaff 访谈 Thomas Graf (2016 年 5 月),和 [另外一个 Ivan Pepelnjak 的播客][82],仍然是 Thomas Graf 的与 eBPF、P4、XDP 和 Cilium (2016 年 10 月)。 +* 这里也有一个关于 **Cilium** 的播客节目:一个 *[OvS Orbit episode (#4)][81]*,它是 Ben Pfaff 访谈 Thomas Graf (2016 年 5 月),和 *[另外一个 Ivan Pepelnjak 的播客][82]*,仍然是 Thomas Graf 的与 eBPF、P4、XDP 和 Cilium (2016 年 10 月)。 * **Open vSwitch** (OvS),它是 **Open Virtual Network**(OVN,一个开源的网络虚拟化解决方案)相关的项目,正在考虑在不同的层次上使用 eBPF,它已经实现了几个概念验证原型: - * [使用 eBPF 的 Offloading OVS 流处理器][48] (William (Cheng-Chun) Tu, OvS conference, San Jose, November 2016) + * [*使用 eBPF 的 Offloading OVS 流处理器*][48] (William (Cheng-Chun) Tu, OvS conference, San Jose, November 2016) - * [将 OVN 的灵活性与 IOVisor 的高效率相结合][49] (Fulvio Risso, Matteo Bertrone and Mauricio Vasquez Bernal, OvS conference, San Jose, November 2016) + * *[将 OVN 的灵活性与 IOVisor 的高效率相结合][49]* (Fulvio Risso, Matteo Bertrone and Mauricio Vasquez Bernal, OvS conference, San Jose, November 2016) 据我所知,这些 eBPF 的使用案例看上去仅处于提议阶段(并没有合并到 OvS 的主分支中),但是,看它带来了什么将是非常有趣的事情。 * XDP 的设计对分布式拒绝访问(DDoS)攻击是非常有用的。越来越多的演示都关注于它。例如,从 Cloudflare 中的人们的讨论([_XDP in practice: integrating XDP in our DDoS mitigation pipeline_][83])或者从 Facebook 上([_Droplet: DDoS countermeasures powered by BPF + XDP_][84])在 netdev 2.1 会议上,在 Montreal、Canada、在 2017 年 4 月,都存在这样的很多使用案例。 +* Kubernetes 可以用很多种方式与 eBPF 交互。这里有一篇关于 *[在 Kubernetes 中使用 eBPF][196]* 的文章,它解释了现有的产品 (Cilium,Weave Scope) 如何支持 eBPF 与 Kubernetes 一起工作,并且进一步描述了,在容器部署环境中,eBPF 感兴趣的交互内容是什么。 + * [_CETH for XDP_][85] (Yan Chan 和 Yunsong Lu、Linux Meetup、Santa Clara、July 2016): **CETH**,是由 Mellanox 发起的,为实现更快的网络 I/O 而主张的通用以太网驱动程序架构。 -* [**VALE 交换机**][86],另一个虚拟交换机,它可以与 netmap 框架结合,有 [一个 BPF 扩展模块][87]。 +* [***VALE 交换机***][86],另一个虚拟交换机,它可以与 netmap 框架结合,有 *[一个 BPF 扩展模块][87]*。 -* **Suricata**,一个开源的入侵检测系统,它的捕获旁通特性 [似乎是依赖于 eBPF 组件][88]: +* **Suricata**,一个开源的入侵检测系统,它的捕获旁通特性 [*似乎是依赖于 eBPF 组件*][88]: + [*Suricate 文档的 eBPF 和 XDP 部分*][197] + [*SEPTun-Mark-II*][198] (Suricata Extreme 性能调优指南 — Mark II),Published by Michal Purzynski 和 Peter Manev in March 2018 + [*介绍这个特性的博客文章*][199] Published by Éric Leblond in September 2016 [_The adventures of a Suricate in eBPF land_][89]  (Éric Leblond, netdev 1.2, Tokyo, October 2016) [_eBPF and XDP seen from the eyes of a meerkat_][90]  (Éric Leblond, Kernel Recipes, Paris, September 2017) +当使用原生驱动的 XDP 时,这个项目要求实现非常高的性能。 -* [InKeV: 对于 DCN 的内核中分布式网络虚拟化][91] (Z. Ahmed, M. H. Alizai and A. A. Syed, SIGCOMM, August 2016): +* [*InKeV: 对于 DCN 的内核中分布式网络虚拟化*][91] (Z. Ahmed, M. H. Alizai and A. A. Syed, SIGCOMM, August 2016): **InKeV** 是一个基于 eBPF 的虚拟网络、目标数据中心网络的数据路径架构。它最初由 PLUMgrid 提出,并且声称相比基于 OvS 的 OpenStack 解决方案可以获得更好的性能。 * [_**gobpf** - 从 Go 中利用 eBPF_][92] (Michael Schubert, fosdem17, Brussels, Belgium, February 2017): “一个从 Go 中的库,可以去创建、加载和使用 eBPF 程序” -* [**ply**][93] 是为 Linux 实现的一个小的但是非常灵活的开源动态 **跟踪器**,它的一些特性非常类似于 bcc 工具,是受 awk 和 dtrace 启发,但使用一个更简单的语言。它是由 Tobias Waldekranz 写的。 +* [***ply***][93] 是为 Linux 实现的一个小的但是非常灵活的开源动态 **跟踪器**,它的一些特性非常类似于 bcc 工具,是受 awk 和 dtrace 启发,但使用一个更简单的语言。它是由 Tobias Waldekranz 写的。 * 如果你读过我以前的文章,你可能对我在这篇文章中的讨论感兴趣,[使用 eBPF 实现 OpenState 接口][151],关于包状态处理,在 fosdem17 中。 @@ -272,33 +287,33 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 ### 关于 BPF -* **BPF 的规范**(包含 classic 和 extended 版本)可以在 Linux 内核的文档中,和特定的文件 [linux/Documentation/networking/filter.txt][94] 中找到。BPF 使用以及它的内部结构也被记录在那里。此外,当加载 BPF 代码失败时,在这里可以找到 **被校验器抛出的错误信息**,这有助于你排除不明确的错误信息。 +* **BPF 的规范**(包含 classic 和 extended 版本)可以在 Linux 内核的文档中,和特定的文件 *[linux/Documentation/networking/filter.txt][94]* 中找到。BPF 使用以及它的内部结构也被记录在那里。此外,当加载 BPF 代码失败时,在这里可以找到 **被校验器抛出的错误信息**,这有助于你排除不明确的错误信息。 -* 此外,在内核树中,在 eBPF 那里有一个关于 **常见的问 & 答** 的文档,它在文件 [linux/Documentation/bpf/bpf_design_QA.txt][95] 中。 +* 此外,在内核树中,在 eBPF 那里有一个关于 **常见的问 & 答** 的文档,它在文件 [*linux/Documentation/bpf/bpf_design_QA.txt*][95] 中。 -* … 但是,内核文档是非常难懂的,并且非常不容易阅读。如果你只是去查找一个简单的 eBPF 语言的描述,可以去 IO Visor 的 GitHub 仓库,那儿有 [它的 **概括性描述**][96]。 +* … 但是,内核文档是非常难懂的,并且非常不容易阅读。如果你只是去查找一个简单的 eBPF 语言的描述,可以去 IO Visor 的 GitHub 仓库,那儿有 [***它的概括性描述***][96]。 -* 顺便说一下,IO Visor 项目收集了许多 **关于 BPF 的资源**。大部分,分别在 bcc 仓库的 [文档目录][97] 中,和 [bpf-docs 仓库][98] 的整个内容中,它们都在 GitHub 上。注意,这个非常好的 [BPF **参考指南**][99] 包含一个详细的 BPF C 和 bcc Python 的 helper 的描述。 +* 顺便说一下,IO Visor 项目收集了许多 **关于 BPF 的资源**。大部分,分别在 bcc 仓库的 *[文档目录][97]* 中,和 *[bpf-docs 仓库][98]* 的整个内容中,它们都在 GitHub 上。注意,这个非常好的 *[BPF **参考指南**][99]* 包含一个详细的 BPF C 和 bcc Python 的 helper 的描述。 -* 想深入到 BPF,那里有一些必要的 **Linux 手册页**。第一个是 [`bpf(2)` man page][100] 关于 `bpf()` **系统调用**,它用于从用户空间去管理 BPF 程序和映射。它也包含一个 BPF 高级特性的描述(程序类型、映射、等等)。第二个是主要去处理希望去附加到 tc 接口的 BPF 程序:它是 [`tc-bpf(8)` man page][101],它是 **使用 BPF 和 tc** 的一个参考,并且包含一些示例命令和参考代码。 +* 想深入到 BPF,那里有一些必要的 **Linux 手册页**。第一个是 [*`bpf(2)` man 页面*][100] 关于 `bpf()` **系统调用**,它用于从用户空间去管理 BPF 程序和映射。它也包含一个 BPF 高级特性的描述(程序类型、映射、等等)。第二个是主要去处理希望去附加到 tc 接口的 BPF 程序:它是 [*`tc-bpf(8)` man 页面*][101],它是 **使用 BPF 和 tc** 的一个参考,并且包含一些示例命令和参考代码。 -* Jesper Dangaard Brouer 发起了一个 **更新 eBPF Linux 文档** 的尝试,包含 **不同的映射**。[他有一个草案][102],欢迎去贡献。一旦完成,这个文档将被合并进 man 页面并且进入到内核文档。 +* Jesper Dangaard Brouer 发起了一个 **更新 eBPF Linux 文档** 的尝试,包含 **不同的映射**。[*他有一个草案*][102],欢迎去贡献。一旦完成,这个文档将被合并进 man 页面并且进入到内核文档。 -* Cilium 项目也有一个非常好的 [**BPF 和 XDP 参考指南**][103],它是由核心的 eBPF 开发者写的,它被证明对于 eBPF 开发者是极其有用的。 +* Cilium 项目也有一个非常好的 [***BPF 和 XDP 参考指南***][103],它是由核心的 eBPF 开发者写的,它被证明对于 eBPF 开发者是极其有用的。 -* David Miller 在 [xdp-newbies][152] 邮件列表中发了几封关于 eBPF/XDP 内部结构的富有启发性的电子邮件。我找不到一个单独的地方收集它们的链接,因此,这里是一个列表: +* David Miller 在 *[xdp-newbies][152]* 邮件列表中发了几封关于 eBPF/XDP 内部结构的富有启发性的电子邮件。我找不到一个单独的地方收集它们的链接,因此,这里是一个列表: - * [bpf.h 和你 …][50] + * [*bpf.h 和你 …*][50] - * [Contextually speaking…][51] + * [*Contextually speaking…*][51] - * [BPF 校验器概述][52] + * [*BPF 校验器概述*][52] 最后一个可能是目前来说关于校验器的最佳的总结。 -* Ferris Ellis 发布的 [一个关于 **eBPF 的系列博客文章**][104]。作为我写的这个短文,第一篇文章是关于 eBPF 的历史背景和未来期望。接下来的文章将更多的是技术方面,和前景展望。 +* Ferris Ellis 发布的 *[一个关于 **eBPF 的系列博客文章**][104]*。作为我写的这个短文,第一篇文章是关于 eBPF 的历史背景和未来期望。接下来的文章将更多的是技术方面,和前景展望。 -* [一个 **每个内核版本的 BPF 特性列表**][153] 在 bcc 仓库中可以找到。如果你想去知道运行一个给定的特性所要求的最小的内核版本,它是非常有用的。我贡献和添加了链接到提交中,它介绍了每个特性,因此,你也可以从那里很容易地去访问提交历史。 +* [***一个每个内核版本的 BPF 特性列表***][153] 在 bcc 仓库中可以找到。如果你想去知道运行一个给定的特性所要求的最小的内核版本,它是非常有用的。我贡献和添加了链接到提交中,它介绍了每个特性,因此,你也可以从那里很容易地去访问提交历史。 ### 关于 tc @@ -306,36 +321,36 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 * 找到关于 **Linux 上 QoS** 的简单教程是很困难的。这里有两个链接,它们很长而且很难懂,但是,如果你可以抽时间去阅读它,你将学习到几乎关于 tc 的任何东西(虽然,关于 BPF 它什么也没有)。它们在这里:[_怎么去实现流量控制_  (Martin A. Brown, 2006)][105],和 [_怎么去实现 Linux 的高级路由 & 流量控制_  (“LARTC”) (Bert Hubert & al., 2002)][106]。 -* 在你的系统上的 **tc 手册页面** 并不是最新日期的,因为它们中的几个最近已经增加了。如果你没有找到关于特定的队列规则、分类或者过滤器的文档,它可能在最新的 [tc 组件的手册页面][107] 中。 +* 在你的系统上的 **tc 手册页面** 并不是最新日期的,因为它们中的几个最近已经增加了。如果你没有找到关于特定的队列规则、分类或者过滤器的文档,它可能在最新的 *[tc 组件的手册页面][107]* 中。 -* 一些额外的材料可以在 iproute2 包自已的文件中找到:这个包中有 [一些文档][108],包括一些文件,它可以帮你去理解 [**tc 的 action** 的功能][109]。 +* 一些额外的材料可以在 iproute2 包自已的文件中找到:这个包中有 [*一些文档*][108],包括一些文件,它可以帮你去理解 *[**tc 的 action** 的功能][109]*。 **注意:** 这些文件在 2017 年 10 月 已经从 iproute2 中删除,然而,从 Git 历史中却一直可用。 -* 非精确资料:这里是 [一个关于 tc 的几个特性的研讨会][110](包含过滤、BPF、tc offload、…) 由 Jamal Hadi Salim 在 netdev 1.2 会议上组织的(October 2016)。 +* 非精确资料:这里是 [*一个关于 tc 的几个特性的研讨会*][110](包含过滤、BPF、tc offload、…) 由 Jamal Hadi Salim 在 netdev 1.2 会议上组织的(October 2016)。 -* 额外信息 — 如果你使用 `tc` 较多,这里有一些好消息:我用这个工具 [写了一个 bash 完整的功能][111],并且它被包 iproute2 带到内核版本 4.6 和更高版中! +* 额外信息 — 如果你使用 `tc` 较多,这里有一些好消息:我用这个工具 *[写了一个 bash 完整的功能][111]*,并且它被包 iproute2 带到内核版本 4.6 和更高版中! ### 关于 XDP -* 对于 XDP 的一些 [进展中的文档(包括规范)][112] 已经由 Jesper Dangaard Brouer 启动,并且意味着将成为一个合作的工作。正在推进(2016 年 9 月):你期望它去改变,并且或许在一些节点上移动(Jesper [称为贡献][113],如果你想去改善它)。 +* 对于 XDP 的一些 *[进展中的文档(包括规范)][112]* 已经由 Jesper Dangaard Brouer 启动,并且意味着将成为一个合作的工作。正在推进(2016 年 9 月):你期望它去改变,并且或许在一些节点上移动(Jesper *[称为贡献][113]*,如果你想去改善它)。 -* 自来 Cilium 项目的 [BPF 和 XDP 参考指南][114] … 好吧,这个名字已经说明了一切。 +* 自来 Cilium 项目的 *[BPF 和 XDP 参考指南][114]* … 好吧,这个名字已经说明了一切。 ### 关于 P4 和 BPF -[P4][159] 是一个用于指定交换机行为的语言。它可以被编译为许多种目标硬件或软件。因此,你可能猜到了,这些目标中的一个就是 BPF … 仅部分支持的:一些 P4 特性并不能被转化到 BPF 中,并且,用类似的方法,BPF 可以做的事情,而使用 P4 却不能表达出现。不过,**P4 与 BPF 使用** 的相关文档,[用于去隐藏在 bcc 仓库中][160]。这个改变在 P4_16 版本中,p4c 引用的编辑器包含 [一个 eBPF 后端][161]。 +*[P4][159]* 是一个用于指定交换机行为的语言。它可以被编译为许多种目标硬件或软件。因此,你可能猜到了,这些目标中的一个就是 BPF … 仅部分支持的:一些 P4 特性并不能被转化到 BPF 中,并且,用类似的方法,BPF 可以做的事情,而使用 P4 却不能表达出现。不过,**P4 与 BPF 使用** 的相关文档,[*用于去隐藏在 bcc 仓库中*][160]。这个改变在 P4_16 版本中,p4c 引用的编辑器包含 *[一个 eBPF 后端][161]*。 ![](https://qmonnet.github.io/whirl-offload/img/icons/flask.svg) ### 教程 -Brendan Gregg 为想去 **使用 bcc 工具** 跟踪和监视内核中的事件的人制作了一个非常好的 **教程**。[第一个教程是关于如何使用 bcc 工具][162],它总共有十一步,教你去理解怎么去使用已有的工具,而 [**针对 Python 开发者** 的一个目标][163] 是专注于开发新工具,它总共有十七节 “课程”。 +Brendan Gregg 为想去 **使用 bcc 工具** 跟踪和监视内核中的事件的人制作了一个非常好的 **教程**。[*第一个教程是关于如何使用 bcc 工具*][162],它总共有十一步,教你去理解怎么去使用已有的工具,而 [***针对 Python 开发者** 的一个目标*][163] 是专注于开发新工具,它总共有十七节 “课程”。 Sasha Goldshtein 也有一些 [_**Linux 跟踪研究材料**_][164] 涉及到使用几个 BPF 去进行跟踪。 -作者为 Jean-Tiare Le Bigot 的文章为 ping 请求和回复,提供了一个详细的(和有指导意义的)[使用 perf 和 eBPF 去设置一个低级的跟踪器][165] 的示例。 +作者为 Jean-Tiare Le Bigot 的文章为 ping 请求和回复,提供了一个详细的(和有指导意义的)[*使用 perf 和 eBPF 去设置一个低级的跟踪器*][165] 的示例。 -对于网络相关的 eBPF 使用案例也有几个教程。那里有一些有趣的文档,包含一个 _eBPF Offload 入门指南_,由 Netronome 在 [Open NFP][166] 平台上操作的。其它的那些,来自 Jesper 的演讲,[_XDP 能为其它人做什么_][167],可能是 XDP 入门的最好的方法之一。 +对于网络相关的 eBPF 使用案例也有几个教程。那里有一些有趣的文档,包含一个 _eBPF Offload 入门指南_,由 Netronome 在 *[Open NFP][166]* 平台上操作的。其它的那些,来自 Jesper 的演讲,[_XDP 能为其它人做什么_][167],可能是 XDP 入门的最好的方法之一。 ![](https://qmonnet.github.io/whirl-offload/img/icons/gears.svg) @@ -345,27 +360,33 @@ Sasha Goldshtein 也有一些 [_**Linux 跟踪研究材料**_][164] 涉及到使 ### 来自内核的示例 -主要的程序类型都包含在内核的示例中:过滤器绑定到套接字或者到 tc 接口、事件跟踪/监视、甚至是 XDP。你可以在 [linux/samples/bpf/][168] 目录中找到这些示例。 +主要的程序类型都包含在内核的示例中:过滤器绑定到套接字或者到 tc 接口、事件跟踪/监视、甚至是 XDP。你可以在 *[linux/samples/bpf/][168]* 目录中找到这些示例。 + +现在,更多的示例已经作为单元测试被添加到 *[linux/tools/testing/selftests/bpf][200]* 目录下,这里面包含对硬件 offload 的测试或者对于 libbpf 的测试。 + +Jesper 的 Dangaard Brouer 在他的 *[prototype-kernel][201]* 仓库中也维护了一套专门的示例。 这些示例与那些内核中提供的示例非常类似,但是它们可以以在内核基本文件 (Makefiles 和 headers) 之外编译。 也不要忘记去看一下 git 相关的提交历史,它们有一些指定的特性的介绍,它们也包含一些特性的详细的示例。 ### 来自包 iproute2 的示例 -iproute2 包也提供了几个示例。它们都很明显地偏向网络编程,因此,这个程序是附加到 tc ingress 或者 egress 接口上。这些示例在 [iproute2/examples/bpf/][169] 目录中。 +iproute2 包也提供了几个示例。它们都很明显地偏向网络编程,因此,这个程序是附加到 tc ingress 或者 egress 接口上。这些示例在 *[iproute2/examples/bpf/][169]* 目录中。 ### 来自 bcc 工具集的示例 -许多示例都 [与 bcc 一起提供][170]: +许多示例都 *[与 bcc 一起提供][170]*: * 一些网络编程的示例在关联的目录下面。它们包括套接字过滤器、tc 过滤器、和一个 XDP 程序。 -* `tracing` 目录包含许多 **跟踪编程** 的示例。前面的教程中提到的都在那里。那些程序涉及了事件跟踪的很大的一个范围,并且,它们中的一些是面向生产系统的。注意,某些 Linux 分发版(至少是 Debian、Ubuntu、Fedora、Arch Linux)、这些程序已经被 [打包了][115] 并且可以很 “容易地” 通过比如 `# apt install bcc-tools` 进行安装。但是在写这篇文章的时候(除了 Arch Linux),第一个要求是去安装 IO Visor 的包仓库。 +* `tracing` 目录包含许多 **跟踪编程** 的示例。前面的教程中提到的都在那里。那些程序涉及了事件跟踪的很大的一个范围,并且,它们中的一些是面向生产系统的。注意,某些 Linux 分发版(至少是 Debian、Ubuntu、Fedora、Arch Linux)、这些程序已经被 *[打包了][115]* 并且可以很 “容易地” 通过比如 `# apt install bcc-tools` 进行安装。但是在写这篇文章的时候(除了 Arch Linux),第一个要求是去安装 IO Visor 的包仓库。 * 那里也有 **使用 Lua** 作为一个不同的 BPF 后端(那是因为 BPF 程序是用 Lua 写的,它是 C 语言的一个子集,它允许为前端和后端使用相同的语言)的一些示例,它在第三个目录中。 +* 当然,[*bcc 工具*][202] 自身就是 eBPF 程序使用案例的有趣示例。 + ### 手册页面 -虽然 bcc 一般可以用很容易的方式在内核中去注入和运行一个 BPF 程序,通过 `tc` 工具去将程序附加到 tc 接口也可以被执行。因此,如果你打算将 **BPF 与 tc 一起使用**,你可以在 [`tc-bpf(8)` 手册页面][171] 中找到一些调用示例。 +虽然 bcc 一般可以用很容易的方式在内核中去注入和运行一个 BPF 程序,通过 `tc` 工具去将程序附加到 tc 接口也可以被执行。因此,如果你打算将 **BPF 与 tc 一起使用**,你可以在 *[`tc-bpf(8)` 手册页面][171]* 中找到一些调用示例。 ![](https://qmonnet.github.io/whirl-offload/img/icons/srcfile.svg) @@ -375,37 +396,39 @@ iproute2 包也提供了几个示例。它们都很明显地偏向网络编程 ### 在内核中的 BPF 代码 -* 文件 [linux/include/linux/bpf.h][116] 和它的副本 [linux/include/uapi/bpf.h][117] 包含有关 eBPF 的 **定义**,它分别被内核中和用户空间程序的接口使用。 +* 文件 *[linux/include/linux/bpf.h][116]* 和它的副本 *[linux/include/uapi/bpf.h][117]* 包含有关 eBPF 的 **定义**,它分别被内核中和用户空间程序的接口使用。 -* 相同的方式,文件 [linux/include/linux/filter.h][118] 和 [linux/include/uapi/filter.h][119] 包含的信息被 **运行的 BPF 程序** 使用。 +* 相同的方式,文件 *[linux/include/linux/filter.h][118]* 和 *[linux/include/uapi/filter.h][119]* 包含的信息被 **运行的 BPF 程序** 使用。 -* BPF 相关的 **主要的代码片断** 在 [linux/kernel/bpf/][120] 目录下面。**被系统以不同的操作许可调用** 比如,程序加载或者映射管理是在文件 `syscall.c` 中实现,虽然 `core.c` 包含在 **解析器** 中。其它的文件有明显的命名:`verifier.c` 包含在 **校验器** 中(不是开玩笑的),`arraymap.c` 的代码用于与阵列类型的 **映射** 去互动,等等。 +* BPF 相关的 **主要的代码片断** 在 *[linux/kernel/bpf/][120]* 目录下面。**被系统以不同的操作许可调用** 比如,程序加载或者映射管理是在文件 `syscall.c` 中实现,虽然 `core.c` 包含在 **解析器** 中。其它的文件有明显的命名:`verifier.c` 包含在 **校验器** 中(不是开玩笑的),`arraymap.c` 的代码用于与阵列类型的 **映射** 去互动,等等。 -* **helpers**,以及几个网络(与 tc、XDP 一起)和用户可用的相关功能是实现在 [linux/net/core/filter.c][121] 中。它也包含代码去移植 cBPF 字节码到 eBPF 中(因为在运行之前,内核中的所有的 cBPF 程序被转换成 eBPF) +* **helpers**,以及几个网络(与 tc、XDP 一起)和用户可用的相关功能是实现在 [*linux/net/core/filter.c*][121] 中。它也包含代码去移植 cBPF 字节码到 eBPF 中(因为在运行之前,内核中的所有的 cBPF 程序被转换成 eBPF) -* **JIT 编译器** 在它们各自的架构目录下面,比如,x86 架构的在 [linux/arch/x86/net/bpf_jit_comp.c][122] 中。 +* 功能和 **helpers** 相关的 **事件跟踪** 都在 *[linux/kernel/trace/bpf_trace.c][203]* 中。 -* 在 [linux/net/sched/][123] 目录下,你可以找到 **tc 的 BPF 组件** 相关的代码,尤其是在文件 `act_bpf.c` (action)和 `cls_bpf.c`(filter)中。 +* **JIT 编译器** 在它们各自的架构目录下面,比如,x86 架构的在 *[linux/arch/x86/net/bpf_jit_comp.c][122]* 中。 -* 我并没有在 BPF 上深入到 **事件跟踪** 中,因此,我并不真正了解这些程序的钩子。在 [linux/kernel/trace/bpf_trace.c][124] 那里有一些东西。如果你对它感 兴趣,并且想去了解更多,你可以在 Brendan Gregg 的演示或者博客文章上去深入挖掘。 +* 在 *[linux/net/sched/][123]* 目录下,你可以找到 **tc 的 BPF 组件** 相关的代码,尤其是在文件 `act_bpf.c` (action)和 `cls_bpf.c`(filter)中。 -* 我也没有使用过 **seccomp-BPF**。但它的代码在 [linux/kernel/seccomp.c][125],并且可以在 [linux/tools/testing/selftests/seccomp/seccomp_bpf.c][126] 中找到一些它的使用示例。 +* 我并没有在 BPF 上深入到 **事件跟踪** 中,因此,我并不真正了解这些程序的钩子。在 *[linux/kernel/trace/bpf_trace.c][124]* 那里有一些东西。如果你对它感 兴趣,并且想去了解更多,你可以在 Brendan Gregg 的演示或者博客文章上去深入挖掘。 + +* 我也没有使用过 **seccomp-BPF**。但它的代码在 *[linux/kernel/seccomp.c][125]*,并且可以在 [*linux/tools/testing/selftests/seccomp/seccomp_bpf.c*][126] 中找到一些它的使用示例。 ### XDP 钩子代码 -一旦将 BPF 虚拟机加载进内核,由一个 Netlink 命令将 **XDP** 程序从用户空间钩入到内核网络路径中。接收它的是在 [linux/net/core/dev.c][172] 文件中的被调用的 `dev_change_xdp_fd()` 函数,并且由它设置一个 XDP 钩子。比如,钩子位于在 NICs 支持的驱动中。例如,为一些 Mellanox 硬件使用的 mlx4 驱动的钩子实现在 [drivers/net/ethernet/mellanox/mlx4/][173] 目录下的文件中。文件 en_netdev.c 接收 Netlink 命令并调用 `mlx4_xdp_set()`,它再被在文件 en_rx.c 实现的实例 `mlx4_en_process_rx_cq()` 调用(对于 RX 侧)。 +一旦将 BPF 虚拟机加载进内核,由一个 Netlink 命令将 **XDP** 程序从用户空间钩入到内核网络路径中。接收它的是在 *[linux/net/core/dev.c][172]* 文件中的被调用的 `dev_change_xdp_fd()` 函数,并且由它设置一个 XDP 钩子。比如,钩子位于在 NICs 支持的驱动中。例如,为一些 Mellanox 硬件使用的 mlx4 驱动的钩子实现在 *[drivers/net/ethernet/mellanox/mlx4/][173]* 目录下的文件中。文件 en_netdev.c 接收 Netlink 命令并调用 `mlx4_xdp_set()`,它再被在文件 en_rx.c 实现的实例 `mlx4_en_process_rx_cq()` 调用(对于 RX 侧)。 ### 在 bcc 中的 BPF 逻辑 -[在 bcc 的 GitHub 仓库][174] 上找到的 **bcc** 工具集的其中一个代码。**Python 代码**,包含在 `BPF` 类中,最初它在文件 [bcc/src/python/bcc/__init__.py][175] 中。但是许多感兴趣的东西 — 我的意见是 — 比如,加载 BPF 程序到内核中,碰巧在 [libbcc 的 **C 库**][176]中。 +[*在 bcc 的 GitHub 仓库*][174] 上找到的 **bcc** 工具集的其中一个代码。**Python 代码**,包含在 `BPF` 类中,最初它在文件 *[bcc/src/python/bcc/__init__.py][175]* 中。但是许多感兴趣的东西 — 我的意见是 — 比如,加载 BPF 程序到内核中,碰巧在 *[libbcc 的 **C 库**][176]*中。 ### 使用 tc 去管理 BPF 的代码 -**在 tc** 中与 iproute2 包中一起带来的与 BPF 相关的代码。其中的一些在 [iproute2/tc/][177] 目录中。文件 f_bpf.c 和 m_bpf.c(和 e_bpf.c)是各自用于处理 BPF 的过滤器和动作的(和tc `exec` 命令,或许什么命令都可以)。文件 q_clsact.c 定义了 `clsact`,qdisc 是为 BPF 特别创建的。但是,**大多数的 BPF 用户空间逻辑** 是在 [iproute2/lib/bpf.c][178] 库中实现的,因此,如果你想去使用 BPF 和 tc,这里可能是会将你搞混乱的地方(它是从文件 iproute2/tc/tc_bpf.c 中来的,你也可以在旧版本的包中找到代码相同的地方)。 +**在 tc** 中与 iproute2 包中一起带来的与 BPF 相关的代码。其中的一些在 *[iproute2/tc/][177]* 目录中。文件 f_bpf.c 和 m_bpf.c(和 e_bpf.c)是各自用于处理 BPF 的过滤器和动作的(和tc `exec` 命令,或许什么命令都可以)。文件 q_clsact.c 定义了 `clsact`,qdisc 是为 BPF 特别创建的。但是,**大多数的 BPF 用户空间逻辑** 是在 *[iproute2/lib/bpf.c][178]* 库中实现的,因此,如果你想去使用 BPF 和 tc,这里可能是会将你搞混乱的地方(它是从文件 iproute2/tc/tc_bpf.c 中来的,你也可以在旧版本的包中找到代码相同的地方)。 ### BPF 实用工具 -内核中也带有 BPF 相关的三个工具的源代码(`bpf_asm.c`, `bpf_dbg.c`, `bpf_jit_disasm.c`)、根据你的版本不同,在 [linux/tools/net/][179] 或者 [linux/tools/bpf/][180] 目录下面: +内核中也带有 BPF 相关的三个工具的源代码(`bpf_asm.c`, `bpf_dbg.c`, `bpf_jit_disasm.c`)、根据你的版本不同,在 *[linux/tools/net/][179]* 或者 *[linux/tools/bpf/][180]* 目录下面: * `bpf_asm` 是一个极小的汇编程序。 @@ -417,25 +440,27 @@ iproute2 包也提供了几个示例。它们都很明显地偏向网络编程 阅读在源文件顶部的注释可以得到一个它们使用方法的概述。 +与 eBPF 一起工作的其它必需的文件是来自内核树的两个**用户空间库**,它们可以用于管理 eBPF 程序或者映射来自外部的程序。这个函数可以通过 *[linux/tools/lib/bpf/][204]* 目录中的头文件 `bpf.h` 和 `libbpf.h`(更高级别) 来访问。比如,工具 `bpftool` 主要依赖这些库。 + ### 其它感兴趣的 chunks -如果你对关于 BPF 的不常见的语言的使用感兴趣,bcc 包含 [一个为 BPF 目标的 **P4 编译器**][181]以及 [一个 **Lua 前端**][182],它可以被使用,它以代替 C 的一个子集,并且(在 Lua 的案例中)可以用于 Python 工具。 +如果你对关于 BPF 的不常见的语言的使用感兴趣,bcc 包含 *[一个为 BPF 目标的 **P4 编译器***][181]以及 [***一个 Lua 前端***][182],它可以被使用,它以代替 C 的一个子集,并且(在 Lua 的案例中)可以用于 Python 工具。 ### LLVM 后端 -在 [这个提交][183] 中,clang / LLVM 用于将 C 编译成 BPF 后端,将它添加到 LLVM 源(也可以在 [the GitHub mirror][184] 上访问)。 +在 *[这个提交][183]* 中,clang / LLVM 用于将 C 编译成 BPF 后端,将它添加到 LLVM 源(也可以在 [the GitHub mirror][184] 上访问)。 ### 在用户空间中运行 -到目前为止,我知道那里有至少两种 eBPF 用户空间实现。第一个是 [uBPF][185],它是用 C 写的。它包含一个解析器、一个 x86_64 架构的 JIT 编译器、一个汇编器和一个反汇编器。 +到目前为止,我知道那里有至少两种 eBPF 用户空间实现。第一个是 *[uBPF][185]*,它是用 C 写的。它包含一个解析器、一个 x86_64 架构的 JIT 编译器、一个汇编器和一个反汇编器。 -uBPF 的代码似乎被重用了,去产生了一个 [通用实现][186],claims 支持 FreeBSD 内核、FreeBSD 用户空间、Linux 内核、Linux 用户空间和 Mac OSX 用户空间。它被 [VALE 交换机的 BPF 扩展模块][187]使用。 +uBPF 的代码似乎被重用了,去产生了一个 [*通用实现*][186],claims 支持 FreeBSD 内核、FreeBSD 用户空间、Linux 内核、Linux 用户空间和 Mac OSX 用户空间。它被 [*VALE 交换机的 BPF 扩展模块*][187]使用。 -其它用户空间的实现是我做的:[rbpf][188],基于 uBPF,但是用 Rust 写的。写了解析器和 JIT 编译器 (Linux 下两个都有,Mac OSX 和 Windows 下仅有解析器),以后可能会有更多。 +其它用户空间的实现是我做的:[*rbpf*][188],基于 uBPF,但是用 Rust 写的。写了解析器和 JIT 编译器 (Linux 下两个都有,Mac OSX 和 Windows 下仅有解析器),以后可能会有更多。 ### 提交日志 -正如前面所说的,如果你希望得到更多的关于它的信息,不要犹豫,去看一些提交日志,它介绍了一些特定的 BPF 特性。你可以在许多地方搜索日志,比如,在 [git.kernel.org][189]、[在 GitHub 上][190]、或者如果你克隆过它还有你的本地仓库中。如果你不熟悉 git,你可以尝试像这些去做 `git blame ` 去看看介绍特定代码行的提交内容,然后,`git show ` 去看详细情况(或者在 `git log` 的结果中按关键字搜索,但是这样做通常比较单调乏味)也可以看在 bcc 仓库中的 [按内核版本区分的 eBPF 特性列表][191],它链接到相关的提交上。 +正如前面所说的,如果你希望得到更多的关于它的信息,不要犹豫,去看一些提交日志,它介绍了一些特定的 BPF 特性。你可以在许多地方搜索日志,比如,在 *[git.kernel.org][189]、[在 GitHub 上][190]*、或者如果你克隆过它还有你的本地仓库中。如果你不熟悉 git,你可以尝试像这些去做 `git blame ` 去看看介绍特定代码行的提交内容,然后,`git show ` 去看详细情况(或者在 `git log` 的结果中按关键字搜索,但是这样做通常比较单调乏味)也可以看在 bcc 仓库中的 *[按内核版本区分的 eBPF 特性列表][191]*,它链接到相关的提交上。 ![](https://qmonnet.github.io/whirl-offload/img/icons/wand.svg) @@ -445,7 +470,7 @@ uBPF 的代码似乎被重用了,去产生了一个 [通用实现][186],cla ### 编译时的错误 -* 确保你有一个最新的 Linux 内核版本(也可以看 [这个文档][127])。 +* 确保你有一个最新的 Linux 内核版本(也可以看 *[这个文档][127]*)。 * 如果你自己编译内核:确保你安装了所有正确的组件,包括内核镜像、头文件和 libc。 @@ -463,7 +488,7 @@ uBPF 的代码似乎被重用了,去产生了一个 [通用实现][186],cla (seems fixed as of today). -* 对于使用 `bcc` 的其它问题,不要忘了去看一看这个工具集的 [答疑][128]。 +* 对于使用 `bcc` 的其它问题,不要忘了去看一看这个工具集的 *[答疑][128]*。 * 如果你从一个并不精确匹配你的内核版本的 iproute2 包中下载了示例,可能会通过在文件中包含的头文件触发一些错误。这些示例片断都假设安装在你的系统中内核的头文件与 iproute2 包是相同版本的。如果不是这种情况,下载正确的 iproute2 版本,或者编辑示例中包含的文件的路径,指向到 iproute2 中包含的头文件上(在运行时一些问题可能或者不可能发生,取决于你使用的特性)。 @@ -477,32 +502,32 @@ uBPF 的代码似乎被重用了,去产生了一个 [通用实现][186],cla * 静态使用 tc,注意不使用过滤器,动作不会直接附加到 qdiscs 或者接口。 -* 通过内核校验器抛出错误到解析器可能很难。[内核文档][129]或许可以提供帮助,因此,可以 [参考指南][130] 或者,万不得一的情况下,可以去看源代码(祝你好运!)。记住,校验器 _不运行_ 程序,对于这种类型的错误,它也是非常重要的。如果你得到一个关于无效内存访问或者关于未初始化的数据的错误,它并不意味着那些问题真实发生了(或者有时候,它们完全有可能发生)。它意味着你的程序是以校验器预计可能发生错误的方式写的,并且因此而拒绝这个程序。 +* 通过内核校验器抛出错误到解析器可能很难。[*内核文档*][129]或许可以提供帮助,因此,可以 *[参考指南][130]* 或者,万不得一的情况下,可以去看源代码(祝你好运!)。记住,校验器 _不运行_ 程序,对于这种类型的错误,它也是非常重要的。如果你得到一个关于无效内存访问或者关于未初始化的数据的错误,它并不意味着那些问题真实发生了(或者有时候,它们完全有可能发生)。它意味着你的程序是以校验器预计可能发生错误的方式写的,并且因此而拒绝这个程序。 * 注意 `tc` 工具有一个 `verbose` 模式,它与 BPF 一起工作的很好:在你的命令行尾部尝试追加一个 `verbose`。 -* bcc 也有一个 verbose 选项:`BPF` 类有一个 `debug` 参数,它可以带 `DEBUG_LLVM_IR`、`DEBUG_BPF` 和 `DEBUG_PREPROCESSOR` 三个标志中任何组合(详细情况在 [源文件][131]中)。 为调试代码,它甚至嵌入了 [一些条件去打印输出代码][132]。 +* bcc 也有一个 verbose 选项:`BPF` 类有一个 `debug` 参数,它可以带 `DEBUG_LLVM_IR`、`DEBUG_BPF` 和 `DEBUG_PREPROCESSOR` 三个标志中任何组合(详细情况在 *[源文件][131]*中)。 为调试代码,它甚至嵌入了 [*一些条件去打印输出代码*][132]。 -* LLVM v4.0+ 为 eBPF 程序 [嵌入一个反汇编器][133]。因此,如果你用 clang 编译你的程序,在编译时添加 `-g` 标志允许你通过内核校验器去以人类可读的格式去转储你的程序。处理转储文件,使用: +* LLVM v4.0+ 为 eBPF 程序 *[嵌入一个反汇编器][133]*。因此,如果你用 clang 编译你的程序,在编译时添加 `-g` 标志允许你通过内核校验器去以人类可读的格式去转储你的程序。处理转储文件,使用: ``` $ llvm-objdump -S -no-show-raw-insn bpf_program.o ``` -* 使用映射工作?你想去看 [bpf-map][134],一个为 Cilium 项目而用 Go 创建的非常有用的工具,它可以用于去转储内核中 eBPF 映射的内容。那里也有在 Rust 中的 [一个克隆][135]。 +* 使用映射工作?你想去看 [*bpf-map*][134],一个为 Cilium 项目而用 Go 创建的非常有用的工具,它可以用于去转储内核中 eBPF 映射的内容。那里也有在 Rust 中的 [*一个克隆*][135]。 -* 那里有一个旧的 [在 **StackOverflow** 上的 `bpf` 标签][136],但是,在这篇文章中它一直没有被使用过(并且那里几乎没有与新的 eBPF 相关的东西)。如果你是一位来自未来的阅读者,你可能想去看看在这方面是否有更多的活动。 +* 那里有一个旧的 *[在 **StackOverflow** 上的 `bpf` 标签][136]*,但是,在这篇文章中它一直没有被使用过(并且那里几乎没有与新的 eBPF 相关的东西)。如果你是一位来自未来的阅读者,你可能想去看看在这方面是否有更多的活动。 ![](https://qmonnet.github.io/whirl-offload/img/icons/zoomin.svg) ### 更多! -* 如果你想很容易地去 **测试 XDP**,那是 [一个 Vagrant 设置][137] 可以使用。你也可以 **测试 bcc**[在一个 Docker 容器中][138]。 +* 如果你想很容易地去 **测试 XDP**,那是 *[一个 Vagrant 设置][137]* 可以使用。你也可以 **测试 bcc** *[在一个 Docker 容器中][138]*。 -* 想知道围绕 BPF 的 **开发和活动** 在哪里吗?好吧,内核补丁总是结束于 [netdev 上的邮件列表][139](相关 Linux 内核的网络栈开发):以关键字 “BPF” 或者 “XDP” 来搜索。自 2017 年 4 月开始,那里也有 [一个专门用于 XDP 编程的邮件列表][140](是为了架构或者寻求帮助)。[在 IO Visor 的邮件列表上][141]也有许多的讨论和辨论,因为 BPF 是一个重要的项目。如果你只是想随时了解情况,那里也有一个 [@IOVisor Twitter 帐户][142]。 +* 想知道围绕 BPF 的 **开发和活动** 在哪里吗?好吧,内核补丁总是结束于 *[netdev 上的邮件列表][139]*(相关 Linux 内核的网络栈开发):以关键字 “BPF” 或者 “XDP” 来搜索。自 2017 年 4 月开始,那里也有 *[一个专门用于 XDP 编程的邮件列表][140]*(是为了架构或者寻求帮助)。[*在 IO Visor 的邮件列表上*][141]也有许多的讨论和辨论,因为 BPF 是一个重要的项目。如果你只是想随时了解情况,那里也有一个 [*@IOVisor Twitter 帐户*][142]。 -我经常会回到这篇博客中,来看一看 [关于 BPF][192] 有没有新的文章! +我经常会回到这篇博客中,来看一看 *[关于 BPF][192]* 有没有新的文章! _特别感谢 Daniel Borkmann 指引我找到了许多的 [附加的文档][154],因此我才完成了这个合集。_ @@ -561,7 +586,7 @@ via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ [42]:http://jvns.ca/blog/2017/04/07/xdp-bpf-tutorial/ [43]:http://www.slideshare.net/ThomasGraf5/clium-container-networking-with-bpf-xdp [44]:http://www.slideshare.net/Docker/cilium-bpf-xdp-for-containers-66969823 -[45]:https://www.youtube.com/watch?v=TnJF7ht3ZYc&list=PLkA60AVN3hh8oPas3cq2VA9xB7WazcIgs +[45]:https://www.youtube.com/watch?v=TnJF7ht3ZYc&amp;amp;list=PLkA60AVN3hh8oPas3cq2VA9xB7WazcIgs [46]:http://www.slideshare.net/ThomasGraf5/cilium-fast-ipv6-container-networking-with-bpf-and-xdp [47]:https://fosdem.org/2017/schedule/event/cilium/ [48]:http://openvswitch.org/support/ovscon2016/7/1120-tu.pdf @@ -629,7 +654,7 @@ via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ [110]:http://netdevconf.org/1.2/session.html?jamal-tc-workshop [111]:https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/commit/bash-completion/tc?id=27d44f3a8a4708bcc99995a4d9b6fe6f81e3e15b [112]:https://prototype-kernel.readthedocs.io/en/latest/networking/XDP/index.html -[113]:https://marc.info/?l=linux-netdev&m=147436253625672 +[113]:https://marc.info/?l=linux-netdev&amp;amp;m=147436253625672 [114]:http://docs.cilium.io/en/latest/bpf/ [115]:https://github.com/iovisor/bcc/blob/master/INSTALL.md [116]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/bpf.h @@ -709,5 +734,15 @@ via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ [190]:https://github.com/torvalds/linux [191]:https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md [192]:https://qmonnet.github.io/whirl-offload/categories/#BPF - - +[193]:https://lwn.net/Articles/740157/ +[194]:https://www.netdevconf.org/2.2/session.html?viljoen-xdpoffload-talk +[195]:https://fosdem.org/2018/schedule/event/xdp/ +[196]:http://blog.kubernetes.io/2017/12/using-ebpf-in-kubernetes.html +[197]:http://suricata.readthedocs.io/en/latest/capture-hardware/ebpf-xdp.html?highlight=XDP#ebpf-and-xdp +[198]:https://github.com/pevma/SEPTun-Mark-II +[199]:https://www.stamus-networks.com/2016/09/28/suricata-bypass-feature/ +[200]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/tools/testing/selftests/bpf +[201]:https://github.com/netoptimizer/prototype-kernel/tree/master/kernel/samples/bpf +[202]:https://github.com/iovisor/bcc/tree/master/tools +[203]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/bpf_trace.c +[204]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/tools/lib/bpf From 40dffff3e510a4d95dc0c5d3f369105a6faa4740 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 2 Apr 2018 17:21:13 +0800 Subject: [PATCH 0252/1057] Delete 20171109 How to record statistics about a Linux machine-s uptime.md --- ...atistics about a Linux machine-s uptime.md | 217 ------------------ 1 file changed, 217 deletions(-) delete mode 100644 sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md diff --git a/sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md b/sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md deleted file mode 100644 index 9b26d7cf7c..0000000000 --- a/sources/tech/20171109 How to record statistics about a Linux machine-s uptime.md +++ /dev/null @@ -1,217 +0,0 @@ -Translating by MjSeven - -How to record statistics about a Linux machine’s uptime -====== -Linux/Unix sysadmins have a weird obsession with server uptime. There is a xkcd comic devoted to this subject where a good sysadmin is an unstoppable force that it stands between the forces of darkness and your cat blog's servers. -[![Fig.01: Devotion to Duty https://xkcd.com/705/][1]][1] -One can tell how long the Linux system has been running using the uptime command or [w command][2] or top command. I can get [a report of the historical and statistical running time of the system][3], keeping it between restarts using tuptime tool. - -Like uptime command but with the more impressive output. Recently I discovered another tool called uptimed that records statistics about a machine's uptime. Let us see how to get uptime record statistics using uptimed and uprecords on Linux operating system. - -Finding uptime is pretty easy, just type the following on your Linux based system: -``` -$ **uptime -p** -up 2 weeks, 4 days, 7 hours, 28 minutes -``` -To keep historical stats about uptime use either [tuptime][3] or uptimed tool. - -## uptimed installation - -The simplest way to install uptimed locally is through your package managers such as apt/apt-get/yum and friends as per your Linux distro. - -### Install uptimed on a Debian/Ubuntu Linux - -Type the following [apt command][4]/[apt-get command][5]: -`$ sudo apt-get install uptimed` -Sample outputs: -``` -Reading package lists... Done -Building dependency tree -Reading state information... Done -The following additional packages will be installed: - libuptimed0 -The following NEW packages will be installed: - libuptimed0 uptimed -0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. -Need to get 40.7 kB of archives. -After this operation, 228 kB of additional disk space will be used. -Do you want to continue? [Y/n] y -Get:1 http://mirrors.linode.com/ubuntu xenial/universe amd64 libuptimed0 amd64 1:0.3.17-4 [9,050 B] -Get:2 http://mirrors.linode.com/ubuntu xenial/universe amd64 uptimed amd64 1:0.3.17-4 [31.6 kB] -Fetched 40.7 kB in 0s (2,738 kB/s) -Preconfiguring packages ... -Selecting previously unselected package libuptimed0. -(Reading database ... 39163 files and directories currently installed.) -Preparing to unpack .../libuptimed0_1%3a0.3.17-4_amd64.deb ... -Unpacking libuptimed0 (1:0.3.17-4) ... -Selecting previously unselected package uptimed. -Preparing to unpack .../uptimed_1%3a0.3.17-4_amd64.deb ... -Unpacking uptimed (1:0.3.17-4) ... -Processing triggers for systemd (229-4ubuntu21) ... -Processing triggers for ureadahead (0.100.0-19) ... -Processing triggers for man-db (2.7.5-1) ... -Setting up libuptimed0 (1:0.3.17-4) ... -Setting up uptimed (1:0.3.17-4) ... -Processing triggers for libc-bin (2.23-0ubuntu9) ... -Processing triggers for systemd (229-4ubuntu21) ... -Processing triggers for ureadahead (0.100.0-19) ... -``` - -### Install uptimed on a CentOS/RHEL/Fedora/Oracle/Scientific Linux - -First [enable EPEL repo on a CentOS/RHEL][6]: -`$ sudo yum -y install epel-release` -Next, type the following [yum command][7]: -`$ sudo yum install uptimed` -Sample outputs: -``` -Loaded plugins: fastestmirror -Loading mirror speeds from cached hostfile - * base: centos.excellmedia.net - * epel: ftp.cuhk.edu.hk - * extras: centos.excellmedia.net - * updates: centos.excellmedia.net -Resolving Dependencies ---> Running transaction check ----> Package uptimed.x86_64 0:0.4.0-6.el7 will be installed ---> Finished Dependency Resolution - -Dependencies Resolved - -=============================================================================== - Package Arch Version Repository Size -=============================================================================== -Installing: - uptimed x86_64 0.4.0-6.el7 epel 47 k - -Transaction Summary -=============================================================================== -Install 1 Package - -Total download size: 47 k -Installed size: 98 k -Is this ok [y/d/N]: y -Downloading packages: -uptimed-0.4.0-6.el7.x86_64.rpm | 47 kB 00:01 -Running transaction check -Running transaction test -Transaction test succeeded -Running transaction - Installing : uptimed-0.4.0-6.el7.x86_64 1/1 - Verifying : uptimed-0.4.0-6.el7.x86_64 1/1 - -Installed: - uptimed.x86_64 0:0.4.0-6.el7 - -Complete! -``` - -If you are using **a Fedora Linux** , run the following dnf command: -`$ sudo dnf install uptimed` - -### Install uptimed on an Arch Linux - -Type the following pacman command: -`$ sudo pacman -S uptimed` - -### Install uptimed on a Gentoo Linux - -Type the following emerge command: -`$ sudo emerge --ask uptimed` - -## How to configure uptimed - -Edit the file /etc/uptimed.conf using a text editor such as vim command: -`$ sudo vim /etc/uptimed.conf` -At least set an email address to mail milestones/records to. Assumes sendmail compatible MTA installed as /usr/lib/sendmail. -``` -EMAIL=vivek@server1.cyberciti.biz -``` -Save and close the file. - -### How do I enable uptimed service at boot time? - -Enable uptimed service using the systemctl command: -`$ sudo systemctl enable uptimed` - -### How do I start/stop/restart or view status of uptimed service? - -``` -$ sudo systemctl start uptimed ## start it ## -$ sudo systemctl stop uptimed ## stop it ## -$ sudo systemctl restart uptimed ## restart it ## -$ sudo systemctl status uptimed ## view status ## -``` -Sample outputs: -``` -● uptimed.service - uptime record daemon - Loaded: loaded (/lib/systemd/system/uptimed.service; enabled; vendor preset: enabled) - Active: active (running) since Thu 2017-11-09 17:49:14 UTC; 18min ago - Main PID: 11137 (uptimed) - CGroup: /system.slice/uptimed.service - └─11137 /usr/sbin/uptimed -f - -Nov 09 17:49:14 gfs04 systemd[1]: Started uptime record daemon. -``` - -## How to see uptime record - -Simply type the following command to see statistics from the uptimed(8) program: -``` -$ uprecords -``` -Sample outputs: -[![Fig.02: uprecords in action][9]][9] -uprecords has a few more option: -``` -$ uprecords -? -``` -Sample outputs: -``` -usage: uprecords [OPTION]... - - -? this help - -a do not print ansi codes - -b sort by boottime - -B reverse sort by boottime - -k sort by sysinfo - -K reverse sort by sysinfo - -d print downtime seen before every uptimes instead of system - -c do not show current entry if not in top entries - -f run continously in a loop - -s do not print extra statistics - -w wide output (more than 80 cols per line) - -i INTERVAL use INTERVAL seconds for loop instead of 5, implies -f - -m COUNT show a maximum of top COUNT entries instead of 10 - -M show next milestone - -v version information -``` - -## Conclusion - -This is an excellent little tool to show your server uptime records to prove your uptime and business continuity. On a related note, you should get the official [XKCD sysadmin t-shirt][10] as comic was made into a shirt, which includes a new illustration on the back. -[![Fig.03: Sysadmin XKCD shirt features the original comic on the front and a new illustration on the back.][11]][11] - - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/hardware/see-records-statistics-about-a-linux-servers-uptime/ - -作者:[][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz -[1]:https://www.cyberciti.biz/media/new/cms/2017/11/devotion_to_duty.png -[2]:https://www.cyberciti.biz//www.cyberciti.biz/faq/unix-linux-w-command-examples-syntax-usage-2/ (See Linux/Unix w command examples for more info) -[3]:https://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/ -[4]:https://www.cyberciti.biz//www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) -[5]:https://www.cyberciti.biz//www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) -[6]:https://www.cyberciti.biz/faq/installing-rhel-epel-repo-on-centos-redhat-7-x/ -[7]:https://www.cyberciti.biz//www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/ (See Linux/Unix yum command examples for more info) -[8]:https://www.cyberciti.biz/cdn-cgi/l/email-protection -[9]:https://www.cyberciti.biz/media/new/cms/2017/11/uprecord-screenshot.jpg -[10]:https://store.xkcd.com/collections/apparel/products/sysadmin -[11]:https://www.cyberciti.biz/media/new/cms/2017/11/sysadmin_shirt_5_1024x1024.jpg From 7c1fc74396a7730bfc1a6fef58081cc919bf47f8 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 2 Apr 2018 17:21:51 +0800 Subject: [PATCH 0253/1057] Create 20171109 How to record statistics about a Linux machine-s uptime.md --- ...atistics about a Linux machine-s uptime.md | 221 ++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md diff --git a/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md b/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md new file mode 100644 index 0000000000..385de3f741 --- /dev/null +++ b/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md @@ -0,0 +1,221 @@ +如何记录有关 Linux 机器正常运行时间的统计信息 +===== + +Linux/Unix 系统管理员对服务器正常运行时间有一种奇怪的痴迷。这有一个关于这个主题的 xkcd 漫画,一个好的系统管理员是一股不可阻挡的力量,它站在黑暗势力和你的猫博客服务器之间。(这句话实在理解不了。) + +[![Fig.01: Devotion to Duty https://xkcd.com/705/][1]][1] + +我们可以使用 uptime 命令或 [w 命令][2] 或 top 命令来判断 Linux 系统运行了多久。我可以[获得系统的历史和统计运行时间的报告][3],使用 tuptime 工具将其保持在重新启动之间。 + +就像 uptime 命令一样,但输出结果更令人印象深刻。最近我发现了另一种称为 uptimed 的工具,用于记录关于机器正常运行时间和统计信息。让我们看看如何使用 Linux 操作系统上的 uptimed 和 uprecords 来获得正常运行时间的记录统计信息。 + +查找正常运行时间非常简单,只需在基于 Linux 的系统上键入以下命令即可: +``` +$ **uptime -p** +up 2 weeks, 4 days, 7 hours, 28 minutes +``` + +要保留有关 uptime 的历史统计信息,请使用 [tuptime][3] 或 uptime 工具。 + +## 安装 uptimed + +安装 uptimed 的最简单的方式是通过你的软件包管理器,比如 apt/apt-get/yum,这些你的 Linux 发行版的朋友。 + +### 在 Debian/Ubuntu Linux 上安装 uptimed + +键入以下 [apt 命令][4]/[apt-get 命令][5]: +`$ sudo apt-get install uptimed` +示例输出: +``` +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following additional packages will be installed: + libuptimed0 +The following NEW packages will be installed: + libuptimed0 uptimed +0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. +Need to get 40.7 kB of archives. +After this operation, 228 kB of additional disk space will be used. +Do you want to continue? [Y/n] y +Get:1 http://mirrors.linode.com/ubuntu xenial/universe amd64 libuptimed0 amd64 1:0.3.17-4 [9,050 B] +Get:2 http://mirrors.linode.com/ubuntu xenial/universe amd64 uptimed amd64 1:0.3.17-4 [31.6 kB] +Fetched 40.7 kB in 0s (2,738 kB/s) +Preconfiguring packages ... +Selecting previously unselected package libuptimed0. +(Reading database ... 39163 files and directories currently installed.) +Preparing to unpack .../libuptimed0_1%3a0.3.17-4_amd64.deb ... +Unpacking libuptimed0 (1:0.3.17-4) ... +Selecting previously unselected package uptimed. +Preparing to unpack .../uptimed_1%3a0.3.17-4_amd64.deb ... +Unpacking uptimed (1:0.3.17-4) ... +Processing triggers for systemd (229-4ubuntu21) ... +Processing triggers for ureadahead (0.100.0-19) ... +Processing triggers for man-db (2.7.5-1) ... +Setting up libuptimed0 (1:0.3.17-4) ... +Setting up uptimed (1:0.3.17-4) ... +Processing triggers for libc-bin (2.23-0ubuntu9) ... +Processing triggers for systemd (229-4ubuntu21) ... +Processing triggers for ureadahead (0.100.0-19) ... +``` + +### 在 CentOS/RHEL/Fedora/Oracle/Scientific Linux 上安装 uptimed + +首先 [在 CentOS/RHEL 使用 EPEL repo][6]: +`$ sudo yum -y install epel-release` +然后,键入以下 [yum 命令][7]: +`$ sudo yum install uptimed` +示例输出: +``` +Loaded plugins: fastestmirror +Loading mirror speeds from cached hostfile + * base: centos.excellmedia.net + * epel: ftp.cuhk.edu.hk + * extras: centos.excellmedia.net + * updates: centos.excellmedia.net +Resolving Dependencies +--> Running transaction check +---> Package uptimed.x86_64 0:0.4.0-6.el7 will be installed +--> Finished Dependency Resolution + +Dependencies Resolved + +=============================================================================== + Package Arch Version Repository Size +=============================================================================== +Installing: + uptimed x86_64 0.4.0-6.el7 epel 47 k + +Transaction Summary +=============================================================================== +Install 1 Package + +Total download size: 47 k +Installed size: 98 k +Is this ok [y/d/N]: y +Downloading packages: +uptimed-0.4.0-6.el7.x86_64.rpm | 47 kB 00:01 +Running transaction check +Running transaction test +Transaction test succeeded +Running transaction + Installing : uptimed-0.4.0-6.el7.x86_64 1/1 + Verifying : uptimed-0.4.0-6.el7.x86_64 1/1 + +Installed: + uptimed.x86_64 0:0.4.0-6.el7 + +Complete! +``` + +如果你正在使用 **Fedora Linux**,运行以下 dnf 命令: +`$ sudo dnf install uptimed` + +### 在 Arch Linux 上安装 uptimed + +键入以下 pacman 命令: +`$ sudo pacman -S uptimed` + +### 在 Gentoo Linux 上安装 uptimed + +键入以下 emerge 命令: +`$ sudo emerge --ask uptimed` + +## 如何配置 uptimed + +使用文本编辑器编辑 /etc/uptimed.conf 文件,例如 vim 命令: +`$ sudo vim /etc/uptimed.conf` +最少设置一个 email 地址来发送记录。假定发送邮件兼容 MTA。 +``` +EMAIL=vivek@server1.cyberciti.biz +``` +保存并关闭文件。 + +### 如何在系统启动时启动 uptimed 服务? + +使用 systemctl 命令启动 uptimed 服务: +`$ sudo systemctl enable uptimed` + +### 我该如何 启动/停止/重启 或者查看 uptimed 服务的状态? + +``` +$ sudo systemctl start uptimed ## start it ## +$ sudo systemctl stop uptimed ## stop it ## +$ sudo systemctl restart uptimed ## restart it ## +$ sudo systemctl status uptimed ## view status ## +``` +示例输出: +``` +● uptimed.service - uptime record daemon + Loaded: loaded (/lib/systemd/system/uptimed.service; enabled; vendor preset: enabled) + Active: active (running) since Thu 2017-11-09 17:49:14 UTC; 18min ago + Main PID: 11137 (uptimed) + CGroup: /system.slice/uptimed.service + └─11137 /usr/sbin/uptimed -f + +Nov 09 17:49:14 gfs04 systemd[1]: Started uptime record daemon. +``` + +## 如何查看 uptime 记录 + +只需键入以下命令即可查看 uptimed(8) 程序的统计信息: +``` +$ uprecords +``` + +示例输出: +[![Fig.02: uprecords in action][9]][9] + +uprecords 有一些选项: +``` +$ uprecords -? +``` +示例输出: +``` +usage: uprecords [OPTION]... + + -? this help + -a do not print ansi codes + -b sort by boottime + -B reverse sort by boottime + -k sort by sysinfo + -K reverse sort by sysinfo + -d print downtime seen before every uptimes instead of system + -c do not show current entry if not in top entries + -f run continously in a loop + -s do not print extra statistics + -w wide output (more than 80 cols per line) + -i INTERVAL use INTERVAL seconds for loop instead of 5, implies -f + -m COUNT show a maximum of top COUNT entries instead of 10 + -M show next milestone + -v version information +``` + +## 结论 + +这是一个极好的小工具,可以显示服务器正常运行时间的记录,以证明机器正常运行时间和你的业务连续性。在相关说明中,你将获得官方的 [XKCD 系统管理员 T恤][10] 因为漫画被制作成衬衫,其中包括背面的新插图。 + +[![Fig.03: Sysadmin XKCD shirt features the original comic on the front and a new illustration on the back.][11]][11] + +-------------------------------------------------------------------------------- + +via: https://www.cyberciti.biz/hardware/see-records-statistics-about-a-linux-servers-uptime/ + +作者:[][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz +[1]:https://www.cyberciti.biz/media/new/cms/2017/11/devotion_to_duty.png +[2]:https://www.cyberciti.biz//www.cyberciti.biz/faq/unix-linux-w-command-examples-syntax-usage-2/ (See Linux/Unix w command examples for more info) +[3]:https://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/ +[4]:https://www.cyberciti.biz//www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) +[5]:https://www.cyberciti.biz//www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) +[6]:https://www.cyberciti.biz/faq/installing-rhel-epel-repo-on-centos-redhat-7-x/ +[7]:https://www.cyberciti.biz//www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/ (See Linux/Unix yum command examples for more info) +[8]:https://www.cyberciti.biz/cdn-cgi/l/email-protection +[9]:https://www.cyberciti.biz/media/new/cms/2017/11/uprecord-screenshot.jpg +[10]:https://store.xkcd.com/collections/apparel/products/sysadmin +[11]:https://www.cyberciti.biz/media/new/cms/2017/11/sysadmin_shirt_5_1024x1024.jpg From 7b21d5c17015aef652fe8ca1ee8ff3f91b586b0f Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 2 Apr 2018 17:45:13 +0800 Subject: [PATCH 0254/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20buil?= =?UTF-8?q?d=20a=20plotter=20with=20Arduino?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...331 How to build a plotter with Arduino.md | 262 ++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 sources/tech/20180331 How to build a plotter with Arduino.md diff --git a/sources/tech/20180331 How to build a plotter with Arduino.md b/sources/tech/20180331 How to build a plotter with Arduino.md new file mode 100644 index 0000000000..bd7f95c160 --- /dev/null +++ b/sources/tech/20180331 How to build a plotter with Arduino.md @@ -0,0 +1,262 @@ +How to build a plotter with Arduino +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_Arduino_520x292.png?itok=joCojk4e) +Back in school, there was an HP plotter well hidden in a closet in the science department. I got to play with it for a while and always wanted to have one of my own. Fast forward many, many years. Stepper motors are easily available, I am back into doing stuff with electronics and micro-controllers, and I recently saw someone creating displays with engraved acrylic. This triggered me to finally build my own plotter. + + +![The plotter in action ][2] + +The DIY plotter; see it in action in this [video][3]. + +As an old-school 5V guy, I really like the original [Arduino Uno][4]. Here's a list of the other components I used (fyi, I am not affiliated with any of these companies): + + * [FabScan shield][5]: Physically hosts the stepper motor drivers. + * [SilentStepSticks][6]: Motor drivers, as the Arduino on its own can't handle the voltage and current that a stepper motor needs. I am using ones with a Trinamic TMC2130 chip, but in standalone mode for now. Those are replacements for the Pololu 4988, but allow for much quieter operation. + * [SilentStepStick protectors][7]: Diodes that prevent the turning motor from frying your motor drivers (you want them, believe me). + * Stepper motors: I selected NEMA 17 motors with 12V (e.g., models from [Watterott][8] and [SparkFun][9]). + * [Linear guide rails][10] + * Wooden base plate + * Wood screws + * GT2 belt + * [GT2 timing pulley][11] + + + +This is a work in progress that I created as a personal project. If you are looking for a ready-made kit, then check out the [MaXYposi][12] from German Make magazine. + +### Hardware setup + +As you can see here, I started out much too large. This plotter can't comfortably sit on my desk, but it's okay, as I did it for learning purposes (and, as I have to re-do some things, next time I'll use smaller beams). + + +![Plotter base plate with X-axis and Y-axis rails][14] + +Plotter base plate with X-axis and Y-axis rails + +The belt is mounted on both sides of the rail and then slung around the motor with some helper wheels: + + +![The belt routing on the motor][16] + +The belt routing on the motor + +I've stacked several components on top of the Arduino. The Arduino is on the bottom, above that is the FabScan shield, next is a StepStick protector on motor slots 1+2, and the SilentStepStick is on top. Note that the SCK and SDI pins are not connected. + + +![Arduino and Shield][18] + +Arduino stack setup ([larger image][19]) + +Be careful to correctly attach the wires to the motor. When in doubt, look at the data sheet or an ohmmeter to figure out which wires belong together. + +### Software setup + +#### The basics + +While software like [grbl][20] can interpret so-called G-codes for tool movement and other things, and I could have just flashed it to the Arduino, I am curious and wanted to better understand things. (My X-Y plotter software is available at [GitHub][21] and comes without any warranty.) + +To drive a stepper motor with the StepStick (or compatible) driver, you basically need to send a high and then a low signal to the respective pin. Or in Arduino terms: +``` +digitalWrite(stepPin, HIGH); + +delayMicroseconds(30); + +digitalWrite(stepPin, LOW); + +``` + +Where `stepPin` is the pin number for the stepper: 3 for motor 1 and 6 for motor 2. + +Before the stepper does any work, it must be enabled. +``` +digitalWrite(enPin, LOW); + +``` + +Actually, the StepStick knows three states for the pin: + + * Low: Motor is enabled + * High: Motor is disabled + * Pin not connected: Motor is enabled but goes into an energy-saving mode after a while + + + +When a motor is enabled, its coils are powered and it keeps its position. It is almost impossible to manually turn its axis. This is good for precision purposes, but it also means that both motors and driver chips are "flooded" with power and will warm up. + +And last, but not least, we need a way to determine the plotter's direction: +``` +digitalWrite(dirPin, direction); + +``` + +The following table lists the functions and the pins + +Function Motor1 Motor2 Enable 2 5 Direction 4 7 Step 3 6 + +Before we can use the pins, we need to set them to `OUTPUT` mode in the `setup()` section of the code +``` +pinMode(enPin1, OUTPUT); + +pinMode(stepPin1, OUTPUT); + +pinMode(dirPin1, OUTPUT); + +digitalWrite(enPin1, LOW); + +``` + +With this knowledge, we can easily get the stepper to move around: +``` +    totalRounds = ... + +    for (int rounds =0 ; rounds < 2*totalRounds; rounds++) { + +       if (dir==0){ // set direction + +         digitalWrite(dirPin2, LOW); + +       } else { + +         digitalWrite(dirPin2, HIGH); + +       } + +       delay(1); // give motors some breathing time + +       dir = 1-dir; // reverse direction + +       for (int i=0; i < 6400; i++) { + +         int t = abs(3200-i) / 200; + +         digitalWrite(stepPin2, HIGH); + +         delayMicroseconds(70 + t); + +         digitalWrite(stepPin2, LOW); + +         delayMicroseconds(70 + t); + +       } + +    } + +``` + +This will make the slider move left and right. This code deals with one stepper, but for an X-Y plotter, we have two axes to consider. + +#### Command interpreter + +I started to implement a simple command interpreter to use path specifications, such as: +``` +"X30|Y30|X-30 Y-30|X-20|Y-20|X20|Y20|X-40|Y-25|X40 Y25 + +``` + +to describe relative movements in millimeters (1mm equals 80 steps). + +The plotter software implements a _continuous mode_ , which allows a PC to feed large paths (in chunks) to the plotter. (This how I plotted the Hilbert curve in this [video][22].) + +### Building a better pen holder + +In the first image above, the pen was tied to the Y-axis with some metal string. This was not precise and also did not enable the software to raise and lower the hand (this explains the big black dots). + +I have since created a better, more precise pen holder that uses a servo to raise and lower the pen. This new, improved holder can be seen in this picture and in the Hilbert curve video linked above. + +![Servo to raise/lower the pen ][24] + +Close-up view of the servo arm in the upper position raising the pen + +The pen is attached with a little clamp (the one shown is a size 8 clamp typically used to attach cables to walls). The servo arm can raise the pen; when the arm goes down, gravity will lower the pen. + +#### Driving the servo + +Driving the servo is relatively straightforward: Just provide the position and the servo does all the work. +``` +#include + + + +// Servo pin + +#define servoData PIN_A1 + + + +// Positions + +#define PEN_UP 10 + +#define PEN_DOWN 50 + + + +Servo penServo; + + + +void setup() { + +  // Attach to servo and raise pen + +  penServo.attach(servoData); + +  penServo.write(PEN_UP); + +} + +``` + +I am using the servo headers on the Motor 4 place of the FabScan shield, so I've used analog pin 1. + +Lowering the pen is as easy as: +``` +  penServo.write(PEN_DOWN); + +``` + +### Next steps + +One of my next steps will be to add some end detectors, but I may skip them and use the StallGuard mode of the TMC2130 instead. Those detectors can also be used to implement a `home` command. + +And perhaps in the future I'll add a real Z-axis that can hold an engraver to do wood milling, or PCB drilling, or acrylic engraving, or ... (a laser comes to mind as well). + +This was originally published on the [Some Things to Remember][25] blog and is reprinted with permission. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/diy-plotter-arduino + +作者:[Heiko W.Rupp][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/pilhuhn +[1]:https://opensource.com/file/384786 +[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/plotter-in-action.png?itok=q9oHrJGr (The plotter in action ) +[3]:https://twitter.com/pilhuhn/status/948205323726344193 +[4]:https://en.wikipedia.org/wiki/Arduino#Official_boards +[5]:http://www.watterott.com/de/Arduino-FabScan-Shield +[6]:http://www.watterott.com/de/SilentStepStick-TMC2130 +[7]:http://www.watterott.com/de/SilentStepStick-Protector +[8]:http://www.watterott.com/de/Schrittmotor-incl-Anschlusskabel +[9]:https://www.sparkfun.com/products/9238 +[10]:https://www.ebay.de/itm/CNC-Set-12x-600mm-Linearfuhrung-Linear-Guide-Rail-Stage-3D-/322917927292?hash=item4b2f68897c +[11]:http://www.watterott.com/de/OpenBuilds-GT2-2mm-Aluminium-Timing-Pulley +[12]:https://www.heise.de/make/artikel/MaXYposi-Projektseite-zum-universellen-XY-Portalroboter-von-Make-3676050.html +[13]:https://opensource.com/file/384776 +[14]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/entire_plotter.jpg?itok=40iSEs5K (Plotter base plate with X-axis and Y-axis rails) +[15]:https://opensource.com/file/384791 +[16]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/y_motor_detail.jpg?itok=SICJBdRv (The belt routing on the motor) +[17]:https://opensource.com/file/384771 +[18]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/arduino_and_shield.jpg?itok=OFumhpJm +[19]:https://www.dropbox.com/s/7bp3bo5g2ujser8/IMG_20180103_110111.jpg?dl=0 +[20]:https://github.com/gnea/grbl +[21]:https://github.com/pilhuhn/xy-plotter +[22]:https://twitter.com/pilhuhn/status/949737734654124032 +[23]:/https://opensource.comfile/384781 +[24]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pen_servo.jpg?itok=b2cnwB3P (Servo to raise/lower the pen ) +[25]:http://pilhuhn.blogspot.com/2018/01/homegrown-xy-plotter-with-arduino.html From 2772b76f72e06137b73c1b6ccaaa74050386bb38 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 2 Apr 2018 17:47:13 +0800 Subject: [PATCH 0255/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Emacs=20#4:=20A?= =?UTF-8?q?utomated=20emails=20to=20org-mode=20and=20org-mode=20syncing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...emails to org-mode and org-mode syncing.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 sources/tech/20180331 Emacs -4- Automated emails to org-mode and org-mode syncing.md diff --git a/sources/tech/20180331 Emacs -4- Automated emails to org-mode and org-mode syncing.md b/sources/tech/20180331 Emacs -4- Automated emails to org-mode and org-mode syncing.md new file mode 100644 index 0000000000..4efe606f51 --- /dev/null +++ b/sources/tech/20180331 Emacs -4- Automated emails to org-mode and org-mode syncing.md @@ -0,0 +1,72 @@ +Emacs #4: Automated emails to org-mode and org-mode syncing +====== +This is fourth in [a series on Emacs and org-mode][1]. + +Hopefully by now you’ve started to see how powerful and useful org-mode is. If you’re like me, you’re thinking: + +“I’d really like to have this in sync across all my devices.” + +and, perhaps: + +“Can I forward emails into org-mode?” + +This being Emacs, the answers, of course, are “Yes.” + +### Syncing + +Since org-mode just uses text files, syncing is pretty easily accomplished using any number of tools. I use git with git-remote-gcrypt. Due to some limitations of git-remote-gcrypt, each machine tends to push to its own branch, and to master on command. Each machine merges from all the other branches and pushes the result to master after a merge. A cron job causes pushes to the machine’s branch to happen, and a bit of elisp coordinates it all — making sure to save buffers before a sync, refresh them from disk after, etc. + +The code for this post is somewhat more extended, so I will be linking to it on github rather than posting inline. + +I have a directory $HOME/org where all my org-stuff lives. In ~/org lives [a Makefile][2] that handles the syncing. It defines these targets: + + * push: adds, commits, and pushes to a branch named after the machine’s hostname + * fetch: does a simple git fetch + * sync: adds, commits, pulls remote changes, merges, and (assuming the merge was successful) pushes to the branch named after the machine’s hostname plus master + + + +Now, in my user’s crontab, I have this: +``` +*/15 * * * * make -C $HOME/org push fetch 2>&1 | logger --tag 'orgsync' + +``` + +The [accompanying elisp code][3] defines a shortcut (C-c s) to cause a sync to occur. Thanks to the cronjob, as long as files were saved — even if I didn’t explicitly sync on the other boxen — they’ll be pulled in. + +I have found this setup to work really well. + +### Emailing to org-mode + +Before going down this path, one should ask the question: do you really need it? I use org-mode with mu4e, and the integration is excellent; any org task can link to an email by message-id, and this is ideal — it lets a person do things like make a reminder to reply to a message in a week. + +However, org is not just about reminders. It’s also a knowledge base, authoring system, etc. And, not all of my mail clients use mu4e. (Note: things like MobileOrg exist for mobile devices). I don’t actually use this as much as I thought I would, but it has its uses and I thought I’d document it here too. + +Now I didn’t want to just be able to accept plain text email. I wanted to be able to handle attachments, HTML mail, etc. This quickly starts to sound problematic — but with tools like ripmime and pandoc, it’s not too bad. + +The first step is to set up some way to get mail into a specific folder. A plus-extension, special user, whatever. I then use a [fetchmail configuration][4] to pull it down and run my [insorgmail][5] script. + +This script is where all the interesting bits happen. It starts with ripmime to process the message. HTML bits are converted from HTML to org format using pandoc. an org hierarchy is made to represent the structure of the email as best as possible. emails can get pretty complicated, with HTML and the rest, but I have found this does an acceptable job with my use cases. + +### Up next… + +My last post on org-mode will talk about using it to write documents and prepare slides — a use for which I found myself surprisingly pleased with it, but which needed a bit of tweaking. + + + +-------------------------------------------------------------------------------- + +via: http://changelog.complete.org/archives/9898-emacs-4-automated-emails-to-org-mode-and-org-mode-syncing + +作者:[John Goerzen][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://changelog.complete.org/ +[1]:https://changelog.complete.org/archives/tag/emacs2018 +[2]:https://github.com/jgoerzen/public-snippets/blob/master/emacs/org-tools/Makefile +[3]:https://github.com/jgoerzen/public-snippets/blob/master/emacs/org-tools/emacs-config.org +[4]:https://github.com/jgoerzen/public-snippets/blob/master/emacs/org-tools/fetchmailrc.orgmail +[5]:https://github.com/jgoerzen/public-snippets/blob/master/emacs/org-tools/insorgmail From c3f86b61a93592bf7103bb53acbdd757b22fcfaa Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 3 Apr 2018 08:50:20 +0800 Subject: [PATCH 0256/1057] translated --- ...g a community is worth the extra effort.md | 68 ------------------- ...g a community is worth the extra effort.md | 66 ++++++++++++++++++ 2 files changed, 66 insertions(+), 68 deletions(-) delete mode 100644 sources/tech/20180116 Why building a community is worth the extra effort.md create mode 100644 translated/tech/20180116 Why building a community is worth the extra effort.md diff --git a/sources/tech/20180116 Why building a community is worth the extra effort.md b/sources/tech/20180116 Why building a community is worth the extra effort.md deleted file mode 100644 index 68467a96cf..0000000000 --- a/sources/tech/20180116 Why building a community is worth the extra effort.md +++ /dev/null @@ -1,68 +0,0 @@ -translating---geekpi - -Why building a community is worth the extra effort -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_brandbalance.png?itok=XSQ1OU16) - -When we launched [Nethesis][1] in 2003, we were just system integrators. We only used existing open source projects. Our business model was clear: Add multiople forms of value to those projects: know-how, documentation for the Italian market, extra modules, professional support, and training courses. We gave back to upstream projects as well, through upstream code contributions and by participating in their communities. - -Times were different then. We couldn't use the term "open source" too loudly. People associated it with words like: "nerdy," "no value" and, worst of all, "free." Not too good for a business. - -On a Saturday in 2010, with pasties and espresso in hand, the Nethesis staff were discussing how to move things forward (hey, we like to eat and drink while we innovate!). In spite of the momentum working against us, we decided not to change course. In fact, we decided to push harder--to make open source, and an open way of working, a successful model for running a business. - -Over the years, we've proven that model's potential. And one thing has been key to our success: community. - -In this three-part series, I'll explain the important role community plays in an open organization's existence. I'll explore why an organization would want to build a community, and discuss how to build one--because I really do believe it's the best way to generate new innovations today. - -### The crazy idea - -Together with the Nethesis guys, we decided to build our own open source project: our own operating system, built on top of CentOS (because we didn't want to reinvent the wheel). We assumed that we had the experience, know-how, and workforce to achieve it. We felt brave. - -And we very much wanted to build an operating system called [NethServer][2] with one mission: making a sysadmin's life easier with open source. We knew we could create a Linux distribution for a server that would be more accessible, easier to adopt, and simpler to understand than anything currently offered. - -Above all, though, we decided to create a real, 100% open project with three primary rules: - - * completely free to download, - * openly developed, and - * community-driven - - - -That last one is important. We were a company; we were able to develop it by ourselves. We would have been more effective (and made quicker decisions) if we'd done the work in-house. It would be so simple, like any other company in Italy. - -But we were so deeply into open source culture culture that we chose a different path. - -We really wanted as many people as possible around us, around the product, and around the company. We wanted as many perspectives on the work as possible. We realized: Alone, you can go fast--but if you want to go far, you need to go together. - -So we decided to build a community instead. - -### What next? - -We realized that creating a community has so many benefits. For example, if the people who use your product are really involved in the project, they will provide feedback and use cases, write documentation, catch bugs, compare with other products, suggest features, and contribute to development. All of this generates innovations, attracts contributors and customers, and expands your product's user base. - -But quicky the question arose: How can we build a community? We didn't know how to achieve that. We'd participated in many communities, but we'd never built one. - -We were good at code--not with people. And we were a company, an organization with very specific priorities. So how were we going to build a community and a foster good relationships between the company and the community itself? - -We did the first thing you had to do: study. We learned from experts, blogs, and lots of books. We experimented. We failed many times, collected data from the outcomes, and tested them again. - -Eventually we learned the golden rule of the community management: There is no golden rule of community management. - -People are too complex and communities are too different to have one rule "to rule them all," - -One thing I can say, however, is that an healthy relationship between a community and a company is always a process of give and take. In my next article, I'll discuss what your organization should expect to give if it wants a flourishing and innovating community. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/1/why-build-community-1 - -作者:[Alessio Fattorini][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/alefattorini -[1]:http://www.nethesis.it/ -[2]:http://www.nethserver.org/ diff --git a/translated/tech/20180116 Why building a community is worth the extra effort.md b/translated/tech/20180116 Why building a community is worth the extra effort.md new file mode 100644 index 0000000000..6ff0d4d213 --- /dev/null +++ b/translated/tech/20180116 Why building a community is worth the extra effort.md @@ -0,0 +1,66 @@ +为什么建设一个社区值得额外的努力 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_brandbalance.png?itok=XSQ1OU16) + +当我们在 2003 年推出 [Nethesis][1] 时,我们还只是系统集成商。我们只使用现有的开源项目。我们的业务模式非常明确:为这些项目增加多种形式的价值:实践知识、针对意大利市场的文档、额外模块、专业支持和培训课程。我们还通过向上游贡献代码并参与其社区来回馈上游项目。 + +那时时代不同。我们不能太张扬地使用“开源”这个词。人们将它与诸如“书呆子”,“没有价值”而最糟糕的是“自由”这些词联系起来。这些不太适合生意。 + +在 2010 年的一个星期六,Nethesis 的工作人员,他们手中拿着馅饼和浓咖啡,正在讨论如何推进事情发展(嘿,我们喜欢在创新的同时吃喝东西!)。尽管势头对我们不利,但我们决定不改变方向。事实上,我们决定加大力度 - 去做开源和开放的工作方式,这是一个成功运营企业的模式。 + +多年来,我们已经证明了该模型的潜力。有一件事是我们成功的关键:社区。 + +在这个由三部分组成的系列文章中,我将解释社区在开放组织的存在中扮演的重要角色。我将探讨为什么一个组织希望建立一个社区,并讨论如何建立一个社区 - 因为我确实认为这是如今产生新创新的最佳方式。 + +### 这个疯狂的想法 + +与 Nethesis 伙伴一起,我们决定构建自己的开源项目:我们自己的操作系统,它建立在 CentOS 之上(因为我们不想重新发明轮子)。我们假设我们拥有实现它的经验、实践知识和人力。我们感到很勇敢。 + +我们非常希望构建一个名为 [NethServer][2] 的操作系统,其使命是:通过开源使系统管理员的生活更轻松。我们知道我们可以为服务器创建一个 Linux 发行版,与当前提供的任何东西相比,这些发行版更容易获取、更易于使用,并且更易于理解。 + +不过,最重要的是,我们决定创建一个真正的,100% 开放的项目,其主要规则有三条: + + * 完全免费下载 + * 开发公开 + * 社区驱动 + + + +最后一个很重要。我们是一家公司。我们能够自己开发它。如果我们在内部完成这项工作,我们将会更有效(并且做出更快的决定)。与其他任何意大利公司一样,这将非常简单。 + +但是我们已经如此深入到开源文化中,所以我们选择了不同的路径。 + +我们确实希望有尽可能多的人围绕着我们、围绕着产品、围绕着公司周围。我们希望对工作有尽可能多的视角。我们意识到:独自一人,你可以走得快 - 但是如果你想走很远,你需要一起走。 + +所以我们决定建立一个社区。 + +### 下一步是什么? + +我们意识到创建社区有很多好处。例如,如果使用产品的人真正参与到项目中,他们将提供反馈和测试用例、编写文档、发现 bug,与其他产品进行比较,建议功能并为开发做出贡献。所有这些都会产生创新,吸引贡献者和客户,并扩展你产品的用户群。 + +但是很快就出现了这样一个问题:我们如何建立一个社区?我们不知道如何实现这一点。我们参加了很多社区,但我们从未建立过一个社区。 + +我们擅长编码 - 而不是人。我们是一家公司,是一个有非常具体优先事项的组织。那么我们如何建立一个社区,并在公司和社区之间建立良好的关系呢? + +我们做了你必须做的第一件事:学习。我们从专家、博客和许多书中学到了知识。我们进行了实验。我们失败了多次,从结果中收集数据,并再次进行测试。 + +最终我们学到了社区管理的黄金法则:没有社区管理的黄金法则。 + +人们太复杂了,社区无法用一条规则来“统治他们”。 + +然而,我可以说的一件事是,社区和公司之间的健康关系总是一个给予和接受的过程。在我的下一篇文章中,我将讨论你的组织如果想要一个蓬勃发展和创新的社区,应该期望提供什么。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/18/1/why-build-community-1 + +作者:[Alessio Fattorini][a] +译者:[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/alefattorini +[1]:http://www.nethesis.it/ +[2]:http://www.nethserver.org/ From f86d0fb9165c4b236ffe496b747d4aeb5ae2e35e Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 3 Apr 2018 08:54:47 +0800 Subject: [PATCH 0257/1057] translating --- sources/tech/20171027 Scary Linux commands for Halloween.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171027 Scary Linux commands for Halloween.md b/sources/tech/20171027 Scary Linux commands for Halloween.md index 4c1c29470e..9ba85a29ba 100644 --- a/sources/tech/20171027 Scary Linux commands for Halloween.md +++ b/sources/tech/20171027 Scary Linux commands for Halloween.md @@ -1,3 +1,5 @@ +translating---geekpi + Scary Linux commands for Halloween ====== With Halloween so fast approaching, it's time for a little focus on the spookier side of Linux. What commands might bring up images of ghosts, witches and zombies? Which might encourage the spirit of trick or treat? From 74c2090d2519d3c75b27297e662702e2836dab59 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 3 Apr 2018 10:37:08 +0800 Subject: [PATCH 0258/1057] Update 20171207 How to use KVM cloud images on Ubuntu Linux.md --- .../20171207 How to use KVM cloud images on Ubuntu Linux.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md b/sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md index 4420807de7..114b277835 100644 --- a/sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md +++ b/sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + How to use KVM cloud images on Ubuntu Linux ====== From 48eda5ff834657172ca787a354591cd85e5d6972 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 3 Apr 2018 11:01:01 +0800 Subject: [PATCH 0259/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Understanding?= =?UTF-8?q?=20Linux=20filesystems:=20ext4=20and=20beyond?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ding Linux filesystems- ext4 and beyond.md | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md diff --git a/sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md new file mode 100644 index 0000000000..9e1b37b043 --- /dev/null +++ b/sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -0,0 +1,249 @@ +Understanding Linux filesystems: ext4 and beyond +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR) + +The majority of modern Linux distributions default to the ext4 filesystem, just as previous Linux distributions defaulted to ext3, ext2, and—if you go back far enough—ext. + +If you're new to Linux—or to filesystems—you might wonder what ext4 brings to the table that ext3 didn't. You might also wonder whether ext4 is still in active development at all, given the flurries of news coverage of alternate filesystems such as btrfs, xfs, and zfs. + +We can't cover everything about filesystems in a single article, but we'll try to bring you up to speed on the history of Linux's default filesystem, where it stands, and what to look forward to. + +I drew heavily on Wikipedia's various ext filesystem articles, kernel.org's wiki entries on ext4, and my own experiences while preparing this overview. + +### A brief history of ext + +#### MINIX filesystem + +Before there was ext, there was the MINIX filesystem. If you're not up on your Linux history, MINIX was a very small Unix-like operating system for IBM PC/AT microcomputers. Andrew Tannenbaum developed it for teaching purposes and released its source code (in print form!) in 1987. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/ibm_pc_at.jpg?itok=Tfk3hQYB) + +Although you could peruse MINIX's source, it was not actually free and open source software (FOSS). The publishers of Tannebaum's book required a $69 license fee to operate MINIX, which was included in the cost of the book. Still, this was incredibly inexpensive for the time, and MINIX adoption took off rapidly, soon exceeding Tannenbaum's original intent of using it simply to teach the coding of operating systems. By and throughout the 1990s, you could find MINIX installations thriving in universities worldwide—and a young Linus Torvalds used MINIX to develop the original Linux kernel, first announced in 1991, and released under the GPL in December 1992. + +But wait, this is a filesystem article, right? Yes, and MINIX had its own filesystem, which early versions of Linux also relied on. Like MINIX, it could uncharitably be described as a "toy" example of its kind—the MINIX filesystem could handle filenames only up to 14 characters and address only 64MB of storage. In 1991, the typical hard drive was already 40-140MB in size. Linux clearly needed a better filesystem! + +#### ext + +While Linus hacked away on the fledgling Linux kernel, Rémy Card worked on the first ext filesystem. First implemented in 1992—only a year after the initial announcement of Linux itself!—ext solved the worst of the MINIX filesystem's problems. + +1992's ext used the new virtual filesystem (VFS) abstraction layer in the Linux kernel. Unlike the MINIX filesystem before it, ext could address up to 2GB of storage and handle 255-character filenames. + +But ext didn't have a long reign, largely due to its primitive timestamping (only one timestamp per file, rather than the three separate stamps for inode creation, file access, and file modification we're familiar with today). A mere year later, ext2 ate its lunch. + +#### ext2 + +Rémy clearly realized ext's limitations pretty quickly, since he designed ext2 as its replacement a year later. While ext still had its roots in "toy" operating systems, ext2 was designed from the start as a commercial-grade filesystem, along the same principles as BSD's Berkeley Fast File System. + +Ext2 offered maximum filesizes in the gigabytes and filesystem sizes in the terabytes, placing it firmly in the big leagues for the 1990s. It was quickly and widely adopted, both in the Linux kernel and eventually in MINIX, as well as by third-party modules making it available for MacOS and Windows. + +There were still problems to solve, though: ext2 filesystems, like most filesystems of the 1990s, were prone to catastrophic corruption if the system crashed or lost power while data was being written to disk. They also suffered from significant performance losses due to fragmentation (the storage of a single file in multiple places, physically scattered around a rotating disk) as time went on. + +Despite these problems, ext2 is still used in some isolated cases today—most commonly, as a format for portable USB thumb drives. + +#### ext3 + +In 1998, six years after ext2's adoption, Stephen Tweedie announced he was working on significantly improving it. This became ext3, which was adopted into mainline Linux with kernel version 2.4.15, in November 2001. + + +![Packard Bell computer][2] + +Mid-1990s Packard Bell computer, [Spacekid][3], [CC0][4] + +Ext2 had done very well by Linux distributions for the most part, but—like FAT, FAT32, HFS, and other filesystems of the time—it was prone to catastrophic corruption during power loss. If you lose power while writing data to the filesystem, it can be left in what's called an inconsistent state—one in which things have been left half-done and half-undone. This can result in loss or corruption of vast swaths of files unrelated to the one being saved or even unmountability of the entire filesystem. + +Ext3, and other filesystems of the late 1990s, such as Microsoft's NTFS, uses journaling to solve this problem. The journal is a special allocation on disk where writes are stored in transactions; if the transaction finishes writing to disk, its data in the journal is committed to the filesystem itself. If the system crashes before that operation is committed, the newly rebooted system recognizes it as an incomplete transaction and rolls it back as though it had never taken place. This means that the file being worked on may still be lost, but the filesystem itself remains consistent, and all other data is safe. Three levels of journaling are available in the Linux kernel implementation of ext3: **journal** , **ordered** , and **writeback**. + + * **Journal** is the lowest risk mode, writing both data and metadata to the journal before committing it to the filesystem. This ensures consistency of the file being written to, as well as the filesystem as a whole, but can significantly decrease performance. + * **Ordered** is the default mode in most Linux distributions; ordered mode writes metadata to the journal but commits data directly to the filesystem. As the name implies, the order of operations here is rigid: First, metadata is committed to the journal; second, data is written to the filesystem, and only then is the associated metadata in the journal flushed to the filesystem itself. This ensures that, in the event of a crash, the metadata associated with incomplete writes is still in the journal, and the filesystem can sanitize those incomplete writes while rolling back the journal. In ordered mode, a crash may result in corruption of the file or files being actively written to during the crash, but the filesystem itself—and files not actively being written to—are guaranteed safe. + * **Writeback** is the third—and least safe—journaling mode. In writeback mode, like ordered mode, metadata is journaled, but data is not. Unlike ordered mode, metadata and data alike may be written in whatever order makes sense for best performance. This can offer significant increases in performance, but it's much less safe. Although writeback mode still offers a guarantee of safety to the filesystem itself, files that were written to during or before the crash are vulnerable to loss or corruption. + + + +Like ext2 before it, ext3 uses 16-bit internal addressing. This means that with a blocksize of 4K, the largest filesize it can handle is 2 TiB in a maximum filesystem size of 16 TiB. + +#### ext4 + +Theodore Ts'o (who by then was ext3's principal developer) announced ext4 in 2006, and it was added to mainline Linux two years later, in kernel version 2.6.28. Ts'o describes ext4 as a stopgap technology which significantly extends ext3 but is still reliant on old technology. He expects it to be supplanted eventually by a true next-generation filesystem. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dell_precision_380_workstation.jpeg?itok=3EjYXY2i) + +Ext4 is functionally very similar to ext3, but brings large filesystem support, improved resistance to fragmentation, higher performance, and improved timestamps. + +### Ext4 vs ext3 + +Ext3 and ext4 have some very specific differences, which I'll focus on here. + +#### Backwards compatibility + +Ext4 was specifically designed to be as backward-compatible as possible with ext3. This not only allows ext3 filesystems to be upgraded in place to ext4; it also permits the ext4 driver to automatically mount ext3 filesystems in ext3 mode, making it unnecessary to maintain the two codebases separately. + +#### Large filesystems + +Ext3 filesystems used 32-bit addressing, limiting them to 2 TiB files and 16 TiB filesystems (assuming a 4 KiB blocksize; some ext3 filesystems use smaller blocksizes and are thus limited even further). + +Ext4 uses 48-bit internal addressing, making it theoretically possible to allocate files up to 16 TiB on filesystems up to 1,000,000 TiB (1 EiB). Early implementations of ext4 were still limited to 16 TiB filesystems by some userland utilities, but as of 2011, e2fsprogs has directly supported the creation of >16TiB ext4 filesystems. As one example, Red Hat Enterprise Linux contractually supports ext4 filesystems only up to 50 TiB and recommends ext4 volumes no larger than 100 TiB. + +#### Allocation improvements + +Ext4 introduces a lot of improvements in the ways storage blocks are allocated before writing them to disk, which can significantly increase both read and write performance. + +##### Extents + +An extent is a range of contiguous physical blocks (up to 128 MiB, assuming a 4 KiB block size) that can be reserved and addressed at once. Utilizing extents decreases the number of inodes required by a given file and significantly decreases fragmentation and increases performance when writing large files. + +##### Multiblock allocation + +Ext3 called its block allocator once for each new block allocated. This could easily result in heavy fragmentation when multiple writers are open concurrently. However, ext4 uses delayed allocation, which allows it to coalesce writes and make better decisions about how to allocate blocks for the writes it has not yet committed. + +##### Persistent pre-allocation + +When pre-allocating disk space for a file, most file systems must write zeroes to the blocks for that file on creation. Ext4 allows the use of `fallocate()` instead, which guarantees the availability of the space (and attempts to find contiguous space for it) without first needing to write to it. This significantly increases performance in both writes and future reads of the written data for streaming and database applications. + +##### Delayed allocation + +This is a chewy—and contentious—feature. Delayed allocation allows ext4 to wait to allocate the actual blocks it will write data to until it's ready to commit that data to disk. (By contrast, ext3 would allocate blocks immediately, even while the data was still flowing into a write cache.) + +Delaying allocation of blocks as data accumulates in cache allows the filesystem to make saner choices about how to allocate those blocks, reducing fragmentation (write and, later, read) and increasing performance significantly. Unfortunately, it increases the potential for data loss in programs that have not been specifically written to call `fsync()` when the programmer wants to ensure data has been flushed entirely to disk. + +Let's say a program rewrites a file entirely: + +`fd=open("file" ,O_TRUNC); write(fd, data); close(fd);` + +With legacy filesystems, `close(fd);` is sufficient to guarantee that the contents of `file` will be flushed to disk. Even though the write is not, strictly speaking, transactional, there's very little risk of losing the data if a crash occurs after the file is closed. + +If the write does not succeed (due to errors in the program, errors on the disk, power loss, etc.), both the original version and the newer version of the file may be lost or corrupted. If other processes access the file as it is being written, they will see a corrupted version. And if other processes have the file open and do not expect its contents to change—e.g., a shared library mapped into multiple running programs—they may crash. + +To avoid these issues, some programmers avoid using `O_TRUNC` at all. Instead, they might write to a new file, close it, then rename it over the old one: + +`fd=open("newfile"); write(fd, data); close(fd); rename("newfile", "file");` + +Under filesystems without delayed allocation, this is sufficient to avoid the potential corruption and crash problems outlined above: Since `rename()` is an atomic operation, it won't be interrupted by a crash; and running programs will continue to reference the old, now unlinked version of `file` for as long as they have an open filehandle to it. But because ext4's delayed allocation can cause writes to be delayed and re-ordered, the `rename("newfile","file")` may be carried out before the contents of `newfile` are actually written to disk, which opens the problem of parallel processes getting bad versions of `file` all over again. + +To mitigate this, the Linux kernel (since version 2.6.30) attempts to detect these common code cases and force the files in question to be allocated immediately. This reduces, but does not prevent, the potential for data loss—and it doesn't help at all with new files. If you're a developer, please take note: The only way to guarantee data is written to disk immediately is to call `fsync()` appropriately. + +#### Unlimited subdirectories + +Ext3 was limited to a total of 32,000 subdirectories; ext4 allows an unlimited number. Beginning with kernel 2.6.23, ext4 uses HTree indices to mitigate performance loss with huge numbers of subdirectories. + +#### Journal checksumming + +Ext3 did not checksum its journals, which presented problems for disk or controller devices with caches of their own, outside the kernel's direct control. If a controller or a disk with its own cache did writes out of order, it could break ext3's journaling transaction order, potentially corrupting files being written to during (or for some time preceding) a crash. + +In theory, this problem is resolved by the use of write barriers—when mounting the filesystem, you set `barrier=1` in the mount options, and the device will then honor `fsync()` calls all the way down to the metal. In practice, it's been discovered that storage devices and controllers frequently do not honor write barriers—improving performance (and benchmarks, where they're compared to their competitors) but opening up the possibility of data corruption that should have been prevented. + +Checksumming the journal allows the filesystem to realize that some of its entries are invalid or out-of-order on the first mount after a crash. This thereby avoids the mistake of rolling back partial or out-of-order journal entries and further damaging the filesystem—even if the storage devices lie and don't honor barriers. + +#### Fast filesystem checks + +Under ext3, the entire filesystem—including deleted and empty files—required checking when `fsck` is invoked. By contrast, ext4 marks unallocated blocks and sections of the inode table as such, allowing `fsck` to skip them entirely. This greatly reduces the time to run `fsck` on most filesystems and has been implemented since kernel 2.6.24. + +#### Improved timestamps + +Ext3 offered timestamps granular to one second. While sufficient for most uses, mission-critical applications are frequently looking for much, much tighter time control. Ext4 makes itself available to those enterprise, scientific, and mission-critical applications by offering timestamps in the nanoseconds. + +Ext3 filesystems also did not provide sufficient bits to store dates beyond January 18, 2038. Ext4 adds an additional two bits here, extending [the Unix epoch][5] another 408 years. If you're reading this in 2446 AD, you have hopefully already moved onto a better filesystem—but it'll make me posthumously very, very happy if you're still measuring the time since UTC 00:00, January 1, 1970. + +#### Online defragmentation + +Neither ext2 nor ext3 directly supported online defragmentation—that is, defragging the filesystem while mounted. Ext2 had an included utility, **e2defrag** , that did what the name implies—but it needed to be run offline while the filesystem was not mounted. (This is, obviously, especially problematic for a root filesystem.) The situation was even worse in ext3—although ext3 was much less likely to suffer from severe fragmentation than ext2 was, running **e2defrag** against an ext3 filesystem could result in catastrophic corruption and data loss. + +Although ext3 was originally deemed "unaffected by fragmentation," processes that employ massively parallel write processes to the same file (e.g., BitTorrent) made it clear that this wasn't entirely the case. Several userspace hacks and workarounds, such as [Shake][6], addressed this in one way or another—but they were slower and in various ways less satisfactory than a true, filesystem-aware, kernel-level defrag process. + +Ext4 addresses this problem head on with **e4defrag** , an online, kernel-mode, filesystem-aware, block-and-extent-level defragmentation utility. + +### Ongoing ext4 development + +Ext4 is, as the Monty Python plague victim once said, "not quite dead yet!" Although [its principal developer regards it][7] as a mere stopgap along the way to a truly [next-generation filesystem][8], none of the likely candidates will be ready (due to either technical or licensing problems) for deployment as a root filesystem for some time yet. + +There are still a few key features being developed into future versions of ext4, including metadata checksumming, first-class quota support, and large allocation blocks. + +#### Metadata checksumming + +Since ext4 has redundant superblocks, checksumming the metadata within them offers the filesystem a way to figure out for itself whether the primary superblock is corrupt and needs to use an alternate. It is possible to recover from a corrupt superblock without checksumming—but the user would first need to realize that it was corrupt, and then try manually mounting the filesystem using an alternate. Since mounting a filesystem read-write with a corrupt primary superblock can, in some cases, cause further damage, this isn't a sufficient solution, even with a sufficiently experienced user! + +Compared to the extremely robust per-block checksumming offered by next-gen filesystems such as btrfs or zfs, ext4's metadata checksumming is a pretty weak feature. But it's much better than nothing. + +Although it sounds like a no-brainer—yes, checksum ALL THE THINGS!—there are some significant challenges to bolting checksums into a filesystem after the fact; see [the design document][9] for the gritty details. + +#### First-class quota support + +Wait, quotas?! We've had those since the ext2 days! Yes, but they've always been an afterthought, and they've always kinda sucked. It's probably not worth going into the hairy details here, but the [design document][10] lays out the ways quotas will be moved from userspace into the kernel and more correctly and performantly enforced. + +#### Large allocation blocks + +As time goes by, those pesky storage systems keep getting bigger and bigger. With some solid-state drives already using 8K hardware blocksizes, ext4's current limitation to 4K blocks gets more and more limiting. Larger storage blocks can decrease fragmentation and increase performance significantly, at the cost of increased "slack" space (the space left over when you only need part of a block to store a file or the last piece of a file). + +You can view the hairy details in the [design document][11]. + +### Practical limitations of ext4 + +Ext4 is a robust, stable filesystem, and it's what most people should probably be using as a root filesystem in 2018. But it can't handle everything. Let's talk briefly about some of the things you shouldn't expect from ext4—now or probably in the future. + +Although ext4 can address up to 1 EiB—equivalent to 1,000,000 TiB—of data, you really, really shouldn't try to do so. There are problems of scale above and beyond merely being able to remember the addresses of a lot more blocks, and ext4 does not now (and likely will not ever) scale very well beyond 50-100 TiB of data. + +Ext4 also doesn't do enough to guarantee the integrity of your data. As big an advancement as journaling was back in the ext3 days, it does not cover a lot of the common causes of data corruption. If data is [corrupted][12] while already on disk—by faulty hardware, impact of cosmic rays (yes, really), or simple degradation of data over time—ext4 has no way of either detecting or repairing such corruption. + +Building on the last two items, ext4 is only a pure filesystem, and not a storage volume manager. This means that even if you've got multiple disks—and therefore parity or redundancy, which you could theoretically recover corrupt data from—ext4 has no way of knowing that or using it to your benefit. While it's theoretically possible to separate a filesystem and storage volume management system in discrete layers without losing automatic corruption detection and repair features, that isn't how current storage systems are designed, and it would present significant challenges to new designs. + +### Alternate filesystems + +Before we get started, a word of warning: Be very careful with any alternate filesystem which isn't built into and directly supported as a part of your distribution's mainline kernel! + +Even if a filesystem is safe, using it as the root filesystem can be absolutely terrifying if something hiccups during a kernel upgrade. If you aren't extremely comfortable with the idea of booting from alternate media and poking manually and patiently at kernel modules, grub configs, and DKMS from a chroot... don't go off the reservation with the root filesystem on a system that matters to you. + +There may well be good reasons to use a filesystem your distro doesn't directly support—but if you do, I strongly recommend you mount it after the system is up and usable. (For example, you might have an ext4 root filesystem, but store most of your data on a zfs or btrfs pool.) + +#### XFS + +XFS is about as mainline as a non-ext filesystem gets under Linux. It's a 64-bit, journaling filesystem that has been built into the Linux kernel since 2001 and offers high performance for large filesystems and high degrees of concurrency (i.e., a really large number of processes all writing to the filesystem at once). + +XFS became the default filesystem for Red Hat Enterprise Linux, as of RHEL 7. It still has a few disadvantages for home or small business users—most notably, it's a real pain to resize an existing XFS filesystem, to the point it usually makes more sense to create another one and copy your data over. + +While XFS is stable and performant, there's not enough of a concrete end-use difference between it and ext4 to recommend its use anywhere that it isn't the default (e.g., RHEL7) unless it addresses a specific problem you're having with ext4, such as >50 TiB capacity filesystems. + +XFS is not in any way a "next-generation" filesystem in the ways that ZFS, btrfs, or even WAFL (a proprietary SAN filesystem) are. Like ext4, it should most likely be considered a stopgap along the way towards [something better][8]. + +#### ZFS + +ZFS was developed by Sun Microsystems and named after the zettabyte—equivalent to 1 trillion gigabytes—as it could theoretically address storage systems that large. + +A true next-generation filesystem, ZFS offers volume management (the ability to address multiple individual storage devices in a single filesystem), block-level cryptographic checksumming (allowing detection of data corruption with an extremely high accuracy rate), [automatic corruption repair][12] (where redundant or parity storage is available), rapid [asynchronous incremental replication][13], inline compression, and more. [A lot more][14]. + +The biggest problem with ZFS, from a Linux user's perspective, is the licensing. ZFS was licensed CDDL, which is a semi-permissive license that conflicts with the GPL. There is a lot of controversy over the implications of using ZFS with the Linux kernel, with opinions ranging from "it's a GPL violation" to "it's a CDDL violation" to "it's perfectly fine, it just hasn't been tested in court." Most notably, Canonical has included ZFS code inline in its default kernels since 2016 without legal challenge so far. + +At this time, even as a very avid ZFS user myself, I would not recommend ZFS as a root Linux filesystem. If you want to leverage the benefits of ZFS on Linux, set up a small root filesystem on ext4, then put ZFS on your remaining storage, and put data, applications, whatever you like on it—but keep root on ext4, until your distribution explicitly supports a zfs root. + +#### btrfs + +Btrfs—short for B-Tree Filesystem, and usually pronounced "butter"—was announced by Chris Mason in 2007 during his tenure at Oracle. Btrfs aims at most of the same goals as ZFS, offering multiple device management, per-block checksumming, asynchronous replication, inline compression, and [more][8]. + +As of 2018, btrfs is reasonably stable and usable as a standard single-disk filesystem but should probably not be relied on as a volume manager. It suffers from significant performance problems compared to ext4, XFS, or ZFS in many common use cases, and its next-generation features—replication, multiple-disk topologies, and snapshot management—can be pretty buggy, with results ranging from catastrophically reduced performance to actual data loss. + +The ongoing status of btrfs is controversial; SUSE Enterprise Linux adopted it as its default filesystem in 2015, whereas Red Hat announced it would no longer support btrfs beginning with RHEL 7.4 in 2017. It is probably worth noting that production, supported deployments of btrfs use it as a single-disk filesystem, not as a multiple-disk volume manager a la ZFS—even Synology, which uses btrfs on its storage appliances, but layers it atop conventional Linux kernel RAID (mdraid) to manage the disks. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/ext4-filesystem + +作者:[Jim Salter][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/jim-salter +[1]:https://opensource.com/file/391546 +[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/packard_bell_pc.jpg?itok=VI8dzcwp (Packard Bell computer) +[3]:https://commons.wikimedia.org/wiki/File:Old_packard_bell_pc.jpg +[4]:https://creativecommons.org/publicdomain/zero/1.0/deed.en +[5]:https://en.wikipedia.org/wiki/Unix_time +[6]:https://vleu.net/shake/ +[7]:http://www.linux-mag.com/id/7272/ +[8]:https://arstechnica.com/information-technology/2014/01/bitrot-and-atomic-cows-inside-next-gen-filesystems/ +[9]:https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums +[10]:https://ext4.wiki.kernel.org/index.php/Design_For_1st_Class_Quota_in_Ext4 +[11]:https://ext4.wiki.kernel.org/index.php/Design_for_Large_Allocation_Blocks +[12]:https://en.wikipedia.org/wiki/Data_degradation#Visual_example_of_data_degradation +[13]:https://arstechnica.com/information-technology/2015/12/rsync-net-zfs-replication-to-the-cloud-is-finally-here-and-its-fast/ +[14]:https://arstechnica.com/information-technology/2014/02/ars-walkthrough-using-the-zfs-next-gen-filesystem-on-linux/ From cbb442b4ec74b3c5e61dba4db4cac9cf6bdb9393 Mon Sep 17 00:00:00 2001 From: ch-cn Date: Tue, 3 Apr 2018 11:17:33 +0800 Subject: [PATCH 0260/1057] translated/20171016 5 SSH alias examples in Linux.md --- .../20171016 5 SSH alias examples in Linux.md | 193 ----------------- .../20171016 5 SSH alias examples in Linux.md | 200 ++++++++++++++++++ 2 files changed, 200 insertions(+), 193 deletions(-) delete mode 100644 sources/tech/20171016 5 SSH alias examples in Linux.md create mode 100644 translated/20171016 5 SSH alias examples in Linux.md diff --git a/sources/tech/20171016 5 SSH alias examples in Linux.md b/sources/tech/20171016 5 SSH alias examples in Linux.md deleted file mode 100644 index cd7e79db0b..0000000000 --- a/sources/tech/20171016 5 SSH alias examples in Linux.md +++ /dev/null @@ -1,193 +0,0 @@ -ch-cn translating -5 SSH alias examples in Linux -====== -[![][1]][1] - -As a Linux user, we use[ ssh command][2] to log in to remote machines. The more you use ssh command, the more time you are wasting in typing some significant commands. We can use either [alias defined in your .bashrc file][3] or functions to minimize the time you spend on CLI. But this is not a better solution. The better solution is to use **SSH-alias** in ssh config file. - -A couple of examples where we can better the ssh commands we use. - -Connecting to ssh to AWS instance is a pain. Just to type below command, every time is complete waste your time as well. - -to -``` -ssh aws1 -``` - -Connecting to a system when debugging. - -to -``` -ssh xyz -``` - -In this post, we will see how to achieve shorting of your ssh commands without using bash alias or functions. The main advantage of ssh alias is that all your ssh command shortcuts are stored in a single file and easy to maintain. The other advantage is we can use same alias **for both SSH and SCP commands alike**. - -Before we jump into actual configurations, we should know difference between /etc/ssh/ssh_config, /etc/ssh/sshd_config, and ~/.ssh/config files. Below is the explanation for these files. - -## Difference between /etc/ssh/ssh_config and ~/.ssh/config - -System-level SSH configurations are stored in /etc/ssh/ssh_config. Whereas user-level ssh configurations are stored in ~/.ssh/config file. - -## Difference between /etc/ssh/ssh_config and /etc/ssh/sshd_config - -System-level SSH configurations are stored in /etc/ssh/ssh_config. Whereas system level SSH server configurations are stored in /etc/ssh/sshd_config file. - -## **Syntax for configuration in ~/.ssh/config file** - -Syntax for ~/.ssh/config file content. -``` -config val -config val1 val2 -``` - -**Example1:** Create SSH alias for a host(www.linuxnix.com) - -Edit file ~/.ssh/config with following content -``` -Host tlj - User root - HostName 18.197.176.13 - port 22 -``` - -Save the file - -The above ssh alias uses - - 1. **tlj as an alias name** - 2. **root as a user who will log in** - 3. **18.197.176.13 as hostname IP address** - 4. **22 as a port to access SSH service.** - - - -Output: -``` -sanne@Surendras-MacBook-Pro:~ > ssh tlj -Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) - * Documentation: https://help.ubuntu.com - * Management: https://landscape.canonical.com - * Support: https://ubuntu.com/advantage - Get cloud support with Ubuntu Advantage Cloud Guest: - http://www.ubuntu.com/business/services/cloud -Last login: Sat Oct 14 01:00:43 2017 from 20.244.25.231 -root@linuxnix:~# exit -logout -Connection to 18.197.176.13 closed. -``` - -**Example2:** Using ssh key to login to the system without using password using **IdentityFile**. - -Example: -``` -Host aws - User ec2-users - HostName ec2-54-200-184-202.us-west-2.compute.amazonaws.com - IdentityFile ~/Downloads/surendra.pem - port 22 -``` - -**Example3:** Use a different alias for the same host. In below example, we use **tlj, linuxnix, linuxnix.com** for same IP/hostname 18.197.176.13. - -~/.ssh/config file content -``` -Host tlj linuxnix linuxnix.com - User root - HostName 18.197.176.13 - port 22 -``` - -**Output:** -``` -sanne@Surendras-MacBook-Pro:~ > ssh tlj -Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) -* Documentation: https://help.ubuntu.com -* Management: https://landscape.canonical.com -* Support: https://ubuntu.com/advantage -Get cloud support with Ubuntu Advantage Cloud Guest: -http://www.ubuntu.com/business/services/cloud -Last login: Sat Oct 14 01:00:43 2017 from 220.244.205.231 -root@linuxnix:~# exit -logout -Connection to 18.197.176.13 closed. -sanne@Surendras-MacBook-Pro:~ > ssh linuxnix.com -Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) -* Documentation: https://help.ubuntu.com -* Management: https://landscape.canonical.com -* Support: https://ubuntu.com/advantage -``` -``` -Get cloud support with Ubuntu Advantage Cloud Guest: -http://www.ubuntu.com/business/services/cloud -Last login: Sun Oct 15 20:31:08 2017 from 1.129.110.13 -root@linuxnix:~# exit -logout -Connection to 138.197.176.103 closed. -[6571] sanne@Surendras-MacBook-Pro:~ > ssh linuxnix -Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) -* Documentation: https://help.ubuntu.com -* Management: https://landscape.canonical.com -* Support: https://ubuntu.com/advantage -Get cloud support with Ubuntu Advantage Cloud Guest: -http://www.ubuntu.com/business/services/cloud -Last login: Sun Oct 15 20:31:20 2017 from 1.129.110.13 -root@linuxnix:~# exit -logout -Connection to 18.197.176.13 closed. -``` - -**Example4:** Copy a file to remote system using same SSH alias - -Syntax: -``` -**scp :** -``` - -Example: -``` -sanne@Surendras-MacBook-Pro:~ > scp abc.txt tlj:/tmp -abc.txt 100% 12KB 11.7KB/s 00:01 -sanne@Surendras-MacBook-Pro:~ > -``` - -As we already set ssh host as an alias, using SCP is a breeze as both ssh and SCP use almost same syntax and options. - -To do scp a file from local machine to remote one use below. - -**Examaple5:** Resolve SSH timeout issues in Linux. By default, your ssh logins are timed out if you don 't activily use the terminial. - -[SSH timeouts][5] are one more pain where you have to re-login to a remote machine after a certain time. We can set SSH time out right in side your ~/.ssh/config file to make your session active for whatever time you want. To achieve this we will use two SSH options for keeping the session alive. One ServerAliveInterval keeps your session live for number of seconds and ServerAliveCountMax will initial session after session for a given number. -``` -**ServerAliveInterval A** -**ServerAliveCountMax B** -``` - -**Example:** -``` -Host tlj linuxnix linuxnix.com - User root - HostName 18.197.176.13 - port 22 - ServerAliveInterval 60** - ServerAliveCountMax 30 -``` - -We will see some other exiting howto in our next post. Keep visiting linuxnix.com. - --------------------------------------------------------------------------------- - -via: https://www.linuxnix.com/5-ssh-alias-examples-using-ssh-config-file/ - -作者:[Surendra Anne;Max Ntshinga;Otto Adelfang;Uchechukwu Okeke][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxnix.com -[1]:https://www.linuxnix.com/wp-content/uploads/2017/10/SSH-alias-1.png -[2]:https://www.linuxnix.com/ssh-access-remote-linux-server/ -[3]:https://www.linuxnix.com/linux-alias-command-explained-with-examples/ -[4]:/cdn-cgi/l/email-protection -[5]:https://www.linuxnix.com/how-to-auto-logout/ diff --git a/translated/20171016 5 SSH alias examples in Linux.md b/translated/20171016 5 SSH alias examples in Linux.md new file mode 100644 index 0000000000..dee347dfe2 --- /dev/null +++ b/translated/20171016 5 SSH alias examples in Linux.md @@ -0,0 +1,200 @@ +Linux 中的 5 个 SSH 别名例子 +====== +[![][1]][1] + +作为一个 Linux 用户,我们常用[ ssh 命令][2] 来登入远程机器。ssh 命令你用得越多,你在键入一些重要的命令上花的时间也越多。我们可以用 [定义在你的 .bashrc 文件里的别名][3] 或函数来大幅度缩减花在命令行界面(CLI)的时间。但这不是最佳解决之道。最佳办法是在 ssh 配置文件中使用 **SSH-别名** 。 + +这里是我们能把 ssh 命令用得更好的几个例子。 + +ssh 到 AWS(译注:Amazon Web Services,亚马逊公司旗下云计算服务平台)实例的连接是一种痛。仅仅输入以下命令,每次也完全是浪费你时间。 + +``` +ssh -p 3000 -i /home/surendra/mysshkey.pem ec2-user@ec2-54-20-184-202.us-west-2.compute.amazonaws.com +``` + +缩短到 +``` +ssh aws1 +``` + +调试时连接到系统。 + +``` +ssh -vvv the_good_user@red1.taggle.abc.com.au +``` + +缩短到 +``` +ssh xyz +``` + +在本篇中,我们将看到如何不使用 bash 别名或函数实现 ssh 命令的缩短。ssh 别名的主要优点是所有的 ssh 命令快捷方式都存储在一个单一文件,如此就易于维护。其他优点是 **对于类似于 SSH 和 SCP 的命令** 我们能用相同的别名。 + +在我们进入实际配置之前,我们应该知道 /etc/ssh/ssh_config、/etc/ssh/sshd_config 和 ~/.ssh/config 文件三者的区别。以下是对这些文件的解释。 + +## /etc/ssh/ssh_config 和 ~/.ssh/config 间的区别 + +系统级别的 SSH 配置项存放在 /etc/ssh/ssh_config,而用户级别的 ssh 配置项存放在 ~/.ssh/config 文件中。 + +## /etc/ssh/ssh_config 和 /etc/ssh/sshd_config 间的区别 + +系统级别的 SSH 配置项是在 /etc/ssh/ssh_config 文件中,而系统级别的 SSH 服务端配置项存放在 /etc/ssh/sshd_config 文件。 + +## **在 ~/.ssh/config 文件里配置项的语法** + +~/.ssh/config 文件内容的语法。 +``` +配置项 值 +配置项 值1 值2 +``` + +**例 1:** 创建主机(www.linuxnix.com)的 SSH 别名 + +编辑 ~/.ssh/config 文件写入以下内容 +``` +Host tlj + User root + HostName 18.197.176.13 + port 22 +``` + +保存此文件 + +以上 ssh 别名用了 + + 1. **tlj 作为一个别名的名称** + 2. **root 作为将要登入的用户** + 3. **18.197.176.13 作为主机的 IP 地址** + 4. **22 作为访问 SSH 服务的端口。** + + + +输出: +``` +sanne@Surendras-MacBook-Pro:~ > ssh tlj +Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + Get cloud support with Ubuntu Advantage Cloud Guest: + http://www.ubuntu.com/business/services/cloud +Last login: Sat Oct 14 01:00:43 2017 from 20.244.25.231 +root@linuxnix:~# exit +logout +Connection to 18.197.176.13 closed. +``` + +**例 2:** 不用密码用 ssh 密钥登到系统要用 **IdentityFile** 。 + +例: +``` +Host aws + User ec2-users + HostName ec2-54-200-184-202.us-west-2.compute.amazonaws.com + IdentityFile ~/Downloads/surendra.pem + port 22 +``` + +**例 3:** 对同一主机使用不同的别名。在下例中,我们对同一 IP/主机 18.197.176.13 用了 **tlj, linuxnix, linuxnix.com** 三个别名。 + +~/.ssh/config 文件内容 +``` +Host tlj linuxnix linuxnix.com + User root + HostName 18.197.176.13 + port 22 +``` + +**输出:** +``` +sanne@Surendras-MacBook-Pro:~ > ssh tlj +Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) +* Documentation: https://help.ubuntu.com +* Management: https://landscape.canonical.com +* Support: https://ubuntu.com/advantage +Get cloud support with Ubuntu Advantage Cloud Guest: +http://www.ubuntu.com/business/services/cloud +Last login: Sat Oct 14 01:00:43 2017 from 220.244.205.231 +root@linuxnix:~# exit +logout +Connection to 18.197.176.13 closed. +sanne@Surendras-MacBook-Pro:~ > ssh linuxnix.com +Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) +* Documentation: https://help.ubuntu.com +* Management: https://landscape.canonical.com +* Support: https://ubuntu.com/advantage +``` +``` +Get cloud support with Ubuntu Advantage Cloud Guest: +http://www.ubuntu.com/business/services/cloud +Last login: Sun Oct 15 20:31:08 2017 from 1.129.110.13 +root@linuxnix:~# exit +logout +Connection to 138.197.176.103 closed. +[6571] sanne@Surendras-MacBook-Pro:~ > ssh linuxnix +Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64) +* Documentation: https://help.ubuntu.com +* Management: https://landscape.canonical.com +* Support: https://ubuntu.com/advantage +Get cloud support with Ubuntu Advantage Cloud Guest: +http://www.ubuntu.com/business/services/cloud +Last login: Sun Oct 15 20:31:20 2017 from 1.129.110.13 +root@linuxnix:~# exit +logout +Connection to 18.197.176.13 closed. +``` + +**例 4:** 用相同的 SSH 别名复制文件到远程系统 + +语法: +``` +**scp <文件名> :<位置>** +``` + +例子: +``` +sanne@Surendras-MacBook-Pro:~ > scp abc.txt tlj:/tmp +abc.txt 100% 12KB 11.7KB/s 00:01 +sanne@Surendras-MacBook-Pro:~ > +``` + +若我们已经将 ssh 主机设置好一个别名,由于 ssh 和 SCP 两者用几乎相同的语法和选项,SCP 用起来就轻而易举 + +请在下面尝试从本机 scp 一个文件到远程机器。 + +**例 5:** 解决 Linux中的 SSH 超时问题。默认情况,如果你不积极地使用终端,你的 ssh 登入就会超时。 + +[SSH 超时问题][5] 是一个更痛的点意味着你在一段时间后不得不重新登入到远程机器。我们能在 ~/.ssh/config 文件里边恰当地设置 SSH 超时时间来使你的会话不管在什么时间总是激活的。我们将用 2 个能保持会话存活的 SSH 选项来实现这一目的。之一是 ServerAliveInterval 保持你会话存活的秒数和 ServerAliveCountMax 在(经历了一个)给定数值的会话之后初始化会话。 +``` +**ServerAliveInterval A** +**ServerAliveCountMax B** +``` + +**例:** +``` +Host tlj linuxnix linuxnix.com + User root + HostName 18.197.176.13 + port 22 + ServerAliveInterval 60** + ServerAliveCountMax 30 +``` + +在下篇中我们将会看到一些其他的退出方式。请保持访问 linuxnix.com。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxnix.com/5-ssh-alias-examples-using-ssh-config-file/ + +作者:[Surendra Anne;Max Ntshinga;Otto Adelfang;Uchechukwu Okeke][a] +译者:[ch-cn](https://github.com/ch-cn) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxnix.com +[1]:https://www.linuxnix.com/wp-content/uploads/2017/10/SSH-alias-1.png +[2]:https://www.linuxnix.com/ssh-access-remote-linux-server/ +[3]:https://www.linuxnix.com/linux-alias-command-explained-with-examples/ +[4]:/cdn-cgi/l/email-protection +[5]:https://www.linuxnix.com/how-to-auto-logout/ From 391eafb94906e73a114f8ec0ed6351d56ec2bc88 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 3 Apr 2018 11:26:45 +0800 Subject: [PATCH 0261/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Meet=20OpenAuto?= =?UTF-8?q?,=20an=20Android=20Auto=20emulator=20for=20Raspberry=20Pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Android Auto emulator for Raspberry Pi.md | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md diff --git a/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md b/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md new file mode 100644 index 0000000000..bac0819e74 --- /dev/null +++ b/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md @@ -0,0 +1,81 @@ +Meet OpenAuto, an Android Auto emulator for Raspberry Pi +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lightbulb_computer_person_general_.png?itok=BRGJXU7e) + +In 2015, Google introduced [Android Auto][1], a system that allows users to project certain apps from their Android smartphones onto a car's infotainment display. Android Auto's driver-friendly interface, with larger touchscreen buttons and voice commands, aims to make it easier and safer for drivers to control navigation, music, podcasts, radio, phone calls, and more while keeping their eyes on the road. Android Auto can also run as an app on an Android smartphone, enabling owners of older-model vehicles without modern head unit displays to take advantage of these features. + +While there are many [apps][2] available for Android Auto, developers are working to add to its catalog. A new, open source tool named [OpenAuto][3] is hoping to make that easier by giving developers a way to emulate Android Auto on a Raspberry Pi. With OpenAuto, developers can test their applications in conditions similar to how they'll work on an actual car head unit. + +OpenAuto's creator, Michal Szwaj, answered some questions about his project for Opensource.com. Some responses have been edited for conciseness and clarity. + +### What is OpenAuto? + +In a nutshell, OpenAuto is an emulator for the Android Auto head unit. It emulates the head unit software and allows you to use Android Auto on your PC or on any other embedded platform like Raspberry Pi 3. + +Head unit software is a frontend for the Android Auto projection. All magic related to the Android Auto, like navigation, Google Voice Assistant, or music playback, is done on the Android device. Projection of Android Auto on the head unit is accomplished using the [H.264][4] codec for video and [PCM][5] codec for audio streaming. This is what the head unit software mostly does—it decodes the H.264 video stream and PCM audio streams and plays them back together. Another function of the head unit is providing user inputs. OpenAuto supports both touch events and hard keys. + +### What platforms does OpenAuto run on? + +My target platform for deployment of the OpenAuto is Raspberry Pi 3 computer. For successful deployment, I needed to implement support of video hardware acceleration using the Raspberry Pi 3 GPU (VideoCore 4). Thanks to this, Android Auto projection on the Raspberry Pi 3 computer can be handled even using 1080p@60 fps resolution. I used [OpenMAX IL][6] and IL client libraries delivered together with the Raspberry Pi firmware to implement video hardware acceleration. + +Taking advantage of the fact that the Raspberry Pi operating system is Raspbian based on Debian Linux, OpenAuto can be also built for any other Linux-based platform that provides support for hardware video decoding. Most of the Linux-based platforms provide support for hardware video decoding directly in GStreamer. Thanks to highly portable libraries like Boost and [Qt][7], OpenAuto can be built and run on the Windows platform. Support of MacOS is being implemented by the community and should be available soon. + +![][https://www.youtube.com/embed/k9tKRqIkQs8?origin=https://opensource.com&enablejsapi=1] + +### What software libraries does the project use? + +The core of the OpenAuto is the [aasdk][8] library, which provides support for all Android Auto features. aasdk library is built on top of the Boost, libusb, and OpenSSL libraries. [libusb][9] implements communication between the head unit and an Android device (via USB bus). [Boost][10] provides support for the asynchronous mechanisms for communication. It is required for high efficiency and scalability of the head unit software. [OpenSSL][11] is used for encrypting communication. + +The aasdk library is designed to be fully reusable for any purposes related to implementation of the head unit software. You can use it to build your own head unit software for your desired platform. + +Another very important library used in OpenAuto is Qt. It provides support for OpenAuto's multimedia, user input, and graphical interface. And the build system OpenAuto is using is [CMake][12]. + +Note: The Android Auto protocol is taken from another great Android Auto head unit project called [HeadUnit][13]. The people working on this project did an amazing job in reverse engineering the AndroidAuto protocol and creating the protocol buffers that structurize all messages. + +### What equipment do you need to run OpenAuto on Raspberry Pi? + +In addition to a Raspberry Pi 3 computer and an Android device, you need: + + * **USB sound card:** The Raspberry Pi 3 doesn't have a microphone input, which is required to use Google Voice Assistant + * **Video output device:** You can use either a touchscreen or any other video output device connected to HDMI or composite output (RCA) + * **Input device:** For example, a touchscreen or a USB keyboard + + + +### What else do you need to get started? + +In order to use OpenAuto, you must build it first. On the OpenAuto's wiki page you can find [detailed instructions][14] for how to build it for the Raspberry Pi 3 platform. On other Linux-based platforms, the build process will look very similar. + +On the wiki page you can also find other useful instructions, such as how to configure the Bluetooth Hands-Free Profile (HFP) and Advanced Audio Distribution Profile (A2DP) and PulseAudio. + +### What else should we know about OpenAuto? + +OpenAuto allows anyone to create a head unit based on the Raspberry Pi 3 hardware. Nevertheless, you should always be careful about safety and keep in mind that OpenAuto is just an emulator. It was not certified by any authority and was not tested in a driving environment, so using it in a car is not recommended. + +OpenAuto is licensed under GPLv3. For more information, visit the [project's GitHub page][3], where you can find its source code and other information. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/openauto-emulator-Raspberry-Pi + +作者:[Michal Szwaj][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/michalszwaj +[1]:https://www.android.com/auto/faq/ +[2]:https://play.google.com/store/apps/collection/promotion_3001303_android_auto_all +[3]:https://github.com/f1xpl/openauto +[4]:https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC +[5]:https://en.wikipedia.org/wiki/Pulse-code_modulation +[6]:https://www.khronos.org/openmaxil +[7]:https://www.qt.io/ +[8]:https://github.com/f1xpl/aasdk +[9]:http://libusb.info/ +[10]:http://www.boost.org/ +[11]:https://www.openssl.org/ +[12]:https://cmake.org/ +[13]:https://github.com/gartnera/headunit +[14]:https://github.com/f1xpl/ From 99d6d9c6548bfd2888738ef193385ff61893f038 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 3 Apr 2018 12:03:47 +0800 Subject: [PATCH 0262/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Could=20we=20ru?= =?UTF-8?q?n=20Python=202=20and=20Python=203=20code=20in=20the=20same=20VM?= =?UTF-8?q?=20with=20no=20code=20changes=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ode in the same VM with no code changes.md | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 sources/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md diff --git a/sources/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md b/sources/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md new file mode 100644 index 0000000000..1c43c1e430 --- /dev/null +++ b/sources/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md @@ -0,0 +1,120 @@ +Could we run Python 2 and Python 3 code in the same VM with no code changes? +====== + +Theoretically, yes. Zed Shaw famously jested that if this is impossible then Python 3 must not be Turing-complete. But in practice, this is unrealistic and I'll share why by giving you a few examples. + +### What does it mean to be a dict? + +Let’s imagine a Python 6 VM. It can read `module3.py` which was written for Python 3.6 but in this module it can import `module2.py` which was written for Python 2.7 and successfully use it with no issues. This is obviously toy code but let’s say that `module2.py` includes functions like: +``` + + +def update_config_from_dict(config_dict): + items = config_dict.items() + while items: + k, v = items.pop() + memcache.set(k, v) + +def config_to_dict(): + result = {} + for k, v in memcache.getall(): + result[k] = v + return result + +def update_in_place(config_dict): + for k, v in config_dict.items(): + new_value = memcache.get(k) + if new_value is None: + del config_dict[k] + elif new_value != v: + config_dict[k] = v + +``` + +Now, when we want to use those functions from `module3`, we are faced with a problem: the dict type in Python 3.6 is different from the dict type in Python 2.7. In Python 2, dicts were unordered and their `.keys()`, `.values()`, `.items()` methods returned proper lists. That meant calling `.items()` created a copy of the state in the dictionary. In Python 3 those methods return dynamic views on the current state of the dictionary. + +This means if `module3` called `module2.update_config_from_dict(some_dictionary)`, it would fail to run because the value returned by `dict.items()` in Python 3 isn’t a list and doesn’t have a `.pop()` method. The reverse is also true. If `module3` called `module2.config_to_dict()`, it would presumably return a Python 2 dictionary. Now calling `.items()` is suddenly returning a list so this code would not work correctly (which works fine with Python 3 dictionaries): +``` + + +def main(cmdline_options): + d = module2.config_to_dict() + items = d.items() + for k, v in items: + print(f'Config from memcache: {k}={v}') + for k, v in cmdline_options: + d[k] = v + for k, v in items: + print(f'Config with cmdline overrides: {k}={v}') + +``` + +Finally, using `module2.update_in_place()` would fail because the value of `.items()` in Python 3 now doesn’t allow the dictionary to change during iteration. + +There’s more issues with this dictionary situation. Should a Python 2 dictionary respond `True` to `isinstance(d, dict)` on Python 3? If it did, it’d be a lie. If it didn’t, code would break anyway. + +### Python should magically know types and translate! + +Why can’t our Python 6 VM recognize that in Python 3 code we mean something else when calling `some_dict.keys()` than in Python 2 code? Well, Python doesn’t know what the author of the code thought `some_dict` should be when she was writing that code. There is nothing in the code that signifies whether it’s a dictionary at all. Type annotations weren’t there in Python 2 and, since they’re optional, even in Python 3 most code doesn’t use them yet. + +At runtime, when you call `some_dict.keys()`, Python simply looks up an attribute on the object that happens to hide under the `some_dict` name and tries to run `__call__()` on that attribute. There’s some technicalities with method binding, descriptors, slots, etc. but this is the gist of it. We call this behavior “duck typing”. + +Because of duck typing, the Python 6 VM would not be able to make compile-time decisions to translate calls and attribute lookups correctly. + +### OK, so let’s make this decision at runtime instead + +The Python 6 VM could implement this by tagging every attribute lookup with information “call comes from py2” or “call comes from py3” and make the object on the other side dispatch the right attribute. That would slow things down a lot and use more memory, too. It would require us to keep both versions of the given type in memory with a proxy used by user code. We would need to sync the state of those objects behind the user’s back, doubling the work. After all, the memory representation of the new dictionary is different than in Python 2. + +If your head spun thinking about the problems with dictionaries, think about all the issues with Unicode strings in Python 3 and the do-it-all byte strings in Python 2. + +### Is everything lost? Can’t Python 3 run old code ever? + +Everything is not lost. Projects get ported to Python 3 every day. The recommended way to port Python 2 code to work on both versions of Python is to run [Python-Modernize][1] on your code. It will catch code that wouldn’t work on Python 3 and translate it to use the [six][2] library instead so it runs on both Python 2 and Python 3 after. It’s an adaptation of `2to3` which was producing Python 3-only code. `Modernize` is preferred since it provides a more incremental migration route. All this is outlined very well in the [Porting Python 2 Code to Python 3][3] document in the Python documentation. + +But wait, didn’t you say a Python 6 VM couldn’t do this automatically? Right. `Modernize` looks at your code and tries to guess what’s going to be safe. It will make some changes that are unnecessary and miss others that are necessary. Famously, it won’t help you with strings. That transformation is not trivial if your code didn’t keep the boundaries between “binary data from outside” and “text data within the process”. + +So, migrating big projects cannot be done automatically and involves humans running tests, finding problems and fixing them. Does it work? Yes, I helped [moving a million lines of code to Python 3][4] and the switch caused no incidents. This particular move regained 1/3 of memory on our servers and made the code run 12% faster. That was on Python 3.5. But Python 3.6 got quite a bit faster and depending on your workload you could maybe even achieve [a 4X speedup][5] . + +### Dear Zed + +Hi, man. I follow your story for over 10 years now. I’ve been watching when you were upset you were getting no credit for Mongrel even though the Rails ecosystem pretty much ran all on it. I’ve been there when you reimagined it and started the Mongrel 2 project. I was following your surprising move to use Fossil for it. I’ve seen you abruptly depart from the Ruby community with your “Rails is a Ghetto” post. I was thrilled when you started working on “Learn Python The Hard Way” and have been recommending it ever since. I met you in 2013 at [DjangoCon Europe][6] and we talked quite a bit about painting, singing and burnout. [This photo of you][7] is one of my first posts on Instagram. + +You almost pulled another “Is a Ghetto” move with your [“The Case Against Python 3”][8] post. I think your heart is in the right place but that post caused a lot of confusion, including many people seriously thinking you believe Python 3 is not Turing-complete. I spent quite a few hours convincing people that you said so in jest. But given your very valuable contribution of “Learn Python The Hard Way”, I think it was worth doing that. Especially that you did update your book for Python 3. Thank you for doing that work. If there really are people in our community that called for blacklisting you and your book on the grounds of your post alone, call them out. It’s a lose-lose situation and it’s wrong. + +For the record, no core Python dev thinks that the Python 2 -> Python 3 transition was smooth and well planned, [including Guido van Rossum][9]. Seriously, watch that video. Hindsight is 20/20 of course. In this sense we are in fact aggressively agreeing with each other. If we went to do it all over again, it would look differently. But at this point, [on January 1st 2020 Python 2 will reach End Of Life][10]. Most third-party libraries already support Python 3 and even started releasing Python 3-only versions (see [Django][11] or the [Python 3 Statement of the scientific projects][12]). + +We are also aggressively agreeing on another thing. Just like you with Mongrel, Python core devs are volunteers who aren’t compensated for their work. Most of us invested a lot of time and effort in this project, and so [we are naturally sensitive][13] to dismissive and aggressive comments against their contribution. Especially if the message is both attacking the current state of affairs and calling for more free labor. + +I hoped that by 2018 you’d let your 2016 post go. There were a bunch of good rebuttals. [I especially like eevee’s][14]. It specifically addresses the “run Python 2 alongside Python 3” scenario as not realistic, just like running Ruby 1.8 and Ruby 2.x in the same VM, or like running Lua 5.1 alongside 5.3. You can’t even run C binaries compiled against libc.so.5 with libc.so.6. What I find most surprising though is that you claimed that Python core is “purposefully” creating broken tools like 2to3, created by Guido in whose best interest it is for everybody to migrate as smoothly and quickly as possible. I’m glad that you backed out of that claim in your post later but you have to realize you antagonized people who read the original version. Accusations of deliberate harm better be backed by strong evidence. + +But it seems like you still do that. [Just today][15] you said that Python core “ignores” attempts to solve the API problem, specifically `six`. As I wrote above, `six` is covered by the official porting guide in the Python documentation. More importantly, `six` was written by Benjamin Peterson, the release manager of Python 2.7. A lot of people learned to program thanks to you and you have a large following online. People will read a tweet like this and they will believe it at face value. This is harmful. + +I have a suggestion. Let’s put this “Python 3 was poorly managed” dispute behind us. Python 2 is dying, we are slow to kill it and the process was ugly and bloody but it’s a one way street. Arguing about it is not actionable anymore. Instead, let’s focus on what we can do now to make Python 3.8 better than any other Python release. Maybe you prefer the role of an outsider looking in, but you would be much more impactful as a member of this community. Saying “we” instead of “they”. + +-------------------------------------------------------------------------------- + +via: http://lukasz.langa.pl/13/could-we-run-python-2-and-python-3-code-same-vm/ + +作者:[Łukasz Langa][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]:http://lukasz.langa.pl +[1]:https://python-modernize.readthedocs.io/ +[2]:http://pypi.python.org/pypi/six +[3]:https://docs.python.org/3/howto/pyporting.html +[4]:https://www.youtube.com/watch?v=66XoCk79kjM +[5]:https://twitter.com/llanga/status/963834977745022976 +[6]:https://www.instagram.com/p/ZVC9CwH7G1/ +[7]:https://www.instagram.com/p/ZXtdtUn7Gk/ +[8]:https://learnpythonthehardway.org/book/nopython3.html +[9]:https://www.youtube.com/watch?v=Oiw23yfqQy8 +[10]:https://mail.python.org/pipermail/python-dev/2018-March/152348.html +[11]:https://pypi.python.org/pypi/Django/2.0.3 +[12]:http://python3statement.org/ +[13]:https://www.youtube.com/watch?v=-Nk-8fSJM6I +[14]:https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/ +[15]:https://twitter.com/zedshaw/status/977909970795745281 From c03cf3f9eeac2e9080e9524870cb069951e49741 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 3 Apr 2018 12:27:06 +0800 Subject: [PATCH 0263/1057] PRF:20180308 Dive into BPF a list of reading material.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @qhwdw 辛苦了,这么长而复杂的文章,也只有这种文章才是值得长久流传的。 --- ...ive into BPF a list of reading material.md | 519 +++++++++--------- 1 file changed, 252 insertions(+), 267 deletions(-) diff --git a/translated/tech/20180308 Dive into BPF a list of reading material.md b/translated/tech/20180308 Dive into BPF a list of reading material.md index a2b3754d5d..9137cfd3a6 100644 --- a/translated/tech/20180308 Dive into BPF a list of reading material.md +++ b/translated/tech/20180308 Dive into BPF a list of reading material.md @@ -1,73 +1,15 @@ 深入理解 BPF:一个阅读清单 ============================================================ -* [什么是 BPF?][143] +_~ [更新于][146] 2017-11-02 ~_ -* [深入理解字节码( bytecode)][144] +## 什么是 BPF? -* [资源][145] - * [简介][23] - * [关于 BPF][1] +BPF,及伯克利包过滤器**B**erkeley **P**acket **F**ilter,最初构想提出于 1992 年,其目的是为了提供一种过滤包的方法,并且要避免从内核空间到用户空间的无用的数据包复制行为。它最初是由从用户空间注入到内核的一个简单的字节码构成,它在那个位置利用一个校验器进行检查 —— 以避免内核崩溃或者安全问题 —— 并附着到一个套接字上,接着在每个接收到的包上运行。几年后它被移植到 Linux 上,并且应用于一小部分应用程序上(例如,`tcpdump`)。其简化的语言以及存在于内核中的即时编译器(JIT),使 BPF 成为一个性能卓越的工具。 - * [关于 XDP][2] +然后,在 2013 年,Alexei Starovoitov 对 BPF 进行彻底地改造,并增加了新的功能,改善了它的性能。这个新版本被命名为 eBPF (意思是 “extended BPF”),与此同时,将以前的 BPF 变成 cBPF(意思是 “classic” BPF)。新版本出现了如映射和尾调用tail call这样的新特性,并且 JIT 编译器也被重写了。新的语言比 cBPF 更接近于原生机器语言。并且,在内核中创建了新的附着点。 - * [关于 基于 eBPF 或者 eBPF 相关的其它组件][3] - - * [文档][24] - * [关于 BPF][4] - - * [关于 tc][5] - - * [关于 XDP][6] - - * [关于 P4 和 BPF][7] - - * [教程][25] - - * [示例][26] - * [来自内核的示例][8] - - * [来自包 iproute2 的示例][9] - - * [来自 bcc 工具集的示例][10] - - * [手册页面][11] - - * [代码][27] - * [内核中的 BPF 代码][12] - - * [XDP 钩子(hook)代码][13] - - * [bcc 中的 BPF 逻辑][14] - - * [通过 tc 使用代码去管理 BPF][15] - - * [BPF 实用工具][16] - - * [其它感兴趣的 chunks][17] - - * [LLVM 后端][18] - - * [在用户空间中运行][19] - - * [提交日志][20] - - * [排错][28] - * [编译时的错误][21] - - * [加载和运行时的错误][22] - - * [更多][29] - - _~ [更新于][146] 2017-11-02 ~_ - -# 什么是 BPF? - -BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第一个字母的组合,在 1992 年提出最初的设想,它的目的是为了提供一种过滤包的方法,并且要避免这种从内核空间到用户空间的没用的数据包复制行为。它最初是由从用户空间注入到内核的一个简单的字节码构成,它在那个位置利用一个校验器进行检查 —— 以避免内核崩溃或者安全问题 —— 并附加到一个套接字上,接着在每个接收到的包上运行。几年后它被移植到 Linux 上,并且应用于一小部分应用程序上(例如,tcpdump)。简化的语言以及存在于内核中的即时编译器(JIT),使 BPF 成为一个性能卓越的工具。 - -然后,在 2013 年,Alexei Starovoitov 对 BPF 进行彻底地改造,并增加了新的功能,改善了它的性能。这个新版本被命名为 eBPF (意思是 “extended BPF”),与此同时,将以前的 BPF 变成 cBPF(意思是 “classic” BPF)。新版本出现了如映射和尾调用这样的新特性,并且 JIT 编译器也被重写了。新的语言比 cBPF 更接近于原生机器语言。并且,在内核中创建了新的附加点。 - -感谢那些新的钩子,eBPF 程序才可以被设计用于各种各样的使用案例,它分为两个应用领域。其中一个应用领域是内核跟踪和事件监控。BPF 程序可以被附加到探针,而且它与其它跟踪模式相比,有很多的优点(有时也有一些缺点)。 +感谢那些新的钩子,eBPF 程序才可以被设计用于各种各样的情形下,其分为两个应用领域。其中一个应用领域是内核跟踪和事件监控。BPF 程序可以被附着到探针(kprobe),而且它与其它跟踪模式相比,有很多的优点(有时也有一些缺点)。 另外一个应用领域是网络编程。除了套接字过滤器外,eBPF 程序还可以附加到 tc(Linux 流量控制工具)的入站或者出站接口上,以一种很高效的方式去执行各种包处理任务。这种使用方式在这个领域开创了一个新的天地。 @@ -75,207 +17,247 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 甚至一些项目,如 P4、Open vSwitch,[考虑][155] 或者开始去接洽使用 BPF。其它的一些,如 CETH、Cilium,则是完全基于它的。BPF 是如此流行,因此,我们可以预计,不久之后,将围绕它有更多工具和项目出现 … -# 深入理解字节码 +## 深入理解字节码 -就像我一样:我的一些工作(包括 [BEBA][156])是非常依赖 eBPF 的,并且在这个网站上以后的几篇文章将关注于这个主题。这篇文章的基本逻辑是,在深入到细节之前,我希望以某种方式去介绍 BPF —— 我的意思是,更多地介绍在 BPF 上开发的新功能,它在开始节已经提供了一些简短的概述:什么是 BPF 映射?尾调用?内部结构是什么样子?等等。但是,在这个网站上已经有很多这个主题的介绍了,而且,我也不希望去写另一篇 “BPF 介绍” 的重复文章。 +就像我一样:我的一些工作(包括 [BEBA][156])是非常依赖 eBPF 的,并且在这个网站上以后的几篇文章将关注于这个主题。按理说,在深入到细节之前,我应该以某种方式去介绍 BPF —— 我的意思是,真正的介绍,在第一节所提供的简要介绍上更多地介绍在 BPF 上开发的新功能:什么是 BPF 映射?尾调用?内部结构是什么样子?等等。但是,在这个网站上已经有很多这个主题的介绍了,而且,我也不希望去写另一篇 “BPF 介绍” 的重复文章。 -毕竟,我花费了很多的时间去阅读和学习关于 BPF 的知识,因此,在这里我们将要做什么呢,我收集了非常多的关于 BPF 的阅读材料:介绍、文档、也有教程或者示例。这里有很多的材料可以去阅读,但是,为了去阅读它,首先要去 _找到_ 它。因此,为了能够帮助更多想去学习和使用 BPF 的人,现在的这篇文章是介绍了一个资源清单。这里有各种阅读材料,它可以帮你深入理解内核字节码的机制。 +毕竟,我花费了很多的时间去阅读和学习关于 BPF 的知识,因此,在这里我们将要做什么呢,我收集了非常多的关于 BPF 的阅读材料:介绍、文档,也有教程或者示例。这里有很多的材料可以去阅读,但是,为了去阅读它,首先要去 _找到_ 它。因此,为了能够帮助更多想去学习和使用 BPF 的人,现在的这篇文章给出了一个资源清单。这里有各种阅读材料,它可以帮你深入理解内核字节码的机制。 -# 资源 +## 资源 ![](https://qmonnet.github.io/whirl-offload/img/icons/pic.svg) ### 简介 -这篇文章中下面的链接提供了一个 BPF 的基本的概述,或者,一些与它密切相关的一些主题。如果你对 BPF 非常陌生,你可以在这些介绍文章中挑选出一篇你喜欢的文章去阅读。如果你已经理解了 BPF,你可以针对特定的主题去阅读,下面是阅读清单。 +这篇文章中下面的链接提供了 BPF 的基本概述,或者,一些与它密切相关的一些主题。如果你对 BPF 非常陌生,你可以在这些介绍文章中挑选出一篇你喜欢的文章去阅读。如果你已经理解了 BPF,你可以针对特定的主题去阅读,下面是阅读清单。 -### 关于 BPF +#### 关于 BPF -关于 eBPF 的简介: +**关于 eBPF 的常规介绍**: -* [*全面介绍 eBPF*][193](Matt Flemming,on LWN.net,December 2017): -一篇写的很好的,并且易于理解的,介绍 eBPF 子系统组件的概述文章。 +* [全面介绍 eBPF][193](Matt Flemming,on LWN.net,December 2017): + + 一篇写的很好的,并且易于理解的,介绍 eBPF 子系统组件的概述文章。 -* [_利用 BPF 和 XDP 实现可编程的内核网络数据路径_][53]  (Daniel Borkmann, OSSNA17, Los Angeles, September 2017): - 快速理解所有的关于 eBPF 和 XDP 的基础概念的许多文章中的一篇(大多数是关于网络处理的) +* [利用 BPF 和 XDP 实现可编程的内核网络数据路径][53]  (Daniel Borkmann, OSSNA17, Los Angeles, September 2017): -* [*BSD 包过滤器*][54] (Suchakra Sharma, June 2017):  - 一篇非常好的介绍文章,大多数是关于跟踪方面的。 + 快速理解所有的关于 eBPF 和 XDP 的基础概念的最好讲稿中的一篇(主要是关于网络处理的) -* [_BPF:跟踪及更多_][55]  (Brendan Gregg, January 2017): - 大多数内容是跟踪使用案例相关的。 +* [BSD 包过滤器][54] (Suchakra Sharma, June 2017):  -* [_Linux BPF 的超强功能_][56]  (Brendan Gregg, March 2016): - 第一部分是关于 **火焰图(flame graphs)** 的使用。 + 一篇非常好的介绍文章,主要是关于跟踪方面的。 + +* [BPF:跟踪及更多][55](Brendan Gregg, January 2017): + + 主要内容是跟踪使用案例相关的。 + +* [Linux BPF 的超强功能][56] (Brendan Gregg, March 2016): + + 第一部分是关于火焰图flame graph的使用。 + +* [IO Visor][57](Brenden Blanco, SCaLE 14x, January 2016): -* [_IO Visor_][57]  (Brenden Blanco, SCaLE 14x, January 2016): 介绍了 **IO Visor 项目**。 -* [_大型机上的 eBPF_][58]  (Michael Holzheu, LinuxCon, Dubin, October 2015) +* [大型机上的 eBPF][58](Michael Holzheu, LinuxCon, Dubin, October 2015) -* [_在 Linux 上新的(令人激动的)跟踪新产品_][59]  (Elena Zannoni, LinuxCon, Japan, 2015) +* [在 Linux 上新的(令人激动的)跟踪新产品][59](Elena Zannoni, LinuxCon, Japan, 2015) -* [_BPF — 内核中的虚拟机_][60]  (Alexei Starovoitov, February 2015): - eBPF 的作者写的一篇介绍文章。 +* [BPF — 内核中的虚拟机][60](Alexei Starovoitov, February 2015): -* [_扩展 extended BPF_][61]  (Jonathan Corbet, July 2014) + eBPF 的作者写的一篇讲稿。 + +* [扩展 extended BPF][61] (Jonathan Corbet, July 2014) **BPF 内部结构**: -* Daniel Borkmann 正在做的一项令人称奇的工作,它用于去展现 eBPF 的 **内部结构**,尤其是,它的关于 **eBPF 用于 tc ** 的几次演讲和论文。 - * [_使用 tc 的 cls_bpf 的高级可编程和它的最新更新_][30]  (netdev 1.2, Tokyo, October 2016): - Daniel 介绍了 eBPF 的细节,它使用了隧道和封装、直接包访问、和其它特性。 +* Daniel Borkmann 正在做的一项令人称奇的工作,它用于去展现 eBPF 的 **内部结构**,尤其是,它的关于 **随同 tc 使用** 的几次演讲和论文。 + * [使用 tc 的 cls_bpf 的高级可编程和它的最新更新][30](netdev 1.2, Tokyo, October 2016): + + Daniel 介绍了 eBPF 的细节,及其用于隧道和封装、直接包访问和其它特性。 - * [_自 netdev 1.1 以来的 cls_bpf/eBPF 更新_][31]  (netdev 1.2, Tokyo, October 2016, part of [this tc workshop][32]) + * [自 netdev 1.1 以来的 cls_bpf/eBPF 更新][31]  (netdev 1.2, Tokyo, October 2016, part of [this tc workshop][32]) - * [_使用 cls_bpf 实现完全可编程的 tc 分类器_][33]  (netdev 1.1, Sevilla, February 2016): - 介绍 eBPF 之后,它提供了许多 BPF 内部机制(映射管理、tail 调用、校验器)的见解。对于大多数有志于 BPF 的人来说,这是必读的![全文在这里][34]。 + * [使用 cls_bpf 实现完全可编程的 tc 分类器][33]  (netdev 1.1, Sevilla, February 2016): + + 介绍 eBPF 之后,它提供了许多 BPF 内部机制(映射管理、尾调用、校验器)的见解。对于大多数有志于 BPF 的人来说,这是必读的![全文在这里][34]。 - * [_Linux tc 和 eBPF_][35]  (fosdem16, Brussels, Belgium, January 2016) + * [Linux tc 和 eBPF][35] (fosdem16, Brussels, Belgium, January 2016) - * [_eBPF 和 XDP 攻略和最新更新_][36]  (fosdem17, Brussels, Belgium, February 2017) + * [eBPF 和 XDP 攻略和最新更新][36] (fosdem17, Brussels, Belgium, February 2017) - 这些介绍可能是理解 eBPF 内部机制设计与实现的最佳文档资源之一。 + 这些介绍可能是理解 eBPF 内部机制设计与实现的最佳文档资源之一。 -[***IO Visor 博客***][157] 有一些关于 BPF 感兴趣的技术文章。它们中的一些包含了许多营销讨论。 +[IO Visor 博客][157] 有一些关于 BPF 的值得关注技术文章。它们中的一些包含了一点营销讨论。 **内核跟踪**:总结了所有的已有的方法,包括 BPF: -* [_邂逅 eBPF 和内核跟踪_][62]  (Viller Hsiao, July 2016): +* [邂逅 eBPF 和内核跟踪][62] (Viller Hsiao, July 2016): + Kprobes、uprobes、ftrace -* [_Linux 内核跟踪_][63]  (Viller Hsiao, July 2016): +* [Linux 内核跟踪][63](Viller Hsiao, July 2016): + Systemtap、Kernelshark、trace-cmd、LTTng、perf-tool、ftrace、hist-trigger、perf、function tracer、tracepoint、kprobe/uprobe … -关于 **事件跟踪和监视**,Brendan Gregg 使用 eBPF 的一些心得,它使用 eBPFR 的一些案例,他做的非常出色。如果你正在做一些内核跟踪方面的工作,你应该去看一下他的关于 eBPF 和火焰图相关的博客文章。其中的大多数都可以 *[从这篇文章中][158]* 访问,或者浏览他的博客。 +关于 **事件跟踪和监视**,Brendan Gregg 大量使用了 eBPF,并且就其使用 eBPFR 的一些案例写了极好的文档。如果你正在做一些内核跟踪方面的工作,你应该去看一下他的关于 eBPF 和火焰图相关的博客文章。其中的大多数都可以 [从这篇文章中][158] 访问,或者浏览他的博客。 介绍 BPF,也介绍 **Linux 网络的一般概念**: -* [_Linux 网络详解_][64]  (Thomas Graf, LinuxCon, Toronto, August 2016) +* [Linux 网络详解][64] (Thomas Graf, LinuxCon, Toronto, August 2016) -* [_内核网络攻略_][65]  (Thomas Graf, LinuxCon, Seattle, August 2015) +* [内核网络攻略][65]  (Thomas Graf, LinuxCon, Seattle, August 2015) -**硬件 offload**(译者注:offload 是指原本由软件来处理的一些操作交由硬件来完成,以提升吞吐量,降低 CPU 负荷。): +**硬件卸载offload**(LCTT 译注:“卸载”是指原本由软件来处理的一些操作交由硬件来完成,以提升吞吐量,降低 CPU 负荷。): -* eBPF 与 tc 或者 XDP 一起支持硬件 offload,开始于 Linux 内核版本 4.9,并且由 Netronome 提出的。这里是关于这个特性的介绍:[*eBPF/XDP hardware offload to SmartNICs*][147] (Jakub Kicinski 和 Nic Viljoen, netdev 1.2, Tokyo, October 2016) +* eBPF 与 tc 或者 XDP 一起支持硬件卸载,开始于 Linux 内核版本 4.9,是由 Netronome 提出的。这里是关于这个特性的介绍:[eBPF/XDP 硬件卸载到 SmartNICs][147](Jakub Kicinski 和 Nic Viljoen, netdev 1.2, Tokyo, October 2016) -* 年后出现的更新版: -[*综合的关于 XDP offload 处理边界的案例*][194](Jakub Kicinski 和 Nic Viljoen,netdev 2.2 ,Seoul,November 2017) +* 一年后出现的更新版: + + [综合 XDP 卸载——处理边界案例][194](Jakub Kicinski 和 Nic Viljoen,netdev 2.2 ,Seoul,November 2017) * 我现在有一个简短的,但是在 2018 年的 FOSDEM 上有一个更新版: -[*XDP 硬件 Offload 的挑战*][195](Quentin Monnet,FOSDEM 2018,Brussels,February 2018) + + [XDP 硬件卸载的挑战][195](Quentin Monnet,FOSDEM 2018,Brussels,February 2018) 关于 **cBPF**: -* [_BSD 包过滤器:一个用户级包捕获的新架构_][66] (Steven McCanne 和 Van Jacobson, 1992): - 它是关于(classic)BPF 的最早的论文。 +* [BSD 包过滤器:一个用户级包捕获的新架构][66] (Steven McCanne 和 Van Jacobson, 1992): -* *[关于 BPF 的 FreeBSD 手册][67]* 是理解 cBPF 程序的可用资源。 + 它是关于(经典)BPF 的最早的论文。 -* 关于 cBPF,Daniel Borkmann 实现的至少两个演示,[*一是,在 2013 年 mmap 中,BPF 和 Netsniff-NG*][68],以及 *[在 2014 中关于 tc 和 cls_bpf 的的一个非常完整的演示][69]*。 +* [BPF 的 FreeBSD 手册][67] 是理解 cBPF 程序有用的资源。 -* 在 Cloudflare 的博客上,Marek Majkowski 提出的它的 *[BPF 字节码与 **iptables** 的 `xt_bpf` 模块一起的应用][70]*。值得一提的是,从 Linux 内核 4.10 开始,eBPF 也是通过这个模块支持的。(虽然,我并不知道关于这件事的任何讨论或者文章) +* 关于 cBPF,Daniel Borkmann 做至少两个演讲,[一是,在 2013 年 mmap 中,BPF 和 Netsniff-NG][68],以及 [在 2014 中关于 tc 和 cls_bpf 的的一个非常完整的演讲][69]。 -* [*Libpcap 过滤器语法*][71] +* 在 Cloudflare 的博客上,Marek Majkowski 提出的他的 [与 iptables 的 `xt_bpf` 模块一起使用 BPF 字节码][70]。值得一提的是,从 Linux 内核 4.10 开始,eBPF 也是通过这个模块支持的。(虽然,我并不知道关于这件事的任何讨论或者文章) -### 关于 XDP +* [Libpcap 过滤器语法][71] -* 在 IO Visor 网站上的 *[XDP 概述][72]*。 +#### 关于 XDP -* [_eXpress Data Path (XDP)_][73]  (Tom Herbert, Alexei Starovoitov, March 2016): - 这是第一个关于 XDP 的演示。 +* 在 IO Visor 网站上的 [XDP 概述][72]。 -* [_BoF - BPF 能为你做什么?_][74]  (Brenden Blanco, LinuxCon, Toronto, August 2016)。 +* [eXpress Data Path (XDP)][73]  (Tom Herbert, Alexei Starovoitov, March 2016): -* [_eXpress Data Path_][148]  (Brenden Blanco, Linux Meetup at Santa Clara, July 2016): - 包含一些(有点营销的意思?)**benchmark 结果**!使用一个单核心: + 这是第一个关于 XDP 的演讲。 + +* [BoF - BPF 能为你做什么?][74]  (Brenden Blanco, LinuxCon, Toronto, August 2016)。 + +* [eXpress Data Path][148] (Brenden Blanco, Linux Meetup at Santa Clara, July 2016): + + 包含一些(有点营销的意思?)**基准测试结果**!使用单一核心: + * ip 路由丢弃: ~3.6 百万包每秒(Mpps) - + * 使用 BPF,tc(使用 clsact qdisc)丢弃: ~4.2 Mpps * 使用 BPF,XDP 丢弃:20 Mpps (CPU 利用率 < 10%) * XDP 重写转发(在端口上它接收到的包):10 Mpps - (测试是用 mlx4 驱动执行的)。 + (测试是用 mlx4 驱动程序执行的)。 * Jesper Dangaard Brouer 有几个非常好的幻灯片,它可以从本质上去理解 XDP 的内部结构。 - * [_XDP − eXpress Data Path, Intro and future use-cases_][37]  (September 2016): - _“Linux 内核与 DPDK 的斗争”_ 。**未来的计划**(在写这篇文章时)它用 XDP 和 DPDK 进行比较。 - * [_网络性能研讨_][38]  (netdev 1.2, Tokyo, October 2016): + * [XDP − eXpress Data Path,介绍及将来的用法][37] (September 2016): + + “Linux 内核与 DPDK 的斗争” 。**未来的计划**(在写这篇文章时)它用 XDP 和 DPDK 进行比较。 + + * [网络性能研讨][38]  (netdev 1.2, Tokyo, October 2016): + 关于 XDP 内部结构和预期演化的附加提示。 - * [_XDP – eXpress Data Path, 可用于 DDoS 防护_][39]  (OpenSourceDays, March 2017): - 包含了关于 XDP 的详细情况和使用案例、用于 **benchmarking** 的 **benchmark 结果**、和 **代码片断**,以及使用 eBPF/XDP(基于一个 IP 黑名单模式)的用于 **基本的 DDoS 防护**。 + * [XDP – eXpress Data Path, 可用于 DDoS 防护][39] (OpenSourceDays, March 2017): + + 包含了关于 XDP 的详细情况和使用案例,以及 **性能测试** 的 **性能测试结果** 和 **代码片断**,以及使用 eBPF/XDP(基于一个 IP 黑名单模式)的用于 **基本的 DDoS 防护**。 - * [_内存 vs. 网络,激发和修复内存瓶颈_][40]  (LSF Memory Management Summit, March 2017): - 面对 XDP 开发者提出关于当前 **内存问题** 的许多细节。不要从这一个开始,如果你已经理解了 XDP,并且想去了解它在页面分配方面的真实工作方式,这是一个非常有用的资源。 + * [内存 vs. 网络,激发和修复内存瓶颈][40] (LSF Memory Management Summit, March 2017): + + 提供了许多 XDP 开发者当前所面对 **内存问题** 的许多细节。不要从这一个开始,但如果你已经理解了 XDP,并且想去了解它在页面分配方面的真实工作方式,这是一个非常有用的资源。 - * [_XDP 能为其它人做什么_][41](netdev 2.1, Montreal, April 2017),with Andy Gospodarek: - 对于普通人使用 eBPF 和 XDP 怎么去开始。这个演示也由 Julia Evans 在 [他的博客][42] 上做了总结。 + * [XDP 能为其它人做什么][41](netdev 2.1, Montreal, April 2017),及 Andy Gospodarek: + + 普通人怎么开始使用 eBPF 和 XDP。这个演讲也由 Julia Evans 在 [她的博客][42] 上做了总结。 - ( Jesper 也创建了并且尝试去扩展了有关 eBPF 和 XDP 的一些文档,查看 [相关节][75]。) + * [XDP 能为其它人做什么][205],第二版(netdev 2.2, Seoul, November 2017),同一个作者: + + 该演讲的修订版本,包含了新的内容。 + +(Jesper 也创建了并且尝试去扩展了有关 eBPF 和 XDP 的一些文档,查看 [相关节][75]。) -* [_XDP 研讨 — 介绍、体验、和未来发展_][76](Tom Herbert, netdev 1.2, Tokyo, October 2016) — 在这篇文章中,只有视频可用,我不知道是否有幻灯片。 +* [XDP 研讨 — 介绍、体验和未来发展][76](Tom Herbert, netdev 1.2, Tokyo, October 2016) -* [_在 Linux 上进行高速包过滤_][149]  (Gilberto Bertin, DEF CON 25, Las Vegas, July 2017) — 在 Linux 上的最先进的包过滤的介绍,面向 DDoS 的保护、讨论了关于在内核中进行包处理、内核旁通、XDP 和 eBPF。 + 在这篇文章中,只有视频可用,我不知道是否有幻灯片。 -### 关于 基于 eBPF 或者 eBPF 相关的其它组件 +* [在 Linux 上进行高速包过滤][149] (Gilberto Bertin, DEF CON 25, Las Vegas, July 2017) + + 在 Linux 上的最先进的包过滤的介绍,面向 DDoS 的保护、讨论了关于在内核中进行包处理、内核旁通、XDP 和 eBPF。 + +#### 关于 基于 eBPF 或者 eBPF 相关的其它组件 + +* [在边界上的 P4][77] (John Fastabend, May 2016): -* [_在边界上的 P4_][77]  (John Fastabend, May 2016): 提出了使用 **P4**,一个包处理的描述语言,使用 BPF 去创建一个高性能的可编程交换机。 -* 如果你喜欢音频的介绍,这里有一个相关的 [OvS Orbit 片断(#11),叫做 _在边缘上的 **P4**_][78],日期是 2016 年 8 月。OvS Orbit 是对 Ben Pfaff 的访谈,它是 Open vSwitch 的其中一个核心维护者。在这个场景中,John Fastabend 是被访谈者。 +* 如果你喜欢音频的演讲,这里有一个相关的 [OvS Orbit 片断(#11),叫做 在边界上的 P4][78],日期是 2016 年 8 月。OvS Orbit 是对 Ben Pfaff 的访谈,它是 Open vSwitch 的其中一个核心维护者。在这个场景中,John Fastabend 是被访谈者。 -* [_P4, EBPF 和 Linux TC Offload_][79]  (Dinan Gunawardena and Jakub Kicinski, August 2016): - 另一个演示 **P4** 的,使用一些相关的元素在 Netronome 的 **NFP**(网络流处理器)架构上去实现 eBPF 硬件 offload。 +* [P4, EBPF 和 Linux TC 卸载][79] (Dinan Gunawardena 和 Jakub Kicinski, August 2016): -* **Cilium** 是一个由 Cisco 最先发起的技术,它依赖 BPF 和 XDP 去提供 “在容器中基于 eBPF 程序,在运行中生成的强制实施的快速的内核中的网络和安全策略”。[这个项目的代码][150] 在 GitHub 上可以访问到。Thomas Graf 对这个主题做了很多的演示: - * [_Cilium: 对容器利用 BPF & XDP 实现网络 & 安全_][43],也特别展示了一个负载均衡的使用案例(Linux Plumbers conference, Santa Fe, November 2016) + 另一个 **P4** 的演讲,一些有关于 Netronome 的 **NFP**(网络流处理器)架构上的 eBPF 硬件卸载的因素。 - * [_Cilium: 对容器利用 BPF & XDP 实现网络 & 安全_][44] (Docker Distributed Systems Summit, October 2016 — [video][45]) +* **Cilium** 是一个由 Cisco 最先发起的技术,它依赖 BPF 和 XDP 去提供 “基于 eBPF 程序即时生成的,用于容器的快速内核强制的网络和安全策略”。[这个项目的代码][150] 在 GitHub 上可以访问到。Thomas Graf 对这个主题做了很多的演讲: + * [Cilium:对容器利用 BPF & XDP 实现网络 & 安全][43],也特别展示了一个负载均衡的使用案例(Linux Plumbers conference, Santa Fe, November 2016) - * [_Cilium: 使用 BPF 和 XDP 的快速 IPv6 容器网络_][46] (LinuxCon, Toronto, August 2016) + * [Cilium:对容器利用 BPF & XDP 实现网络 & 安全][44] (Docker Distributed Systems Summit, October 2016 — [video][45]) - * [_Cilium: 为窗口使用 BPF & XDP_][47] (fosdem17, Brussels, Belgium, February 2017) + * [Cilium:使用 BPF 和 XDP 的快速 IPv6 容器网络][46] (LinuxCon, Toronto, August 2016) - 在不同的演示中重复了大量的内容;如果有疑问,就选最近的一个。Daniel Borkmann 作为 Google 开源博客的特邀作者,也写了 [Cilium 简介][80]。 + * [Cilium: 用于容器的 BPF & XDP][47] (fosdem17, Brussels, Belgium, February 2017) -* 这里也有一个关于 **Cilium** 的播客节目:一个 *[OvS Orbit episode (#4)][81]*,它是 Ben Pfaff 访谈 Thomas Graf (2016 年 5 月),和 *[另外一个 Ivan Pepelnjak 的播客][82]*,仍然是 Thomas Graf 的与 eBPF、P4、XDP 和 Cilium (2016 年 10 月)。 + 在上述不同的演讲中重复了大量的内容;嫌麻烦就选最近的一个。Daniel Borkmann 作为 Google 开源博客的特邀作者,也写了 [Cilium 简介][80]。 + +* 这里也有一个关于 **Cilium** 的播客节目:一个是 [OvS Orbit episode (#4)][81],它是 Ben Pfaff 访谈 Thomas Graf (2016 年 5 月),和 [另外一个 Ivan Pepelnjak 的播客][82],仍然是 Thomas Graf 关于 eBPF、P4、XDP 和 Cilium 方面的(2016 年 10 月)。 * **Open vSwitch** (OvS),它是 **Open Virtual Network**(OVN,一个开源的网络虚拟化解决方案)相关的项目,正在考虑在不同的层次上使用 eBPF,它已经实现了几个概念验证原型: - * [*使用 eBPF 的 Offloading OVS 流处理器*][48] (William (Cheng-Chun) Tu, OvS conference, San Jose, November 2016) + * [使用 eBPF 卸载 OVS 流处理器][48] (William (Cheng-Chun) Tu, OvS conference, San Jose, November 2016) - * *[将 OVN 的灵活性与 IOVisor 的高效率相结合][49]* (Fulvio Risso, Matteo Bertrone and Mauricio Vasquez Bernal, OvS conference, San Jose, November 2016) + * [将 OVN 的灵活性与 IOVisor 的高效率相结合][49] (Fulvio Risso, Matteo Bertrone 和 Mauricio Vasquez Bernal, OvS conference, San Jose, November 2016) - 据我所知,这些 eBPF 的使用案例看上去仅处于提议阶段(并没有合并到 OvS 的主分支中),但是,看它带来了什么将是非常有趣的事情。 + 据我所知,这些 eBPF 的使用案例看上去仅处于提议阶段(并没有合并到 OvS 的主分支中),但是,看它带来了什么将是非常值得关注的事情。 -* XDP 的设计对分布式拒绝访问(DDoS)攻击是非常有用的。越来越多的演示都关注于它。例如,从 Cloudflare 中的人们的讨论([_XDP in practice: integrating XDP in our DDoS mitigation pipeline_][83])或者从 Facebook 上([_Droplet: DDoS countermeasures powered by BPF + XDP_][84])在 netdev 2.1 会议上,在 Montreal、Canada、在 2017 年 4 月,都存在这样的很多使用案例。 +* XDP 的设计对分布式拒绝访问(DDoS)攻击是非常有用的。越来越多的演讲都关注于它。例如,在 2017 年 4 月加拿大蒙特利尔举办的 netdev 2.1 会议上,来自 Cloudflare 的人们的讲话([XDP 实践:将 XDP 集成到我们的 DDoS 缓解管道][83])或者来自 Facebook 的([Droplet:由 BPF + XDP 驱动的 DDoS 对策][84])都存在这样的很多使用案例。 -* Kubernetes 可以用很多种方式与 eBPF 交互。这里有一篇关于 *[在 Kubernetes 中使用 eBPF][196]* 的文章,它解释了现有的产品 (Cilium,Weave Scope) 如何支持 eBPF 与 Kubernetes 一起工作,并且进一步描述了,在容器部署环境中,eBPF 感兴趣的交互内容是什么。 +* Kubernetes 可以用很多种方式与 eBPF 交互。这里有一篇关于 [在 Kubernetes 中使用 eBPF][196] 的文章,它解释了现有的产品(Cilium、Weave Scope)如何支持 eBPF 与 Kubernetes 一起工作,并且进一步描述了,在容器部署环境中,eBPF 感兴趣的交互内容是什么。 + +* [CETH for XDP][85] (Yan Chan 和 Yunsong Lu、Linux Meetup、Santa Clara、July 2016): -* [_CETH for XDP_][85] (Yan Chan 和 Yunsong Lu、Linux Meetup、Santa Clara、July 2016): **CETH**,是由 Mellanox 发起的,为实现更快的网络 I/O 而主张的通用以太网驱动程序架构。 -* [***VALE 交换机***][86],另一个虚拟交换机,它可以与 netmap 框架结合,有 *[一个 BPF 扩展模块][87]*。 +* [**VALE 交换机**][86],另一个虚拟交换机,它可以与 netmap 框架结合,有 [一个 BPF 扩展模块][87]。 -* **Suricata**,一个开源的入侵检测系统,它的捕获旁通特性 [*似乎是依赖于 eBPF 组件*][88]: - [*Suricate 文档的 eBPF 和 XDP 部分*][197] - [*SEPTun-Mark-II*][198] (Suricata Extreme 性能调优指南 — Mark II),Published by Michal Purzynski 和 Peter Manev in March 2018 - [*介绍这个特性的博客文章*][199] Published by Éric Leblond in September 2016 - [_The adventures of a Suricate in eBPF land_][89]  (Éric Leblond, netdev 1.2, Tokyo, October 2016) - [_eBPF and XDP seen from the eyes of a meerkat_][90]  (Éric Leblond, Kernel Recipes, Paris, September 2017) -当使用原生驱动的 XDP 时,这个项目要求实现非常高的性能。 +* **Suricata**,一个开源的入侵检测系统,它的旁路捕获旁特性依赖于 XDP。有一些关于它的资源: + + * [Suricate 文档的 eBPF 和 XDP 部分][197] + + * [SEPTun-Mark-II][198] (Suricata Extreme 性能调优指南 — Mark II), Michal Purzynski 和 Peter Manev 发布于 2018 年 3 月。 + + * [介绍这个特性的博客文章][199] Éric Leblond 发布于 2016 年 9 月。 + * [Suricate 的 eBPF 历险记][89]  (Éric Leblond, netdev 1.2, Tokyo, October 2016) + * [eBPF 和 XDP 一窥][90]  (Éric Leblond, Kernel Recipes, Paris, September 2017) + + 当使用原生驱动的 XDP 时,这个项目要求实现非常高的性能。 + +* [InKeV:对于 DCN 的内核中分布式网络虚拟化][91] (Z. Ahmed, M. H. Alizai 和 A. A. Syed, SIGCOMM, August 2016): -* [*InKeV: 对于 DCN 的内核中分布式网络虚拟化*][91] (Z. Ahmed, M. H. Alizai and A. A. Syed, SIGCOMM, August 2016): **InKeV** 是一个基于 eBPF 的虚拟网络、目标数据中心网络的数据路径架构。它最初由 PLUMgrid 提出,并且声称相比基于 OvS 的 OpenStack 解决方案可以获得更好的性能。 -* [_**gobpf** - 从 Go 中利用 eBPF_][92] (Michael Schubert, fosdem17, Brussels, Belgium, February 2017): - “一个从 Go 中的库,可以去创建、加载和使用 eBPF 程序” +* [gobpf - 在 Go 中使用 eBPF][92] (Michael Schubert, fosdem17, Brussels, Belgium, February 2017): -* [***ply***][93] 是为 Linux 实现的一个小的但是非常灵活的开源动态 **跟踪器**,它的一些特性非常类似于 bcc 工具,是受 awk 和 dtrace 启发,但使用一个更简单的语言。它是由 Tobias Waldekranz 写的。 + “一个来自 Go 库,可以去创建、加载和使用 eBPF 程序” + +* [ply][93] 是为 Linux 实现的一个小而灵活的开源动态 **跟踪器**,它的一些特性非常类似于 bcc 工具,是受 awk 和 dtrace 启发,但使用一个更简单的语言。它是由 Tobias Waldekranz 写的。 * 如果你读过我以前的文章,你可能对我在这篇文章中的讨论感兴趣,[使用 eBPF 实现 OpenState 接口][151],关于包状态处理,在 fosdem17 中。 @@ -283,198 +265,199 @@ BPF,是伯克利包过滤器(**B**erkeley **P**acket **F**ilter)的第 ### 文档 -一旦你对 BPF 是做什么的有一个大体的理解。你可以抛开一般的演示而深入到文档中了。下面是 BPF 的规范和功能的最全面的文档,按你的需要挑一个开始阅读吧! +一旦你对 BPF 是做什么的有一个大体的理解。你可以抛开一般的演讲而深入到文档中了。下面是 BPF 的规范和功能的最全面的文档,按你的需要挑一个开始阅读吧! -### 关于 BPF +#### 关于 BPF -* **BPF 的规范**(包含 classic 和 extended 版本)可以在 Linux 内核的文档中,和特定的文件 *[linux/Documentation/networking/filter.txt][94]* 中找到。BPF 使用以及它的内部结构也被记录在那里。此外,当加载 BPF 代码失败时,在这里可以找到 **被校验器抛出的错误信息**,这有助于你排除不明确的错误信息。 +* **BPF 的规范**(包含 classic 和 extended 版本)可以在 Linux 内核的文档中,和特定的文件 [linux/Documentation/networking/filter.txt][94] 中找到。BPF 使用以及它的内部结构也被记录在那里。此外,当加载 BPF 代码失败时,在这里可以找到 **被校验器抛出的错误信息**,这有助于你排除不明确的错误信息。 -* 此外,在内核树中,在 eBPF 那里有一个关于 **常见的问 & 答** 的文档,它在文件 [*linux/Documentation/bpf/bpf_design_QA.txt*][95] 中。 +* 此外,在内核树中,在 eBPF 那里有一个关于 **常见问答** 的文档,它在文件 [linux/Documentation/bpf/bpf\_design\_QA.txt][95] 中。 -* … 但是,内核文档是非常难懂的,并且非常不容易阅读。如果你只是去查找一个简单的 eBPF 语言的描述,可以去 IO Visor 的 GitHub 仓库,那儿有 [***它的概括性描述***][96]。 +* … 但是,内核文档是非常难懂的,并且非常不容易阅读。如果你只是去查找一个简单的 eBPF 语言的描述,可以去 IO Visor 的 GitHub 仓库,那儿有 [它的概括性描述][96]。 -* 顺便说一下,IO Visor 项目收集了许多 **关于 BPF 的资源**。大部分,分别在 bcc 仓库的 *[文档目录][97]* 中,和 *[bpf-docs 仓库][98]* 的整个内容中,它们都在 GitHub 上。注意,这个非常好的 *[BPF **参考指南**][99]* 包含一个详细的 BPF C 和 bcc Python 的 helper 的描述。 +* 顺便说一下,IO Visor 项目收集了许多 **关于 BPF 的资源**。大部分分别在 bcc 仓库的 [文档目录][97] 中,和 [bpf-docs 仓库][98] 的整个内容中,它们都在 GitHub 上。注意,这个非常好的 [BPF 参考指南][99] 包含一个详细的 BPF C 和 bcc Python 的 helper 的描述。 -* 想深入到 BPF,那里有一些必要的 **Linux 手册页**。第一个是 [*`bpf(2)` man 页面*][100] 关于 `bpf()` **系统调用**,它用于从用户空间去管理 BPF 程序和映射。它也包含一个 BPF 高级特性的描述(程序类型、映射、等等)。第二个是主要去处理希望去附加到 tc 接口的 BPF 程序:它是 [*`tc-bpf(8)` man 页面*][101],它是 **使用 BPF 和 tc** 的一个参考,并且包含一些示例命令和参考代码。 +* 想深入到 BPF,那里有一些必要的 **Linux 手册页**。第一个是 [bpf(2) man 页面][100] 关于 `bpf()` **系统调用**,它用于从用户空间去管理 BPF 程序和映射。它也包含一个 BPF 高级特性的描述(程序类型、映射等等)。第二个是主要是处理希望附加到 tc 接口的 BPF 程序:它是 [tc-bpf(8) man 页面][101],是 **使用 BPF 和 tc** 的一个参考,并且包含一些示例命令和参考代码。 -* Jesper Dangaard Brouer 发起了一个 **更新 eBPF Linux 文档** 的尝试,包含 **不同的映射**。[*他有一个草案*][102],欢迎去贡献。一旦完成,这个文档将被合并进 man 页面并且进入到内核文档。 +* Jesper Dangaard Brouer 发起了一个 **更新 eBPF Linux 文档** 的尝试,包含 **不同的映射**。[他有一个草案][102],欢迎去贡献。一旦完成,这个文档将被合并进 man 页面并且进入到内核文档。 -* Cilium 项目也有一个非常好的 [***BPF 和 XDP 参考指南***][103],它是由核心的 eBPF 开发者写的,它被证明对于 eBPF 开发者是极其有用的。 +* Cilium 项目也有一个非常好的 [BPF 和 XDP 参考指南][103],它是由核心的 eBPF 开发者写的,它被证明对于 eBPF 开发者是极其有用的。 -* David Miller 在 *[xdp-newbies][152]* 邮件列表中发了几封关于 eBPF/XDP 内部结构的富有启发性的电子邮件。我找不到一个单独的地方收集它们的链接,因此,这里是一个列表: +* David Miller 在 [xdp-newbies][152] 邮件列表中发了几封关于 eBPF/XDP 内部结构的富有启发性的电子邮件。我找不到一个单独的地方收集它们的链接,因此,这里是一个列表: - * [*bpf.h 和你 …*][50] + * [bpf.h 和你 …][50] - * [*Contextually speaking…*][51] + * [从语境上讲…][51] - * [*BPF 校验器概述*][52] + * [BPF 校验器概述][52] 最后一个可能是目前来说关于校验器的最佳的总结。 -* Ferris Ellis 发布的 *[一个关于 **eBPF 的系列博客文章**][104]*。作为我写的这个短文,第一篇文章是关于 eBPF 的历史背景和未来期望。接下来的文章将更多的是技术方面,和前景展望。 +* Ferris Ellis 发布的 [一个关于 eBPF 的系列博客文章][104]。作为我写的这个短文,第一篇文章是关于 eBPF 的历史背景和未来期望。接下来的文章将更多的是技术方面,和前景展望。 -* [***一个每个内核版本的 BPF 特性列表***][153] 在 bcc 仓库中可以找到。如果你想去知道运行一个给定的特性所要求的最小的内核版本,它是非常有用的。我贡献和添加了链接到提交中,它介绍了每个特性,因此,你也可以从那里很容易地去访问提交历史。 +* [每个内核版本的 BPF 特性列表][153] 在 bcc 仓库中可以找到。如果你想去知道运行一个给定的特性所要求的最小的内核版本,它是非常有用的。我贡献和添加了链接到提交中,它介绍了每个特性,因此,你也可以从那里很容易地去访问提交历史。 -### 关于 tc +#### 关于 tc -当为了网络目的使用 BPF 与 tc 进行结合时,Linux 流量控制(**t**raffic **c**ontrol)工具,它可用于去采集关于 tc 的可用功能的信息。这里有几个关于它的资源。 +当为了网络目的结合使用 BPF 与 tc (Linux 流量控制**t**raffic **c**ontrol工具)时,它可用于收集 tc 的常规功能的信息。这里有几个关于它的资源。 -* 找到关于 **Linux 上 QoS** 的简单教程是很困难的。这里有两个链接,它们很长而且很难懂,但是,如果你可以抽时间去阅读它,你将学习到几乎关于 tc 的任何东西(虽然,关于 BPF 它什么也没有)。它们在这里:[_怎么去实现流量控制_  (Martin A. Brown, 2006)][105],和 [_怎么去实现 Linux 的高级路由 & 流量控制_  (“LARTC”) (Bert Hubert & al., 2002)][106]。 +* 找到关于 **Linux 上 QoS** 的简单教程是很困难的。这里有两个链接,它们很长而且很难懂,但是,如果你可以抽时间去阅读它,你将学习到几乎关于 tc 的任何东西(虽然,没有什么关于 BPF 的)。它们在这里:[怎么去实现流量控制  (Martin A. Brown, 2006)][105],和 [怎么去实现 Linux 的高级路由 & 流量控制 (LARTC) (Bert Hubert & al., 2002)][106]。 -* 在你的系统上的 **tc 手册页面** 并不是最新日期的,因为它们中的几个最近已经增加了。如果你没有找到关于特定的队列规则、分类或者过滤器的文档,它可能在最新的 *[tc 组件的手册页面][107]* 中。 +* 在你的系统上的 **tc 手册页面** 并不是最新的,因为它们中的几个最近已经增加了内容。如果你没有找到关于特定的队列规则、分类或者过滤器的文档,它可能在最新的 [tc 组件的手册页面][107] 中。 + +* 一些额外的材料可以在 iproute2 包自已的文件中找到:这个包中有 [一些文档][108],包括一些文件,它可以帮你去理解 [tc 的 action 的功能][109]。 -* 一些额外的材料可以在 iproute2 包自已的文件中找到:这个包中有 [*一些文档*][108],包括一些文件,它可以帮你去理解 *[**tc 的 action** 的功能][109]*。 **注意:** 这些文件在 2017 年 10 月 已经从 iproute2 中删除,然而,从 Git 历史中却一直可用。 -* 非精确资料:这里是 [*一个关于 tc 的几个特性的研讨会*][110](包含过滤、BPF、tc offload、…) 由 Jamal Hadi Salim 在 netdev 1.2 会议上组织的(October 2016)。 +* 不完全是文档:[有一个关于 tc 的几个特性的研讨会][110](包含过滤、BPF、tc 卸载、…) 由 Jamal Hadi Salim 在 netdev 1.2 会议上组织的(October 2016)。 -* 额外信息 — 如果你使用 `tc` 较多,这里有一些好消息:我用这个工具 *[写了一个 bash 完整的功能][111]*,并且它被包 iproute2 带到内核版本 4.6 和更高版中! +* 额外信息 — 如果你使用 `tc` 较多,这里有一些好消息:我用这个工具 [写了一个 bash 补完功能][111],并且它被包 iproute2 带到内核版本 4.6 和更高版中! -### 关于 XDP +#### 关于 XDP -* 对于 XDP 的一些 *[进展中的文档(包括规范)][112]* 已经由 Jesper Dangaard Brouer 启动,并且意味着将成为一个合作的工作。正在推进(2016 年 9 月):你期望它去改变,并且或许在一些节点上移动(Jesper *[称为贡献][113]*,如果你想去改善它)。 +* 对于 XDP 的一些 [进展中的文档(包括规范)][112] 已经由 Jesper Dangaard Brouer 启动,并且意味着将成为一个协作工作。正在推进的(2016 年 9 月):你期望它去改变,并且或许在一些节点上移动(Jesper [称为贡献][113],如果你想去改善它)。 -* 自来 Cilium 项目的 *[BPF 和 XDP 参考指南][114]* … 好吧,这个名字已经说明了一切。 +* 自来 Cilium 项目的 [BPF 和 XDP 参考指南][114] … 好吧,这个名字已经说明了一切。 -### 关于 P4 和 BPF +#### 关于 P4 和 BPF -*[P4][159]* 是一个用于指定交换机行为的语言。它可以被编译为许多种目标硬件或软件。因此,你可能猜到了,这些目标中的一个就是 BPF … 仅部分支持的:一些 P4 特性并不能被转化到 BPF 中,并且,用类似的方法,BPF 可以做的事情,而使用 P4 却不能表达出现。不过,**P4 与 BPF 使用** 的相关文档,[*用于去隐藏在 bcc 仓库中*][160]。这个改变在 P4_16 版本中,p4c 引用的编辑器包含 *[一个 eBPF 后端][161]*。 +[P4][159] 是一个用于指定交换机行为的语言。它可以为多种目标硬件或软件编译。因此,你可能猜到了,这些目标中的一个就是 BPF … 仅部分支持的:一些 P4 特性并不能被转化到 BPF 中,并且,用类似的方法,BPF 可以做的事情,而使用 P4 却不能表达出现。不过,**P4 与 BPF 使用** 的相关文档,[被隐藏在 bcc 仓库中][160]。这个改变在 P4_16 版本中,p4c 引用的编辑器包含 [一个 eBPF 后端][161]。 ![](https://qmonnet.github.io/whirl-offload/img/icons/flask.svg) ### 教程 -Brendan Gregg 为想去 **使用 bcc 工具** 跟踪和监视内核中的事件的人制作了一个非常好的 **教程**。[*第一个教程是关于如何使用 bcc 工具*][162],它总共有十一步,教你去理解怎么去使用已有的工具,而 [***针对 Python 开发者** 的一个目标*][163] 是专注于开发新工具,它总共有十七节 “课程”。 +Brendan Gregg 为想要 **使用 bcc 工具** 跟踪和监视内核中的事件的人制作了一个非常好的 **教程**。[第一个教程是关于如何使用 bcc 工具][162],它有许多章节,可以教你去理解怎么去使用已有的工具,而 [针对 Python 开发者的一篇][163] 专注于开发新工具,它总共有十七节 “课程”。 -Sasha Goldshtein 也有一些 [_**Linux 跟踪研究材料**_][164] 涉及到使用几个 BPF 去进行跟踪。 +Sasha Goldshtein 也有一些 [Linux 跟踪研究材料][164] 涉及到使用几个 BPF 工具进行跟踪。 -作者为 Jean-Tiare Le Bigot 的文章为 ping 请求和回复,提供了一个详细的(和有指导意义的)[*使用 perf 和 eBPF 去设置一个低级的跟踪器*][165] 的示例。 +Jean-Tiare Le Bigot 的另一篇文章提供了一个详细的(和有指导意义的)[使用 perf 和 eBPF 去设置一个低级的跟踪器][165] 的示例。 -对于网络相关的 eBPF 使用案例也有几个教程。那里有一些有趣的文档,包含一个 _eBPF Offload 入门指南_,由 Netronome 在 *[Open NFP][166]* 平台上操作的。其它的那些,来自 Jesper 的演讲,[_XDP 能为其它人做什么_][167],可能是 XDP 入门的最好的方法之一。 +对于网络相关的 eBPF 使用案例也有几个教程。有一些值得关注的文档,包括一篇 _eBPF 卸载入门指南_,是关于在 [Open NFP][166] 平台上用 Netronome 操作的。其它的那些,来自 Jesper 的演讲,[XDP 能为其它人做什么][167](及其[第二版][205]),可能是 XDP 入门的最好的方法之一。 ![](https://qmonnet.github.io/whirl-offload/img/icons/gears.svg) ### 示例 -有示例是非常好的。看看它们是如何工作的。但是 BPF 程序示例是分散在几个项目中的,因此,我列出了我所知道的所有的示例。示例并不是使用相同的 helper(例如,tc 和 bcc 都有一套它们自己的 helper,使它可以很容易地去用 C 语言写 BPF 程序) +有示例是非常好的。看看它们是如何工作的。但是 BPF 程序示例是分散在几个项目中的,因此,我列出了我所知道的所有的示例。示例并不是总是使用相同的 helper(例如,tc 和 bcc 都有一套它们自己的 helper,使它可以很容易地去用 C 语言写 BPF 程序) -### 来自内核的示例 +#### 来自内核的示例 -主要的程序类型都包含在内核的示例中:过滤器绑定到套接字或者到 tc 接口、事件跟踪/监视、甚至是 XDP。你可以在 *[linux/samples/bpf/][168]* 目录中找到这些示例。 +内核中包含了大多数类型的程序:过滤器绑定到套接字或者 tc 接口、事件跟踪/监视、甚至是 XDP。你可以在 [linux/samples/bpf/][168] 目录中找到这些示例。 -现在,更多的示例已经作为单元测试被添加到 *[linux/tools/testing/selftests/bpf][200]* 目录下,这里面包含对硬件 offload 的测试或者对于 libbpf 的测试。 +现在,更多的示例已经作为单元测试被添加到 [linux/tools/testing/selftests/bpf][200] 目录下,这里面包含对硬件卸载的测试或者对于 libbpf 的测试。 -Jesper 的 Dangaard Brouer 在他的 *[prototype-kernel][201]* 仓库中也维护了一套专门的示例。 这些示例与那些内核中提供的示例非常类似,但是它们可以以在内核基本文件 (Makefiles 和 headers) 之外编译。 +Jesper 的 Dangaard Brouer 在他的 [prototype-kernel][201] 仓库中也维护了一套专门的示例。 这些示例与那些内核中提供的示例非常类似,但是它们可以脱离内核架构(Makefile 和头文件)编译。 -也不要忘记去看一下 git 相关的提交历史,它们有一些指定的特性的介绍,它们也包含一些特性的详细的示例。 +也不要忘记去看一下 git 相关的提交历史,它们介绍了一些特定的特性,也许包含了一些特性的详细示例。 -### 来自包 iproute2 的示例 +#### 来自包 iproute2 的示例 -iproute2 包也提供了几个示例。它们都很明显地偏向网络编程,因此,这个程序是附加到 tc ingress 或者 egress 接口上。这些示例在 *[iproute2/examples/bpf/][169]* 目录中。 +iproute2 包也提供了几个示例。它们都很明显地偏向网络编程,因此,这个程序是附着到 tc 入站或者出站接口上。这些示例在 [iproute2/examples/bpf/][169] 目录中。 -### 来自 bcc 工具集的示例 +#### 来自 bcc 工具集的示例 -许多示例都 *[与 bcc 一起提供][170]*: +许多示例都是 [与 bcc 一起提供的][170]: -* 一些网络编程的示例在关联的目录下面。它们包括套接字过滤器、tc 过滤器、和一个 XDP 程序。 +* 一些网络的示例放在相关的目录下面。它们包括套接字过滤器、tc 过滤器、和一个 XDP 程序。 -* `tracing` 目录包含许多 **跟踪编程** 的示例。前面的教程中提到的都在那里。那些程序涉及了事件跟踪的很大的一个范围,并且,它们中的一些是面向生产系统的。注意,某些 Linux 分发版(至少是 Debian、Ubuntu、Fedora、Arch Linux)、这些程序已经被 *[打包了][115]* 并且可以很 “容易地” 通过比如 `# apt install bcc-tools` 进行安装。但是在写这篇文章的时候(除了 Arch Linux),第一个要求是去安装 IO Visor 的包仓库。 +* `tracing` 目录包含许多 **跟踪编程** 的示例。前面的教程中提到的都在那里。那些程序涉及了很大部分的事件监视功能,并且,它们中的一些是面向生产系统的。注意,某些 Linux 发行版(至少是 Debian、Ubuntu、Fedora、Arch Linux)、这些程序已经被 [打包了][115] 并且可以很 “容易地” 通过比如 `# apt install bcc-tools` 进行安装。但是在写这篇文章的时候(除了 Arch Linux),首先要求安装 IO Visor 的包仓库。 -* 那里也有 **使用 Lua** 作为一个不同的 BPF 后端(那是因为 BPF 程序是用 Lua 写的,它是 C 语言的一个子集,它允许为前端和后端使用相同的语言)的一些示例,它在第三个目录中。 +* 也有一些 **使用 Lua** 作为一个不同的 BPF 后端(那是因为 BPF 程序是用 Lua 写的,它是 C 语言的一个子集,它允许为前端和后端使用相同的语言)的一些示例,它在第三个目录中。 -* 当然,[*bcc 工具*][202] 自身就是 eBPF 程序使用案例的有趣示例。 +* 当然,[bcc 工具][202] 自身就是 eBPF 程序使用案例的值得关注示例。 -### 手册页面 +#### 手册页面 -虽然 bcc 一般可以用很容易的方式在内核中去注入和运行一个 BPF 程序,通过 `tc` 工具去将程序附加到 tc 接口也可以被执行。因此,如果你打算将 **BPF 与 tc 一起使用**,你可以在 *[`tc-bpf(8)` 手册页面][171]* 中找到一些调用示例。 +虽然 bcc 一般很容易在内核中去注入和运行一个 BPF 程序,将程序附着到 tc 接口也能通过 `tc` 工具自己完成。因此,如果你打算将 **BPF 与 tc 一起使用**,你可以在 [`tc-bpf(8)` 手册页面][171] 中找到一些调用示例。 ![](https://qmonnet.github.io/whirl-offload/img/icons/srcfile.svg) ### 代码 -有时候,BPF 文档或者示例并不足够多,而且你可能没有其它的方式在你喜欢的文本编辑器(它当然应该是 Vim)中去显示代码并去阅读它。或者,你可能深入到代码中想去做一个补丁程序或者为机器增加一些新特性。因此,这里对有关的文件的几个建议,找到你想要的功能取决于你自己! +有时候,BPF 文档或者示例并不够,而且你只想在你喜欢的文本编辑器(它当然应该是 Vim)中去显示代码并去阅读它。或者,你可能想深入到代码中去做一个补丁程序或者为机器增加一些新特性。因此,这里对有关的文件的几个建议,找到你想要的函数只取决于你自己! -### 在内核中的 BPF 代码 +#### 在内核中的 BPF 代码 -* 文件 *[linux/include/linux/bpf.h][116]* 和它的副本 *[linux/include/uapi/bpf.h][117]* 包含有关 eBPF 的 **定义**,它分别被内核中和用户空间程序的接口使用。 +* 文件 [linux/include/linux/bpf.h][116] 及其相对的 [linux/include/uapi/bpf.h][117] 包含有关 eBPF 的 **定义**,它们分别用在内核中和用户空间程序的接口。 -* 相同的方式,文件 *[linux/include/linux/filter.h][118]* 和 *[linux/include/uapi/filter.h][119]* 包含的信息被 **运行的 BPF 程序** 使用。 +* 相同的方式,文件 [linux/include/linux/filter.h][118] 和 [linux/include/uapi/filter.h][119] 包含了用于 **运行 BPF 程序** 的信息。 -* BPF 相关的 **主要的代码片断** 在 *[linux/kernel/bpf/][120]* 目录下面。**被系统以不同的操作许可调用** 比如,程序加载或者映射管理是在文件 `syscall.c` 中实现,虽然 `core.c` 包含在 **解析器** 中。其它的文件有明显的命名:`verifier.c` 包含在 **校验器** 中(不是开玩笑的),`arraymap.c` 的代码用于与阵列类型的 **映射** 去互动,等等。 +* BPF 相关的 **主要的代码片断** 在 [linux/kernel/bpf/][120] 目录下面。**系统调用的不同操作许可**,比如,程序加载或者映射管理是在文件 `syscall.c` 中实现,而 `core.c` 包含了 **解析器**。其它文件的命名显而易见:`verifier.c` 包含 **校验器**(不是开玩笑的),`arraymap.c` 的代码用于与数组类型的 **映射** 交互,等等。 -* **helpers**,以及几个网络(与 tc、XDP 一起)和用户可用的相关功能是实现在 [*linux/net/core/filter.c*][121] 中。它也包含代码去移植 cBPF 字节码到 eBPF 中(因为在运行之前,内核中的所有的 cBPF 程序被转换成 eBPF) +* 有几个与网络(及 tc、XDP )相关的函数和 **helpers** 是用户可用,其实现在 [linux/net/core/filter.c][121] 中。它也包含了移植 cBPF 字节码到 eBPF 的代码(因为在运行之前,内核中的所有的 cBPF 程序被转换成 eBPF)。 -* 功能和 **helpers** 相关的 **事件跟踪** 都在 *[linux/kernel/trace/bpf_trace.c][203]* 中。 +* 相关于 **事件跟踪** 的函数和 **helpers** 都在 [linux/kernel/trace/bpf_trace.c][203] 中。 -* **JIT 编译器** 在它们各自的架构目录下面,比如,x86 架构的在 *[linux/arch/x86/net/bpf_jit_comp.c][122]* 中。 +* **JIT 编译器** 在它们各自的架构目录下面,比如,x86 架构的在 [linux/arch/x86/net/bpf_jit_comp.c][122] 中。例外是用于硬件卸载的 JIT 编译器,它们放在它们的驱动程序下,例如 Netronome NFP 网卡的就放在 [linux/drivers/net/ethernet/netronome/nfp/bpf/jit.c][206] 。 -* 在 *[linux/net/sched/][123]* 目录下,你可以找到 **tc 的 BPF 组件** 相关的代码,尤其是在文件 `act_bpf.c` (action)和 `cls_bpf.c`(filter)中。 +* 在 [linux/net/sched/][123] 目录下,你可以找到 **tc 的 BPF 组件** 相关的代码,尤其是在文件 `act_bpf.c` (action)和 `cls_bpf.c`(filter)中。 -* 我并没有在 BPF 上深入到 **事件跟踪** 中,因此,我并不真正了解这些程序的钩子。在 *[linux/kernel/trace/bpf_trace.c][124]* 那里有一些东西。如果你对它感 兴趣,并且想去了解更多,你可以在 Brendan Gregg 的演示或者博客文章上去深入挖掘。 +* 我并没有在 BPF 上深入到 **事件跟踪** 中,因此,我并不真正了解这些程序的钩子。在 [linux/kernel/trace/bpf_trace.c][124] 那里有一些东西。如果你对它感 兴趣,并且想去了解更多,你可以在 Brendan Gregg 的演示或者博客文章上去深入挖掘。 -* 我也没有使用过 **seccomp-BPF**。但它的代码在 *[linux/kernel/seccomp.c][125]*,并且可以在 [*linux/tools/testing/selftests/seccomp/seccomp_bpf.c*][126] 中找到一些它的使用示例。 +* 我也没有使用过 **seccomp-BPF**,不过你能在 [linux/kernel/seccomp.c][125] 找到它的代码,并且可以在 [linux/tools/testing/selftests/seccomp/seccomp_bpf.c][126] 中找到一些它的使用示例。 -### XDP 钩子代码 +#### XDP 钩子代码 -一旦将 BPF 虚拟机加载进内核,由一个 Netlink 命令将 **XDP** 程序从用户空间钩入到内核网络路径中。接收它的是在 *[linux/net/core/dev.c][172]* 文件中的被调用的 `dev_change_xdp_fd()` 函数,并且由它设置一个 XDP 钩子。比如,钩子位于在 NICs 支持的驱动中。例如,为一些 Mellanox 硬件使用的 mlx4 驱动的钩子实现在 *[drivers/net/ethernet/mellanox/mlx4/][173]* 目录下的文件中。文件 en_netdev.c 接收 Netlink 命令并调用 `mlx4_xdp_set()`,它再被在文件 en_rx.c 实现的实例 `mlx4_en_process_rx_cq()` 调用(对于 RX 侧)。 +一旦装载进内核的 BPF 虚拟机,由一个 Netlink 命令将 **XDP** 程序从用户空间钩入到内核网络路径中。接收它的是在 [linux/net/core/dev.c][172] 文件中的 `dev_change_xdp_fd()` 函数,它被调用并设置一个 XDP 钩子。钩子被放在支持的网卡的驱动程序中。例如,用于 Netronome 硬件钩子的 ntp 驱动程序实现放在 [drivers/net/ethernet/netronome/nfp/][207] 中。文件 `nfp_net_common.c` 接受 Netlink 命令,并调用 `nfp_net_xdp_setup()`,它会转而调用 `nfp_net_xdp_setup_drv()` 实例来安装该程序。 -### 在 bcc 中的 BPF 逻辑 +#### 在 bcc 中的 BPF 逻辑 -[*在 bcc 的 GitHub 仓库*][174] 上找到的 **bcc** 工具集的其中一个代码。**Python 代码**,包含在 `BPF` 类中,最初它在文件 *[bcc/src/python/bcc/__init__.py][175]* 中。但是许多感兴趣的东西 — 我的意见是 — 比如,加载 BPF 程序到内核中,碰巧在 *[libbcc 的 **C 库**][176]*中。 +[在 bcc 的 GitHub 仓库][174] 能找到的 **bcc** 工具集的代码。其 **Python 代码**,包含在 `BPF` 类中,最初它在文件 [bcc/src/python/bcc/\_\_init\_\_.py][175] 中。但是许多我觉得有意思的东西,比如,加载 BPF 程序到内核中,出现在 [libbcc 的 C 库][176]中。 -### 使用 tc 去管理 BPF 的代码 +#### 使用 tc 去管理 BPF 的代码 -**在 tc** 中与 iproute2 包中一起带来的与 BPF 相关的代码。其中的一些在 *[iproute2/tc/][177]* 目录中。文件 f_bpf.c 和 m_bpf.c(和 e_bpf.c)是各自用于处理 BPF 的过滤器和动作的(和tc `exec` 命令,或许什么命令都可以)。文件 q_clsact.c 定义了 `clsact`,qdisc 是为 BPF 特别创建的。但是,**大多数的 BPF 用户空间逻辑** 是在 *[iproute2/lib/bpf.c][178]* 库中实现的,因此,如果你想去使用 BPF 和 tc,这里可能是会将你搞混乱的地方(它是从文件 iproute2/tc/tc_bpf.c 中来的,你也可以在旧版本的包中找到代码相同的地方)。 +当然,这些代码与 iproute2 包中的 **tc 中的** BPF 相关。其中的一些在 [iproute2/tc/][177] 目录中。文件 `f_bpf.c` 和 `m_bpf.c`(和 `e_bpf.c`)各自用于处理 BPF 的过滤器和动作的(和 tc `exec` 命令,等等)。文件 `q_clsact.c` 定义了为 BPF 特别创建的 `clsact` qdisc。但是,**大多数的 BPF 用户空间逻辑** 是在 [iproute2/lib/bpf.c][178] 库中实现的,因此,如果你想去使用 BPF 和 tc,这里可能是会将你搞混乱的地方(它是从文件 iproute2/tc/tc_bpf.c 中移动而来的,你也可以在旧版本的包中找到相同的代码)。 -### BPF 实用工具 +#### BPF 实用工具 -内核中也带有 BPF 相关的三个工具的源代码(`bpf_asm.c`, `bpf_dbg.c`, `bpf_jit_disasm.c`)、根据你的版本不同,在 *[linux/tools/net/][179]* 或者 *[linux/tools/bpf/][180]* 目录下面: +内核中也带有 BPF 相关的三个工具的源代码(`bpf_asm.c`、 `bpf_dbg.c`、 `bpf_jit_disasm.c`),根据你的版本不同,在 [linux/tools/net/][179] (直到 Linux 4.14)或者 [linux/tools/bpf/][180] 目录下面: -* `bpf_asm` 是一个极小的汇编程序。 +* `bpf_asm` 是一个极小的 cBPF 汇编程序。 * `bpf_dbg` 是一个很小的 cBPF 程序调试器。 * `bpf_jit_disasm` 对于两种 BPF 都是通用的,并且对于 JIT 调试来说非常有用。 -* `bpftool` 是由 Jakub Kicinski 写的通用工具,并且它可以与 eBPF 程序和来自用户空间的映射进行交互,例如,去展示、转储、pin 程序、或者去展示、创建、pin、更新、删除映射。 +* `bpftool` 是由 Jakub Kicinski 写的通用工具,它可以与 eBPF 程序交互并从用户空间的映射,例如,去展示、转储、pin 程序、或者去展示、创建、pin、更新、删除映射。 阅读在源文件顶部的注释可以得到一个它们使用方法的概述。 -与 eBPF 一起工作的其它必需的文件是来自内核树的两个**用户空间库**,它们可以用于管理 eBPF 程序或者映射来自外部的程序。这个函数可以通过 *[linux/tools/lib/bpf/][204]* 目录中的头文件 `bpf.h` 和 `libbpf.h`(更高级别) 来访问。比如,工具 `bpftool` 主要依赖这些库。 +与 eBPF 一起工作的其它必需的文件是来自内核树的两个**用户空间库**,它们可以用于管理 eBPF 程序或者映射来自外部的程序。这个函数可以通过 [linux/tools/lib/bpf/][204] 目录中的头文件 `bpf.h` 和 `libbpf.h`(更高层面封装)来访问。比如,工具 `bpftool` 主要依赖这些库。 -### 其它感兴趣的 chunks +#### 其它值得关注的部分 -如果你对关于 BPF 的不常见的语言的使用感兴趣,bcc 包含 *[一个为 BPF 目标的 **P4 编译器***][181]以及 [***一个 Lua 前端***][182],它可以被使用,它以代替 C 的一个子集,并且(在 Lua 的案例中)可以用于 Python 工具。 +如果你对关于 BPF 的不常见的语言的使用感兴趣,bcc 包含 [一个 BPF 目标的 **P4 编译器**][181]以及 [**一个 Lua 前端**][182],它可以被用以代替 C 的一个子集,并且(用 Lua )替代 Python 工具。 -### LLVM 后端 +#### LLVM 后端 -在 *[这个提交][183]* 中,clang / LLVM 用于将 C 编译成 BPF 后端,将它添加到 LLVM 源(也可以在 [the GitHub mirror][184] 上访问)。 +这个 BPF 后端用于 clang / LLVM 将 C 编译到 eBPF ,是在 [这个提交][183] 中添加到 LLVM 源代码的(也可以在 [这个 GitHub 镜像][184] 上访问)。 -### 在用户空间中运行 +#### 在用户空间中运行 -到目前为止,我知道那里有至少两种 eBPF 用户空间实现。第一个是 *[uBPF][185]*,它是用 C 写的。它包含一个解析器、一个 x86_64 架构的 JIT 编译器、一个汇编器和一个反汇编器。 +到目前为止,我知道那里有至少两种 eBPF 用户空间实现。第一个是 [uBPF][185],它是用 C 写的。它包含一个解析器、一个 x86_64 架构的 JIT 编译器、一个汇编器和一个反汇编器。 -uBPF 的代码似乎被重用了,去产生了一个 [*通用实现*][186],claims 支持 FreeBSD 内核、FreeBSD 用户空间、Linux 内核、Linux 用户空间和 Mac OSX 用户空间。它被 [*VALE 交换机的 BPF 扩展模块*][187]使用。 +uBPF 的代码似乎被重用来产生了一个 [通用实现][186],其声称支持 FreeBSD 内核、FreeBSD 用户空间、Linux 内核、Linux 用户空间和 Mac OSX 用户空间。它被 [VALE 交换机的 BPF 扩展模块][187]使用。 -其它用户空间的实现是我做的:[*rbpf*][188],基于 uBPF,但是用 Rust 写的。写了解析器和 JIT 编译器 (Linux 下两个都有,Mac OSX 和 Windows 下仅有解析器),以后可能会有更多。 +其它用户空间的实现是我做的:[rbpf][188],基于 uBPF,但是用 Rust 写的。写了解析器和 JIT 编译器 (Linux 下两个都有,Mac OSX 和 Windows 下仅有解析器),以后可能会有更多。 -### 提交日志 +#### 提交日志 -正如前面所说的,如果你希望得到更多的关于它的信息,不要犹豫,去看一些提交日志,它介绍了一些特定的 BPF 特性。你可以在许多地方搜索日志,比如,在 *[git.kernel.org][189]、[在 GitHub 上][190]*、或者如果你克隆过它还有你的本地仓库中。如果你不熟悉 git,你可以尝试像这些去做 `git blame ` 去看看介绍特定代码行的提交内容,然后,`git show ` 去看详细情况(或者在 `git log` 的结果中按关键字搜索,但是这样做通常比较单调乏味)也可以看在 bcc 仓库中的 *[按内核版本区分的 eBPF 特性列表][191]*,它链接到相关的提交上。 +正如前面所说的,如果你希望得到更多的关于一些特定的 BPF 特性的信息,不要犹豫,去看一些提交日志。你可以在许多地方搜索日志,比如,在 [git.kernel.org][189]、[在 GitHub 上][190]、或者如果你克隆过它还有你的本地仓库中。如果你不熟悉 git,你可以尝试像这些去做 `git blame ` 去看看介绍特定代码行的提交内容,然后,`git show ` 去看详细情况(或者在 `git log` 的结果中按关键字搜索,但是这样做通常比较单调乏味)也可以看在 bcc 仓库中的 [按内核版本区分的 eBPF 特性列表][191],它链接到相关的提交上。 ![](https://qmonnet.github.io/whirl-offload/img/icons/wand.svg) ### 排错 -对 eBPF 的狂热是最近的事情,因此,到目前为止我还找不到许多关于怎么去排错的资源。所以这里只有几个,在使用 BPF 进行工作的时候,我对自己遇到的问题进行了记录。 +对 eBPF 的追捧是最近的事情,因此,到目前为止我还找不到许多关于怎么去排错的资源。所以这里只有几个,是我在使用 BPF 进行工作的时候,对自己遇到的问题进行的记录。 -### 编译时的错误 +#### 编译时的错误 -* 确保你有一个最新的 Linux 内核版本(也可以看 *[这个文档][127]*)。 +* 确保你有一个最新的 Linux 内核版本(也可以看 [这个文档][127])。 * 如果你自己编译内核:确保你安装了所有正确的组件,包括内核镜像、头文件和 libc。 -* 当使用 `tc-bpf`(用于去编译 C 代码到 BPF 中)的 man 页面提供的 `bcc` shell 函数时:我只是添加包含 clang 调用的头部: +* 当使用 `tc-bpf`(用于去编译 C 代码到 BPF 中)的 man 页面提供的 `bcc` shell 函数时:我曾经必须添加包含 clang 调用的头文件: ``` __bcc() { @@ -483,65 +466,64 @@ uBPF 的代码似乎被重用了,去产生了一个 [*通用实现*][186],c -emit-llvm -c $1 -o - | \ llc -march=bpf -filetype=obj -o "`basename $1 .c`.o" } - ``` - (seems fixed as of today). + (现在似乎修复了)。 -* 对于使用 `bcc` 的其它问题,不要忘了去看一看这个工具集的 *[答疑][128]*。 +* 对于使用 `bcc` 的其它问题,不要忘了去看一看这个工具集的 [答疑][128]。 -* 如果你从一个并不精确匹配你的内核版本的 iproute2 包中下载了示例,可能会通过在文件中包含的头文件触发一些错误。这些示例片断都假设安装在你的系统中内核的头文件与 iproute2 包是相同版本的。如果不是这种情况,下载正确的 iproute2 版本,或者编辑示例中包含的文件的路径,指向到 iproute2 中包含的头文件上(在运行时一些问题可能或者不可能发生,取决于你使用的特性)。 +* 如果你从一个并不精确匹配你的内核版本的 iproute2 包中下载了示例,可能会由于在文件中包含的头文件触发一些错误。这些示例片断都假设安装在你的系统中内核的头文件与 iproute2 包是相同版本的。如果不是这种情况,下载正确的 iproute2 版本,或者编辑示例中包含的文件的路径,指向到 iproute2 中包含的头文件上(在运行时一些问题可能或者不可能发生,取决于你使用的特性)。 -### 在加载和运行时的错误 +#### 在加载和运行时的错误 -* 使用 tc 去加载一个程序,确保你使用了一个与使用中的内核版本等价的 iproute2 中的 tc 二进制文件。 +* 使用 `tc` 去加载一个程序,确保你使用了一个与使用中的内核版本等价的 iproute2 中的 `tc` 二进制文件。 -* 使用 bcc 去加载一个程序,确保在你的系统上安装了 bcc(仅下载源代码去运行 Python 脚本是不够的)。 +* 使用 `bcc` 去加载一个程序,确保在你的系统上安装了 bcc(仅下载源代码去运行 Python 脚本是不够的)。 -* 使用 tc,如果 BPF 程序不能返回一个预期值,检查调用它的方式:过滤器、或者动作、或者使用 “直接传动” 模式的过滤器。 +* 使用 `tc`,如果 BPF 程序不能返回一个预期值,检查调用它的方式:过滤器,或者动作,或者使用 “直传” 模式的过滤器。 -* 静态使用 tc,注意不使用过滤器,动作不会直接附加到 qdiscs 或者接口。 +* 还是 `tc`,注意不使用过滤器,动作不会直接附着到 qdiscs 或者接口。 -* 通过内核校验器抛出错误到解析器可能很难。[*内核文档*][129]或许可以提供帮助,因此,可以 *[参考指南][130]* 或者,万不得一的情况下,可以去看源代码(祝你好运!)。记住,校验器 _不运行_ 程序,对于这种类型的错误,它也是非常重要的。如果你得到一个关于无效内存访问或者关于未初始化的数据的错误,它并不意味着那些问题真实发生了(或者有时候,它们完全有可能发生)。它意味着你的程序是以校验器预计可能发生错误的方式写的,并且因此而拒绝这个程序。 +* 通过内核校验器抛出错误到解析器可能很难。[内核文档][129]或许可以提供帮助,因此,可以 [参考指南][130] 或者,万不得一的情况下,可以去看源代码(祝你好运!)。记住,校验器 _不运行_ 程序,对于这种类型的错误,记住这点是非常重要的。如果你得到一个关于无效内存访问或者关于未初始化的数据的错误,它并不意味着那些问题真实发生了(或者有时候是,它们完全有可能发生)。它意味着你的程序是以校验器预计可能发生错误的方式写的,并且因此而拒绝这个程序。 * 注意 `tc` 工具有一个 `verbose` 模式,它与 BPF 一起工作的很好:在你的命令行尾部尝试追加一个 `verbose`。 -* bcc 也有一个 verbose 选项:`BPF` 类有一个 `debug` 参数,它可以带 `DEBUG_LLVM_IR`、`DEBUG_BPF` 和 `DEBUG_PREPROCESSOR` 三个标志中任何组合(详细情况在 *[源文件][131]*中)。 为调试代码,它甚至嵌入了 [*一些条件去打印输出代码*][132]。 +* `bcc` 也有一个 `verbose` 选项:`BPF` 类有一个 `debug` 参数,它可以带 `DEBUG_LLVM_IR`、`DEBUG_BPF` 和 `DEBUG_PREPROCESSOR` 三个标志中任何组合(详细情况在 [源文件][131]中)。 为调试该代码,它甚至嵌入了 [一些条件去打印输出代码][132]。 -* LLVM v4.0+ 为 eBPF 程序 *[嵌入一个反汇编器][133]*。因此,如果你用 clang 编译你的程序,在编译时添加 `-g` 标志允许你通过内核校验器去以人类可读的格式去转储你的程序。处理转储文件,使用: +* LLVM v4.0+ 为 eBPF 程序 [嵌入一个反汇编器][133]。因此,如果你用 clang 编译你的程序,在编译时添加 `-g` 标志允许你通过内核校验器去以人类可读的格式去转储你的程序。处理转储文件,使用: ``` $ llvm-objdump -S -no-show-raw-insn bpf_program.o - ``` -* 使用映射工作?你想去看 [*bpf-map*][134],一个为 Cilium 项目而用 Go 创建的非常有用的工具,它可以用于去转储内核中 eBPF 映射的内容。那里也有在 Rust 中的 [*一个克隆*][135]。 +* 使用映射?你应该去看看 [bpf-map][134],这是一个为 Cilium 项目而用 Go 创建的非常有用的工具,它可以用于去转储内核中 eBPF 映射的内容。也有一个用 Rust 开发的 [克隆][135]。 -* 那里有一个旧的 *[在 **StackOverflow** 上的 `bpf` 标签][136]*,但是,在这篇文章中它一直没有被使用过(并且那里几乎没有与新的 eBPF 相关的东西)。如果你是一位来自未来的阅读者,你可能想去看看在这方面是否有更多的活动。 +* [在 **StackOverflow** 上有个旧的 bpf 标签][136],但是,在这篇文章中从没用过它(并且那里几乎没有与新版本的 eBPF 相关的东西)。如果你是一位来自未来的阅读者,你可能想去看看在这方面是否有更多的活动(LCTT 译注:意即只有旧东西)。 ![](https://qmonnet.github.io/whirl-offload/img/icons/zoomin.svg) ### 更多! -* 如果你想很容易地去 **测试 XDP**,那是 *[一个 Vagrant 设置][137]* 可以使用。你也可以 **测试 bcc** *[在一个 Docker 容器中][138]*。 +* 如果你想轻松地 **测试 XDP**,有 [一个配置好的 Vagrant ][137] 可以使用。你也可以 [在 Docker 容器中][138] **测试 bcc**。 -* 想知道围绕 BPF 的 **开发和活动** 在哪里吗?好吧,内核补丁总是结束于 *[netdev 上的邮件列表][139]*(相关 Linux 内核的网络栈开发):以关键字 “BPF” 或者 “XDP” 来搜索。自 2017 年 4 月开始,那里也有 *[一个专门用于 XDP 编程的邮件列表][140]*(是为了架构或者寻求帮助)。[*在 IO Visor 的邮件列表上*][141]也有许多的讨论和辨论,因为 BPF 是一个重要的项目。如果你只是想随时了解情况,那里也有一个 [*@IOVisor Twitter 帐户*][142]。 +* 想知道 BPF 的 **开发和活动** 在哪里吗?好吧,内核补丁总是出自于 [netdev 上的邮件列表][139](相关 Linux 内核的网络栈开发):以关键字 “BPF” 或者 “XDP” 来搜索。自 2017 年 4 月开始,那里也有 [一个专门用于 XDP 编程的邮件列表][140](是为了架构或者寻求帮助)。[在 IO Visor 的邮件列表上][141]也有许多的讨论和辨论,因为 BPF 是一个重要的项目。如果你只是想随时了解情况,那里也有一个 [@IOVisor Twitter 帐户][142]。 -我经常会回到这篇博客中,来看一看 *[关于 BPF][192]* 有没有新的文章! +请经常会回到[这篇博客][0]中,来看一看 [关于 BPF][192] 有没有新的文章! -_特别感谢 Daniel Borkmann 指引我找到了许多的 [附加的文档][154],因此我才完成了这个合集。_ +_特别感谢 Daniel Borkmann 指引我找到了 [更多的文档][154],因此我才完成了这个合集。_ -------------------------------------------------------------------------------- via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ -作者:[Quentin Monnet ][a] +作者:[Quentin Monnet][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]:https://qmonnet.github.io/whirl-offload/about/ +[0]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ [1]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-bpf [2]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-xdp [3]:https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/#about-other-components-related-or-based-on-ebpf @@ -746,3 +728,6 @@ via: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ [202]:https://github.com/iovisor/bcc/tree/master/tools [203]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/bpf_trace.c [204]:https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/tools/lib/bpf +[205]:https://www.netdevconf.org/2.2/session.html?gospodarek-xdp-workshop +[206]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/netronome/nfp/bpf/jit.c +[207]:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/netronome/nfp/ \ No newline at end of file From b51dfb302f9330eee9d7e45698fedaa9c3445244 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 3 Apr 2018 12:27:35 +0800 Subject: [PATCH 0264/1057] PUB:20180308 Dive into BPF a list of reading material.md @qhwdw https://linux.cn/article-9507-1.html --- .../20180308 Dive into BPF a list of reading material.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180308 Dive into BPF a list of reading material.md (100%) diff --git a/translated/tech/20180308 Dive into BPF a list of reading material.md b/published/20180308 Dive into BPF a list of reading material.md similarity index 100% rename from translated/tech/20180308 Dive into BPF a list of reading material.md rename to published/20180308 Dive into BPF a list of reading material.md From 829f76bde1c306a4d0866455ed529e88892eac2e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 3 Apr 2018 12:29:46 +0800 Subject: [PATCH 0265/1057] Rename translated/20171016 5 SSH alias examples in Linux.md to translated/tech/20171016 5 SSH alias examples in Linux.md --- translated/{ => tech}/20171016 5 SSH alias examples in Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/{ => tech}/20171016 5 SSH alias examples in Linux.md (100%) diff --git a/translated/20171016 5 SSH alias examples in Linux.md b/translated/tech/20171016 5 SSH alias examples in Linux.md similarity index 100% rename from translated/20171016 5 SSH alias examples in Linux.md rename to translated/tech/20171016 5 SSH alias examples in Linux.md From 918f9b9969905146bc514d3913b2f92dbe4c075a Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 3 Apr 2018 12:52:28 +0800 Subject: [PATCH 0266/1057] PRF:20180221 cTop - A CLI Tool For Container Monitoring.md @kimii --- ...p - A CLI Tool For Container Monitoring.md | 68 +++++++++++-------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md b/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md index 3abee66227..a32ecf7701 100644 --- a/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md +++ b/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md @@ -1,95 +1,107 @@ -cTop - 用于容器监控的 CLI 工具 +cTop:用于容器监控的命令行工具 ====== + 最近 Linux 容器很火,我们中的大多数人甚至已经在使用它,同时一些人也开始学习它。 我们已经介绍了有名的 GUI(用户图形界面) 工具如 Portainer 和 Rancher 。这将会有助于我们通过 GUI 管理容器。 -这篇指南将会通过 cTop 命令帮助我们理解和监控 Linux 容器。它是一个类似 top 命令的命令行工具。 +这篇指南将会通过 cTop 命令帮助我们理解和监控 Linux 容器。它是一个类似 `top` 命令的命令行工具。 ### 什么是 cTop -[ctop][1] 为多个容器提供了一个简洁凝练的实时指标概览。它是一个类 Top 的针对容器指标的界面。 +[ctop][1] 为多个容器提供了一个简洁凝练的实时指标概览。它是一个类 `top` 的针对容器指标的界面。 -它展示了容器指标比如 CPU 利用率,内存利用率,磁盘 I/O 读写,进程 ID(PID)和网络发送(TX - 从此服务器发送)以及接受(RX - 此服务器接受)。 +它展示了容器指标比如 CPU 利用率、内存利用率、磁盘 I/O 读写、进程 ID(PID)和网络发送(TX - 从此服务器发送)以及接受(RX - 此服务器接受)。 + +`ctop` 带有对 Docker 和 runc 的内建支持;对其他容器和集群系统的连接计划在未来版本中推出。 -ctop 伴随着对 Docker 和 runc 的内建支持;对其他容器和集群系统的连接计划在未来版本中推出。 它不需要任何参数并且默认使用 Docker 主机变量。 **建议阅读:** -**(#)** [Portainer – 一个简单的 Docker 管理 GUI][2] -**(#)** [Rancher – 一个完整的生产环境容器管理平台][3] + +- [Portainer – 一个简单的 Docker 图形管理界面][2] +- [Rancher – 一个完整的生产环境容器管理平台][3] ### 如何安装 cTop -开发者提供了一个简单的 shell 脚本来帮助我们直接使用 ctop。我们要做的,只是在“/bin”目录下下载 ctop shell 文件来保证全局访问。最后给予 ctop 脚本文件执行权限。 +开发者提供了一个简单的 shell 脚本来帮助我们直接使用 `ctop`。我们要做的,只是在 `/bin` 目录下下载 `ctop` shell 文件来保证全局访问。最后给予 `ctop` 脚本文件执行权限。 + +在 `/usr/local/bin` 目录下下载 ctop shell 脚本。 -在“/usr/local/bin”目录下下载 ctop shell 脚本。 ``` $ sudo wget https://github.com/bcicen/ctop/releases/download/v0.7/ctop-0.7-linux-amd64 -O /usr/local/bin/ctop - ``` -对 ctop shell 脚本设置执行权限。 +对 `ctop` shell 脚本设置执行权限。 + ``` $ sudo chmod +x /usr/local/bin/ctop - ``` -另外你可以通过 docker 来安装和运行 ctop。在此之前先确保你已经安装过 docker。为了安装 docker,参考以下链接。 +另外你可以通过 docker 来安装和运行 `ctop`。在此之前先确保你已经安装过 docker。为了安装 docker,参考以下链接。 **建议阅读:** -**(#)** [如何在 Linux 上安装 Docker][4] -**(#)** [如何在 Linux 上玩转 Docker 镜像][5] -**(#)** [如何在 Linux 上玩转 Docker 容器][6] -**(#)** [如何在 Docker 容器中安装,运行应用][7] + +- [如何在 Linux 上安装 Docker][4] +- [如何在 Linux 上玩转 Docker 镜像][5] +- [如何在 Linux 上玩转 Docker 容器][6] +- [如何在 Docker 容器中安装,运行应用][7] + ``` $ docker run --rm -ti \ --name=ctop \ -v /var/run/docker.sock:/var/run/docker.sock \ quay.io/vektorlab/ctop:latest - ``` ### 如何使用 cTop -直接启动 ctop 程序而不用任何参数。默认它与“a”键绑定来展示所有容器(运行的和没运行的)。 -ctop 头部显示你的系统时间和容器的总数。 +直接启动 `ctop` 程序而不用任何参数。默认它绑定的 `a` 键用来展示所有容器(运行的和没运行的)。 + +`ctop` 头部显示你的系统时间和容器的总数。 + ``` $ ctop - ``` 你可能得到以下类似输出。 + ![][9] ### 如何管理容器 -你可以使用 ctop 来管理容器。选择一个你想要管理的容器然后按下“Enter”键,选择所需选项如 start,stop,remove 等。 +你可以使用 `ctop` 来管理容器。选择一个你想要管理的容器然后按下回车键,选择所需选项如 `start`、`stop`、`remove` 等。 + ![][10] ### 如何给容器排序 -默认 ctop 使用 state 字段来给容器排序。按下“s”键来用不同的方面给容器排序。 +默认 `ctop` 使用 `state` 字段来给容器排序。按下 `s` 键来按不同的方面给容器排序。 + ![][11] ### 如何查看容器指标 -如何你想要查看关于容器的更多细节和指标,只用选择你想要查看的相应容器然后按“o”键。 +如何你想要查看关于容器的更多细节和指标,只用选择你想要查看的相应容器然后按 `o` 键。 + ![][12] ### 如何查看容器日志 -选择你想要查看日志的相应容器然后按“l”键。 +选择你想要查看日志的相应容器然后按 `l` 键。 + ![][13] ### 仅显示活动容器 -使用“-a”选项运行 ctop 命令来仅显示活动容器 +使用 `-a` 选项运行 `ctop` 命令来仅显示活动容器 + ![][14] ### 打开帮助对话框 -运行 ctop,只需按“h”键来打开帮助部分。 +运行 `ctop`,只需按 `h` 键来打开帮助部分。 + ![][15] -------------------------------------------------------------------------------- @@ -98,7 +110,7 @@ via: https://www.2daygeek.com/ctop-a-command-line-tool-for-container-monitoring- 作者:[2DAYGEEK][a] 译者:[kimii](https://github.com/kimii) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From aca759ee2d7880f25d6a2153c7d26a2859d33354 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 3 Apr 2018 12:53:29 +0800 Subject: [PATCH 0267/1057] PUB:20180221 cTop - A CLI Tool For Container Monitoring.md @kimii https://linux.cn/article-9508-1.html --- .../20180221 cTop - A CLI Tool For Container Monitoring.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180221 cTop - A CLI Tool For Container Monitoring.md (100%) diff --git a/translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md b/published/20180221 cTop - A CLI Tool For Container Monitoring.md similarity index 100% rename from translated/tech/20180221 cTop - A CLI Tool For Container Monitoring.md rename to published/20180221 cTop - A CLI Tool For Container Monitoring.md From 2b1f85ce6351af016f475910bd96eeae7a55753d Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 3 Apr 2018 13:05:39 +0800 Subject: [PATCH 0268/1057] PRF:20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md @geekpi --- ...nfiguring MSMTP On Ubuntu 16.04 (Again).md | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/translated/tech/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md b/translated/tech/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md index fdd9c678c2..5fcbb6b05b 100644 --- a/translated/tech/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md +++ b/translated/tech/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md @@ -1,14 +1,20 @@ -(再次)在 Ubuntu 16.04 上配置 MSMTP +在 Ubuntu 16.04 上配置 msmtp ====== -这篇文章是在我之前的博客中发表过的在 Ubuntu 16.04 上配置 MSMTP 的一个副本。我再次发表是为了后续,我并不知道它是否能在更高版本上工作。由于我没有再托管自己的 Ubuntu/MSMTP 服务器了,所以我现在看不到有更新的,但是如果我需要重新设置,我会创建一个更新的帖子!无论如何,这是我现有的。 + +这篇文章是在我之前的博客中发表过的在 Ubuntu 16.04 上配置 MSMTP 的一个副本。我再次发表是为了后续,我并不知道它是否能在更高版本上工作。由于我没有再托管自己的 Ubuntu/MSMTP 服务器了,所以我现在看不到有需要更新的地方,但是如果我需要重新设置,我会创建一个更新的帖子!无论如何,这是我现有的。 我之前写了一篇在 Ubuntu 12.04 上配置 msmtp 的文章,但是正如我在之前的文章中暗示的那样,当我升级到 Ubuntu 16.04 后出现了一些问题。接下来的内容基本上是一样的,但 16.04 有一些小的更新。和以前一样,这里假定你使用 Apache 作为 Web 服务器,但是我相信如果你选择其他的 Web 服务器,也应该相差不多。 -我使用 [msmtp][1] 发送来自这个博客的邮件俩通知我评论和更新等。这里我会记录如何配置它通过 Google Apps 帐户发送电子邮件,虽然这应该与标准帐户一样。 +我使用 [msmtp][1] 发送来自这个博客的邮件俩通知我评论和更新等。这里我会记录如何配置它通过 Google Apps 帐户发送电子邮件,虽然这应该与标准的 Google 帐户一样。 首先,我们需要安装 3 个软件包: -`sudo apt-get install msmtp msmtp-mta ca-certificates` -安装完成后,就需要一个默认配置。默认情况下,msmtp 会在 `/etc/msmtprc` 中查找,所以我使用 vim 创建了这个文件,尽管任何文本编辑器都可以做到这一点。这个文件看起来像这样: + +``` +sudo apt-get install msmtp msmtp-mta ca-certificates +``` + +安装完成后,就需要一个默认配置。默认情况下,msmtp 会在 `/etc/msmtprc` 中查找,所以我使用 `vim` 创建了这个文件,尽管任何文本编辑器都可以做到这一点。这个文件看起来像这样: + ``` # Set defaults. defaults @@ -17,50 +23,57 @@ tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt # Setup WP account's settings. -account +account GMAIL host smtp.gmail.com port 587 auth login -user -password -from +user YOUR USERNAME +password YOUR PASSWORD +from FROM@ADDRESS logfile /var/log/msmtp/msmtp.log account default : - ``` -任何大写项(即``)都是需要替换为你特定的配置。日志文件是一个例外,当然你也可以将活动/警告/错误放在任何你想要的地方。 +任何大写选项都是需要替换为你特定的配置。日志文件是一个例外,当然你也可以将活动/警告/错误放在任何你想要的地方。 文件保存后,我们将更新上述配置文件的权限 ,如果该文件的权限过于开放,msmtp 将不会运行,并且创建日志文件的目录。 + ``` sudo mkdir /var/log/msmtp sudo chown -R www-data:adm /var/log/msmtp sudo chmod 0600 /etc/msmtprc - ``` 接下来,我选择为 msmtp 日志配置 logrotate,以确保日志文件不会太大并让日志目录更加整洁。为此,我们创建 `/etc/logrotate.d/msmtp` 并使用按以下内容配置。请注意,这是可选的,你可以选择不这样做,或者你可以选择以不同方式配置日志。 ``` /var/log/msmtp/*.log { -rotate 12 -monthly -compress -missingok -notifempty + rotate 12 + monthly + compress + missingok + notifempty } ``` 现在配置了日志,我们需要通过编辑 `/etc/php/7.0/apache2/php.ini` 告诉 PHP 使用 msmtp,并将 sendmail 路径从 -`sendmail_path =` + +``` +sendmail_path = +``` + 变成 -`sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -a -t"` + +``` +sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -a -t" +``` + 这里我遇到了一个问题,即使我指定了帐户名称,但是当我测试它时,它并没有正确发送电子邮件。这就是为什么 `account default : ` 这行被放在 msmtp 配置文件的末尾。要测试配置,请确保 PHP 文件已保存并运行 `sudo service apache2 restart`,然后运行 `php -a` 并执行以下命令 + ``` mail ('personal@email.com', 'Test Subject', 'Test body text'); exit(); - ``` 此时发生的任何错误都将显示在输出中,因此错误诊断会相对容易。如果一切顺利,你现在应该可以使用 PHP sendmail(至少 WordPress 可以)中用 Gmail(或 Google Apps)从 Ubuntu 服务器发送电子邮件。 @@ -74,7 +87,7 @@ via: https://codingproductivity.wordpress.com/2018/01/18/configuring-msmtp-on-ub 作者:[JOE][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 0d745a6f6f3602280a40f8490d707d3afc530c55 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 3 Apr 2018 13:05:56 +0800 Subject: [PATCH 0269/1057] PUB:20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md @geekpi --- .../20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md (100%) diff --git a/translated/tech/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md b/published/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md similarity index 100% rename from translated/tech/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md rename to published/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md From 80d41c058dc536cbf1360af59b138d33050c78d2 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 3 Apr 2018 14:28:28 +0800 Subject: [PATCH 0270/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Python=20ChatOp?= =?UTF-8?q?s=20libraries:=20Opsdroid=20and=20Errbot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... ChatOps libraries- Opsdroid and Errbot.md | 241 ++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 sources/tech/29180329 Python ChatOps libraries- Opsdroid and Errbot.md diff --git a/sources/tech/29180329 Python ChatOps libraries- Opsdroid and Errbot.md b/sources/tech/29180329 Python ChatOps libraries- Opsdroid and Errbot.md new file mode 100644 index 0000000000..5f409956f7 --- /dev/null +++ b/sources/tech/29180329 Python ChatOps libraries- Opsdroid and Errbot.md @@ -0,0 +1,241 @@ +Python ChatOps libraries: Opsdroid and Errbot +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd) +This article was co-written with [Lacey Williams Henschel][1]. + +ChatOps is conversation-driven development. The idea is you can write code that is executed in response to something typed in a chat window. As a developer, you could use ChatOps to merge pull requests from Slack, automatically assign a support ticket to someone from a received Facebook message, or check the status of a deployment through IRC. + +In the Python world, the most widely used ChatOps libraries are Opsdroid and Errbot. In this month's Python column, let's chat about what it's like to use them, what each does well, and how to get started with them. + +### Opsdroid + +[Opsdroid][2] is a relatively young (since 2016) open source chatbot library written in Python. It has good documentation, a great tutorial, and includes plugins to help you connect to popular chat services. + +#### What's built in + +The library itself doesn't ship with everything you need to get started, but this is by design. The lightweight framework encourages you to enable its existing connectors (what Opsdroid calls the plugins that help you connect to chat services) or write your own, but it doesn't weigh itself down by shipping with connectors you may not need. You can easily enable existing Opsdroid connectors for: + + ++ The command line ++ Cisco Spark ++ Facebook ++ GitHub ++ Matrix ++ Slack ++ Telegram ++ Twitter ++ Websockets + + +Opsdroid calls the functions the chatbot performs "skills." Skills are `async` Python functions and use Opsdroid's matching decorators, called "matchers." You can configure your Opsdroid project to use skills from the same codebase your configuration file is in or import skills from outside public or private repositories. + +You can enable some existing Opsdroid skills as well, including [seen][3], which tells you when a specific user was last seen by the bot, and [weather][4], which will report the weather to the user. + +Finally, Opdroid allows you to configure databases using its existing database modules. Current databases with Opsdroid support include: + + ++ Mongo ++ Redis ++ SQLite + + +You configure databases, skills, and connectors in the `configuration.yaml` file in your Opsdroid project. + +#### Opsdroid pros + +**Docker support:** Opsdroid is meant to work well in Docker from the get-go. Docker instructions are part of its [installation documentation][5]. Using Opsdroid with Docker Compose is also simple: Set up Opsdroid as a service and when you run `docker-compose up`, your Opsdroid service will start and your chatbot will be ready to chat. +``` +version: "3" + + + +services: + +  opsdroid: + +    container_name: opsdroid + +    build: + +      context: . + +      dockerfile: Dockerfile + +``` + +**Lots of connectors:** Opsdroid supports nine connectors to services like Slack and GitHub out of the box; all you need to do is enable those connectors in your configuration file and pass necessary tokens or API keys. For example, to enable Opsdroid to post in a Slack channel named `#updates`, add this to the `connectors` section of your configuration file: +``` + - name: slack + +    api-token: "this-is-my-token" + +    default-room: "#updates" + +``` + +You will have to [add a bot user][6] to your Slack workspace before configuring Opsdroid to connect to Slack. + +If you need to connect to a service that Opsdroid does not support, there are instructions for adding your own connectors in the [docs][7]. + +**Pretty good docs.** Especially for a young-ish library in active development, Opsdroid's docs are very helpful. The docs include a [tutorial][8] that leads you through creating a couple of different basic skills. The Opsdroid documentation on [skills][9], [connectors][7], [databases][10], and [matchers][11] is also clear. + +The repositories for its supported skills and connectors provide helpful example code for when you start writing your own custom skills and connectors. + +**Natural language processing:** Opsdroid supports regular expressions for its skills, but also several NLP APIs, including [Dialogflow][12], [luis.ai][13], [Recast.AI][14], and [wit.ai][15]. + +#### Possible Opsdroid concern + +Opsdroid doesn't yet enable the full features of some of its connectors. For example, the Slack API allows you to add color bars, images, and other "attachments" to your message. The Opsdroid Slack connector doesn't enable the "attachments" feature, so you would need to write a custom Slack connector if those features were important to you. If a connector is missing a feature you need, though, Opsdroid would welcome your [contribution][16]. The docs could use some more examples, especially of expected use cases. + +#### Example usage + +`hello/__init__.py` +``` +from opsdroid.matchers import match_regex + +import random + + + + + +@match_regex(r'hi|hello|hey|hallo') + +async def hello(opsdroid, config, message): + +    text = random.choice(["Hi {}", "Hello {}", "Hey {}"]).format(message.user) + +    await message.respond(text) + +``` + +`configuration.yaml` +``` +connectors: + +  - name: websocket + + + +skills: + + + +  - name: hello + +    repo: "https://github.com//hello-skill" + +``` + +### Errbot + +[Errbot][17] is a batteries-included open source chatbot. Errbot was released in 2012 and has everything anyone would expect from a mature project, including good documentation, a great tutorial, and plenty of plugins to help you connect to existing popular chat services. + +#### What's built in + +Unlike Opsdroid, which takes a more lightweight approach, Errbot ships with everything you need to build a customized bot safely. + +Errbot includes support for XMPP, IRC, Slack, Hipchat, and Telegram services natively. It lists support for 10 other services through community-supplied backends. + +#### Errbot pros + +**Good docs:** Errbot's docs are mature and easy to use. + +**Dynamic plugin architecture:** Errbot allow you to securely install, uninstall, update, enable, and disable plugins by chatting with the bot. This makes development and adding features easy. For the security conscious, this can all be locked down thanks to Errbot's granular permission system. + +Errbot uses your plugin docstrings to generate documentation for available commands when someone types `!help`, which makes it easier to know what each command does. + +**Built-in administration and security:** Errbot allows you to restrict lists of users who have administrative rights and even has fine-grained access controls. For example, you can restrict which commands may be called by specific users and/or specific rooms. + +**Extensive plugin framework:** Errbot supports hooks, callbacks, subcommands, webhooks, polling, and many [more features][18]. If those aren't enough, you can even write [Dynamic plugins][19]. This feature is useful if you want to enable chat commands based on what commands are available on a remote server. + +**Ships with a testing framework:** Errbot supports [pytest][20] and ships with some useful utilities that make testing your plugins easy and possible. Its "[testing your plugins][21]" docs are well thought out and provide enough to get started. + +#### Possible Errbot concerns + +**Initial !:** By default, Errbot commands are issued starting with an exclamation mark (`!help` and `!hello`). Some people may like this, but others may find it annoying. Thankfully, this is easy to turn off. + +**Plugin metadata:** At first, Errbot's [Hello World][22] plugin example seems easy to use. However, I couldn't get my plugin to load until I read further into the tutorial and discovered that I also needed a `.plug` file, a file Errbot uses to load plugins. This is a pretty minor nitpick, but it wasn't obvious to me until I dug further into the docs. + +#### Example usage + +`hello.py` +``` +import random + +from errbot import BotPlugin, botcmd + + + +class Hello(BotPlugin): + + + +    @botcmd + +    def hello(self, msg, args): + +        text = random.choice(["Hi {}", "Hello {}", "Hey {}"]).format(message.user) + +        return text + +``` + +`hello.plug` +``` +[Core] + +Name = Hello + +Module = hello + + + +[Python] + +Version = 2+ + + + +[Documentation] + +Description = Example "Hello" plugin + +``` + +Have you used Errbot or Opsdroid? If so, please leave a comment with your impressions on these tools. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/python-chatops-libraries-opsdroid-and-errbot + +作者:[Jeff Triplett][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/laceynwilliams +[1]:https://opensource.com/users/laceynwilliams +[2]:https://opsdroid.github.io/ +[3]:https://github.com/opsdroid/skill-seen +[4]:https://github.com/opsdroid/skill-weather +[5]:https://opsdroid.readthedocs.io/en/stable/#docker +[6]:https://api.slack.com/bot-users +[7]:https://opsdroid.readthedocs.io/en/stable/extending/connectors/ +[8]:https://opsdroid.readthedocs.io/en/stable/tutorials/introduction/ +[9]:https://opsdroid.readthedocs.io/en/stable/extending/skills/ +[10]:https://opsdroid.readthedocs.io/en/stable/extending/databases/ +[11]:https://opsdroid.readthedocs.io/en/stable/matchers/overview/ +[12]:https://opsdroid.readthedocs.io/en/stable/matchers/dialogflow/ +[13]:https://opsdroid.readthedocs.io/en/stable/matchers/luis.ai/ +[14]:https://opsdroid.readthedocs.io/en/stable/matchers/recast.ai/ +[15]:https://opsdroid.readthedocs.io/en/stable/matchers/wit.ai/ +[16]:https://opsdroid.readthedocs.io/en/stable/contributing/ +[17]:http://errbot.io/en/latest/ +[18]:http://errbot.io/en/latest/features.html#extensive-plugin-framework +[19]:http://errbot.io/en/latest/user_guide/plugin_development/dynaplugs.html +[20]:http://pytest.org/ +[21]:http://errbot.io/en/latest/user_guide/plugin_development/testing.html +[22]:http://errbot.io/en/latest/index.html#simple-to-build-upon From b658abc043ea87d419306aa98e1b5cba7bf8ec7e Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 3 Apr 2018 14:29:00 +0800 Subject: [PATCH 0271/1057] Delete 20171207 How to use KVM cloud images on Ubuntu Linux.md --- ...to use KVM cloud images on Ubuntu Linux.md | 236 ------------------ 1 file changed, 236 deletions(-) delete mode 100644 sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md diff --git a/sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md b/sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md deleted file mode 100644 index 114b277835..0000000000 --- a/sources/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md +++ /dev/null @@ -1,236 +0,0 @@ -Translating by MjSeven - - -How to use KVM cloud images on Ubuntu Linux -====== - -Kernel-based Virtual Machine (KVM) is a virtualization module for the Linux kernel that turns it into a hypervisor. You can create an Ubuntu cloud image with KVM from the command line using Ubuntu virtualisation front-end for libvirt and KVM. - -How do I download and use a cloud image with kvm running on an Ubuntu Linux server? How do I create create a virtual machine without the need of a complete installation on an Ubuntu Linux 16.04 LTS server?Kernel-based Virtual Machine (KVM) is a virtualization module for the Linux kernel that turns it into a hypervisor. You can create an Ubuntu cloud image with KVM from the command line using Ubuntu virtualisation front-end for libvirt and KVM. - -This quick tutorial shows to install and use uvtool that provides a unified and integrated VM front-end to Ubuntu cloud image downloads, libvirt, and cloud-init. - -### Step 1 - Install KVM - -You must have kvm installed and configured. Use the [apt command][1]/[apt-get command][2] as follows: -``` -$ sudo apt install qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker -$ kvm-ok -## [configure bridged networking as described here][3] -$ sudo vi /etc/network/interfaces -$ sudo systemctl restart networking -$ sudo brctl show -``` -See "[How to install KVM on Ubuntu 16.04 LTS Headless Server][4]" for more info. - -### Step 2 - Install uvtool - -Type the following [apt command][1]/[apt-get command][2]: -``` -$ sudo apt install uvtool -``` -Sample outputs: -``` -[sudo] password for vivek: -Reading package lists... Done -Building dependency tree -Reading state information... Done -The following packages were automatically installed and are no longer required: - gksu libgksu2-0 libqt5designer5 libqt5help5 libqt5printsupport5 libqt5sql5 libqt5sql5-sqlite libqt5xml5 python3-dbus.mainloop.pyqt5 python3-notify2 python3-pyqt5 python3-sip -Use 'sudo apt autoremove' to remove them. -The following additional packages will be installed: - cloud-image-utils distro-info python-boto python-pyinotify python-simplestreams socat ubuntu-cloudimage-keyring uvtool-libvirt -Suggested packages: - cloud-utils-euca shunit2 python-pyinotify-doc -The following NEW packages will be installed: - cloud-image-utils distro-info python-boto python-pyinotify python-simplestreams socat ubuntu-cloudimage-keyring uvtool uvtool-libvirt -0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. -Need to get 1,211 kB of archives. -After this operation, 6,876 kB of additional disk space will be used. -Get:1 http://in.archive.ubuntu.com/ubuntu artful/main amd64 distro-info amd64 0.17 [20.3 kB] -Get:2 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 python-boto all 2.44.0-1ubuntu2 [740 kB] -Get:3 http://in.archive.ubuntu.com/ubuntu artful/main amd64 python-pyinotify all 0.9.6-1 [24.6 kB] -Get:4 http://in.archive.ubuntu.com/ubuntu artful/main amd64 ubuntu-cloudimage-keyring all 2013.11.11 [4,504 B] -Get:5 http://in.archive.ubuntu.com/ubuntu artful/main amd64 cloud-image-utils all 0.30-0ubuntu2 [17.2 kB] -Get:6 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 python-simplestreams all 0.1.0~bzr450-0ubuntu1 [29.7 kB] -Get:7 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 socat amd64 1.7.3.2-1 [342 kB] -Get:8 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 uvtool all 0~git122-0ubuntu1 [6,498 B] -Get:9 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 uvtool-libvirt all 0~git122-0ubuntu1 [26.9 kB] -Fetched 1,211 kB in 3s (393 kB/s) -Selecting previously unselected package distro-info. -(Reading database ... 199933 files and directories currently installed.) -Preparing to unpack .../0-distro-info_0.17_amd64.deb ... -Unpacking distro-info (0.17) ... -Selecting previously unselected package python-boto. -Preparing to unpack .../1-python-boto_2.44.0-1ubuntu2_all.deb ... -Unpacking python-boto (2.44.0-1ubuntu2) ... -Selecting previously unselected package python-pyinotify. -Preparing to unpack .../2-python-pyinotify_0.9.6-1_all.deb ... -Unpacking python-pyinotify (0.9.6-1) ... -Selecting previously unselected package ubuntu-cloudimage-keyring. -Preparing to unpack .../3-ubuntu-cloudimage-keyring_2013.11.11_all.deb ... -Unpacking ubuntu-cloudimage-keyring (2013.11.11) ... -Selecting previously unselected package cloud-image-utils. -Preparing to unpack .../4-cloud-image-utils_0.30-0ubuntu2_all.deb ... -Unpacking cloud-image-utils (0.30-0ubuntu2) ... -Selecting previously unselected package python-simplestreams. -Preparing to unpack .../5-python-simplestreams_0.1.0~bzr450-0ubuntu1_all.deb ... -Unpacking python-simplestreams (0.1.0~bzr450-0ubuntu1) ... -Selecting previously unselected package socat. -Preparing to unpack .../6-socat_1.7.3.2-1_amd64.deb ... -Unpacking socat (1.7.3.2-1) ... -Selecting previously unselected package uvtool. -Preparing to unpack .../7-uvtool_0~git122-0ubuntu1_all.deb ... -Unpacking uvtool (0~git122-0ubuntu1) ... -Selecting previously unselected package uvtool-libvirt. -Preparing to unpack .../8-uvtool-libvirt_0~git122-0ubuntu1_all.deb ... -Unpacking uvtool-libvirt (0~git122-0ubuntu1) ... -Setting up distro-info (0.17) ... -Setting up ubuntu-cloudimage-keyring (2013.11.11) ... -Setting up cloud-image-utils (0.30-0ubuntu2) ... -Setting up socat (1.7.3.2-1) ... -Setting up python-pyinotify (0.9.6-1) ... -Setting up python-boto (2.44.0-1ubuntu2) ... -Setting up python-simplestreams (0.1.0~bzr450-0ubuntu1) ... -Processing triggers for doc-base (0.10.7) ... -Processing 1 added doc-base file... -Setting up uvtool (0~git122-0ubuntu1) ... -Processing triggers for man-db (2.7.6.1-2) ... -Setting up uvtool-libvirt (0~git122-0ubuntu1) ... -``` - - -### Step 3 - Download the Ubuntu Cloud image - -You need to use the uvt-simplestreams-libvirt command. It maintains a libvirt volume storage pool as a local mirror of a subset of images available from a simplestreams source, such as Ubuntu cloud images. To update uvtool's libvirt volume storage pool with all current amd64 images, run: -`$ uvt-simplestreams-libvirt sync arch=amd64` -To just update/grab Ubuntu 16.04 LTS (xenial/amd64) image run: -`$ uvt-simplestreams-libvirt --verbose sync release=xenial arch=amd64` -Sample outputs: -``` -Adding: com.ubuntu.cloud:server:16.04:amd64 20171121.1 -``` - -Pass the query option to queries the local mirror: -`$ uvt-simplestreams-libvirt query` -Sample outputs: -``` -release=xenial arch=amd64 label=release (20171121.1) -``` - -Now, I have an image for Ubuntu xenial and I create the VM. - -### Step 4 - Create the SSH keys - -You need ssh keys for login into KVM VMs. Use the ssh-keygen command to create a new one if you do not have any keys at all. -`$ ssh-keygen` -See "[How To Setup SSH Keys on a Linux / Unix System][5]" and "[Linux / UNIX: Generate SSH Keys][6]" for more info. - -### Step 5 - Create the VM - -It is time to create the VM named vm1 i.e. create an Ubuntu Linux 16.04 LTS VM: -`$ uvt-kvm create vm1` -By default vm1 created using the following characteristics: - - 1. RAM/memory : 512M - 2. Disk size: 8GiB - 3. CPU: 1 vCPU core - - - -To control ram, disk, cpu, and other characteristics use the following syntax: -`$ uvt-kvm create vm1 \ ---memory MEMORY \ ---cpu CPU \ ---disk DISK \ ---bridge BRIDGE \ ---ssh-public-key-file /path/to/your/SSH_PUBLIC_KEY_FILE \ ---packages PACKAGES1, PACKAGES2, .. \ ---run-script-once RUN_SCRIPT_ONCE \ ---password PASSWORD -` -Where, - - 1. **\--password PASSWORD** : Set the password for the ubuntu user and allow login using the ubuntu user (not recommended use ssh keys). - 2. **\--run-script-once RUN_SCRIPT_ONCE** : Run RUN_SCRIPT_ONCE script as root on the VM the first time it is booted, but never again. Give full path here. This is useful to run custom task on VM such as setting up security or other stuff. - 3. **\--packages PACKAGES1, PACKAGES2, ..** : Install the comma-separated packages on first boot. - - - -To get help, run: -``` -$ uvt-kvm -h -$ uvt-kvm create -h -``` - -#### How do I delete my VM? - -To destroy/delete your VM named vm1, run (please use the following command with care as there would be no confirmation box): -`$ uvt-kvm destroy vm1` - -#### To find out the IP address of the vm1, run: - -`$ uvt-kvm ip vm1` -192.168.122.52 - -#### To list all VMs run - -`$ uvt-kvm list` -Sample outputs: -``` -vm1 -freebsd11.1 - -``` - -### Step 6 - How to login to the vm named vm1 - -The syntax is: -`$ uvt-kvm ssh vm1` -Sample outputs: -``` -Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64) - - comic core.md Dict.md lctt2014.md lctt2016.md LCTT翻译规范.md LICENSE Makefile published README.md sign.md sources translated 选题模板.txt 中文排版指北.md Documentation: https://help.ubuntu.com - comic core.md Dict.md lctt2014.md lctt2016.md LCTT翻译规范.md LICENSE Makefile published README.md sign.md sources translated 选题模板.txt 中文排版指北.md Management: https://landscape.canonical.com - comic core.md Dict.md lctt2014.md lctt2016.md LCTT翻译规范.md LICENSE Makefile published README.md sign.md sources translated 选题模板.txt 中文排版指北.md Support: https://ubuntu.com/advantage - - Get cloud support with Ubuntu Advantage Cloud Guest: - http://www.ubuntu.com/business/services/cloud - -0 packages can be updated. -0 updates are security updates. - - -Last login: Thu Dec 7 09:55:06 2017 from 192.168.122.1 - -``` - -Another option is to use the regular ssh command from macOS/Linux/Unix/Windows client: -`$ ssh [[email protected]][7] -$ ssh -i ~/.ssh/id_rsa [[email protected]][7]` -Sample outputs: -[![Connect to the running VM using ssh][8]][8] -Once vim created you can use the virsh command as usual: -`$ virsh list` - - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/faq/how-to-use-kvm-cloud-images-on-ubuntu-linux/ - -作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz -[1]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) -[2]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) -[3]:https://www.cyberciti.biz/faq/how-to-create-bridge-interface-ubuntu-linux/ -[4]:https://www.cyberciti.biz/faq/installing-kvm-on-ubuntu-16-04-lts-server/ -[5]:https://www.cyberciti.biz/faq/how-to-set-up-ssh-keys-on-linux-unix/ -[6]:https://www.cyberciti.biz/faq/linux-unix-generating-ssh-keys/ -[7]:https://www.cyberciti.biz/cdn-cgi/l/email-protection -[8]:https://www.cyberciti.biz/media/new/faq/2017/12/connect-to-the-running-VM-using-ssh.jpg From 47a6b560982e56196a35f26d5b81e0d64fcc52d5 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 3 Apr 2018 14:29:34 +0800 Subject: [PATCH 0272/1057] Create 20171207 How to use KVM cloud images on Ubuntu Linux.md --- ...to use KVM cloud images on Ubuntu Linux.md | 237 ++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md diff --git a/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md b/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md new file mode 100644 index 0000000000..f96a1d1125 --- /dev/null +++ b/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md @@ -0,0 +1,237 @@ +如何在 Ubuntu Linux 上使用 KVM 云镜像 +===== + +基于内核的虚拟机(KVM)时 Linux 内核的虚拟化模块,可将其转变为虚拟机管理程序。你可以使用 Ubuntu 虚拟化前端为 libvirt 和 KVM 在命令行中使用 KVM 创建 Ubuntu 云镜像。 + +如何下载并使用运行在 Ubuntu Linux 服务器上的 KVM 云镜像?如何在 Ubuntu Linux 16.04 LTS 服务器上无需完整安装即可创建虚拟机?基于内核的虚拟机(KVM)时 Linux 内核的虚拟化模块,可将其转变为虚拟机管理程序。你可以使用 Ubuntu 虚拟化前端为 libvirt 和 KVM 在命令行中使用 KVM 创建 Ubuntu 云镜像。 + +这个快速教程展示了如何安装和使用 uvtool,它为 Ubuntu 云镜像下载,libvirt 和 clout_int 提供了统一的集成虚拟机前端。 + +### 步骤 1 - 安装 KVM + +你必须安装并配置 KVM。使用 [apt 命令][1]/[apt-get 命令][2],如下所示: +``` +$ sudo apt install qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker +$ kvm-ok +## [configure bridged networking as described here][3] +$ sudo vi /etc/network/interfaces +$ sudo systemctl restart networking +$ sudo brctl show +``` + +参阅[如何在 Ubuntu 16.04 LTS Headless 服务器上安装 KVM][4] 以获得更多信息。(译注:Headless 服务器是指没有本地接口的计算设备,专用于向其他计算机及其用户提供服务。) + +### 步骤 2 - 安装 uvtool + +键入以下 [apt 命令][1]/[apt-get 命令][2]: +``` +$ sudo apt install uvtool +``` + +示例输出: +``` +[sudo] password for vivek: +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages were automatically installed and are no longer required: + gksu libgksu2-0 libqt5designer5 libqt5help5 libqt5printsupport5 libqt5sql5 libqt5sql5-sqlite libqt5xml5 python3-dbus.mainloop.pyqt5 python3-notify2 python3-pyqt5 python3-sip +Use 'sudo apt autoremove' to remove them. +The following additional packages will be installed: + cloud-image-utils distro-info python-boto python-pyinotify python-simplestreams socat ubuntu-cloudimage-keyring uvtool-libvirt +Suggested packages: + cloud-utils-euca shunit2 python-pyinotify-doc +The following NEW packages will be installed: + cloud-image-utils distro-info python-boto python-pyinotify python-simplestreams socat ubuntu-cloudimage-keyring uvtool uvtool-libvirt +0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. +Need to get 1,211 kB of archives. +After this operation, 6,876 kB of additional disk space will be used. +Get:1 http://in.archive.ubuntu.com/ubuntu artful/main amd64 distro-info amd64 0.17 [20.3 kB] +Get:2 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 python-boto all 2.44.0-1ubuntu2 [740 kB] +Get:3 http://in.archive.ubuntu.com/ubuntu artful/main amd64 python-pyinotify all 0.9.6-1 [24.6 kB] +Get:4 http://in.archive.ubuntu.com/ubuntu artful/main amd64 ubuntu-cloudimage-keyring all 2013.11.11 [4,504 B] +Get:5 http://in.archive.ubuntu.com/ubuntu artful/main amd64 cloud-image-utils all 0.30-0ubuntu2 [17.2 kB] +Get:6 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 python-simplestreams all 0.1.0~bzr450-0ubuntu1 [29.7 kB] +Get:7 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 socat amd64 1.7.3.2-1 [342 kB] +Get:8 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 uvtool all 0~git122-0ubuntu1 [6,498 B] +Get:9 http://in.archive.ubuntu.com/ubuntu artful/universe amd64 uvtool-libvirt all 0~git122-0ubuntu1 [26.9 kB] +Fetched 1,211 kB in 3s (393 kB/s) +Selecting previously unselected package distro-info. +(Reading database ... 199933 files and directories currently installed.) +Preparing to unpack .../0-distro-info_0.17_amd64.deb ... +Unpacking distro-info (0.17) ... +Selecting previously unselected package python-boto. +Preparing to unpack .../1-python-boto_2.44.0-1ubuntu2_all.deb ... +Unpacking python-boto (2.44.0-1ubuntu2) ... +Selecting previously unselected package python-pyinotify. +Preparing to unpack .../2-python-pyinotify_0.9.6-1_all.deb ... +Unpacking python-pyinotify (0.9.6-1) ... +Selecting previously unselected package ubuntu-cloudimage-keyring. +Preparing to unpack .../3-ubuntu-cloudimage-keyring_2013.11.11_all.deb ... +Unpacking ubuntu-cloudimage-keyring (2013.11.11) ... +Selecting previously unselected package cloud-image-utils. +Preparing to unpack .../4-cloud-image-utils_0.30-0ubuntu2_all.deb ... +Unpacking cloud-image-utils (0.30-0ubuntu2) ... +Selecting previously unselected package python-simplestreams. +Preparing to unpack .../5-python-simplestreams_0.1.0~bzr450-0ubuntu1_all.deb ... +Unpacking python-simplestreams (0.1.0~bzr450-0ubuntu1) ... +Selecting previously unselected package socat. +Preparing to unpack .../6-socat_1.7.3.2-1_amd64.deb ... +Unpacking socat (1.7.3.2-1) ... +Selecting previously unselected package uvtool. +Preparing to unpack .../7-uvtool_0~git122-0ubuntu1_all.deb ... +Unpacking uvtool (0~git122-0ubuntu1) ... +Selecting previously unselected package uvtool-libvirt. +Preparing to unpack .../8-uvtool-libvirt_0~git122-0ubuntu1_all.deb ... +Unpacking uvtool-libvirt (0~git122-0ubuntu1) ... +Setting up distro-info (0.17) ... +Setting up ubuntu-cloudimage-keyring (2013.11.11) ... +Setting up cloud-image-utils (0.30-0ubuntu2) ... +Setting up socat (1.7.3.2-1) ... +Setting up python-pyinotify (0.9.6-1) ... +Setting up python-boto (2.44.0-1ubuntu2) ... +Setting up python-simplestreams (0.1.0~bzr450-0ubuntu1) ... +Processing triggers for doc-base (0.10.7) ... +Processing 1 added doc-base file... +Setting up uvtool (0~git122-0ubuntu1) ... +Processing triggers for man-db (2.7.6.1-2) ... +Setting up uvtool-libvirt (0~git122-0ubuntu1) ... +``` + +### 步骤 3 - 下载 Ubuntu 云镜像 + +你需要使用 uvt-simplestreams-libvirt 命令。它维护一个 libvirt 容量存储池,作为一个简单流源的图像子集的本地镜像,比如 Ubuntu 云镜像。要使用当前所有 amd64 镜像更新 uvtool 的 libvirt 容量存储此,运行: +`$ uvt-simplestreams-libvirt sync arch=amd64` +要更新/获取 Ubuntu 16.04 LTS (xenial/amd64) 镜像,运行: +`$ uvt-simplestreams-libvirt --verbose sync release=xenial arch=amd64` + +示例输出: +``` +Adding: com.ubuntu.cloud:server:16.04:amd64 20171121.1 +``` + +通过 query 选项查询本地镜像: +`$ uvt-simplestreams-libvirt query` +示例输出: +``` +release=xenial arch=amd64 label=release (20171121.1) +``` + +现在,我为 Ubuntu xenial 创建了一个镜像,接下来我会创建虚拟机。 + +### 步骤 4 - 创建 SSH 密钥 + +你需要使用 SSH 密钥才能登录到 KVM 虚拟机。如果你根本没有任何密钥,请使用 ssh-keygen 命令创建一个新的密钥。 +`$ ssh-keygen` +参阅“[如何在 Linux / Unix 系统上设置 SSH 密钥][5]” 和 “[Linux / UNIX: 生成 SSH 密钥][6]” 以获取更多信息。 + +### 步骤 5 - 创建 VM + +是时候创建虚拟机了,它叫 vm1,即创建一个 Ubuntu Linux 16.04 LTS 虚拟机: +`$ uvt-kvm create vm1` + +默认情况下 vm1 使用以下配置创建: + + 1. RAM/memory : 512M + 2. Disk size: 8GiB + 3. CPU: 1 vCPU core + +要控制 ram,disk,cpu 和其他配置,使用以下语法: +``` +$ uvt-kvm create vm1 \ +--memory MEMORY \ +--cpu CPU \ +--disk DISK \ +--bridge BRIDGE \ +--ssh-public-key-file /path/to/your/SSH_PUBLIC_KEY_FILE \ +--packages PACKAGES1, PACKAGES2, .. \ +--run-script-once RUN_SCRIPT_ONCE \ +--password PASSWORD +``` + +其中 + + 1. **\--password PASSWORD** : 设置 ubuntu 用户的密码和允许使用 ubuntu 的用户登录(不推荐使用 ssh 密钥)。 + 2. **\--run-script-once RUN_SCRIPT_ONCE** : 第一次启动时,在虚拟机上以 root 身份运行 RUN_SCRIPT_ONCE 脚本,但再也不会运行。这里给出完整的路径。这对于在虚拟机上运行自定义任务时非常有用,例如设置安全性或其他内容。 + 3. **\--packages PACKAGES1, PACKAGES2, ..** : 在第一次启动时安装逗号分隔的软件包。 + +要获取帮助,运行: +``` +$ uvt-kvm -h +$ uvt-kvm create -h +``` + +#### 如何删除虚拟机? + +要销毁/删除名为 vm1 的虚拟机,运行(请小心使用以下命令,因为没有确认框): +`$ uvt-kvm destroy vm1` + +#### 获取 vm1 的 IP 地址,运行: + +`$ uvt-kvm ip vm1` +192.168.122.52 + +#### 列出所有运行的虚拟机 + +`$ uvt-kvm list` +示例输出: +``` +vm1 +freebsd11.1 +``` + +### 步骤 6 - 如何登录 vm1 + +语法是: +`$ uvt-kvm ssh vm1` +示例输出: +``` +Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + Get cloud support with Ubuntu Advantage Cloud Guest: + http://www.ubuntu.com/business/services/cloud + +0 packages can be updated. +0 updates are security updates. + + +Last login: Thu Dec 7 09:55:06 2017 from 192.168.122.1 + +``` + +另一个选择是从 macOS/Linux/Unix/Windows 客户端使用常规的 ssh 命令: +``` +$ ssh ubuntu@192.168.122.52 +$ ssh -i ~/.ssh/id_rsa ubuntu@192.168.122.52 +``` +(上面的是根据原文修改的) +示例输出: +[![Connect to the running VM using ssh][8]][8] + +一旦创建了 vim,你可以照常使用 virsh 命令: +`$ virsh list` + + +-------------------------------------------------------------------------------- + +via: https://www.cyberciti.biz/faq/how-to-use-kvm-cloud-images-on-ubuntu-linux/ + +作者:[Vivek Gite][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz +[1]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) +[2]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) +[3]:https://www.cyberciti.biz/faq/how-to-create-bridge-interface-ubuntu-linux/ +[4]:https://www.cyberciti.biz/faq/installing-kvm-on-ubuntu-16-04-lts-server/ +[5]:https://www.cyberciti.biz/faq/how-to-set-up-ssh-keys-on-linux-unix/ +[6]:https://www.cyberciti.biz/faq/linux-unix-generating-ssh-keys/ +[7]:https://www.cyberciti.biz/cdn-cgi/l/email-protection +[8]:https://www.cyberciti.biz/media/new/faq/2017/12/connect-to-the-running-VM-using-ssh.jpg From 356712aa49ae30fcc45b2375f13e6ce4294699a9 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 3 Apr 2018 14:30:26 +0800 Subject: [PATCH 0273/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Crea?= =?UTF-8?q?te/Extend=20Swap=20Partition=20In=20Linux=20Using=20LVM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...xtend Swap Partition In Linux Using LVM.md | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md diff --git a/sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md b/sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md new file mode 100644 index 0000000000..66d3156bf2 --- /dev/null +++ b/sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md @@ -0,0 +1,149 @@ +How To Create/Extend Swap Partition In Linux Using LVM +====== +We are using LVM for flexible volume management so, why can’t we use LVM for swap space? + +This allow users to increase the swap partition whenever we need. + +If you upgraded the RAM in your system, it is necessary to add more swap space. + +This help you to manage the system that run applications that require a large amount of memory. + +Swap can be created in three ways + + * Create a new swap partition + * Create a new swap file + * Extend swap on an existing logical volume (LVM) + + + +It’s recommended to create a dedicated swap partition instead of swap file. + +**Suggested Read :** +**(#)** [3 Easy Ways To Create Or Extend Swap Space In Linux][1] +**(#)** [Automatically Create/Remove And Mount Swap File In Linux Using Shell Script][2] + +What is the recommended swap size in Linux? + +### What Is Swap Space + +Swap space in Linux is used when the amount of physical memory (RAM) is full. When physical RAM is full, inactive pages in memory are moved to the swap space. + +This helps system to run the application continuously but it’s not considered a replacement for more RAM. + +Swap space is located on hard drives so, it would not processing the request like physical RAM. + +### How To Create A Swap Partition Using LVM + +As we already know how to create logical volume do the same for swap as well. Just follow the below procedure. + +Create a logical volume which you required. In my case i’m going to create `5GB` of swap partition. +``` +$ sudo lvcreate -L 5G -n LogVol_swap1 vg00 + Logical volume "LogVol_swap1" created. + +``` + +Format the new swap space. +``` +$ sudo mkswap /dev/vg00/LogVol_swap1 +Setting up swapspace version 1, size = 5 GiB (5368705024 bytes) +no label, UUID=d278e9d6-4c37-4cb0-83e5-2745ca708582 + +``` + +Add the following entry to the `/etc/fstab` file. +``` +# vi /etc/fstab +/dev/mapper/vg00-LogVol_swap1 swap swap defaults 0 0 + +``` + +Enable the extended logical volume. +``` +$ sudo swapon -va +swapon: /swapfile: already active -- ignored +swapon: /dev/mapper/vg00-LogVol_swap1: found signature [pagesize=4096, signature=swap] +swapon: /dev/mapper/vg00-LogVol_swap1: pagesize=4096, swapsize=5368709120, devsize=5368709120 +swapon /dev/mapper/vg00-LogVol_swap1 + +``` + +Test that the swap space has been added properly. +``` +$ cat /proc/swaps +Filename Type Size Used Priority +/swapfile file 1459804 526336 -1 +/dev/dm-0 partition 5242876 0 -2 + +$ free -g + total used free shared buff/cache available +Mem: 1 1 0 0 0 0 +Swap: 6 0 6 + +``` + +### How To Expand A Swap Partition Using LVM + +Just follow the below procedure to extend an LVM swap logical volume. + +Disable swapping for the associated logical volume. +``` +$ sudo swapoff -v /dev/vg00/LogVol_swap1 +swapoff /dev/vg00/LogVol_swap1 + +``` + +Resize the logical volume. I’m going to increase the swap volume from `5GB to 11GB`. +``` +$ sudo lvresize /dev/vg00/LogVol_swap1 -L +6G + Size of logical volume vg00/LogVol_swap1 changed from 5.00 GiB (1280 extents) to 11.00 GiB (2816 extents). + Logical volume vg00/LogVol_swap1 successfully resized. + +``` + +Format the new swap space. +``` +$ sudo mkswap /dev/vg00/LogVol_swap1 +mkswap: /dev/vg00/LogVol_swap1: warning: wiping old swap signature. +Setting up swapspace version 1, size = 11 GiB (11811155968 bytes) +no label, UUID=2e3b2ee0-ad0b-402c-bd12-5a9431b73623 + +``` + +Enable the extended logical volume. +``` +$ sudo swapon -va +swapon: /swapfile: already active -- ignored +swapon: /dev/mapper/vg00-LogVol_swap1: found signature [pagesize=4096, signature=swap] +swapon: /dev/mapper/vg00-LogVol_swap1: pagesize=4096, swapsize=11811160064, devsize=11811160064 +swapon /dev/mapper/vg00-LogVol_swap1 + +``` + +Test that the logical volume has been extended properly. +``` +$ free -g + total used free shared buff/cache available +Mem: 1 1 0 0 0 0 +Swap: 12 0 12 + +$ cat /proc/swaps +Filename Type Size Used Priority +/swapfile file 1459804 237024 -1 +/dev/dm-0 partition 11534332 0 -2 + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-create-extend-swap-partition-in-linux-using-lvm/ + +作者:[Ramya Nuvvula][a] +译者:[译者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/ramya/ +[1]:https://www.2daygeek.com/add-extend-increase-swap-space-memory-file-partition-linux/ +[2]:https://www.2daygeek.com/shell-script-create-add-extend-swap-space-linux/ From c051812a08dd12633b78226ef6cc7398e4ae7271 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 3 Apr 2018 14:32:05 +0800 Subject: [PATCH 0274/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20conf?= =?UTF-8?q?igure=20multiple=20websites=20with=20Apache=20web=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ultiple websites with Apache web server.md | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 sources/tech/20180329 How to configure multiple websites with Apache web server.md diff --git a/sources/tech/20180329 How to configure multiple websites with Apache web server.md b/sources/tech/20180329 How to configure multiple websites with Apache web server.md new file mode 100644 index 0000000000..0f759cc5fe --- /dev/null +++ b/sources/tech/20180329 How to configure multiple websites with Apache web server.md @@ -0,0 +1,157 @@ +How to configure multiple websites with Apache web server +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/apache-feathers.jpg?itok=fnrpsu3G) +In my [last post][1], I explained how to configure an Apache web server for a single website. It turned out to be very easy. In this post, I will show you how to serve multiple websites using a single instance of Apache. + +Note: I wrote this article on a virtual machine using Fedora 27 with Apache 2.4.29. If you have another distribution or release of Fedora, the commands you will use and the locations and content of the configuration files may be different. + +As my previous article mentioned, all of the configuration files for Apache are located in `/etc/httpd/conf` and `/etc/httpd/conf.d`. The data for the websites is located in `/var/www` by default. With multiple websites, you will need to provide multiple locations, one for each site you host. + +### Name-based virtual hosting + +With name-based virtual hosting, you can use a single IP address for multiple websites. Modern web servers, including Apache, use the `hostname` portion of the specified URL to determine which virtual web host responds to the page request. This requires only a little more configuration than for a single site. + +Even if you are starting with only a single website, I recommend that you set it up as a virtual host, which will make it easier to add more sites later. In this article, I'll pick up where we left off in the previous article, so you'll need to set up the original website, a name-based virtual website. + +### Preparing the original website + +Before you set up a second website, you need to get name-based virtual hosting working for the existing site. If you do not have an existing website, [go back and create one now][1]. + +Once you have your site, add the following stanza to the bottom of its `/etc/httpd/conf/httpd.conf` configuration file (adding this stanza is the only change you need to make to the `httpd.conf` file): +``` + + +    DocumentRoot /var/www/html + +    ServerName www.site1.org + + + +``` + +This will be the first virtual host stanza, and it should remain first, to make it the default definition. That means that HTTP access to the server by IP address, or by another name that resolves to this IP address but that does not have a specific named host configuration stanza, will be directed to this virtual host. All other virtual host configuration stanzas should follow this one. + +You also need to set up your websites with entries in `/etc/hosts` to provide name resolution. Last time, we just used the IP address for `localhost`. Normally, this would be done using whichever name service you use; for example, Google or Godaddy. For your test website, do this by adding a new name to the `localhost` line in `/etc/hosts`. Add the entries for both websites so you don't need to edit this file again later. The result looks like this: +``` +127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 www.site1.org www.site2.org + +``` + +Let’s also change the `/var/www/html/index.html` file to be a little more explicit. It should look like this (with some additional text to identify this as website number 1): +``` +

Hello World

+ + + +Web site 1. + +``` + +Restart the HTTPD server to enable the changes to the `httpd` configuration. You can then look at the website using the Lynx text mode browser from the command line. +``` +[root@testvm1 ~]# systemctl restart httpd + +[root@testvm1 ~]# lynx www.site1.org + + + +                                              Hello World + +  Web site 1. + + + +Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. + +Arrow keys: Up and Down to move.  Right to follow a link; Left to go back. + +H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list + +``` + +You can see that the revised content for the original website is displayed and that there are no obvious errors. Press the “Q” key, followed by “Y” to exit the Lynx web browser. + +### Configuring the second website + +Now you are ready to set up the second website. Create a new website directory structure with the following command: +``` +[root@testvm1 html]# mkdir -p /var/www/html2 + +``` + +Notice that the second website is simply a second `html` directory in the same `/var/www` directory as the first site. + +Now create a new index file, `/var/www/html2/index.html`, with the following content (this index file is a bit different, to distinguish it from the one for the original website): +``` +

Hello World -- Again

+ + + +Web site 2. + +``` + +Create a new configuration stanza in `httpd.conf` for the second website and place it below the previous virtual host stanza (the two should look very similar). This stanza tells the web server where to find the HTML files for the second site. +``` + + +    DocumentRoot /var/www/html2 + +    ServerName www.site2.org + + + +``` + +Restart HTTPD again and use Lynx to view the results. +``` +[root@testvm1 httpd]# systemctl restart httpd + +[root@testvm1 httpd]# lynx www.site2.org + + + +                                    Hello World -- Again + + + +   Web site 2. + + + + + +Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. + +Arrow keys: Up and Down to move.  Right to follow a link; Left to go back. + +H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list + +``` + +Here I have compressed the resulting output to fit this space. The difference in the page indicates that this is the second website. To show both websites at the same time, open another terminal session and use the Lynx web browser to view the other site. + +### Other considerations + +This simple example shows how to serve up two websites with a single instance of the Apache HTTPD server. Configuring the virtual hosts becomes a bit more complex when other factors are considered. + +For example, you may want to use some CGI scripts for one or both of these websites. To do this, you would create directories for the CGI programs in `/var/www`: `/var/www/cgi-bin` and `/var/www/cgi-bin2`, to be consistent with the HTML directory naming. You would then need to add configuration directives to the virtual host stanzas to specify the directory location for the CGI scripts. Each website could also have directories from which files could be downloaded; this would also require entries in the appropriate virtual host stanza. + +The [Apache website][2] describes other methods for managing multiple websites, as well as configuration options from performance tuning to security. + +Apache is a powerful web server that can be used to manage websites ranging from simple to highly complex. Although its overall share is shrinking, Apache remains the single most commonly used HTTPD server on the Internet. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache + +作者:[David Both][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/dboth +[1]:https://opensource.com/article/18/2/how-configure-apache-web-server +[2]:https://httpd.apache.org/docs/2.4/ From 92b6200ad4635c903307e40bbaea94f869bb6388 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 3 Apr 2018 14:34:07 +0800 Subject: [PATCH 0275/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Build=20a=20bab?= =?UTF-8?q?y=20monitor=20with=20a=20Raspberry=20Pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...uild a baby monitor with a Raspberry Pi.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md diff --git a/sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md b/sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md new file mode 100644 index 0000000000..0e83af2d07 --- /dev/null +++ b/sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md @@ -0,0 +1,104 @@ +Build a baby monitor with a Raspberry Pi +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/baby-chick-egg.png?itok=RcFfqdbA) +Hong Kong can be hot and humid, even at night, and many people use air conditioning to make their homes more bearable. When my oldest son was a baby, the air conditioning unit in his bedroom had manual controls and no thermostat functionality. It was either on or off, and allowing it to run continuously overnight caused the room to get cold and wasted energy and money. + +I decided to fix this problem with an [Internet of Things][1] solution based on a [Raspberry Pi][2]. Later I took it a step further with a [baby monitor][3] add-on. In this article, I'll explain how I did it, and the code is [available on my GitHub][4] page. + +### Setting up the air conditioner controller + +I solved the first part of my problem with an Orvibo S20 [WiFi-connected smart plug][5] and smartphone application. Although this allowed me to control the air conditioning unit remotely, it was still a manual process, and I wanted to try and automate it. I found a project on [Instructables][6] that seemed to match my requirements: It used a Raspberry Pi to measure local temperature and humidity readings from an [AM2302 sensor][7] and record them to a MySQL database. + +Using crimp terminal contacts with crimp housings made it a pinch to connect the temperature/humidity sensor to the correct GPIO pins on the Raspberry Pi. Fortunately, the AM2302 sensor has [open source software][8] for taking readings, with helpful [Python][9] examples. + +The software for [interfacing with the AM2302 sensor][10] has been updated since I put my project together, and the original code I used is now considered legacy and unmaintained. The code is made up of a small binary object to connect to the sensor and some Python scripts to interpret the readings and return the correct values. + +![Raspberry Pi, sensor, and Python code][12] + +Raspberry Pi, sensor, and Python code used to build the temperature/humidity monitor. + +With the sensor connected to the Raspberry Pi, the Python code can correctly return temperature and humidity readings. Connecting Python to a MySQL database is straightforward, and there are plenty of code examples that use the `python-``mysql` bindings. Because I needed to monitor the temperature and humidity continuously, I wrote software to do this. + +In fact, I ended up with two solutions, one that would run continuously as a process and periodically poll the sensor (typically at one-minute intervals), and another Python script that ran once and exited. I decided to use the run-once-and-exit approach coupled with cron to call this script every minute. The main reason was that the continuous (looped) script occasionally would not return a reading, which could lead to a buildup of processes trying to read the sensor, and that would eventually cause a system to hang due to lack of available resources. + +I also found a convenient [Perl script][13] to programmatically control my smart plug. This was an essential piece of the jigsaw, as it meant I could trigger the Perl script if certain temperature and/or humidity conditions were met. After some testing, I decided to create a separate `checking` script that would pull the latest values from the MySQL database and set the smart plug on or off depending upon the values returned. Separating the logic to run the plug control script from the sensor-reading script also meant that it operated independently and would continue to run, even if the sensor-reading script developed problems. + +It made sense to make the temperature at which the air conditioner would switch on/off configurable, so I moved these values to a configuration file that the control script read. I also found that, although the sensor was generally accurate, occasionally it would return incorrect readings. The sensor script was modified to not write temperature or humidity values to the MySQL database that were significantly different from the previous values. Likewise the allowed variance of temperature or humidity between consecutive readings was set in a general configuration file, and if the reading was outside these limits the values would not be committed to the database. + +Although this seemed like quite a lot of effort to make a thermostat, recording the data to a MySQL database meant it was available for further analysis to identify usage patterns. There are many graphing options available to present data from a MySQL database, and I decided to use [Google Chart][14]to display the data on a web page. + +![Temperature and humidity chart][16] + +Temperature and humidity measured over the previous six hours. + +### Adding a baby monitor camera + +The open nature of the Raspberry Pi meant I could continue to add functionality—and I had plenty of open GPIO pins available. My next idea was to add a camera module to set it up as a baby monitor, given that the device was already in the baby's bedroom. + +I needed a camera that works in the dark, and the [Pi Noir][17] camera module is perfect for this. The Pi Noir is the same as the Raspberry Pi's regular camera module, except it doesn't have an infrared (IR) filter. This means daytime images may have a slightly purple tint, but it will display images lit with IR light in the dark. + +Now I needed a source of IR light. Due to the Pi's popularity and low barrier of entry, there are a huge number of peripherals and add-ons for it. Of the many IR sources available, the one that caught my attention was the [Bright Pi][18]. It draws power from the Raspberry Pi and fits around the camera Pi module to provide a source of IR and normal light. The only drawback was I needed to dust off my rusty soldering skills. + +It might have taken me longer than most, but my soldering skills were up to it, and I was able to successfully attach all the IR LEDs to the housing and connect the IR light source to the Pi's GPIO pins. This also meant that the Pi could programmatically control when the IR LEDs were lit, as well as their light intensity. + +It also made sense to have the video capture exposed via a web stream so I could watch it from the web page with the temperature and humidity readings chart. After further research, I chose to use a [streaming software][19] that used M-JPEG captures. Exposing the JPG source via the web page also allowed me to connect camera viewer applications on my smartphone to view the camera output there, as well. + +### Putting on the finishing touches + +No Raspberry Pi project is complete without selecting an appropriate case for the Pi and its various components. After a lot of searching and comparing, there was one clear [winner][20]: SmartPi's Lego-style case. The Lego compatibility allowed me to build mounts for the temperature/humidity sensor and camera. Here's the final outcome: + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_case.png?itok=_ofyN73a) + +Since then, I've made other changes and updates to my setup: + + * I upgraded from a Raspberry Pi 2 Model B to a [Raspberry Pi 3][21], which meant I could do away with the USB WiFi module. + * I replaced the Orvibo S20 with a [TP-Link HS110][22] smart plug. + * I also plugged the Pi into a smart plug so I can do remote reboots/resets. + * I migrated the MySQL database off the Raspberry Pi, and it now runs in a container on a NAS device. + * I added a [flexible tripod][23] to allow for the best camera angle. + * I recompiled the USB WiFi module to disable the onboard flashing LED, which was one of the main advantages to upgrading to a Raspberry Pi 3. + * I've since built another monitor for my second child. + * I bought a bespoke night camera for my third child … due to lack of time. + + + +Want to learn more? All the code is [available on my GitHub][4] page. + +Do you have a Raspberry Pi project to share? [Send us your story idea][24]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/build-baby-monitor-raspberry-pi + +作者:[Jonathan Ervine][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/jervine +[1]:https://opensource.com/tags/internet-things +[2]:https://opensource.com/tags/raspberry-pi +[3]:https://opensource.com/article/17/9/gonimo +[4]:https://github.com/jervine/rpi-temp-humid-monitor +[5]:https://www.amazon.co.uk/marsboy-S20-Automation-Control-Smartphone/dp/B01LXKPUDK/ref=sr_1_1/258-6082934-2585109?ie=UTF8&qid=1520578769&sr=8-1&keywords=orvibo+s20 +[6]:http://www.instructables.com/id/Raspberry-Pi-Temperature-Humidity-Network-Monitor/ +[7]:https://www.adafruit.com/product/393 +[8]:https://github.com/adafruit/Adafruit_Python_DHT +[9]:https://opensource.com/tags/python +[10]:https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/legacy/Adafruit_DHT_Driver_Python +[11]:/file/390916 +[12]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_materials.png?itok=2w03CdKM (Raspberry Pi, sensor, and Python code) +[13]:https://github.com/franc-carter/bauhn-wifi +[14]:https://developers.google.com/chart/ +[15]:/file/390876 +[16]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_temp-humidity.png?itok=2jqtQU0x (Temperature and humidity chart) +[17]:https://www.raspberrypi.org/products/pi-noir-camera-v2/ +[18]:https://www.pi-supply.com/product/bright-pi-bright-white-ir-camera-light-raspberry-pi/ +[19]:https://elinux.org/RPi-Cam-Web-Interface +[20]:https://smarticase.com/collections/all/products/smartipi-kit-3 +[21]:https://opensource.com/article/18/3/raspberry-pi-3b-model-news +[22]:https://www.tp-link.com/uk/products/details/cat-5258_HS110.html +[23]:https://www.amazon.com/Flexpod-Flexible-Tripod-Discontinued-Manufacturer/dp/B000JC8WYA +[24]:http://opensource.com/story From 133c723840f39b5f4d3ac124eeeba46469f9fd0f Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 3 Apr 2018 15:52:43 +0800 Subject: [PATCH 0276/1057] Update 20180328 Getting started with Jupyter Notebooks.md --- .../tech/20180328 Getting started with Jupyter Notebooks.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180328 Getting started with Jupyter Notebooks.md b/sources/tech/20180328 Getting started with Jupyter Notebooks.md index 133b93451f..7b11fb7eb3 100644 --- a/sources/tech/20180328 Getting started with Jupyter Notebooks.md +++ b/sources/tech/20180328 Getting started with Jupyter Notebooks.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + Getting started with Jupyter Notebooks ====== From c310dc43f9f535e7012fe56b11eb76b83bc2b8a4 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 3 Apr 2018 17:49:17 +0800 Subject: [PATCH 0277/1057] PRF:20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @pygmalion666 恭喜你,完成了第一篇翻译,用心了。 --- ... Spice To Your UNIX-Linux Shell Scripts.md | 123 ++++++++---------- 1 file changed, 57 insertions(+), 66 deletions(-) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index bed5385d90..022f9229bd 100644 --- a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -1,13 +1,13 @@ -# 10 个增加 UNIX/Linux Shell 脚本趣味的工具 +10 个增加 UNIX/Linux Shell 脚本趣味的工具 ====== 有些误解认为 shell 脚本仅用于 CLI 环境。实际上在 KDE 或 Gnome 桌面下,你可以有效的使用各种工具编写 GUI 或者网络(socket)脚本。shell 脚本可以使用一些 GUI 组件(菜单、警告框、进度条等),你可以控制终端输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户友好的 UNIX/Linux bash 脚本。 -制作 GUI 应用不是一项昂贵的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 +制作 GUI 应用不是一项困难的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 -### 1#:notify-send 命令 +### 1、notify-send 命令 -notify-send 命令允许你使用通知守护进程发送桌面通知给用户。这种避免侵入用户的方式,对于通知桌面用户一个事件或显示一些信息是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt 命令][1] 或 [apt-get 命令][2] 安装的包: +`notify-send` 命令允许你借助通知守护进程发送桌面通知给用户。这种避免打扰用户的方式,对于通知桌面用户一个事件或显示一些信息是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt 命令][1] 或 [apt-get 命令][2] 安装的包: ```bash sudo apt-get install libnotify-bin @@ -24,7 +24,7 @@ Fedora Linux 用户使用下面的 dnf 命令: ```bash `$ sudo dnf install libnotify` In this example, send simple desktop notification from the command line, enter: -### send some notification ## +### 发送一些通知 ### notify-send "rsnapshot done :)" ``` @@ -35,7 +35,7 @@ notify-send "rsnapshot done :)" 下面是另一个附加选项的代码: ```bash -.... +... alert=18000 live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g') [ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i "BSE Sensex touched 18k"; notify_counter=1; } @@ -48,25 +48,25 @@ live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5} 这里: - * -t 5000: 指定超时时间(毫秒) (5000 毫秒 = 5 秒) - * -u low : 设置紧急等级 (如:低、普通、紧急) - * -i gtk-dialog-info : 设置要显示的图标名称或者指定的图标(你可以设置路径为:-i /path/to/your-icon.png) + * `-t 5000`:指定超时时间(毫秒) (5000 毫秒 = 5 秒) + * `-u low`: 设置紧急等级 (如:低、普通、紧急) + * `-i gtk-dialog-info`: 设置要显示的图标名称或者指定的图标(你可以设置路径为:`-i /path/to/your-icon.png`) -关于更多使用 notify-send 功能的信息,请参考 notify-send 手册。在命令行下输入 `man notify-send` 即可看见: +关于更多使用 `notify-send` 功能的信息,请参考 man 手册。在命令行下输入 `man notify-send` 即可看见: ```bash man notify-send ``` -### #2:tput 命令 +### 2、tput 命令 -tput 命令用于设置终端特性。通过 tput 你可以设置: +`tput` 命令用于设置终端特性。通过 `tput` 你可以设置: * 在屏幕上移动光标。 * 获取终端信息。 * 设置颜色(背景和前景)。 * 设置加粗模式。 - * 设置反向模式等等。 + * 设置反转模式等等。 下面有一段示例代码: @@ -116,16 +116,16 @@ tput rc ![Fig.03: tput in action][6] -关于 tput 命令的详细信息,参见手册: +关于 `tput` 命令的详细信息,参见手册: ```bash man 5 terminfo man tput ``` -### #3:setleds 命令 +### 3、setleds 命令 -setleds 命令允许你设置键盘灯。下面是打开数字键灯的示例: +`setleds` 命令允许你设置键盘灯。下面是打开数字键灯的示例: ```bash setleds -D +num @@ -137,18 +137,16 @@ setleds -D +num setleds -D -num ``` - * -caps:关闭大小写锁定 - * +caps:打开大小写锁定 - * -scroll:关闭滚动锁定 - * +scroll:打开滚动锁定 + * `-caps`:关闭大小写锁定灯 + * `+caps`:打开大小写锁定灯 + * `-scroll`:关闭滚动锁定灯 + * `+scroll`:打开滚动锁定灯 -查看 setleds 手册可看见更多信息和选项: +查看 `setleds` 手册可看见更多信息和选项 `man setleds`。 -`man setleds` +### 4、zenity 命令 -### #4:zenity 命令 - -[zenity 命令显示 GTK+ 对话框][7],并且返回用户输入。它允许你使用各种 Shell 脚本向用户展示或请求信息。下面是 whois 指定域名目录服务的 GUI 客户端示例。 +[zenity 命令显示 GTK+ 对话框][7],并且返回用户输入。它允许你使用各种 Shell 脚本向用户展示或请求信息。下面是一个 `whois` 指定域名目录服务的 GUI 客户端示例。 ```bash #!/bin/bash @@ -181,16 +179,16 @@ fi ![Fig.04: zenity in Action][8] -参见手册获取更多 zenity 信息以及其他支持 GTK+ 的组件: +参见手册获取更多 `zenity` 信息以及其他支持 GTK+ 的组件: ```bash zenity --help man zenity ``` -### #5:kdialog 命令 +### 5、kdialog 命令 -kdialog 命令与 zenity 类似,但它是为 KDE 桌面和 QT 应用设计。你可以使用 kdialog 展示对话框。下面示例将在屏幕上显示信息: +`kdialog` 命令与 `zenity` 类似,但它是为 KDE 桌面和 QT 应用设计。你可以使用 `kdialog` 展示对话框。下面示例将在屏幕上显示信息: ```bash kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not found." @@ -202,7 +200,7 @@ kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not fo 参见 《[KDE 对话框 Shell 脚本编程][10]》 教程获取更多信息。 -### #6:Dialog +### 6、Dialog [Dialog 是一个使用 Shell 脚本的应用][11],显示用户界面组件的文本。它使用 curses 或者 ncurses 库。下面是一个示例代码: @@ -224,21 +222,20 @@ case $response in esac ``` -参见 dialog 手册获取详细信息: -`man dialog` +参见 `dialog` 手册获取详细信息:`man dialog`。 -### 关于其他用户界面工具的注意事项 +#### 关于其他用户界面工具的注意事项 UNIX、Linux 提供了大量其他工具来显示和控制命令行中的应用程序,shell 脚本可以使用一些 KDE、Gnome、X 组件集: - * **gmessage** - 基于 GTK xmessage 的克隆. - * **xmessage** - 在窗口中显示或查询消息(X-based /bin/echo) - * **whiptail** - 显示来自 shell 脚本的对话框 - * **python-dialog** - 用于制作简单文本或控制台模式用户界面的 Python 模块 + * `gmessage` - 基于 GTK xmessage 的克隆 + * `xmessage` - 在窗口中显示或询问消息(基于 X 的 /bin/echo) + * `whiptail` - 显示来自 shell 脚本的对话框 + * `python-dialog` - 用于制作简单文本或控制台模式用户界面的 Python 模块 -### #7:logger 命令 +### 7、logger 命令 -logger 命令将信息写到系统日志文件,如: /var/log/messages。它为系统日志模块 syslog 提供了一个 shell 命令行接口: +`logger` 命令将信息写到系统日志文件,如:`/var/log/messages`。它为系统日志模块 syslog 提供了一个 shell 命令行接口: ```bash logger "MySQL database backup failed." @@ -254,19 +251,17 @@ Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature/speed nor Apr 20 00:12:20 vivek-desktop mysqld: Database Server failed ``` -参见 《[如何写消息到 syslog 或 日志文件][12]》 获得更多信息。此外,你也可以查看 logger 手册获取详细信息: +参见 《[如何写消息到 syslog 或 日志文件][12]》 获得更多信息。此外,你也可以查看 logger 手册获取详细信息:`man logger` -`man logger` +### 8、setterm 命令 -### #8:setterm 命令 - -setterm 命令可设置不同的终端属性。下面的示例代码会强制屏幕在 15分钟后变黑,监视器则待机 60 分钟。 +`setterm` 命令可设置不同的终端属性。下面的示例代码会强制屏幕在 15 分钟后变黑,监视器则 60 分钟后待机。 ```bash setterm -blank 15 -powersave powerdown -powerdown 60 ``` -下面的例子将 xterm 窗口中的文本带有下划线展示: +下面的例子将 xterm 窗口中的文本以下划线展示: ```bash setterm -underline on; @@ -274,7 +269,7 @@ echo "Add Your Important Message Here" setterm -underline off ``` -另一个有用的选项是打开或关闭光标: +另一个有用的选项是打开或关闭光标显示: ```bash setterm -cursor off @@ -286,13 +281,11 @@ setterm -cursor off setterm -cursor on ``` -参见 setterm 命令手册获取详细信息: +参见 setterm 命令手册获取详细信息:`man setterm` -`man setterm` +### 9、smbclient:给 MS-Windows 工作站发送消息 -### #9:smbclient:给 MS-Windows 工作站发送消息 - -smbclient 命令可以与 SMB/CIFS 服务器通讯。它可以向 MS-Windows 系统上选定或全部用户发送消息。 +`smbclient` 命令可以与 SMB/CIFS 服务器通讯。它可以向 MS-Windows 系统上选定或全部用户发送消息。 ```bash smbclient -M WinXPPro < Date: Tue, 3 Apr 2018 17:50:02 +0800 Subject: [PATCH 0278/1057] PUB: 20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @pygmalion666 首发地址: https://linux.cn/article-9510-1.html ,你的 LCTT 专页: https://linux.cn/lctt/pygmalion666 --- ...10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md (100%) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/published/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md similarity index 100% rename from translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md rename to published/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md From 23c88077e627a9f6af0cecbd09acbc033d38edbd Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 4 Apr 2018 08:49:19 +0800 Subject: [PATCH 0279/1057] translated --- ...ring the Linux filesystem with Tripwire.md | 114 ------------------ ...ring the Linux filesystem with Tripwire.md | 112 +++++++++++++++++ 2 files changed, 112 insertions(+), 114 deletions(-) delete mode 100644 sources/tech/20180118 Securing the Linux filesystem with Tripwire.md create mode 100644 translated/tech/20180118 Securing the Linux filesystem with Tripwire.md diff --git a/sources/tech/20180118 Securing the Linux filesystem with Tripwire.md b/sources/tech/20180118 Securing the Linux filesystem with Tripwire.md deleted file mode 100644 index 7afb8a5183..0000000000 --- a/sources/tech/20180118 Securing the Linux filesystem with Tripwire.md +++ /dev/null @@ -1,114 +0,0 @@ -translating----geekpi - -Securing the Linux filesystem with Tripwire -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/file_system.jpg?itok=pzCrX1Kc) - -While Linux is considered to be the most secure operating system (ahead of Windows and MacOS), it is still vulnerable to rootkits and other variants of malware. Thus, Linux users need to know how to protect their servers or personal computers from destruction, and the first step they need to take is to protect the filesystem. - -In this article, we'll look at [Tripwire][1], an excellent tool for protecting Linux filesystems. Tripwire is an integrity checking tool that enables system administrators, security engineers, and others to detect alterations to system files. Although it's not the only option available ([AIDE][2] and [Samhain][3] offer similar features), Tripwire is arguably the most commonly used integrity checker for Linux system files, and it is available as open source under GPLv2. - -### How Tripwire works - -It's helpful to know how Tripwire operates in order to understand what it does once it's installed. Tripwire is made up of two major components: policy and database. Policy lists all the files and directories that the integrity checker should take a snapshot of, in addition to creating rules for identifying violations of changes to directories and files. Database consists of the snapshot taken by Tripwire. - -Tripwire also has a configuration file, which specifies the locations of the database, policy file, and Tripwire executable. It also provides two cryptographic keys--site key and local key--to protect important files against tampering. The site key protects the policy and configuration files, while the local key protects the database and generated reports. - -Tripwire works by periodically comparing the directories and files against the snapshot in the database and reporting any changes. - -### Installing Tripwire - -In order to use Tripwire, we need to download and install it first. Tripwire works on almost all Linux distributions; you can download an open source version from [Sourceforge][4] and install it as follows, depending on your version of Linux. - -Debian and Ubuntu users can install Tripwire directly from the repository using `apt-get`. Non-root users should type the `sudo` command to install Tripwire via `apt-get`. -``` - - -sudo apt-get update - -sudo  apt-get install tripwire   -``` - -CentOS and other rpm-based distributions use a similar process. For the sake of best practice, update your repository before installing a new package such as Tripwire. The command `yum install epel-release` simply means we want to install extra repositories. (`epel` stands for Extra Packages for Enterprise Linux.) -``` - - -yum update - -yum install epel-release - -yum install tripwire   -``` - -This command causes the installation to run a configuration of packages that are required for Tripwire to function effectively. In addition, it will ask if you want to select passphrases during installation. You can select "Yes" to both prompts. - -Also, select or choose "Yes" if it's required to build the configuration file. Choose and confirm a passphrase for a site key and for a local key. (A complex passphrase such as `Il0ve0pens0urce` is recommended.) - -### Build and initialize Tripwire's database - -Next, initialize the Tripwire database as follows: -``` - - -tripwire --init -``` - -You'll need to provide your local key passphrase to run the commands. - -### Basic integrity checking using Tripwire - -You can use the following command to instruct Tripwire to check whether your files or directories have been modified. Tripwire's ability to compare files and directories against the initial snapshot in the database is based on the rules you created in the active policy. -``` - - -tripwire  --check   -``` - -You can also limit the `-check` command to specific files or directories, such as in this example: -``` - - -tripwire   --check   /usr/tmp   -``` - -In addition, if you need extended help on using Tripwire's `-check` command, this command allows you to consult Tripwire's manual: -``` - - -tripwire  --check  --help   -``` - -### Generating reports using Tripwire - -To easily generate a daily system integrity report, create a `crontab` with this command: -``` - - -crontab -e -``` - -Afterward, you can edit this file (with the text editor of your choice) to introduce tasks to be run by cron. For instance, you can set up a cron job to send Tripwire reports to your email daily at 5:40 a.m. by using this command: -``` - - -40 5  *  *  *  usr/sbin/tripwire   --check -``` - -Whether you decide to use Tripwire or another integrity checker with similar features, the key issue is making sure you have a solution to protect the security of your Linux filesystem. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/securing-linux-filesystem-tripwire - -作者:[Michael Kwaku Aboagye][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/revoks -[1]:https://www.tripwire.com/ -[2]:http://aide.sourceforge.net/ -[3]:http://www.la-samhna.de/samhain/ -[4]:http://sourceforge.net/projects/tripwire diff --git a/translated/tech/20180118 Securing the Linux filesystem with Tripwire.md b/translated/tech/20180118 Securing the Linux filesystem with Tripwire.md new file mode 100644 index 0000000000..8d2f6db004 --- /dev/null +++ b/translated/tech/20180118 Securing the Linux filesystem with Tripwire.md @@ -0,0 +1,112 @@ +使用 Tripwire 保护 Linux 文件系统 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/file_system.jpg?itok=pzCrX1Kc) + +尽管 Linux 被认为是最安全的操作系统(在 Windows 和 MacOS 之前),但它仍然容易受到 rootkit 和其他恶意软件的影响。因此,Linux 用户需要知道如何保护他们的服务器或个人电脑免遭破坏,他们需要采取的第一步就是保护文件系统。 + +在本文中,我们将看看 [Tripwire][1],这是保护 Linux 文件系统的绝佳工具。Tripwire 是一个完整性检查工具,使系统管理员、安全工程师和其他人能够检测系统文件的变更。虽然它不是唯一的选择([AIDE][2] 和 [Samhain][3] 提供类似功能),但 Tripwire 可以说是 Linux 系统文件中最常用的完整性检查程序,并在 GPLv2 许可证下开源。 + +### Tripwire 如何工作 + +了解 Tripwire 如何运行对了解 Tripwire 在安装后会做什么有所帮助。Tripwire 主要由两个部分组成:策略和数据库。策略列出了完整性检查器应该生成快照的所有文件和目录,还创建了用于识别对目录和文件更改违规的规则。数据库由 Tripwire 生成的快照组成。 + +Tripwire 还有一个配置文件,它指定数据库、策略文件和 Tripwire 可执行文件的位置。它还提供两个加密密钥 - 站点密钥和本地密钥 - 以保护重要文件免遭篡改。站点密钥保护策略和配置文件,而本地密钥保护数据库和生成的报告。 + +Tripwire 定期将目录和文件与数据库中的快照进行比较并报告所有的更改。 + +### 安装 Tripwire + +要 Tripwire,我们需要先下载并安装它。Tripwire 适用于几乎所有的 Linux 发行版。你可以从 [Sourceforge][4] 下载一个开源版本,并如下根据你的 Linux 版本进行安装。 + +Debian 和 Ubuntu 用户可以使用 `apt-get` 直接从仓库安装 Tripwire。非 root 用户应该输入 `sudo` 命令通过 `apt-get` 安装 Tripwire。 +``` + + +sudo apt-get update + +sudo  apt-get install tripwire   +``` + +CentOS 和其他基于 rpm 的发行版使用类似的过程。为了最佳实践,请在安装新软件包(如 Tripwire)之前更新仓库。命令 `yum install epel-release` 意思是我们想要安装额外的存储库。 (`epel` 代表 Extra Packages for Enterprise Linux。) +``` + + +yum update + +yum install epel-release + +yum install tripwire   +``` + +此命令会在安装中运行让 Tripwire 有效运行所需的配置。另外,它会在安装过程中询问你是否使用密码。你可以两个选择都选择 “Yes”。 + +另外,如果需要构建配置文件,请选择 “Yes”。选择并确认站点密钥和本地密钥的密码。(建议使用复杂的密码,例如 `Il0ve0pens0urce`。) + +### 建立并初始化 Tripwire 数据库 + +接下来,按照以下步骤初始化 Tripwire 数据库: +``` + + +tripwire --init +``` + +你需要提供本地密钥密码才能运行这些命令。 + +### 使用 Tripwire 进行基本的完整性检查 + +你可以使用以下命令让 Tripwire 检查你的文件或目录是否已被修改。Tripwire 将文件和目录与数据库中的初始快照进行比较的能力依赖于你在活动策略中创建的规则。 +``` + + +tripwire  --check   +``` + +你还可以将 `-check` 命令限制为特定的文件或目录,如下所示: +``` + + +tripwire   --check   /usr/tmp   +``` + +另外,如果你需要使用 Tripwire 的 `-check` 命令的更多帮助,该命令能够查阅 Tripwire 的手册: +``` + + +tripwire  --check  --help   +``` + +### 使用 Tripwire 生成报告 + +要轻松生成每日系统完整性报告,请使用以下命令创建一个 “crontab”: +``` + + +crontab -e +``` + +之后,你可以编辑此文件(使用你选择的文本编辑器)来引入由 cron 运行的任务。例如,你可以使用以下命令设置一个 cron 作业,在每天的 5:40 将 Tripwire 的报告发送到你的邮箱: +``` + + +40 5  *  *  *  usr/sbin/tripwire   --check +``` + +无论你决定使用 Tripwire 还是其他具有类似功能的完整性检查程序,关键问题都是确保你有解决方案来保护 Linux 文件系统的安全。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/securing-linux-filesystem-tripwire + +作者:[Michael Kwaku Aboagye][a] +译者:[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/revoks +[1]:https://www.tripwire.com/ +[2]:http://aide.sourceforge.net/ +[3]:http://www.la-samhna.de/samhain/ +[4]:http://sourceforge.net/projects/tripwire From c276c885fd3dabf75c5885ddd0a3fec42b1a7f47 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 4 Apr 2018 08:51:25 +0800 Subject: [PATCH 0280/1057] translating --- ...28 How To Create-Extend Swap Partition In Linux Using LVM.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md b/sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md index 66d3156bf2..1eabfccb6a 100644 --- a/sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md +++ b/sources/tech/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md @@ -1,3 +1,5 @@ +translating-----geekpi + How To Create/Extend Swap Partition In Linux Using LVM ====== We are using LVM for flexible volume management so, why can’t we use LVM for swap space? From 659e9aacd4659e0a36ecdd319588b112d9ee9653 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 08:54:58 +0800 Subject: [PATCH 0281/1057] PRF:20180110 Why isn-t open source hot among computer science students.md @amwps290 --- ...rce hot among computer science students.md | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/translated/talk/20180110 Why isn-t open source hot among computer science students.md b/translated/talk/20180110 Why isn-t open source hot among computer science students.md index 0a13b52946..aeca417f66 100644 --- a/translated/talk/20180110 Why isn-t open source hot among computer science students.md +++ b/translated/talk/20180110 Why isn-t open source hot among computer science students.md @@ -1,6 +1,7 @@ -# 为什么开源在计算机专业的学生中不那么流行? - +为什么开源在计算机专业的学生中不那么流行? +=============== +> 高中和大学生们或许因先入为主的观念而畏于参与开源项目。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_OSDC_OpenClass_520x292_FINAL_JD.png?itok=ly78pMqu) @@ -8,46 +9,45 @@ 年轻程序员的技术悟性和创造力是充满活力的。 -这一点可以从我参加今年的全球最大的黑客马拉松 [PennApps][1] 时所目睹的他们勤奋的工作中可以看出。我的高中和大学年龄的同龄人创建的项目包括[可以通过眨眼来让不能说话或行动不便的人来交流的设备][2] 到 [带有物联网功能的煎饼机][3] 。在整个过程中,开源的精神是切实可见的,不同群体之间建立了共同的愿望,思想和技术诀窍的自由流通,无畏的实验和快速的原型设计,以及热衷于参与的渴望。 +这一点可以从我参加今年的(美国)国内最大的黑客马拉松 [PennApps][1] 时所目睹的他们勤奋的工作中可以看出。在 48 小时内,我的高中和大学年龄段的同龄人们创建了从[可以通过眨眼来让不能说话或行动不便的人来交流的设备][2] 到 [带有物联网功能的煎饼机][3] 的项目。在整个过程中,开源的精神是切实可见的,不同群体之间建立了共同的愿望,思想和技术诀窍的自由流通,无畏的实验和快速的原型设计,以及热衷于参与的渴望。 -那么我想知道,为什么在我的技术极客同行中,开源并不是一个热门话题? +那么我想知道,为什么在我的这些技术极客伙伴中,开源并不是一个热门话题? -为了更多地了解大学生在听到“开源”时的想法,我调查了几个大学生,他们都是我所属的专业计算机科学组织的成员。这个社区的所有成员都必须在高中或大学期间申请,并根据他们的计算机科学成就和领导能力进行选择——这是否意味着领导一个学校的机器人团队,建立一个非营利组织,将编码带入资金不足的教室中,或其他一些值得努力的地方。鉴于这些个人在计算机科学方面的成就,我认为他们的观点将有助于理解年轻程序员对开源项目的吸引力(或不吸引人)。 +为了更多地了解大学生在听到“开源”时的想法,我调查了几个大学生,他们都是我所属的专业计算机科学团体的成员。这个社团的所有成员都必须在高中或大学期间申请,并根据他们的计算机科学成就和领导能力进行选择——即是否领导过一个学校的机器人团队,建立过将编码带入资金不足的课堂的非营利组织,或其他一些值得努力的地方。鉴于这些个人在计算机科学方面的成就,我认为他们的观点将有助于理解年轻程序员对开源项目的吸引力(或不吸引人)。 我编写和发布的在线调查包括以下问题: * 你喜欢编写个人项目吗?您是否曾经参与过开源项目? * 你觉得自己开发自己的编程项目,还是对现有的开源工作做出贡献会更有益处? - * 你将如何比较为开源软件组织和专有软件的组织编码的声望? + * 你将如何比较为开源软件组织和专有软件的组织编码获得的声望? +尽管绝大多数人表示,他们至少偶尔会喜欢在业余时间编写个人项目,但大多数人从未参与过开源项目。当我进一步探索这一趋势时,一些关于开源项目和组织的常见的偏见逐渐浮出水面。为了说服我的伙伴们,开源项目值得他们花时间,并且为教育工作者和开源组织提供他们对学生的见解,我将谈谈三个首要的偏见。 -尽管绝大多数人表示,他们至少偶尔会喜欢在业余时间编写个人项目,但大多数人从未参与过开源项目。当我进一步探索这一趋势时,一些关于开源项目和组织的常见的偏见逐渐浮出水面。为了说服我的同行们,开源项目值得他们花时间,并且为教育工作者和开源组织提供他们对学生的见解,我将谈谈三个首要的偏见。 +### 偏见 1:从零开始创建个人项目比为现有的开源项目做贡献更好。 -### 偏见1:从零开始创建个人项目比为现有的开源项目做贡献更好。 +在我所调查的大学年龄程序员中,26 人中有 24 人声称,开发自己的个人项目比开源项目更有益。 -在我所调查的大学年龄程序员中,有 26 人中有 24 人声称,开发自己的个人项目比开源项目更有益。 +作为一名计算机科学专业的大一新生,我也相信这一点。我经常听到年长的同学说,个人项目会让我成为更有吸引力的实习生。没有人提到过为开源项目做出贡献的可能性——所以在我看来,这是无关紧要的。 -作为一名计算机科学专业的大一新生,我也相信这一点。我经常听到年长的同行说,个人项目会让我成为更有吸引力的实习生。没有人提到过为开源项目做出贡献的可能性——所以在我看来,这是无关紧要的。 +我现在意识到开源项目为现实世界提供了强大的准备工作。对开源项目的贡献培养了一种意识,即[工具和语言如何拼合在一起][4],而单个项目却不能。而且,开源是一个协调与协作的练习,可以培养[学生的沟通,团队合作和解决问题的专业技能][5]。 -我现在意识到开源项目为现实世界提供了强大的准备。对开源项目的贡献培养了一种意识,即[工具和语言如何拼凑在一起][4],单个项目却不能。而且,开源是一个协调与协作的练习,培养[学生的沟通,团队合作和解决问题的专业技能][5]。 +### 偏见 2:我的编码技能是不够的。 -### 偏见2:我的编码技能是不够的。 +一些受访者表示,他们被开源项目吓倒了,不知道该从哪里开始贡献,或者担心项目进展缓慢。不幸的是,自卑感往往也会对女性程序员产生影响,而这种感觉并不止于开源社区。事实上,“冒名顶替综合症”甚至可能会被放大,因为[开源的倡导者通常会拒绝官僚主义][6] —— 而且和官僚主义一样难以在内部流动,它有助于新加入的人了解他们在一个组织中的位置。 -一些受访者表示,他们被开源项目吓倒了,不知道该从哪里投稿,或者担心项目进展缓慢。不幸的是,自卑感往往会对女性程序员产生影响,而这种感觉并不止于开源社区。事实上,“冒名顶替综合症”甚至可能会被放大,因为[开源的倡导者通常会拒绝官僚主义][6] - 而且和官僚主义一样难以在内部流动,它有助于新加入的人了解他们在一个组织中的位置。 +我还记得第一次在 GitHub 上查看开源项目时,我对阅读贡献指南感到害怕。然而,这些指南并非旨在吓跑别人,而是提供[指导][7]。为此,我认为贡献指南是建立期望而不依赖于等级结构的一种方式。 -我还记得第一次在 GitHub 上查看开源项目时,我对贡献指南感到害怕。然而,指导方针并非旨在鼓励排他性,而是提供[指导][7]。为此,我认为指导方针是建立期望而不依赖于等级结构的一种方式。 +有几个开源项目积极为新的项目贡献者创造了一个地方。[TEAMMATES][8] 是一种教育反馈管理工具,是为初学者们解决了这个问题一个开源项目。在评论中,各种技能水平的程序员都详细阐述了实现的细节,这表明开源项目是属于热切的新程序员和经验丰富的软件老手的地方。对于那些还在犹豫的年轻程序员来说,一些[开源项目][9]已经考虑周全,采用了[冒名顶替综合症的免责声明][10]。 -几个开源项目积极为新的项目贡献者创造了一个地方。[TEAMMATES][8] 是一种教育反馈管理工具,是许多开源项目中的一个,标志着首次出现问题。在评论中,所有技能水平的程序员都详细阐述了实现的细节,表明开源项目是渴望新的程序员和经验丰富的软件老手的地方。对于那些还在犹豫的年轻程序员来说,一些[开源项目][9]已经考虑周全,采用了[冒名顶替综合症的免责声明][10]。 +### 偏见 3:专有软件公司比开源软件组织做得更好。 -### 偏见3:专有软件公司比开源软件组织做得更好。 +在接受调查的 26 位受访者中,只有 5 位认为开源组织和专有软件组织在声望上是平等的。这可能是由于“开源”意味着“无利可图”,因此质量低下的误解(查看 [“开源”不只是意味着是免费][11])。 -在接受调查的 26 位受访者中,只有 5 位认为公开和专有软件组织在声望上是平等的。这可能是由于“开放”意味着“无利可图”,因此质量低下的误解(查看 [“开源”不只是意味着是免费][11])。 +然而,开源软件和盈利软件并不相互排斥。事实上,小型和大型企业通常都为免费的开源软件的技术支持服务而付款。正如[红帽公司首席执行官 Jim Whitehurst][12] 所解释的那样:“我们拥有一批工程团队,负责跟踪 Linux 的每一项变更--错误修复、安全性增强等等,确保我们客户的关键任务系统保持最新状态和稳定“。 -然而,开源软件和盈利软件并不相互排斥。事实上,小型和大型企业通常都支付免费的开源软件来获得技术支持服务。正如[红帽公司首席执行官 Jim Whitehurst ][12]所解释的那样:“我们拥有一批工程团队,负责跟踪Linux的每一项变更--错误修复,安全性增强等等,确保我们客户的关键任务系统保持最新状态和稳定“。 +另外,开源的本质是通过使更多的人能够检查源代码来提升而不是阻碍质量的提高。[Mobify 首席执行官 Igor Faletski][13] 写道,Mobify 的 “25 位软件开发人员和专业的质量保证人员团队无法满足世界上所有可能使用 [Mobify 的开源]平台的软件开发者,而他们每个人都是该项目的潜在测试者或贡献者。” -另外,开放的本质是通过使更多的人能够检查源代码来提升而不是阻碍质量的提高。[Mobify 首席执行官Igor Faletski ][13]写道,Mobify 的25位软件开发人员和专业的质量保证人员“团队”无法与世界上所有可能使用 [Mobify 的开源]平台的软件开发者相匹配,每个人都是该项目的潜在测试者或贡献者“。 - -另一个问题可能是年轻的程序员不知道他们每天使用的开源软件。 我使用了许多工具——包括 MySQL,Eclipse,Atom,Audacity 和 WordPress——几个月甚至几年,却没有意识到它们是开源的。 经常急于下载教学大纲指定软件以完成课堂作业的大学生可能不知道哪个软件是开源的。 这使得开源看起来比现在更加陌生。 +另一个问题可能是年轻的程序员不知道他们每天使用的开源软件。 我使用了许多工具——包括 MySQL、Eclipse、Atom、Audacity 和 WordPress——几个月甚至几年,却没有意识到它们是开源的。 经常急于下载教学大纲指定软件以完成课堂作业的大学生可能不知道哪个软件是开源的。 这使得开源看起来比现在更加陌生。 所以学生们,在尝试之前不要敲开源码。 看看这个[初学者友好的项目][14]列表和这[六个起点][15],开始你的开源之旅。 @@ -58,14 +58,13 @@ Susie Choi - Susie 是杜克大学计算机科学专业的本科生。她对技术革新和开放源码原则对教育和社会经济不平等问题的影响非常感兴趣。 - -------------------------------------------------------------------------------- via: https://opensource.com/article/17/12/students-and-open-source-3-common-preconceptions 作者:[Susie Choi][a] 译者:[amwps290](https://github.com/amwps290) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 442b0adc842e504c6de2b115f1a7e4cdc089a9f5 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 08:55:22 +0800 Subject: [PATCH 0282/1057] PUB:20180110 Why isn-t open source hot among computer science students.md @amwps290 https://linux.cn/article-9511-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 e1a56da9f4c4b624cd2489a4c7821f78cbc3537e Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 09:21:21 +0800 Subject: [PATCH 0283/1057] PRF:20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md @qhwdw --- ...zed Log Server with Rsyslog in Debian 9.md | 169 +++++++++++------- 1 file changed, 100 insertions(+), 69 deletions(-) diff --git a/translated/tech/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md b/translated/tech/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md index fbdafdf977..f13a69acab 100644 --- a/translated/tech/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md +++ b/translated/tech/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md @@ -1,11 +1,11 @@ 在 Debian 9 上使用 Rsyslog 安装一台中央日志服务器 ====== -在 Linux 上,日志文件包含了系统功能的信息,系统管理员经常使用日志来确认机器上的问题所在。日志可以帮助管理员去还原在过去的时间中在系统中发生的事件。一般情况下,Linux 中所有的日志文件都保存在 **/var/log** 目录下。在这个目录中,有几种类型的日志文件保存着各种信息。比如,记录系统事件的日志文件、记录安全相关信息的日志文件、内核专用的日志文件、用户或者 cron 作业使用的日志文件。日志文件的主要作用是为系统调试。Linux 中的大部分的日志文件都由 rsyslogd 服务来管理。在最新的 Linux 发行版中,日志文件也可能是由 journald 系统服务来管理和控制的。journald 服务是 systemd 初始化程序的一部分。日志守护程序保存的日志以二进制的格式、以易失性的方式写入到内存和 /run/log/journal/ 中的 Ring 缓冲区中,但是,日志服务也可以配置为永久存储系统日志信息。 +在 Linux 上,日志文件包含了系统功能的信息,系统管理员经常使用日志来确认机器上的问题所在。日志可以帮助管理员还原在过去的时间中在系统中发生的事件。一般情况下,Linux 中所有的日志文件都保存在 `/var/log` 目录下。在这个目录中,有保存着各种信息的几种类型的日志文件。比如,记录系统事件的日志文件、记录安全相关信息的日志文件、内核专用的日志文件、用户或者 cron 作业使用的日志文件。日志文件的主要作用是系统调试。Linux 中的大部分的日志文件都由 rsyslogd 服务来管理。在最新的 Linux 发行版中,日志文件也可能是由 journald 系统服务来管理和控制的。journald 服务是 systemd 初始化程序的一部分。journald 以二进制的格式存储日志,以易失性的方式写入到内存和 `/run/log/journal/` 中的环状缓冲区中,但是,journald 也可以配置为永久存储到 syslog 中。 -在 Linux 中,可以配置运行一个 Rsyslog 服务器来中央化管理日志,在一个流行的服务端—客户端模式中,通过 TCP 或者 UDP 传输协议基于网络来发送日志信息,或者从网络设备、服务器、路由器、交换机、以及其它系统或嵌入式设备中接受生成的日志。 +在 Linux 中,可以配置运行一个 Rsyslog 服务器来中央化管理日志,在流行的服务端—客户端模式中,通过 TCP 或者 UDP 传输协议基于网络来发送日志信息,或者从网络设备、服务器、路由器、交换机、以及其它系统或嵌入式设备中接受生成的日志。 -Rsyslog 守护程序可以被同时配置为以客户端或者服务端方式运行。配置作为一台服务器时,Rsyslog 将缺省监听TCP 和 UDP 的 514 端口,来收集远程系统基于网络发送的日志信息。配置为客户端运行时,Rsyslog 将通过相同的 TCP 或 UDP 端口基于网络来发送内部日志信息。 +Rsyslog 守护程序可以被同时配置为以客户端或者服务端方式运行。配置作为服务器时,Rsyslog 将缺省监听 TCP 和 UDP 的 514 端口,来收集远程系统基于网络发送的日志信息。配置为客户端运行时,Rsyslog 将通过相同的 TCP 或 UDP 端口基于网络来发送内部日志信息。 Rsyslog 可以根据选定的属性和动作来过滤 syslog 信息。Rsyslog 拥有的过滤器如下: @@ -13,36 +13,30 @@ Rsyslog 可以根据选定的属性和动作来过滤 syslog 信息。Rsyslog 2. 基于特性的过滤器 3. 基于表达式的过滤器 +设备过滤器代表了生成日志的 Linux 内部子系统。它们目前的分类如下: + * `auth/authpriv` = 由验证进程产生的信息 + * `cron` = cron 任务相关的日志 + * `daemon` = 正在运行的系统服务相关的信息 + * `kernel` = Linux 内核信息 + * `mail` = 邮件服务器信息 + * `syslog` = syslog 或者其它守护程序(DHCP 服务器发送的日志在这里)相关的信息 + * `lpr` = 打印机或者打印服务器信息 + * `local0` ~ `local7` = 管理员控制下的自定义信息 - **设备** 过滤器代表了生成日志的 Linux 内部子系统。它们目前的分类如下: +优先级或者严重程度级别分配如下所述的一个关键字或者一个数字。 - * **auth/authpriv** = 由验证进程产生的信息 - * **cron** = cron 任务相关的日志 - * **daemon** = 正在运行的系统服务相关的信息 - * **kernel** = Linux 内核信息 - * **mail** = 邮件服务器信息 - * **syslog** = syslog 或者其它守护程序(DHCP 服务器发送的日志在这里)相关的信息 - * **lpr** = 打印机或者打印服务器信息 - * **local0 - local7** = 管理员控制下的自定义信息 + * `emerg` = 紧急 - 0 + * `alert` = 警报 - 1 + * `err` = 错误 - 3 + * `warn` = 警告 - 4 + * `notice` = 提示 - 5 + * `info` = 信息 - 6 + * `debug` = 调试 - 7 (最高级别) +此外也有一些 Rsyslog 专用的关键字,比如星号(`*`)可以用来定义所有的设备和优先级,`none` 关键字更具体地表示没有优先级,等号(`=`)表示仅那个优先级,感叹号(`!`)表示取消这个优先级。 - - **优先级或者严重程度** 级别分配如下所述的一个关键字或者一个数字。 - - * **emerg** = 紧急 - 0 - * **alert** = 警报 - 1 - * **err** = 错误 - 3 - * **warn** = 警告 - 4 - * **notice** = 提示 - 5 - * **info** = 信息 - 6 - * **debug** = 调试 - 7 最高级别 - - - -也有一个 Rsyslog 专用的关键字,比如星号(*)可以用来定义所有的设备和优先级,**none** 关键字更具体地表示没有优先级,等号(=)表示仅那个优先级,感叹号(!)表示取消这个优先级。 - -Rsyslog 的动作部分由声明的 **目的地** 来表示。日志信息的目的地可以存储在文件系统中 /var/log/ 目录下的一个文件中,通过命名管道或者 FIFO 作为另一个本地进程的输入。日志信息也可以直达用户,或者丢弃到一个“黑洞”(/dev/null)中、或者发送到标准输出、或者通过一个 TCP/UDP 协议发送到一个远程 syslog 服务器。日志信息也可以保存在一个数据库中,比如 MySQL 或者 PostgreSQL。 +Rsyslog 的动作部分由声明的目的地来表示。日志信息的目的地可以是:存储在文件系统中的一个文件、 `/var/log/` 目录下的一个文件、通过命名管道或者 FIFO 作为输入的另一个本地进程。日志信息也可以直达用户,或者丢弃到一个“黑洞”(`/dev/null`)中、或者发送到标准输出、或者通过一个 TCP/UDP 协议发送到一个远程 syslog 服务器。日志信息也可以保存在一个数据库中,比如 MySQL 或者 PostgreSQL。 ### 配置 Rsyslog 为服务器 @@ -50,60 +44,86 @@ Rsyslog 的动作部分由声明的 **目的地** 来表示。日志信息的目 在基于 Debian 的发行版中: -`sudo apt-get install rsyslog` +``` +sudo apt-get install rsyslog +``` 在基于 RHEL 的发行版中,比如像 CentOS: -`sudo yum install rsyslog` +``` +sudo yum install rsyslog +``` 验证 Rsyslog 守护进程是否在你的系统中运行,根据发行版不同,可以选择运行下列的命令: 在新的使用 systemd 的 Linux 发行版中: -`systemctl status rsyslog.service` +``` +systemctl status rsyslog.service +``` 在老的使用 init 的 Linux 发行版中: -`service rsyslog status` +``` +service rsyslog status +``` -`/etc/init.d/rsyslog status` +或 + +``` +/etc/init.d/rsyslog status +``` 启动 rsyslog 守护进程运行如下的命令。 在使用 init 的老的 Linux 版本: -`service rsyslog start` +``` +service rsyslog start +``` -`/etc/init.d/rsyslog start` +或 + +``` +/etc/init.d/rsyslog start +``` 在最新的 Linux 发行版: -`systemctl start rsyslog.service` +``` +systemctl start rsyslog.service +``` -安装一个 rsyslog 程序运行为服务器模式,可以编辑主要的配置文件 **/etc/rsyslog.conf** 。可以使用下列所示的命令去改变它。 +安装一个 rsyslog 程序运行为服务器模式,可以编辑主要的配置文件 `/etc/rsyslog.conf` 。可以使用下列所示的命令去改变它。 -`sudo vi /etc/rsyslog.conf` +``` +sudo vi /etc/rsyslog.conf +``` + +为了允许在 UDP 的 514 端口上接收日志信息,找到并删除下列行前面的井号(`#`)以取消注释。缺省情况下,UDP 端口用于 syslog 去接收信息。 -为允许在 UDP 的 514 端口上接收日志信息,找到并删除下列行前面的井号(#)以取消注释。缺省情况下,UDP 端口用于 syslog 去接收信息。 ``` $ModLoad imudp $UDPServerRun 514 ``` -因为在网络上使用 UDP 协议交换数据并不可靠,你可以设置 Rsyslog 使用 TCP 协议去向远程服务器输出日志信息。为启用 TCP 协议去接受日志信息,打开 **/etc/rsyslog.conf** 文件并删除如下行前面的井号(#)以取消注释。这将允许 rsyslog 守护程序去绑定并监听 TCP 协议的 514 端口。 +因为在网络上使用 UDP 协议交换数据并不可靠,你可以设置 Rsyslog 使用 TCP 协议去向远程服务器输出日志信息。为了启用 TCP 协议去接受日志信息,打开 `/etc/rsyslog.conf` 文件并删除如下行前面的井号(`#`)以取消注释。这将允许 rsyslog 守护程序去绑定并监听 TCP 协议的 514 端口。 + ``` $ModLoad imtcp - $InputTCPServerRun 514 **** +$InputTCPServerRun 514 ``` _在 rsyslog 上可以**同时**启用两种协议_。 -如果你想去指定那个发送者被允许访问 rsyslog 守护程序,可以在启用协议行的后面添加如下的行: +如果你想去指定哪个发送者被允许访问 rsyslog 守护程序,可以在启用协议行的后面添加如下的行: + ``` $AllowedSender TCP, 127.0.0.1, 10.110.50.0/24, *.yourdomain.com ``` -在接收入站日志信息之前,你需要去创建一个 rsyslog 守护程序解析日志的新模板,这个模板将指示本地 Rsyslog 服务器在哪里保存入站的日志信息。在 **$AllowedSender** 行后以如下示例去创建一个合适的模板。 +在接收入站日志信息之前,你需要去创建一个 rsyslog 守护程序解析日志的新模板,这个模板将指示本地 Rsyslog 服务器在哪里保存入站的日志信息。在 `$AllowedSender` 行后以如下示例去创建一个合适的模板。 + ``` $template Incoming-logs,"/var/log/%HOSTNAME%/%PROGRAMNAME%.log"  *.*  ?Incoming-logs @@ -116,20 +136,22 @@ $template Incoming-logs,"/var/log/%HOSTNAME%/%PROGRAMNAME%.log"  kern.*   ?Incoming-logs ``` -接收到的日志由上面的模板来解析,它将保存在本地文件系统的 /var/log/ 目录的文件中,之后的是以客户端主机名客户端设备名命名的日志文件名字:%HOSTNAME% 和 %PROGRAMNAME% 变量。 +接收到的日志由上面的模板来解析,它将保存在本地文件系统的 `/var/log/` 目录的文件中,之后的是以客户端主机名客户端设备名命名的日志文件名字:`%HOSTNAME%` 和 `%PROGRAMNAME%` 变量。 -下面的 **& ~** 重定向规则,配置 Rsyslog 守护程序去保存入站日志信息到由上面的变量名字指定的文件中。否则,接收到的日志信息将被进一步处理,并将保存在本地的日志文件中,比如,/var/log/syslog 文件中。 +下面的 `& ~` 重定向规则,配置 Rsyslog 守护程序去保存入站日志信息到由上面的变量名字指定的文件中。否则,接收到的日志信息将被进一步处理,并将保存在本地的日志文件中,比如,`/var/log/syslog` 文件中。 为添加一个规则去丢弃所有与邮件相关的日志信息,你可以使用下列的语法。 + ``` mail.* ~ ``` -可以在输出文件名中使用的其它变量还有:%syslogseverity%、%syslogfacility%、%timegenerated%、%HOSTNAME%、%syslogtag%、%msg%、%FROMHOST-IP%、%PRI%、%MSGID%、%APP-NAME%、%TIMESTAMP%、%\$year%、%\$month%、%\$day%。 +可以在输出文件名中使用的其它变量还有:`%syslogseverity%`、`%syslogfacility%`、`%timegenerated%`、`%HOSTNAME%`、`%syslogtag%`、`%msg%`、`%FROMHOST-IP%`、`%PRI%`、`%MSGID%`、`%APP-NAME%`、`%TIMESTAMP%`、%$year%、`%$month%`、`%$day%`。 -以版本 7 启动的 Rsyslog,将使用一个新的配置格式,在一个 Rsyslog 服务器中声明一个模板。 +从 Rsyslog 版本 7 开始,将使用一个新的配置格式,在一个 Rsyslog 服务器中声明一个模板。 一个版本 7 的模板应该看起来是如下行的样子。 + ``` template(name="MyTemplate" type="string"          string="/var/log/%FROMHOST-IP%/%PROGRAMNAME:::secpath-replace%.log" @@ -145,65 +167,74 @@ template(name="MyTemplate" type="list") {     constant(value="/")     property(name="programname" SecurePath="replace")     constant(value=".log") -    } ** -** +    } ``` 为了让 Rsyslog 配置文件的变化生效,你必须重启守护程序来加载新的配置。 -`sudo service rsyslog restart` +``` +sudo service rsyslog restart +``` -`sudo systemctl restart rsyslog` +``` +sudo systemctl restart rsyslog +``` -在一个 Debian 的 Linux 系统上去检查它监听哪个套接字,你可以用 root 权限去运行 **netstat** 命令。将输出传递给一个过滤程序,比如 **grep**。 +在 Debian Linux 系统上去检查它监听哪个套接字,你可以用 root 权限去运行 `netstat` 命令。将输出传递给一个过滤程序,比如 `grep`。 -`sudo netstat -tulpn | grep rsyslog` +``` +sudo netstat -tulpn | grep rsyslog +``` -**请注意:** 为了允许建立入站连接,你必须在防火墙上打开 Rsyslog 的端口。 +请注意: 为了允许建立入站连接,你必须在防火墙上打开 Rsyslog 的端口。 在使用 Firewalld 的基于 RHEL 的发行版上,运行如下的命令: -`firewall-cmd --permanent --add-port=514/tcp` - -`firewall-cmd --permanent --add-port=514/tcp` - -`firewall-cmd -reload` +``` +firewall-cmd --permanent --add-port=514/tcp +firewall-cmd --permanent --add-port=514/tcp +firewall-cmd -reload +``` 在使用 UFW 的基于 Debian 的发行版上,运行如下的命令: -`ufw allow 514/tcp` - -`ufw allow 514/udp` +``` +ufw allow 514/tcp +ufw allow 514/udp +``` Iptables 防火墙规则: -`iptables -A INPUT -p tcp -m tcp --dport 514 -j ACCEPT` - -`iptables -A INPUT -p udp --dport 514 -j ACCEPT` +``` +iptables -A INPUT -p tcp -m tcp --dport 514 -j ACCEPT +iptables -A INPUT -p udp --dport 514 -j ACCEPT +``` ### 配置 Rsyslog 作为一个客户端 -启用 Rsyslog 守护程序以客户端模式运行,并将输出的本地日志信息发送到远程 Rsyslog 服务器,编辑 **/etc/rsyslog.conf** 文件并增加下列的行: +启用 Rsyslog 守护程序以客户端模式运行,并将输出的本地日志信息发送到远程 Rsyslog 服务器,编辑 `/etc/rsyslog.conf` 文件并增加下列的行: ``` *. * @IP_REMOTE_RSYSLOG_SERVER:514 - *. * @FQDN_RSYSLOG_SERVER:514 ``` 这个行启用了 Rsyslog 服务,并将输出的所有内部日志发送到一个远处的 UDP 的 514 端口上运行的 Rsyslog 服务器上。 为了使用 TCP 协议去发送日志信息,使用下列的模板: + ``` *. *  @@IP_reomte_syslog_server:514 ``` 输出所有优先级的、仅与 cron 相关的日志信息到一个 Rsyslog 服务器上,使用如下的模板: + ``` cron.* @ IP_reomte_syslog_server:514 ``` -在 /etc/rsyslog.conf 文件中添加下列行,可以在 Rsyslog 服务器无法通过网络访问时,临时将客户端的日志信息存储在它的一个磁盘缓冲文件中,当网络或者服务器恢复时,再次进行发送。 +在 `/etc/rsyslog.conf` 文件中添加下列行,可以在 Rsyslog 服务器无法通过网络访问时,临时将客户端的日志信息存储在它的一个磁盘缓冲文件中,当网络或者服务器恢复时,再次进行发送。 + ``` $ActionQueueFileName queue $ActionQueueMaxDiskSpace 1g @@ -220,7 +251,7 @@ via: https://www.howtoforge.com/tutorial/rsyslog-centralized-log-server-in-debia 作者:[Matt Vas][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 e7fdfd483f081089643c9ad5079b9ca4f41bde5f Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 09:21:41 +0800 Subject: [PATCH 0284/1057] PUB:20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md @qhwdw https://linux.cn/article-9512-1.html --- ...8 Install a Centralized Log Server with Rsyslog in Debian 9.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md (100%) diff --git a/translated/tech/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md b/published/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md similarity index 100% rename from translated/tech/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md rename to published/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md From 8a081754877b6783465f5cd00a2859e9dd333678 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 09:28:38 +0800 Subject: [PATCH 0285/1057] PRF&PUB:20180110 Why isn-t open source hot among computer science students.md @amwps290 --- ...0 Why isn-t open source hot among computer science students.md | 0 .../talk}/20180220 How slowing down made me a better leader.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180110 Why isn-t open source hot among computer science students.md (100%) rename {published => translated/talk}/20180220 How slowing down made me a better leader.md (100%) diff --git a/translated/talk/20180110 Why isn-t open source hot among computer science students.md b/published/20180110 Why isn-t open source hot among computer science students.md similarity index 100% rename from translated/talk/20180110 Why isn-t open source hot among computer science students.md rename to published/20180110 Why isn-t open source hot among computer science students.md diff --git a/published/20180220 How slowing down made me a better leader.md b/translated/talk/20180220 How slowing down made me a better leader.md similarity index 100% rename from published/20180220 How slowing down made me a better leader.md rename to translated/talk/20180220 How slowing down made me a better leader.md From 6b2ce885a785c9ace8e855c4f68c6bed16363050 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Wed, 4 Apr 2018 12:09:26 +0800 Subject: [PATCH 0286/1057] How to add network bridge with nmcli (NetworkManager) on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完毕 --- ...add network bridge with nmcli (NetworkManager) on Linux.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {sources => translated}/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md (97%) diff --git a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md similarity index 97% rename from sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md rename to translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md index 3836598a93..73aa31afe5 100644 --- a/sources/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md +++ b/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md @@ -31,7 +31,7 @@ nmcli con add type bridge-slave ifname eno1 master br0 nmcli con up br0 ``` -让我们从细节层面看看如何创建一个叫br0的网桥。 +让我们从细节层面看看如何创建一个名为br0的网桥。 ### 获取当前网络配置 @@ -45,7 +45,7 @@ $ nmcli connection show --active ``` [![View the connections with nmcli][2]][2] -我有一个使用eno1网卡的“有线连接”。我的系统还有一个VPN接口。我将要创建一个名为br0的网桥,并连接到eno1. +我有一个使用网卡eno1的“有线连接”。我的系统还有一个VPN接口。我将要创建一个名为br0的网桥,并连接到eno1. ### 如何创建一个名为br0的网桥 From 6c2aa2b27d068f9414423b3e23b09e261438d88f Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Wed, 4 Apr 2018 12:09:57 +0800 Subject: [PATCH 0287/1057] Update 20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完毕 --- ...to add network bridge with nmcli (NetworkManager) on Linux.md | 1 - 1 file changed, 1 deletion(-) diff --git a/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md index 73aa31afe5..2004d4f25c 100644 --- a/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md +++ b/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md @@ -1,4 +1,3 @@ -Translating by kennethXia 如何在Linux里使用nmcli (NetworkManager) 添加网桥 ====== From 41c55c760093db8fc253cd6d39941bb387ad1574 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 20:28:18 +0800 Subject: [PATCH 0288/1057] PRF:20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @kennethXia 恭喜你完成了第一篇翻译!格式上再稍微注意就好了。 --- ...ge with nmcli (NetworkManager) on Linux.md | 77 +++++++++++-------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md index 2004d4f25c..ba63c49894 100644 --- a/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md +++ b/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md @@ -1,67 +1,73 @@ - -如何在Linux里使用nmcli (NetworkManager) 添加网桥 +如何在 Linux 里使用 nmcli 添加网桥 ====== -我正在电脑上使用Debian Linux 9 “stretch”。 我想用NetworkManager 来建网桥。但是根本就没有添加br0的选项。我该如何在Linux里使用nmcli 来为 NetworkManager 创建或者添加网桥呢? +Q:我正在电脑上使用 Debian Linux 9 “stretch”。 我想用 NetworkManager 来建网桥。但是根本就没有添加 br0的选项。我该如何在 Linux 里使用 nmcli 来为 NetworkManager 创建或者添加网桥呢? -网桥没什么特别的,只是把两个网络连在一起。它工作在数据链路层,例如OSI模型的第二层。网桥经常被虚拟机和别的一些软件使用。为了使用网桥而关闭桌面Linux上的NetworkManager 显然是不明智的。nmcli可以创建一个永久的网桥而不编辑任何文件。**本文将展示如何使用NetworkManager 的命令行工具nmcli来创建网桥。** +网桥没什么特别的,只是把两个网络连在一起。它工作在数据链路层,即 OSI 模型的第二层。网桥经常用在虚拟机或别的一些软件中。为了使用网桥而关闭桌面 Linux 上的 NetworkManager 显然是不明智的。`nmcli` 可以创建一个永久的网桥而不需要编辑任何文件。 +本文将展示如何使用 NetworkManager 的命令行工具 `nmcli` 来创建网桥。 +### 如何使用 nmcli 来创建/添加网桥 -### 如何使用nmcli来创建/添加网桥 +使用 NetworkManager 在 Linux 上添加网桥接口的步骤如下: -使用NetworkManager 在Linux上添加网桥接口的步骤如下: - -1. 打开terminal +1. 打开终端 2. 获取当前连接状态: ``` nmcli con show ``` -3. 添加新的网桥: +3. 添加新的网桥: ``` nmcli con add type bridge ifname br0 ``` -4. 创建子网卡: +4. 创建子网卡: ``` nmcli con add type bridge-slave ifname eno1 master br0 ``` -5. 打开br0: +5. 打开 br0: ``` nmcli con up br0 ``` -让我们从细节层面看看如何创建一个名为br0的网桥。 +让我们从细节层面看看如何创建一个名为 br0 的网桥。 ### 获取当前网络配置 -你可以通过NetworkManager的GUI来了解本机的网络连接: +你可以通过 NetworkManager 的 GUI 来了解本机的网络连接: + [![Getting Network Info on Linux][1]][1] -也可以使用如下命令行来查看: +也可以使用如下命令行来查看: + ``` $ nmcli con show $ nmcli connection show --active ``` + [![View the connections with nmcli][2]][2] -我有一个使用网卡eno1的“有线连接”。我的系统还有一个VPN接口。我将要创建一个名为br0的网桥,并连接到eno1. +我有一个使用网卡 `eno1` 的 “有线连接”。我的系统还有一个 VPN 接口。我将要创建一个名为 `br0` 的网桥,并连接到 `eno1`。 -### 如何创建一个名为br0的网桥 +### 如何创建一个名为 br0 的网桥 ``` $ sudo nmcli con add ifname br0 type bridge con-name br0 $ sudo nmcli con add type bridge-slave ifname eno1 master br0 $ nmcli connection show ``` + [![Create bridge interface using nmcli on Linux][3]][3] -你也可以禁用STP: +你也可以禁用 STP: + ``` $ sudo nmcli con modify br0 bridge.stp no $ nmcli con show $ nmcli -f bridge con show br0 ``` -最后一条命令展示了禁用STP后的网桥参数: + +最后一条命令展示了禁用 STP 后的网桥参数: + ``` bridge.mac-address: -- bridge.stp: no @@ -73,27 +79,35 @@ bridge.ageing-time: 300 bridge.multicast-snooping: yes ``` - ### 如何打开网桥 -你必须先关闭"Wired connection 1" ,然后打开br0: +你必须先关闭 `Wired connection 1` ,然后打开 `br0`: + ``` $ sudo nmcli con down "Wired connection 1" $ sudo nmcli con up br0 $ nmcli con show ``` -使用 [ip 命令][4] 来查看IP信息: + +使用 [ip 命令][4] 来查看 IP 信息: + ``` $ ip a s $ ip a s br0 ``` + [![Build a network bridge with nmcli on Linux][5]][5] -### 附录: 如何在KVM上使用br0 +### 附录: 如何在 KVM 上使用 br0 + +现在你可以使用 KVM/VirtualBox/VMware workstation 创建的 VM(虚拟机)来直接连接网络而非通过 NAT。使用 `vi` 或者 [cat 命令][6]为虚拟机创建一个名为 `br0.xml` 的文件: + +``` +$ cat /tmp/br0.xml +``` + +添加以下代码: -现在你可以使用KVM/VirtualBox/VMware workstation创建的VM(虚拟机)来直接连接网络而非通过NAT。使用vi或者cat命令[cat command][6]为虚拟机创建一个名为br0.xml的文件: -`$ cat /tmp/br0.xml` -添加以下代码: ``` br0 @@ -102,14 +116,17 @@ $ ip a s br0 ``` -如下所示运行virsh命令: +如下所示运行 `virsh`命令: + ``` # virsh net-define /tmp/br0.xml # virsh net-start br0 # virsh net-autostart br0 # virsh net-list --all ``` -输出: + +输出: + ``` Name State Autostart Persistent ---------------------------------------------------------- @@ -117,8 +134,8 @@ $ ip a s br0 default inactive no yes ``` +阅读 man 页面获取更多信息: -阅读man页面获取更多信息: ``` $ man ip $ man nmcli @@ -126,7 +143,7 @@ $ man nmcli ### 关于作者 -作者是nixCraft的创建者,老练的系统管理员和一个Linux/Unix shell脚本编程培训师。他为全球客户和各种公司工作,包括IT,教育,国防,空间研究以及非营利组织。 他的联系方式[Twitter][7], [Facebook][8], [Google+][9]. +作者是 nixCraft 的创建者、老练的系统管理员和一个 Linux/Unix shell 脚本编程培训师。他为全球客户和各种公司工作,包括 IT,教育,国防,空间研究以及非营利组织。 他的联系方式 [Twitter][7]、 [Facebook][8]、 [Google+][9]。 -------------------------------------------------------------------------------- @@ -134,7 +151,7 @@ via: https://www.cyberciti.biz/faq/how-to-add-network-bridge-with-nmcli-networkm 作者:[Vivek Gite][a] 译者:[kennethXia](https://github.com/kennethXia) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 29c42a6d033433886ef90ad9e347c18993347291 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 20:29:18 +0800 Subject: [PATCH 0289/1057] PUB: 20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @kennethXia 首发地址: https://linux.cn/article-9513-1.html 您的 LCTT 专页地址: https://linux.cn/lctt/kennethXia --- ... to add network bridge with nmcli (NetworkManager) on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md (100%) diff --git a/translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/published/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md similarity index 100% rename from translated/tech/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md rename to published/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md From 2a5d378f6acaf8b1beb988d2c201966f8ff6452f Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 20:49:08 +0800 Subject: [PATCH 0290/1057] PRF:20171219 How to generate webpages using CGI scripts.md @ucasFL --- ... to generate webpages using CGI scripts.md | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/translated/tech/20171219 How to generate webpages using CGI scripts.md b/translated/tech/20171219 How to generate webpages using CGI scripts.md index 47d424303a..f8a7861716 100644 --- a/translated/tech/20171219 How to generate webpages using CGI scripts.md +++ b/translated/tech/20171219 How to generate webpages using CGI scripts.md @@ -1,28 +1,33 @@ 如何使用 CGI 脚本生成网页 ====== -回到互联网的开端,当我第一次创建了我的第一个商业网站,生活是无比的美好。 +> 通用网关接口(CGI)提供了使用任何语言生成动态网站的简易方法。 -我安装 Apache 并写了一些简单的 HTML 网页,网页上列出了一些关于我的业务的重要信息,比如产品概览以及如何联系我。这是一个静态网站,因为内容很少改变。由于网站的内容很少改变这一性质,因此维护起来也很简单。 +回到互联网的开端,当我第一次创建了我的第一个商业网站,生活是如此的美好。 -## 静态内容 +我安装 Apache 并写了一些简单的 HTML 网页,网页上列出了一些关于我的业务的重要信息,比如产品概览以及如何联系我。这是一个静态网站,因为内容很少改变。由于网站的内容很少发生改变这一性质,因此维护起来也很简单。 -静态内容很简单,同时也很常见。让我们快速的浏览一些静态网页的例子。你不需要一个可运行网站来执行这些小实验,只需要把这些文件放到 home 目录,然后使用浏览器打开。你所看到的内容将和通过 web 服务器提供这一文件看到的内容一样。 +### 静态内容 + +静态内容很简单,同时也很常见。让我们快速的浏览一些静态网页的例子。你不需要一个可运行网站来执行这些小实验,只需要把这些文件放到家目录,然后使用浏览器打开。你所看到的内容将和通过 Web 服务器提供这一文件看到的内容一样。 + +对于一个静态网站,你需要的第一件东西就是 `index.html` 文件,该文件通常放置在 `/var/www/html` 目录下。这个文件的内容可以非常简单,比如可以是像 “Hello, world” 这样一句短文本,没有任何 HTML 标记。它将简单的展示文本串内容。在你的家目录创建 `index.html` 文件,并添加 “hello, world” 作为内容(不需要引号)。在浏览器中通过下面的链接来打开这一文件: -对于一个静态网站,你需要的第一件东西就是 index.html 文件,该文件通常放置在 `/var/www/html` 目录下。这个文件的内容可以非常简单,比如可以是像 "Hello, world" 这样一句短文本,没有任何 HTML 标记。它将简单的展示文本串内容。在你的 home 目录创建 index.html 文件,并添加 "hello, world" 作为内容(不需要引号)。在浏览器中通过下面的链接来打开这一文件: ``` -file:///home//index.html +file:///home/<你的家目录>/index.html ``` 所以 HTML 不是必须的,但是,如果你有大量需要格式化的文本,那么,不用 HTML 编码的网页的结果将会令人难以理解。 所以,下一步就是通过使用一些 HTML 编码来提供格式化,从而使内容更加可读。下面这一命令创建了一个具有 HTML 静态网页所需要的绝对最小标记的页面。你也可以使用你最喜欢的编辑器来创建这一内容。 + ``` echo "

Hello World

" > test1.html ``` -现在,再次查看 index.html 文件,将会看到和刚才有些不同。 +现在,再次查看 `index.html` 文件,将会看到和刚才有些不同。 + +当然,你可以在实际的内容行上添加大量的 HTML 标记,以形成更加完整和标准的网页。下面展示的是更加完整的版本,尽管在浏览器中会看到同样的内容,但这也为更加标准化的网站奠定了基础。继续在 `index.html` 中写入这些内容并通过浏览器查看。 -当然,你可以在实际的内容行上添加大量的 HTML 标记,以形成更加完整和标准的网页。下面展示的是更加完整的版本,尽管在浏览器中会看到同样的内容,但这也为更加标准化的网站奠定了基础。继续在 index.html 中写入这些内容并通过浏览器查看。 ``` @@ -37,24 +42,25 @@ echo "

Hello World

" > test1.html 我使用这些技术搭建了一些静态网站,但我的生活正在改变。 -## 动态网页 +### 动态网页 -我找了一份新工作,这份工作的主要任务就是创建并维护用于一个动态网站的 CGI([公共网关接口][6])代码。字面意思来看,动态意味着在浏览器中生成的网页所需要的 HTML 是由每次访问页面时所访问到的数据生成的。这些数据包括网页表格中的用户输入,以用来在数据库中进行数据查找,结果数据被一些恰当的 HTML 包围着并展示在所请求的浏览器中。但是这不需要非常复杂。 +我找了一份新工作,这份工作的主要任务就是创建并维护用于一个动态网站的 CGI([公共网关接口][6]Common Gateway InterfaceM)代码。字面意思来看,动态意味着在浏览器中生成的网页所需要的 HTML 是由每次访问页面时不同的数据所生成的。这些数据包括网页表单中的用户输入,以用来在数据库中进行数据查找,结果数据被一些恰当的 HTML 包围着并展示在所请求的浏览器中。但是这不需要非常复杂。 通过使用 CGI 脚本,你可以创建一些简单或复杂的交互式程序,通过运行这些程序能够生成基于输入、计算、服务器的当前条件等改变的动态页面。有许多种语言可以用来写 CGI 脚本,在这篇文章中,我将谈到的是 Perl 和 Bash ,其他非常受欢迎的 CGI 语言包括 PHP 和 Python 。 -这篇文章不会介绍 Apache 或其他任何 web 服务器的安装和配置。如果你能够访问一个你可以进行实验的 web 服务器,那么你可以直接查看它们在浏览器中出现的结果。否则,你可以在命令行中运行程序来查看它们所创建的 HTML 文本。你也可以重定向 HTML 输出到一个文件中,然后通过浏览器查看结果文件。 +这篇文章不会介绍 Apache 或其他任何 web 服务器的安装和配置。如果你能够访问一个你可以进行实验的 Web 服务器,那么你可以直接查看它们在浏览器中出现的结果。否则,你可以在命令行中运行程序来查看它们所创建的 HTML 文本。你也可以重定向 HTML 输出到一个文件中,然后通过浏览器查看结果文件。 ### 使用 Perl Perl 是一门非常受欢迎的 CGI 脚本语言,它的优势是强大的文本操作能力。 -为了使 CGI 脚本可执行,你需要在你的网站的 httpd.conf 中添加下面这行内容。这会告诉服务器可执行 CGI 文件的位置。在这次实验中,不必担心这个问题。 +为了使 CGI 脚本可执行,你需要在你的网站的 `httpd.conf` 中添加下面这行内容。这会告诉服务器可执行 CGI 文件的位置。在这次实验中,不必担心这个问题。 + ``` ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" ``` -把下面的 Perl 代码添加到文件 index.cgi,在这次实验中,这个文件应该放在你的 home 目录下。如果你使用 web 服务器,那么应把文件的所有者更改为 apache.apache,同时将文件权限设置为 755,因为无论位于哪,它必须是可执行的。 +把下面的 Perl 代码添加到文件 `index.cgi`,在这次实验中,这个文件应该放在你的家目录下。如果你使用 Web 服务器,那么应把文件的所有者更改为 `apache.apache`,同时将文件权限设置为 755,因为无论位于哪,它必须是可执行的。 ``` #!/usr/bin/perl @@ -67,11 +73,11 @@ print "\n"; 在命令行中运行这个程序并查看结果,它将会展示出它所生成的 HTML 内容 -现在,在浏览器中查看 index.cgi 文件,你所看到的只是文件的内容。浏览器的确将它看做 CGI 内容,但是,Apache 不知道需要将这个文件作为 CGI 程序运行,除非 Apache 的配置中包括上面所展示的 "ScriptAlias" 定义。没有这一配置,Apache 只会简单地将文件中的数据发送给浏览器。如果你能够访问 web 服务器,那么你可以将可执行文件放到 `/var/www/cgi-bin` 目录下。 +现在,在浏览器中查看 `index.cgi` 文件,你所看到的只是文件的内容。浏览器需要将它看做 CGI 内容,但是,Apache 不知道需要将这个文件作为 CGI 程序运行,除非 Apache 的配置中包括上面所展示的 `ScriptAlias` 定义。没有这一配置,Apache 只会简单地将文件中的数据发送给浏览器。如果你能够访问 Web 服务器,那么你可以将可执行文件放到 `/var/www/cgi-bin` 目录下。 如果想知道这个脚本的运行结果在浏览器中长什么样,那么,重新运行程序并把输出重定向到一个新文件,名字可以是任何你想要的。然后使用浏览器来查看这一文件,它包含了脚本所生成的内容。 -上面这个 CGI 程序依旧生成静态内容,因为它总是生成相同的输出。把下面这行内容添加到 CGI 程序中 "Hello, world" 这一行后面。Perl 的 "system" 命令将会执行跟在它后面的 shell 命令,并把结果返回给程序。此时,我们将会通过 `free` 命令获得当前的 RAM 使用量。 +上面这个 CGI 程序依旧生成静态内容,因为它总是生成相同的输出。把下面这行内容添加到 CGI 程序中 “Hello, world” 这一行后面。Perl 的 `system` 命令将会执行跟在它后面的 shell 命令,并把结果返回给程序。此时,我们将会通过 `free` 命令获得当前的内存使用量。 ``` system "free | grep Mem\n"; @@ -83,7 +89,7 @@ system "free | grep Mem\n"; Bash 可能是用于 CGI 脚本中最简单的语言。用 Bash 来进行 CGI 编程的最大优势是它能够直接访问所有的标准 GNU 工具和系统程序。 -把已经存在的 index.cgi 文件重命名为 Perl.index.cgi ,然后创建一个新的 index.cgi 文件并添加下面这些内容。记得设置权限使它可执行。 +把已经存在的 `index.cgi` 文件重命名为 `Perl.index.cgi`,然后创建一个新的 `index.cgi 文件并添加下面这些内容。记得设置权限使它可执行。 ``` #!/bin/bash @@ -105,7 +111,7 @@ exit 0 在命令行中执行这个文件并查看输出,然后再次运行并把结果重定向到一个临时结果文件中。然后,刷新浏览器查看它所展示的网页是什么样子。 -## 结论 +### 结论 创建能够生成许多种动态网页的 CGI 程序实际上非常简单。尽管这是一个很简单的例子,但是现在你应该看到一些可能性了。 @@ -115,7 +121,7 @@ via: https://opensource.com/article/17/12/cgi-scripts 作者:[David Both][a] 译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From ba23554b5c1f86d56b9ef0dfe4da4eba03d8c3ff Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 20:49:29 +0800 Subject: [PATCH 0291/1057] PUB:20171219 How to generate webpages using CGI scripts.md @ucasFL https://linux.cn/article-9514-1.html --- .../20171219 How to generate webpages using CGI scripts.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171219 How to generate webpages using CGI scripts.md (100%) diff --git a/translated/tech/20171219 How to generate webpages using CGI scripts.md b/published/20171219 How to generate webpages using CGI scripts.md similarity index 100% rename from translated/tech/20171219 How to generate webpages using CGI scripts.md rename to published/20171219 How to generate webpages using CGI scripts.md From da5ba75fde23e47f6ff8671cf916bf4ea8563b55 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 21:37:29 +0800 Subject: [PATCH 0292/1057] PRF:20171212 Oh My Fish- Make Your Shell Beautiful.md @MjSeven --- ...2 Oh My Fish- Make Your Shell Beautiful.md | 102 +++++++++++------- 1 file changed, 66 insertions(+), 36 deletions(-) diff --git a/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md b/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md index 7fad56f9ac..1946b302d3 100644 --- a/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md +++ b/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md @@ -3,125 +3,140 @@ Oh My Fish! 让你的 Shell 漂亮起来 ![](https://www.ostechnix.com/wp-content/uploads/2017/12/oh-my-fish-720x340.jpg) -几天前,我们讨论了如何 [**安装** **Fish shell**][1],一个健壮的,完全可用的 shell,带有许多很酷的功能,如自动建议,内置搜索功能,语法高亮显示,基于 web 配置等等。今天,我们将讨论如何使用 **Oh My Fish** (简称 **omf** ) 让我们的 Fish shell 变得漂亮且优雅。它是一个 Fishshell 框架,允许你安装扩展或更改 shell 外观的软件包。它简单易用,快速可扩展。使用 omf,你可以根据你的想法,很容易地安装主题,丰富你的外观和安装插件来调整你的 fish shell。 +几天前,我们讨论了如何[安装 Fish shell][1],这是一个健壮的、完全可用的 shell,带有许多很酷的功能,如自动建议、内置搜索功能、语法高亮显示、基于 web 配置等等。今天,我们将讨论如何使用 Oh My Fish (简称 `omf` ) 让我们的 Fish shell 变得漂亮且优雅。它是一个 Fishshell 框架,允许你安装扩展或更改你的 shell 外观的软件包。它简单易用,快速可扩展。使用 `omf`,你可以根据你的想法,很容易地安装主题,丰富你的外观和安装插件来调整你的 Fish shell。 -#### 安装 Oh My Fish +### 安装 Oh My Fish + +安装 omf 很简单。你要做的只是在你的 Fish shell 中运行下面的命令。 -安装 omf 很简单。你要做的只是在你的 fish shell 中运行下面的命令。 ``` curl -L https://get.oh-my.fish | fish ``` ![][3] -一旦安装完成,你将看到提示已经自动更改,如上图所所示。另外,你会注意到当前时间在 shell 窗口的右边。 +一旦安装完成,你将看到提示符已经自动更改,如上图所所示。另外,你会注意到当前时间在 shell 窗口的右边。 就是这样。让我们继续并调整我们的 fish shell。 -#### 现在,让我们将 Fish Shell 变漂亮 +### 现在,让我们将 Fish Shell 变漂亮 列出所有的安装包,运行: + ``` omf list ``` 这条命令将显示已安装的主题和插件。请注意,包可以是主题或插件。安装包意味着安装主题和插件。 -所有官方和社区支持的包(包括插件和主题)都托管在 [**Omf 主仓库**][4] 中。在这个主仓库中,你可以看到大量的仓库,其中包含大量的插件和主题。 +所有官方和社区支持的包(包括插件和主题)都托管在 [Omf 主仓库][4] 中。在这个主仓库中,你可以看到大量的仓库,其中包含大量的插件和主题。 现在让我们看一下可用的和已安装的主题列表。为此,运行: + ``` omf theme ``` ![][5] -如你所见,我们只有一个已安装的主题,这是默认的,但是还有大量可用的主题。在安装之前,你在[**这里**][6]可以预览所有可用的主题。这个页面包含了所有的主题细节,特性,每个主题的截图示例,以及哪个主题适合谁。 +如你所见,我们只有一个已安装的主题,这是默认的,但是还有大量可用的主题。在安装之前,你在[这里][6]可以预览所有可用的主题。这个页面包含了所有的主题细节,特性,每个主题的截图示例,以及哪个主题适合谁。 -**安装一个新主题** +#### 安装一个新主题 + +请允许我安装一个主题,例如 clearance 主题,这是一个极简的 fish shell 主题,供那些经常使用 `git` 的人使用。为此,运行: -请允许我安装一个主题,例如 **clearance theme - **一个极简的 fish shell 主题,供那些经常使用 git 的人使用。为此,运行: ``` omf install clearance ``` ![][7] -如上图所示,在安装新主题后,fish 的提示立即发生了变化。 +如上图所示,在安装新主题后,Fish shell 的提示立即发生了变化。 让我浏览一下系统文件,看看它如何显示。 ![][8] -看起来不坏!这是一个非常简单的主题。它将当前工作目录,文件夹和文件以不同的颜色区分开来。你可能会注意到,它还会在提示符的顶部显示当前工作目录。现在,**clearance** 是我的默认主题。 +看起来不错!这是一个非常简单的主题。它将当前工作目录,文件夹和文件以不同的颜色区分开来。你可能会注意到,它还会在提示符的顶部显示当前工作目录。现在,clearance 是我的默认主题。 -**改变主题** +#### 改变主题 就像我之前说的一样,这个主题在安装后被立即应用。如果你有多个主题,你可以使用以下命令切换到另一个不同的主题: + ``` omf theme ``` 例如: + ``` omf theme agnoster ``` -现在我正在使用 "agnoster" 主题。 agnoster 就是这样改变了我 shell 的外观。 +现在我正在使用 agnoster 主题。 agnoster 就是这样改变了我 shell 的外观。 ![][9] -**安装插件** +#### 安装插件 + +例如,我想安装一个天气插件。为此,只要运行: -例如,我想安装一个天气插件。为此,,只要运行: ``` omf install weather ``` -天气插件依赖于 [jq][10](LCTT 译注:jq 是一个轻量级且灵活的命令行JSON处理器)。所以,你可能也需要安装 jq。它通常在 Linux 发行版的默认仓库中存在。因此,你可以使用默认的包管理器来安装它。例如,以下命令将在 Arch Linux 及其衍生版中安装 jq。 +天气插件依赖于 [jq][10](LCTT 译注:jq 是一个轻量级且灵活的命令行JSON处理器)。所以,你可能也需要安装 `jq`。它通常在 Linux 发行版的默认仓库中存在。因此,你可以使用默认的包管理器来安装它。例如,以下命令将在 Arch Linux 及其衍生版中安装 `jq`。 + ``` sudo pacman -S jq ``` -现在,在 fish shell 中使用以下命令查看天气: +现在,在 Fish shell 中使用以下命令查看天气: + ``` weather ``` ![][11] -**寻找包** +#### 寻找包 要搜索主题或插件,请执行以下操作: + ``` omf search ``` 例如: + ``` omf search nvm ``` -为了限制搜索的主题范围,使用 **-t** 选项。 +为了限制搜索的主题范围,使用 `-t` 选项。 + ``` - omf search -t chain +omf search -t chain ``` -这条命令只会搜索主题名字中包含 "chain" 的主题。 +这条命令只会搜索主题名字中包含 “chain” 的主题。 + +为了限制搜索的插件范围,使用 `-p` 选项。 -为了限制搜索的插件范围,使用 **-p** 选项。 ``` - omf search -p emacs +omf search -p emacs ``` -**更新包** +#### 更新包 + +要仅更新核心功能(`omf` 本身),运行: -要仅更新核心功能(omf 本身),运行: ``` omf update omf ``` 如果是最新的,你会看到以下输出: + ``` Oh My Fish is up to date. You are now using Oh My Fish version 6. @@ -129,23 +144,27 @@ Updating https://github.com/oh-my-fish/packages-main master... Done! ``` 更新所有包: + ``` omf update ``` 要有选择地更新软件包,只需包含如下所示的包名称: + ``` omf update clearance agnoster ``` -**显示关于包的信息** +#### 显示关于包的信息 当你想知道关于一个主题或插件的信息时,使用以下命令: + ``` omf describe clearance ``` 这条命令将显示关于包的信息。 + ``` Package: clearance Description: A minimalist fish shell theme for people who use git @@ -153,78 +172,89 @@ Repository: https://github.com/oh-my-fish/theme-clearance Maintainer: ``` -**移除包** +#### 移除包 移除一个包,例如 emacs,运行: + ``` omf remove emacs ``` -**管理仓库** +#### 管理仓库 默认情况下,当你安装了 Oh My Fish 时,会自动添加官方仓库。这个仓库包含了开发人员构建的所有包。要管理用户安装的仓库包,使用这条命令: + ``` omf repositories [list|add|remove] ``` 列出所有安装的仓库,运行: + ``` omf repositories list ``` 添加一个仓库: + ``` omf repositories add ``` 例如: + ``` omf repositories add https://github.com/ostechnix/theme-sk ``` 移除一个仓库: + ``` omf repositories remove ``` -**Troubleshooting Oh My Fish** +#### Oh My Fish 排错 + +如果出现了错误,`omf` 足够聪明来帮助你,它可以列出解决问题的方法。例如,我安装了 clearance 包,得到了文件冲突的错误。幸运的是,在继续之前,Oh My Fish 会指示我该怎么做。因此,我只是简单地运行了以下代码来了解如何修正错误。 -如果出现了错误,omf 足够聪明来帮助你,它可以列出解决问题的方法。例如,我删除并安装了 clearance 包(这句不太理解,希望校正者注意),得到了文件冲突的错误。幸运的是,在继续之前,Oh My Fish 会指示我该怎么做。因此,我只是简单地运行了以下代码来了解如何修正错误。 ``` omf doctor ``` 通过运行以下命令来解决错误: + ``` rm ~/.config/fish/functions/fish_prompt.fish ``` ![][12] -无论你何时遇到问题,只要运行 'omf doctor' 命令,并尝试所有的建议方法。 +无论你何时遇到问题,只要运行 `omf doctor` 命令,并尝试所有的建议方法。 -**获取帮助** +###3 获取帮助 显示帮助部分,运行: + ``` omf -h ``` 或者 + ``` omf --help ``` -**卸载 Oh My Fish** +#### 卸载 Oh My Fish 卸载 Oh My Fish,运行以下命令: + ``` omf destroy ``` 继续前进,开始自定义你的 fish shell。获取更多细节,请参考项目的 GitHub 页面。 -这就是全部了。我很快将会在这里开始另一个有趣的指导。在此之前,请继续关注 OSTechNix! +这就是全部了。我很快将会在这里开始另一个有趣的指导。在此之前,请继续关注我们! 干杯! @@ -233,8 +263,8 @@ omf destroy via: https://www.ostechnix.com/oh-fish-make-shell-beautiful/ 作者:[SK][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From fefa7b173833570b8bb8516d695981afcf18325b Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 21:38:08 +0800 Subject: [PATCH 0293/1057] PUB:20171212 Oh My Fish- Make Your Shell Beautiful.md @MjSeven https://linux.cn/article-9515-1.html --- .../20171212 Oh My Fish- Make Your Shell Beautiful.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171212 Oh My Fish- Make Your Shell Beautiful.md (100%) diff --git a/translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md b/published/20171212 Oh My Fish- Make Your Shell Beautiful.md similarity index 100% rename from translated/tech/20171212 Oh My Fish- Make Your Shell Beautiful.md rename to published/20171212 Oh My Fish- Make Your Shell Beautiful.md From f5cdbc93bee13077382b451feff25260ddd43813 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 4 Apr 2018 21:40:03 +0800 Subject: [PATCH 0294/1057] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- published/20171212 Oh My Fish- Make Your Shell Beautiful.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/published/20171212 Oh My Fish- Make Your Shell Beautiful.md b/published/20171212 Oh My Fish- Make Your Shell Beautiful.md index 1946b302d3..4920b7c021 100644 --- a/published/20171212 Oh My Fish- Make Your Shell Beautiful.md +++ b/published/20171212 Oh My Fish- Make Your Shell Beautiful.md @@ -230,7 +230,7 @@ rm ~/.config/fish/functions/fish_prompt.fish 无论你何时遇到问题,只要运行 `omf doctor` 命令,并尝试所有的建议方法。 -###3 获取帮助 +#### 获取帮助 显示帮助部分,运行: From 4e8b17a0669951fb3b4bee81319ccee7fbec4340 Mon Sep 17 00:00:00 2001 From: Auk7F7 <34982730+Auk7F7@users.noreply.github.com> Date: Wed, 4 Apr 2018 22:09:44 +0800 Subject: [PATCH 0295/1057] Update 20171219 How to set GNOME to display a custom slideshow.md --- .../20171219 How to set GNOME to display a custom slideshow.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171219 How to set GNOME to display a custom slideshow.md b/sources/tech/20171219 How to set GNOME to display a custom slideshow.md index 7b74de82c5..ffa8024aab 100644 --- a/sources/tech/20171219 How to set GNOME to display a custom slideshow.md +++ b/sources/tech/20171219 How to set GNOME to display a custom slideshow.md @@ -1,3 +1,4 @@ + translating by Auk7F7 How to set GNOME to display a custom slideshow ====== A very cool, yet lesser known, feature in GNOME is its ability to display a slideshow as your wallpaper. You can select a wallpaper slideshow from the background settings panel in the [GNOME Control Center][1]. Wallpaper slideshows can be distinguished from static wallpapers by a small clock emblem displayed in the lower-right corner of the preview. From 88fc4301673de80f508526ef5577b7a8eae231e2 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 4 Apr 2018 23:29:06 +0800 Subject: [PATCH 0296/1057] Delete 20180328 Getting started with Jupyter Notebooks.md --- ... Getting started with Jupyter Notebooks.md | 93 ------------------- 1 file changed, 93 deletions(-) delete mode 100644 sources/tech/20180328 Getting started with Jupyter Notebooks.md diff --git a/sources/tech/20180328 Getting started with Jupyter Notebooks.md b/sources/tech/20180328 Getting started with Jupyter Notebooks.md deleted file mode 100644 index 7b11fb7eb3..0000000000 --- a/sources/tech/20180328 Getting started with Jupyter Notebooks.md +++ /dev/null @@ -1,93 +0,0 @@ -Translating by MjSeven - - -Getting started with Jupyter Notebooks -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ) -Since the days of papyrus, publishers have struggled with formatting data in ways that engage readers. This is a particular issue in the areas of mathematics, science, and programming, where well-designed charts, illustrations, and equations can be key to helping people understand technical information. - -[The Jupyter Notebook][1] is addressing this problem by reimagining how we produce instructional texts. Jupyter (which I first learned about at [All Things Open][2] in October 2017) is an open source application that enables users to create interactive, shareable notebooks that contain live code, equations, visualizations, and text. - -Jupyter evolved from the [IPython Project][3], which features an interactive shell and a browser-based notebook with support for code, text, and mathematical expressions. Jupyter offers support for over 40 programming languages, including Python, R, and Julia, and its code can be exported to HTML, LaTeX, PDF, images, and videos or as [IPython][4] notebooks to be shared with other users. - -Fun fact: "Jupyter" is an acronym for "Julia, Python, and R." - -Some of its uses, according to Project Jupyter's website, include "data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more." Scientific institutions are using Jupyter Notebooks to explain research results. The code, which can come from actual data, can be tweaked and re-tweaked to visualize different results and scenarios. In this way, Jupyter Notebooks have become living texts and reports. - -### Installing and starting Jupyter - -The Jupyter software is open source, licensed under the [modified BSD license][5], and it can be [installed on Linux, MacOS, or Windows][6]. There are a number of ways to install Jupyter; I tried the PIP and the [Anaconda][7] installs on Linux and MacOS. A PIP install requires that Python is already installed on your computer; Jupyter recommends Python 3. - -Since Python 3 was already installed on my computers, I installed Jupyter by running the following commands in the terminal (on Linux or Mac): -``` -$ python3 -m pip install --upgrade pip - -$ python3 -m pip install jupyter - -``` - -Entering the following command at the terminal prompt started the application right away: -``` -$ jupyter notebook - -``` - -Soon my browser opened and displayed my Jupyter Notebook server at `http://localhost:8888`. (Supported browsers are Google Chrome, Firefox, and Safari.) - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_1.png?itok=UyM1GuVG) - -There's a drop-down menu labeled "New" in the upper-right corner. It enabled me to quickly create a new notebook for my own instructions and code. Note that my new notebook defaults to Python 3, which is my current environment. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_2.png?itok=alDI432q) - -A new notebook with some default values, which can be changed (including the name of the notebook), opened. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_3.png?itok=9zjG-5JC) -Notebooks have two different modes: Command and Edit. Command mode allows you to add or delete cells. You can enter Command mode by pressing the Escape key, and you can get into Edit mode by pressing the Enter key or by clicking in a cell. - -A green highlight around a cell indicates you are in Edit mode, and a blue highlight means you're in Command mode. The following notebook is in Command mode and ready for me to execute the Python code in the cell. Note that I've changed the name of the notebook to First Notebook. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_4.png?itok=-QPxcuFX) - -### Using Jupyter - -A strength of Jupyter Notebooks is that besides being able to enter code, you can also add Markdown with narrative and explanatory text. I wanted to add a heading, so I added a cell above my code and typed a heading in Markdown. When I pressed `Ctrl+Enter`, my heading converted to HTML. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_5.png?itok=-sr9A8-W) - -I can add output from a Bash command or script by appending an `!` to a command. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_6.png?itok=o_g38ECp) - -I can also take advantage of IPython's [line magic and cell magic][8] commands. You can list the magic commands by appending a `%` or `%%` sign to commands inside a code cell. For example, `%lsmagic` produces all the magic commands that can be used in Jupyter notebooks. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_7.png?itok=uit0PtND) - -Examples of these magic commands include `%pwd`, which outputs the present working directory (e.g., `/Users/YourName`) and `%ls`, which lists all the files and subdirectories in the current working directory. Another magic command displays charts generated from `matplotlib` in the notebook. `%%html` renders anything in that cell as HTML, which is useful for embedding video and links. There are cell magic commands for JavaScript and Bash, also. - -If you need more information about using Jupyter Notebooks and its features, the Help section is incredibly complete. - -People are using Jupyter Notebooks in many interesting ways; you can find some great examples in this [gallery][9]. How are you using Jupyter notebooks? Please share your ideas in the comments below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/getting-started-jupyter-notebooks - -作者:[Don Watkins][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/don-watkins -[1]:http://jupyter.org/ -[2]:https://allthingsopen.org/ -[3]:http://ipython.org/ -[4]:https://en.wikipedia.org/wiki/IPython -[5]:https://opensource.org/licenses/BSD-3-Clause -[6]:http://jupyter.org/install.html -[7]:https://www.anaconda.com/download/#linux -[8]:http://ipython.readthedocs.io/en/stable/interactive/magics.html -[9]:https://github.com/jupyter/jupyter/wiki/a-gallery-of-interesting-jupyter-notebooks#mathematics From 87f50d67c0241d5a7b82e4a714103567a8400879 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 4 Apr 2018 23:29:48 +0800 Subject: [PATCH 0297/1057] Create 20180328 Getting started with Jupyter Notebooks.md --- ... Getting started with Jupyter Notebooks.md | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 translated/tech/20180328 Getting started with Jupyter Notebooks.md diff --git a/translated/tech/20180328 Getting started with Jupyter Notebooks.md b/translated/tech/20180328 Getting started with Jupyter Notebooks.md new file mode 100644 index 0000000000..4f90a2007b --- /dev/null +++ b/translated/tech/20180328 Getting started with Jupyter Notebooks.md @@ -0,0 +1,90 @@ +Jupyter Notebooks 入门 +===== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ) +自从 papyrus 发布以来,出版社一直在努力以吸引读者的方式来格式化数据。在数学、科学、和编程领域,这是一个特别的问题,设计良好的图表、插图和方程式可以成为帮助人们理解技术信息的关键。 + +[Jupyter Notebook][1] 通过重新构想我们如何制作教学文本来解决这个问题。Jupyter (我在 2017 年 10 月在 [All Things Open][2] 上首次了解到)是一款开源应用程序,它使用户能够创建包含实时代码,方程式,可视化和文本的交互式共享笔记本。 + +Jupyter 从 [IPython 项目][3]发展而来,该项目具有交互式 shell 和基于浏览器的笔记本,支持代码,文本和数学表达式。Jupyter 支持超过 40 种编程语言,包括 Python,R 和 Julia,其代码可以导出为 HTML,LaTeX,PDF,图像和视频,或者作为 [IPyhton][4] 笔记本与其他用户共享。 + +一个有趣的事实是:"Jupyter" 是 "Julia, Python, 和 R" 的缩写。 + +根据 Jupyter 项目网站介绍,它的一些用途包括“数据清理和转换,数值模拟,统计建模,数据可视化,机器学习等等”。科学机构正在使用 Jupyter Notebooks 来解释研究结果。代码可以来自实际数据,可以调整和重新调整以可视化成不同的结果和情景。通过这种方式,Jupyter Notebooks 已成为生动的文本和报告。 + +### 安装并开始 Jupyter + +Jupyter 软件是开源的,在[修改过的 BSD 许可证][5] 下获得许可,它可以[安装在 Linux,MacOS 或 Windows 上][6]。有很多种方法可以安装 Jupyter;我尝试在 Linux 和 MacOS 上安装 PIP 和 [Anaconda][7]。PIP 安装要求你的计算机上已经安装了 Python;Jupyter 推荐 Python 3。 + +由于 Python 3 已经安装在我的电脑上,我通过在终端(在 Linux 或 Mac 上)运行以下命令来安装 Jupyter: + +``` +$ python3 -m pip install --upgrade pip + +$ python3 -m pip install jupyter + +``` + +在终端提示种输入以下命令立即启动应用程序: +``` +$ jupyter notebook + +``` + +很快,我的浏览器打开并显示了我的 Jupyter Notebook 服务器在 `http://localhost:8888`。(支持的浏览器有 Google Chrome,Firefox 和 Safari) + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_1.png?itok=UyM1GuVG) + +在右上角有一个标有 “New” 的下拉菜单,它使我能够根据自己的指示和代码快速创建新的笔记本。请注意,我的新笔记本默认为 Python 3,这是我目前的环境。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_2.png?itok=alDI432q) + +一个带有一些默认值的新笔记本,它可以被改变(包括笔记本的名字),打开它。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_3.png?itok=9zjG-5JC) +笔记本有两种不同的模式:命令和编辑。命令模式允许你添加或删除单元格。你可以通过按下 Escape 键进入命令模式,按 Enter 键或单击单元格进入编辑模式。 + +单元格周围的绿色突出显示你处于编辑模式,蓝色突出显示你处于命令模式。以下笔记本处于命令模式并准备好执行单元中的 Python 代码。注意,我已将笔记本的名称更改为 First Notebook。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_4.png?itok=-QPxcuFX) + +### 使用 Jupyter + +Jupyter Notebooks 的强大之处在于除了能够输入代码之外,你还可以将 Markdown 与叙述性和解释性文本相结合。我想添加一个标题,所以我在代码上面添加了一个单元格,并在 Markdown 中输入了一个标题。当我按下 `Ctrl+Enter` 时,我的标题转换为 HTML。(译注:或者可以按下 Run 按钮。) + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_5.png?itok=-sr9A8-W) + +我可以通过在命令前追加 `!` 来添加 Bash 命令或脚本的输出。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_6.png?itok=o_g38ECp) + +我也可以利用 IPython 的 [line magic 和 cell magic][8] 命令。你可以通过在代码单元内附加 `%` 或 `%%` 符号来列出魔术命令。例如,`%lsmagic` 产生所有可用于 Jupyter notebooks 的魔法命令。 + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_7.png?itok=uit0PtND) + +这些魔术命令的例子包括 `%pwd`,它输出当前工作目录(例如 `/Users/YourName`)和 `%ls`,它列出当前工作目录中的所有文件和子目录。另一个神奇命令显示从笔记本中的 `matplotlib` 生成的图表。`%%html` 将该单元格中的任何内容呈现为 HTML,这对嵌入视频和链接很有用,还有 JavaScript 和 Bash 的单元魔术命令。 + +如果你需要更多关于使用 Jupyter Notebooks 和它的特性的信息,帮助部分是非常完整的。 + +人们用许多有趣的方式使用 Jupyter Notebooks;你可以在这个 [gallery][9] 里找到一些很好的例子。你如何使用Jupyter笔记本?请在下面的评论中分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/getting-started-jupyter-notebooks + +作者:[Don Watkins][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者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/don-watkins +[1]:http://jupyter.org/ +[2]:https://allthingsopen.org/ +[3]:http://ipython.org/ +[4]:https://en.wikipedia.org/wiki/IPython +[5]:https://opensource.org/licenses/BSD-3-Clause +[6]:http://jupyter.org/install.html +[7]:https://www.anaconda.com/download/#linux +[8]:http://ipython.readthedocs.io/en/stable/interactive/magics.html +[9]:https://github.com/jupyter/jupyter/wiki/a-gallery-of-interesting-jupyter-notebooks#mathematics From c9c514492438b3c4d2f6fabf0fe0cf3ce353bf81 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 5 Apr 2018 09:07:23 +0800 Subject: [PATCH 0298/1057] Update 20170927 Best Linux Distros for the Enterprise.md --- sources/tech/20170927 Best Linux Distros for the Enterprise.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170927 Best Linux Distros for the Enterprise.md b/sources/tech/20170927 Best Linux Distros for the Enterprise.md index 36411a9bfe..797ed71ff2 100644 --- a/sources/tech/20170927 Best Linux Distros for the Enterprise.md +++ b/sources/tech/20170927 Best Linux Distros for the Enterprise.md @@ -1,3 +1,5 @@ +Translating by MjSeven + Best Linux Distros for the Enterprise ====== In this article, I'll share the top Linux distros for enterprise environments. Some of these distros are used in server and cloud environments along with desktop duties. The one constant that all of these Linux options have is that they are enterprise grade Linux distributions -- so you can expect a high greater degree of functionality and, of course, support. From ad0ab1fd2b06637214aa0a78bcf0cb6bbeb78431 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 5 Apr 2018 21:31:07 +0800 Subject: [PATCH 0299/1057] PRF:20180322 How To Find If A CPU Supports Virtualization Technology (VT).md @geekpi --- ...Supports Virtualization Technology (VT).md | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md b/translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md index 5f494db6b8..29796cf7b3 100644 --- a/translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md +++ b/translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md @@ -1,111 +1,113 @@ -如何知道 CPU 是否支持虚拟化技术 (VT) +如何知道 CPU 是否支持虚拟化技术(VT) ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/Virtualization-Technology-720x340.png) -我们已经知道如何[**检查你的 Linux 操作系统是 32 位还是 64 位**] [1]以及如何[**知道你的 Linux 系统是物理机还是虚拟机**] [2]。今天,我们将学习另一个有用的话题 - 如何知道 CPU 是否支持虚拟化技术 (VT)?在安装虚拟化程序(如 VirtualBox 或 VMWare workstation)以在 Linux 系统上运行虚拟机之前,你应该首先验证这一点。现在让我们来看看你的电脑是否支持 VT。相信我,这真的很简单! + +我们已经知道如何[检查你的 Linux 操作系统是 32 位还是 64 位] [1]以及如何[知道你的 Linux 系统是物理机还是虚拟机] [2]。今天,我们将学习另一个有用的话题 - 如何知道 CPU 是否支持虚拟化技术 (VT)?在安装虚拟化程序(如 VirtualBox 或 VMWare workstation)以在 Linux 系统上运行虚拟机之前,你应该首先验证这一点。现在让我们来看看你的电脑是否支持 VT。相信我,这真的很简单! ### 了解 CPU 是否支持虚拟化技术 (VT) 我们可以通过几种方法检查 CPU 是否支持 VT。在这里我向你展示四种方法。 -#### 方法 1:使用 “egrep” 命令 +#### 方法 1:使用 egrep 命令 -**egrep** 是 [**grep**][3] 命令的变体之一,用于使用正则表达式搜索文本文件。为了本指南的目的,我们将grep **/cpu/procinfo/** 文件来确定 CPU 是否支持 VT。 +`egrep` 是 [grep][3] 命令的变体之一,用于使用正则表达式搜索文本文件。为了本指南的目的,我们将 grep `/cpu/procinfo/` 文件来确定 CPU 是否支持 VT。 + +要使用 `egrep` 命令查明你的CPU是否支持VT,请运行: -要使用 egrep 命令查明你的CPU是否支持VT,请运行: ``` $ egrep "(svm|vmx)" /proc/cpuinfo - ``` -**示例输出** +示例输出: + +你将在输出中看到 `vmx`(Intel-VT 技术)或 `svm` (AMD-V 支持)。 -你将在输出中看到 **“vmx”**(Intel-VT 技术)或 **“svm”** (AMD-V 支持)。 ``` flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx lahf_lm epb pti tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts [...] - ``` -由于输出很长,你可能会发现很难在输出中找到 “vmx” 或 “svm”。别担心!你可以像下面那样用颜色来区分这些术语。 +由于输出很长,你可能会发现很难在输出中找到 `vmx` 或 `svm`。别担心!你可以像下面那样用颜色来区分这些术语。 + ``` $ egrep --color -i "svm|vmx" /proc/cpuinfo - ``` ![][5] 如果你没有看到任何输出,这意味着你的系统不支持虚拟化。 -请注意,cpuinfo 中的这些 CPU 标志(vmx 或 svm)表示你的系统支持 VT。在某些 CPU 型号中,默认情况下,可能会在 BIOS 中禁用 VT 支持。在这种情况下,你应该检查 BIOS 设置以启用 VT 支持。 +请注意,`cpuinfo` 中的这些 CPU 标志(`vmx` 或 `svm`)表示你的系统支持 VT。在某些 CPU 型号中,默认情况下,可能会在 BIOS 中禁用 VT 支持。在这种情况下,你应该检查 BIOS 设置以启用 VT 支持。 + +有关 `grep`/`egrep` 命令的更多详细信息,请参阅手册页。 -有关 grep/egrep 命令的更多详细信息,请参阅手册页。 ``` $ man grep - ``` -#### 方法 2: 使用 “lscpu” 命令 +#### 方法 2: 使用 lscpu 命令 -“lscpu” 命令用于显示有关 CPU 架构的信息。它从 sysfs、/proc/cpuinfo 收集信息,并显示主机系统的 CPU、线程、内核、套接字和非统一内存访问 (NUMA) 节点的数量。 +`lscpu` 命令用于显示有关 CPU 架构的信息。它从 `sysfs`、`/proc/cpuinfo` 收集信息,并显示主机系统的 CPU、线程、内核、套接字和非统一内存访问 (NUMA) 节点的数量。 要确定是否启用 VT 支持,只需运行: + ``` $ lscpu - ``` ![][6] 有关更多详细信息,请查看手册页。 + ``` $ man lscpu - ``` -#### 方法 3:使用 “Cpu-checker” 工具 +#### 方法 3:使用 cpu-checker 工具 + +cpu-checker 是另一个有用的工具,用于测试你的 CPU 是否支持虚拟化。就我在网上搜索得到的,该程序仅适用于基于 Ubuntu 的系统。要安装它,请运行: -**Cpu-checker** 是另一个有用的工具,用于测试你的 CPU 是否支持虚拟化。就我在网上搜索得到的,该程序仅适用于基于 Ubuntu 的系统。要安装它,请运行: ``` $ sudo apt-get install cpu-checker - ``` 安装 cpu-checker 包之后,运行以下命令来检查是否启用 VT 支持: + ``` $ sudo kvm-ok - ``` 如果您的 CPU 支持 VT,你将得到以下输出: + ``` INFO: /dev/kvm exists KVM acceleration can be used - ``` 如果你的 CPU 不支持 VT,你会看到如下的输出。 + ``` INFO: Your CPU does not support KVM extensions KVM acceleration can NOT be used - ``` -#### 方法 4:使用 “virt-host-validate” 工具 +#### 方法 4:使用 virt-host-validate 工具 + +该工具专门用于基于 RHEL 的发行版,如 CentOS 和 Scientific Linux。 libvirt-client 包提供 `virt-host-validate` 二进制文件。所以你需要安装 libvert-client 包来使用这个工具。 -该工具专门用于基于 RHEL 的发行版,如 CentOS 和 Scientific Linux。 **libvirt-client** 包提供 **virt-host-validate** 二进制文件。所以你需要安装 “libvert-client” 包来使用这个工具。 ``` $ sudo yum install libvirt-client - ``` -现在,运行 “virt-host-validate” 命令来确定基于 RHEL 的系统中是否启用了 VT。 +现在,运行 `virt-host-validate` 命令来确定基于 RHEL 的系统中是否启用了 VT。 + ``` $ sudo virt-host-validate - ``` -如果所有的结果是 **pass**,那么你的系统支持 VT。 +如果所有的结果是 `pass`,那么你的系统支持 VT。 + ``` QEMU: Checking for hardware virtualization : PASS QEMU: Checking if device /dev/vhost-net exists : PASS @@ -142,14 +144,13 @@ $ sudo virt-host-validate LXC: Checking for cgroup 'devices' controller mount-point : PASS LXC: Checking for cgroup 'blkio' controller support : PASS LXC: Checking for cgroup 'blkio' controller mount-point : PASS - ``` 如果你的系统不支持 VT,你会看到下面的输出。 + ``` QEMU: Checking for hardware virtualization : FAIL (Only emulated CPUs are available, performance will be significantly limited) [...] - ``` 就是这样了。在本文中,我们讨论了确定 CPU 是否支持 VT 的不同方法。如你所见,这很简单。希望这个有用。还有更多好的东西。敬请关注! @@ -163,7 +164,7 @@ via: https://www.ostechnix.com/how-to-find-if-a-cpu-supports-virtualization-tech 作者:[SK][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 6e7ea9c65b4c2459dcc910f3bda2ded17e81f050 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 5 Apr 2018 21:31:26 +0800 Subject: [PATCH 0300/1057] PUB:20180322 How To Find If A CPU Supports Virtualization Technology (VT).md @geekpi --- ...ow To Find If A CPU Supports Virtualization Technology (VT).md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md (100%) diff --git a/translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md b/published/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md similarity index 100% rename from translated/tech/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md rename to published/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md From b6eedea0d521d9887f68b86633bcd815bd84d545 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 5 Apr 2018 22:17:15 +0800 Subject: [PATCH 0301/1057] PRF:20180213 How to clone, modify, add, and delete files in Git.md @MjSeven --- ...e, modify, add, and delete files in Git.md | 83 +++++++++---------- 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/translated/tech/20180213 How to clone, modify, add, and delete files in Git.md b/translated/tech/20180213 How to clone, modify, add, and delete files in Git.md index 9cc05462d4..d552a0f54f 100644 --- a/translated/tech/20180213 How to clone, modify, add, and delete files in Git.md +++ b/translated/tech/20180213 How to clone, modify, add, and delete files in Git.md @@ -1,29 +1,28 @@ -在 Git 中怎样克隆,修改,添加和删除文件? +在 Git 中怎样克隆、修改、添加和删除文件? ===== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_cat.png?itok=ta54QTAf) -在 [本系列的第一篇文章][1] 开始使用 Git 时,我们创建了一个简单的 Git 仓库,并通过它连接到我们的计算机向其中添加一个文件。在本文中,我们将学习一些关于 Git 的其他内容,即如何克隆(下载),修改,添加和删除 Git 仓库中的文件。 - +在 [本系列的第一篇文章][1] 开始使用 Git 时,我们创建了一个简单的 Git 仓库,并用我们的计算机连接到它,向其中添加一个文件。在本文中,我们将学习一些关于 Git 的其他内容,即如何克隆(下载)、修改、添加和删除 Git 仓库中的文件。 ### 让我们来克隆一下 -假设你在 GitHub 上已经有一个 Git 仓库,并且想从它那里获取你的文件-也许你在你的计算机上丢失了本地副本,或者你正在另一台计算机上工作,但是想访问仓库中的文件,你该怎么办?从 GitHub 下载你的文件?没错!我们称之为 Git 术语中的“克隆”。(你也可以将仓库作为 ZIP 文件下载,但我们将在本文中探讨克隆方法。) +假设你在 GitHub 上已经有一个 Git 仓库,并且想从它那里获取你的文件——也许你在你的计算机上丢失了本地副本,或者你正在另一台计算机上工作,但是想访问仓库中的文件,你该怎么办?从 GitHub 下载你的文件?没错!在 Git 术语中我们称之为“克隆clone”。(你也可以将仓库作为 ZIP 文件下载,但我们将在本文中探讨克隆方式。) -让我们克隆在上一篇文章中创建的称为 Demo 的仓库。(如果你还没有创建 Demo 仓库,请跳回到那篇文章并在继续之前执行那些步骤。)要克隆文件,只需打开浏览器并导航到 `https://github.com//Demo` (其中 `` 是你仓库的名称。例如,我的仓库是 `https://github.com/kedark3/Demo`)。一旦你导航到该 URL,点击“克隆或下载”按钮,你的浏览器看起来应该是这样的: +让我们克隆在上一篇文章中创建的名为 Demo 的仓库。(如果你还没有创建 Demo 仓库,请跳回到[那篇文章][1]并在继续之前执行那些步骤)要克隆文件,只需打开浏览器并导航到 `https://github.com//Demo` (其中 `` 是你仓库的名称。例如,我的仓库是 `https://github.com/kedark3/Demo`)。一旦你导航到该 URL,点击“克隆或下载Clone or download”按钮,你的浏览器看起来应该是这样的: ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide11.png?itok=wJYqZyBX) -正如你在上面看到的,“使用 HTTPS 克隆”选项已打开。从该下拉框中复制你的仓库地址(`https://github.com//Demo.git`),打开终端并输入以下命令将 GitHub 仓库克隆到你的计算机: +正如你在上面看到的,“使用 HTTPS 克隆Clone with HTTPS”选项已打开。从该下拉框中复制你的仓库地址(`https://github.com//Demo.git`),打开终端并输入以下命令将 GitHub 仓库克隆到你的计算机: + ``` git clone https://github.com//Demo.git - ``` 然后,要查看 `Demo` 目录中的文件列表,请输入以下命令: + ``` ls Demo/ - ``` 终端看起来应该是这样的: @@ -33,19 +32,14 @@ ls Demo/ ### 修改文件 现在我们已经克隆了仓库,让我们修改文件并在 GitHub 上更新它们。首先,逐个输入下面的命令,将目录更改为 `Demo/`,检查 `README.md` 中的内容,添加新的(附加的)内容到 `README.md`,然后使用 `git status` 检查状态: + ``` cd Demo/ - ls - cat README.md - echo "Added another line to REAMD.md" >> README.md - cat README.md - git status - ``` 如果你逐一运行这些命令,终端看起开将会是这样: @@ -53,13 +47,13 @@ git status ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide12.5.png?itok=jhb-EPH1) 让我们看一下 `git status` 的输出,并了解它的意思。不要担心这样的语句: + ``` On branch master - Your branch is up-to-date with 'origin/master'.". - ``` -因为我们还没有学习这些。(译注:学了你就知道了)下一行说:`Changes not staged for commit`;这是告诉你,它下面列出的文件没有标记就绪(“分阶段”)提交。如果你运行 `git add`,Git 会把这些文件标记为 `Ready for commit`;换句话说就是 `Changes staged for commit`。在我们这样做之前,让我们用 `git diff` 命令来检查我们添加了什么到 Git 中,然后运行 `git add`。 + +因为我们还没有学习这些。(LCTT 译注:学了你就知道了)下一行说:`Changes not staged for commit`(变化未筹划提交);这是告诉你,它下面列出的文件没有被标记准备(“筹划stage”)提交。如果你运行 `git add`,Git 会把这些文件标记为 `Ready for commit`(准备提交);换句话说就是 `Changes staged for commit`(变化筹划提交)。在我们这样做之前,让我们用 `git diff` 命令来检查我们添加了什么到 Git 中,然后运行 `git add`。 这里是终端输出: @@ -70,12 +64,11 @@ Your branch is up-to-date with 'origin/master'.". * `diff --git a/README.md b/README.md` 是 Git 比较的内容(在这个例子中是 `README.md`)。 * `--- a/README.md` 会显示从文件中删除的任何东西。 * `+++ b/README.md` 会显示从文件中添加的任何东西。 -* 任何添加到文件中的内容都以绿色文本打印,并在该行的开头加上 + 号。 -* 如果我们删除了任何内容,它将以红色文本打印,并在该行的开头加上 - 号。 -* 现在 git status 显示“Changes to be committed:”,并列出文件名(即 `README.md`)以及该文件发生了什么(即它已经被 `modified` 并准备提交)。 +* 任何添加到文件中的内容都以绿色文本打印,并在该行的开头加上 `+` 号。 +* 如果我们删除了任何内容,它将以红色文本打印,并在该行的开头加上 `-` 号。 +* 现在 `git status` 显示 `Changes to be committed:`(变化将被提交),并列出文件名(即 `README.md`)以及该文件发生了什么(即它已经被 `modified` 并准备提交)。 - -提示:如果你已经运行了 `git add`,现在你想看看文件有什么不同,通常 `git diff` 不会产生任何东西,因为你已经添加了文件。相反,你必须使用 `git diff --cached`。它会告诉你 Git 添加的当前版本和以前版本文件之间的差别。你的终端输出看起来会是这样: +提示:如果你已经运行了 `git add`,现在你想看看文件有什么不同,通常 `git diff` 不会输出任何东西,因为你已经添加了文件。相反,你必须使用 `git diff --cached`。它会告诉你 Git 添加的当前版本和以前版本文件之间的差别。你的终端输出看起来会是这样: ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide14.png?itok=bva9fHJj) @@ -84,47 +77,47 @@ Your branch is up-to-date with 'origin/master'.". 我们用一些新内容修改了 `README.md` 文件,现在是时候将它上传到 GitHub。 让我们提交更改并将其推送到 GitHub。运行: -``` -git commit -m "更新文件的名字" +``` +git commit -m "Updated Readme file" ``` -这告诉 Git 你正在“提交”已经“添加”的更改,你可能还记得,从本系列的第一部分中,添加一条消息来解释你在提交中所做的操作是非常重要的,以便你在稍后回顾 Git 日志时了解当时的目的。(我们将在下一篇文章中更多地关注这个话题。)`Updated Readme file` 是这个提交的消息--如果你认为这不是解释你所做的事情的最合理的方式,那么请随便写下你的提交消息。 +这告诉 Git 你正在“提交”已经“添加”的更改,你可能还记得,从本系列的第一部分中,添加一条消息来解释你在提交中所做的操作是非常重要的,以便你在稍后回顾 Git 日志时了解当时的目的。(我们将在下一篇文章中更多地关注这个话题。)`Updated Readme file` 是这个提交的消息——如果你认为这没有合理解释你所做的事情,那么请根据需要写下你的提交消息。 运行 `git push -u origin master`,这会提示你输入用户名和密码,然后将文件上传到你的 GitHub 仓库。刷新你的 GitHub 页面,你应该会看到刚刚对 `README.md` 所做的更改。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide15.png?itok=Qa3spy13) -终端的右下角显示我提交了更改,检查了 Git 状态,并将更改推送到了 GitHub。git status 显示: +终端的右下角显示我提交了更改,检查了 Git 状态,并将更改推送到了 GitHub。`git status` 显示: + ``` Your branch is ahead of 'origin/master' by 1 commit -   (use "git push" to publish your local commits) - ``` -第一行表示在本地仓库中有一个提交,但不在原始/主文件中(即在 GitHub 上)。下一行指示我们将这些更改推送到原始/主文件中,这就是我们所做的。(在本例中,请参阅本系列的第一篇文章,以唤醒你对“原始”含义的记忆。我将在下一篇文章中讨论分支的时候,解释“主文件”的含义。) +第一行表示在本地仓库中有一个提交,但不在 `origin/master` 中(即在 GitHub 上)。下一行指示我们将这些更改推送到 `origin/master` 中,这就是我们所做的。(在本例中,请参阅本系列的第一篇文章,以唤醒你对 `origin` 含义的记忆。我将在下一篇文章中讨论分支的时候,解释 `master` 的含义。) ### 添加新文件到 Git 现在我们修改了一个文件并在 GitHub 上更新了它,让我们创建一个新文件,将它添加到 Git,然后将其上传到 GitHub。 运行: + ``` echo "This is a new file" >> file.txt - ``` 这将会创建一个名为 `file.txt` 的新文件。 如果使用 `cat` 查看它: + ``` cat file.txt - ``` + 你将看到文件的内容。现在继续运行: + ``` git status - ``` Git 报告说你的仓库中有一个未跟踪的文件(名为 `file.txt`)。这是 Git 告诉你说在你的计算机中的仓库目录下有一个新文件,然而你并没有告诉 Git,Git 也没有跟踪你所做的任何修改。 @@ -132,17 +125,17 @@ Git 报告说你的仓库中有一个未跟踪的文件(名为 `file.txt`) ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide16.png?itok=UZpSKL13) 我们需要告诉 Git 跟踪这个文件,以便我们可以提交并上传文件到我们的仓库。以下是执行该操作的命令: + ``` git add file.txt - git status - ``` 终端输出如下: + ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide17.png?itok=quV-75Na) -git status 告诉你有 `file.txt` 被修改,对于 Git 来说它是一个 `new file`,Git 在此之前并不知道。现在我们已经为 Git 添加了 `file.txt`,我们可以提交更改并将其推送到 原始/主文件。 +`git status` 告诉你有 `file.txt` 被修改,对于 Git 来说它是一个 `new file`,Git 在此之前并不知道。现在我们已经为 Git 添加了 `file.txt`,我们可以提交更改并将其推送到 `origin/master`。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide18.png?itok=e0D7-eol) @@ -155,26 +148,25 @@ Git 现在已经将这个新文件上传到 GitHub;如果刷新 GitHub 页面 ### 从 Git 中删除文件 如果我们发现我们犯了一个错误,并且需要从我们的仓库中删除 `file.txt`,该怎么办?一种方法是使用以下命令从本地副本中删除文件: + ``` rm file.txt - ``` -如果你现在做 `git status`,Git 就会说有一个文件 `not staged for commit`,并且它已经从仓库的本地拷贝中删除了。如果我们现在运行: +如果你现在做 `git status`,Git 就会说有一个文件 `not staged for commit`(未筹划提交),并且它已经从仓库的本地拷贝中删除了。如果我们现在运行: + ``` git add file.txt - git status - ``` -我知道我们正在删除这个文件,但是我们仍然运行 `git add`,因为我们需要告诉 Git 我们正在做的**更改**,`git add` 可以用在我们添加新文件,修改一个已存在文件的内容,或者从仓库中删除文件。实际上,`git add` 将所有更改考虑在内,并将这些更改分阶段进行提交。如果有疑问,请仔细查看下面终端屏幕截图中每个命令的输出。 + +我知道我们正在删除这个文件,但是我们仍然运行 `git add`,因为我们需要告诉 Git 我们正在做的**更改**,`git add` 可以用于我们添加新文件、修改一个已存在文件的内容、或者从仓库中删除文件时。实际上,`git add` 将所有更改考虑在内,并将这些筹划提交这些更改。如果有疑问,请仔细查看下面终端屏幕截图中每个命令的输出。 Git 会告诉我们已删除的文件正在进行提交。只要你提交此更改并将其推送到 GitHub,该文件也将从 GitHub 的仓库中删除。运行以下命令: + ``` git commit -m "Delete file.txt" - git push -u origin master - ``` 现在你的终端看起来像这样: @@ -185,8 +177,7 @@ git push -u origin master ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/git_guide21.png?itok=RhXM4Gua) -现在你知道如何从你的仓库克隆,添加,修改和删除 Git 文件。本系列的下一篇文章将检查 Git 分支。 - +现在你知道如何从你的仓库克隆、添加、修改和删除 Git 文件。本系列的下一篇文章将检查 Git 分支。 -------------------------------------------------------------------------------- @@ -194,9 +185,9 @@ via: https://opensource.com/article/18/2/how-clone-modify-add-delete-git-files 作者:[Kedar Vijay Kulkarni][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/) 荣誉推出 [a]:https://opensource.com/users/kkulkarn -[1]:https://opensource.com/article/18/1/step-step-guide-git +[1]:https://linux.cn/article-9319-1.html From 1fcd60c53516f4b312d3ba9c6be87c09fea3d54e Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 5 Apr 2018 22:18:02 +0800 Subject: [PATCH 0302/1057] PUB:20180213 How to clone, modify, add, and delete files in Git.md @MjSeven https://linux.cn/article-9517-1.html --- ...20180213 How to clone, modify, add, and delete files in Git.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180213 How to clone, modify, add, and delete files in Git.md (100%) diff --git a/translated/tech/20180213 How to clone, modify, add, and delete files in Git.md b/published/20180213 How to clone, modify, add, and delete files in Git.md similarity index 100% rename from translated/tech/20180213 How to clone, modify, add, and delete files in Git.md rename to published/20180213 How to clone, modify, add, and delete files in Git.md From 46bf6f720c1ebeddaed189cee56dc602e2b48bad Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 5 Apr 2018 22:58:14 +0800 Subject: [PATCH 0303/1057] PRF:20171109 How to record statistics about a Linux machine-s uptime.md @MjSeven --- ...atistics about a Linux machine-s uptime.md | 116 ++++++++++++------ 1 file changed, 78 insertions(+), 38 deletions(-) diff --git a/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md b/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md index 385de3f741..f1684bc9c8 100644 --- a/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md +++ b/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md @@ -1,31 +1,37 @@ -如何记录有关 Linux 机器正常运行时间的统计信息 +如何记录 Linux 的系统运行时间的统计信息 ===== -Linux/Unix 系统管理员对服务器正常运行时间有一种奇怪的痴迷。这有一个关于这个主题的 xkcd 漫画,一个好的系统管理员是一股不可阻挡的力量,它站在黑暗势力和你的猫博客服务器之间。(这句话实在理解不了。) +Linux/Unix 系统管理员对服务器的系统运行时间有一种奇怪的痴迷。这里有一个关于这个主题的 xkcd 漫画,一个好的系统管理员是一股不可阻挡的力量,他伫立在你家猫咪博客的服务器之前,对抗黑暗势力。 [![Fig.01: Devotion to Duty https://xkcd.com/705/][1]][1] -我们可以使用 uptime 命令或 [w 命令][2] 或 top 命令来判断 Linux 系统运行了多久。我可以[获得系统的历史和统计运行时间的报告][3],使用 tuptime 工具将其保持在重新启动之间。 +我们可以使用 `uptime` 命令或 [w 命令][2] 或 `top` 命令来判断 Linux 系统运行了多久。我可以使用 `tuptime` 工具保留每次重新启动的运行时间,以[获得系统运行时间的历史和统计报告][3]。 -就像 uptime 命令一样,但输出结果更令人印象深刻。最近我发现了另一种称为 uptimed 的工具,用于记录关于机器正常运行时间和统计信息。让我们看看如何使用 Linux 操作系统上的 uptimed 和 uprecords 来获得正常运行时间的记录统计信息。 +这就像 `uptime` 命令一样,但输出结果更令人印象深刻。最近我发现了另一种称为 `uptimed` 的工具,用于记录关于机器的系统运行时间和统计信息。让我们看看如何使用 Linux 操作系统上的 `uptimed` 和 `uprecords` 来获得运行时间的记录统计信息。 + +查找系统运行时间非常简单,只需在基于 Linux 的系统上键入以下命令即可: -查找正常运行时间非常简单,只需在基于 Linux 的系统上键入以下命令即可: ``` -$ **uptime -p** +$ uptime -p up 2 weeks, 4 days, 7 hours, 28 minutes ``` -要保留有关 uptime 的历史统计信息,请使用 [tuptime][3] 或 uptime 工具。 +要保留有关 `uptime` 的历史统计信息,请使用 [tuptime][3] 或 `uptimed` 工具。 -## 安装 uptimed +### 安装 uptimed -安装 uptimed 的最简单的方式是通过你的软件包管理器,比如 apt/apt-get/yum,这些你的 Linux 发行版的朋友。 +安装 `uptimed` 的最简单的方式是通过你的软件包管理器,比如 apt/apt-get/yum 这些你的 Linux 发行版的朋友。 -### 在 Debian/Ubuntu Linux 上安装 uptimed +#### 在 Debian/Ubuntu Linux 上安装 uptimed + +键入以下 [apt 命令][4]/[apt-get 命令][5]: + +``` +$ sudo apt-get install uptimed +``` -键入以下 [apt 命令][4]/[apt-get 命令][5]: -`$ sudo apt-get install uptimed` 示例输出: + ``` Reading package lists... Done Building dependency tree @@ -59,13 +65,22 @@ Processing triggers for systemd (229-4ubuntu21) ... Processing triggers for ureadahead (0.100.0-19) ... ``` -### 在 CentOS/RHEL/Fedora/Oracle/Scientific Linux 上安装 uptimed +#### 在 CentOS/RHEL/Fedora/Oracle/Scientific Linux 上安装 uptimed + +首先 [在 CentOS/RHEL 使用 EPEL 仓库][6]: + +``` +$ sudo yum -y install epel-release +``` + +然后,键入以下 [yum 命令][7]: + +``` +$ sudo yum install uptimed +``` -首先 [在 CentOS/RHEL 使用 EPEL repo][6]: -`$ sudo yum -y install epel-release` -然后,键入以下 [yum 命令][7]: -`$ sudo yum install uptimed` 示例输出: + ``` Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile @@ -108,33 +123,51 @@ Installed: Complete! ``` -如果你正在使用 **Fedora Linux**,运行以下 dnf 命令: -`$ sudo dnf install uptimed` +如果你正在使用 Fedora Linux,运行以下 `dnf` 命令: -### 在 Arch Linux 上安装 uptimed +``` +$ sudo dnf install uptimed +``` -键入以下 pacman 命令: -`$ sudo pacman -S uptimed` +#### 在 Arch Linux 上安装 uptimed -### 在 Gentoo Linux 上安装 uptimed +键入以下 `pacman` 命令: -键入以下 emerge 命令: -`$ sudo emerge --ask uptimed` +``` +$ sudo pacman -S uptimed +``` -## 如何配置 uptimed +#### 在 Gentoo Linux 上安装 uptimed + +键入以下 `emerge` 命令: + +``` +$ sudo emerge --ask uptimed +``` + +### 如何配置 uptimed + +使用文本编辑器编辑 `/etc/uptimed.conf` 文件,例如 `vim` 命令: + +``` +$ sudo vim /etc/uptimed.conf +``` + +最少设置一个 email 地址来发送记录。假定有个兼容 sendmail 的 MTA 安装在 `/usr/lib/sendmail`。 -使用文本编辑器编辑 /etc/uptimed.conf 文件,例如 vim 命令: -`$ sudo vim /etc/uptimed.conf` -最少设置一个 email 地址来发送记录。假定发送邮件兼容 MTA。 ``` EMAIL=vivek@server1.cyberciti.biz ``` + 保存并关闭文件。 ### 如何在系统启动时启动 uptimed 服务? -使用 systemctl 命令启动 uptimed 服务: -`$ sudo systemctl enable uptimed` +使用 `systemctl` 命令启动 `uptimed` 服务: + +``` +$ sudo systemctl enable uptimed +``` ### 我该如何 启动/停止/重启 或者查看 uptimed 服务的状态? @@ -144,7 +177,9 @@ $ sudo systemctl stop uptimed ## stop it ## $ sudo systemctl restart uptimed ## restart it ## $ sudo systemctl status uptimed ## view status ## ``` + 示例输出: + ``` ● uptimed.service - uptime record daemon Loaded: loaded (/lib/systemd/system/uptimed.service; enabled; vendor preset: enabled) @@ -156,21 +191,26 @@ $ sudo systemctl status uptimed ## view status ## Nov 09 17:49:14 gfs04 systemd[1]: Started uptime record daemon. ``` -## 如何查看 uptime 记录 +### 如何查看 uptime 记录 + +只需键入以下命令即可查看 `uptimed(8)` 程序的统计信息: -只需键入以下命令即可查看 uptimed(8) 程序的统计信息: ``` $ uprecords ``` 示例输出: + [![Fig.02: uprecords in action][9]][9] -uprecords 有一些选项: +`uprecords` 有一些选项: + ``` $ uprecords -? ``` + 示例输出: + ``` usage: uprecords [OPTION]... @@ -191,9 +231,9 @@ usage: uprecords [OPTION]... -v version information ``` -## 结论 +### 结论 -这是一个极好的小工具,可以显示服务器正常运行时间的记录,以证明机器正常运行时间和你的业务连续性。在相关说明中,你将获得官方的 [XKCD 系统管理员 T恤][10] 因为漫画被制作成衬衫,其中包括背面的新插图。 +这是一个极好的小工具,可以显示服务器正常运行时间的记录,以证明机器正常运行时间和你的业务连续性。在相关说明中,你可以看到官方的 [XKCD 系统管理员 T恤][10] 因为漫画被制作成衬衫,其中包括背面的新插图。 [![Fig.03: Sysadmin XKCD shirt features the original comic on the front and a new illustration on the back.][11]][11] @@ -201,9 +241,9 @@ usage: uprecords [OPTION]... via: https://www.cyberciti.biz/hardware/see-records-statistics-about-a-linux-servers-uptime/ -作者:[][a] +作者:[Vivek Gite][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 bbeb6401d76bf343852551276f061edf199355ba Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 5 Apr 2018 22:59:19 +0800 Subject: [PATCH 0304/1057] PUB:20171109 How to record statistics about a Linux machine-s uptime.md @MjSeven https://linux.cn/article-9518-1.html --- ...109 How to record statistics about a Linux machine-s uptime.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171109 How to record statistics about a Linux machine-s uptime.md (100%) diff --git a/translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md b/published/20171109 How to record statistics about a Linux machine-s uptime.md similarity index 100% rename from translated/tech/20171109 How to record statistics about a Linux machine-s uptime.md rename to published/20171109 How to record statistics about a Linux machine-s uptime.md From 5871fbb3c1c1738e9aacb075f003d01e55cb22af Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 6 Apr 2018 20:19:18 +0800 Subject: [PATCH 0305/1057] PRF:20180313 The Type Command Tutorial With Examples For Beginners.md @geekpi --- ...nd Tutorial With Examples For Beginners.md | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md b/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md index 29b87c6858..5db9fd5426 100644 --- a/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md +++ b/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md @@ -1,22 +1,23 @@ -给初学者的 Type 命令教程 +给初学者的 type 命令教程 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/Type-command-720x340.png) -** Type ** 命令用于查找 Linux 命令的信息。顾名思义,你可以使用 “type” 命令轻松找出给定的命令是否是别名、shell 内置命令、文件、函数或关键字。另外,你也可以找到命令的实际路径。为什么有人需要找到命令类型?例如,如果你经常在共享计算机上工作,则某些人可能会故意或意外地为特定的 Linux 命令创建别名来执行不需要的操作,例如 **“alias ls = rm -rf /”**。因此,在发生更糟糕的事情之前检查它们总是一个好主意。这是 type 命令有用的地方。 +`type` 命令用于查找 Linux 命令的信息。顾名思义,你可以使用 `type` 命令轻松找出给定的命令是否是别名、shell 内置命令、文件、函数或关键字。另外,你也可以找到命令的实际路径。为什么有人需要找到命令类型?例如,如果你经常在共享的计算机上工作,则某些人可能会故意或意外地为特定的 Linux 命令创建别名来执行不需要的操作,例如 `alias ls = rm -rf /`。因此,在发生更糟糕的事情之前检查它们总是一个好主意。这是 `type` 命令有用的地方。 让我给你看一些例子。 -不带任何选项运行 Type 命令。 +不带任何选项运行 `type` 命令。 + ``` $ type ls ls is aliased to `ls --color=auto' - ``` -正如你在上面的输出中看到的那样,“ls” 命令已被别名为 “ls -color-auto”。但是,它是无害的。但只要想想 **ls** 如果被别名为了其他一些危险的命令。你不想那样,是吗? +正如你在上面的输出中看到的那样,`ls` 命令已被别名为 `ls -color-auto`。但是,它是无害的。但只要想想 `ls` 如果被别名为了其他一些危险的命令。你不想那样,是吗? + +你可以使用 `-t` 选项仅找出 Linux 命令的类型。例如: -你可以使用 **-t** 选项仅找出 Linux 命令的类型。例如: ``` $ type -t ls alias @@ -32,49 +33,45 @@ keyword $ type -t rvm function - ``` -该命令仅显示命令的类型,即 alias。它不显示被别名的命令。如果找不到命令,你将在终端中看不到任何内容。 +该命令仅显示命令的类型,例如别名。它不显示被别名的内容。如果该命令找不到,你将在终端中看不到任何内容。 -type 命令的另一个有用的地方是我们可以很容易地找出给定 Linux 命令的绝对路径。为此,请使用 **- p** 选项,如下所示。 +`type` 命令的另一个有用的地方是我们可以很容易地找出给定 Linux 命令的绝对路径。为此,请使用 `-p` 选项,如下所示。 ``` $ type -p cal /usr/bin/cal - ``` -这与 “which ls” 命令类似。如果给定的命令是别名,则不会打印任何内容。 +这与 `which ls` 命令类似。如果给定的命令是别名,则不会打印任何内容。 + +要显示命令的所有信息,请使用 `-a` 选项。 -要显示命令的所有信息,请使用 **-a** 选项。 ``` $ type -a ls ls is aliased to `ls --color=auto' ls is /usr/bin/ls ls is /bin/ls - ``` -如你所见,-a 标志显示给定命令的类型及其绝对路径。有关更多详细信息,请参阅手册页。 +如你所见,`-a` 标志显示给定命令的类型及其绝对路径。有关更多详细信息,请参阅手册页。 + ``` $ man type - ``` 希望这有帮助。会有更多的好东西。请继续访问! 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/the-type-command-tutorial-with-examples-for-beginners/ 作者:[SK][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 485cef77b1fe3bb1195bc4ad59904f699b1dec0b Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 6 Apr 2018 20:19:37 +0800 Subject: [PATCH 0306/1057] PUB:20180313 The Type Command Tutorial With Examples For Beginners.md @geekpi --- ...80313 The Type Command Tutorial With Examples For Beginners.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180313 The Type Command Tutorial With Examples For Beginners.md (100%) diff --git a/translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md b/published/20180313 The Type Command Tutorial With Examples For Beginners.md similarity index 100% rename from translated/tech/20180313 The Type Command Tutorial With Examples For Beginners.md rename to published/20180313 The Type Command Tutorial With Examples For Beginners.md From e57d186faa78fc0c861b13780ce74350e6751ce8 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 21:46:39 +0800 Subject: [PATCH 0307/1057] =?UTF-8?q?20180406-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80308 Dynamic Linux Routing with Quagga.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 sources/tech/20180308 Dynamic Linux Routing with Quagga.md diff --git a/sources/tech/20180308 Dynamic Linux Routing with Quagga.md b/sources/tech/20180308 Dynamic Linux Routing with Quagga.md new file mode 100644 index 0000000000..89e632cda6 --- /dev/null +++ b/sources/tech/20180308 Dynamic Linux Routing with Quagga.md @@ -0,0 +1,111 @@ +Dynamic Linux Routing with Quagga +============================================================ + + +![network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/network_visualization.png?itok=P3Ve7eO1 "network") +Learn how to use the Quagga suite of routing protocols to manage dynamic routing.[Creative Commons Attribution][1][Wikimedia Commons: Martin Grandjean][2] + +So far in this series, we have learned the intricacies of IPv4 addressing in [Linux LAN Routing for Beginners: Part 1][4] and how to create static routes manually in [Linux LAN Routing for Beginners: Part 2][5]. + +Now we're going to use [Quagga][6] to manage dynamic routing for us, just set it and forget it. Quagga is a suite of routing protocols: OSPFv2, OSPFv3, RIP v1 and v2, RIPng, and BGP-4, which are all managed by the zebra daemon. + +OSPF means Open Shortest Path First. OSPF is an interior gateway protocol (IGP); it is for LANs and LANs connected over the Internet. Every OSPF router in your network contains the topology for the whole network, and calculates the best paths through the network. OSPF automatically multicasts any network changes that it detects. You can divide up your network into areas to keep routing tables manageable; the routers in each area only need to know the next hop out of their areas rather than the entire routing table for your network. + +RIP, Routing Information Protocol, is an older protocol. RIP routers periodically multicast their entire routing tables to the network, rather than just the changes as OSPF does. RIP measure routes by hops, and sees any destination over 15 hops as unreachable. RIP is simple to set up, but OSPF is a better choice for speed, efficiency, and scalability. + +BGP-4 is the Border Gateway Protocol version 4\. This is an exterior gateway protocol (EGP) for routing Internet traffic. You won't use BGP unless you are an Internet service provider. + +### Preparing for OSPF + +In our little KVM test lab, there are two virtual machines representing two different networks, and one VM acting as the router. Create two networks: net1 is 192.168.110.0/24 and net2 is 192.168.120.0/24\. It's all right to enable DHCP because you are going to go into your three virtual machines and give each of them static addresses. Host 1 is on net1, Host 2 is on net2, and Router is on both networks. Give Host 1 a gateway of 192.168.110.126, and Host 2 gets 192.168.120.136. + +* Host 1: 192.168.110.125 + +* Host 2: 192.168.120.135 + +* Router: 192.168.110.126 and 192.168.120.136 + +Install Quagga on your router, which on most Linuxes is the quagga package. On Debian there is a separate documentation package, quagga-doc. Uncomment this line in `/etc/sysctl.conf` to enable packet forwarding: + +``` +net.ipv4.ip_forward=1 +``` + +Then run the `sysctl -p` command to load the change. + +### Configuring Quagga + +Look in your Quagga package for example configuration files, such as `/usr/share/doc/quagga/examples/ospfd.conf.sample`. Configuration files should be in `/etc/quagga`, unless your particular Linux flavor does something creative with them. Most Linuxes ship with just two files in this directory, `vtysh.conf` and `zebra.conf`. These provide minimal defaults to enable the daemons to run. zebra always has to run first, and again, unless your distro has done something strange, it should start automatically when you start ospfd. Debian/Ubuntu is a special case, which we will get to in a moment. + +Each router daemon gets its own configuration file, so we must create `/etc/quagga/ospfd.conf`, and populate it with these lines: + +``` +!/etc/quagga/ospfd.conf +hostname router1 +log file /var/log/quagga/ospfd.log +router ospf + ospf router-id 192.168.110.15 + network 192.168.110.0/0 area 0.0.0.0 + network 192.168.120.0/0 area 0.0.0.0 +access-list localhost permit 127.0.0.1/32 +access-list localhost deny any +line vty + access-class localhost +``` + +You may use either the exclamation point or hash marks to comment out lines. Let's take a quick walk through these options. + +* **hostname** is whatever you want. This isn't a normal Linux hostname, but the name you see when you log in with `vtysh` or `telnet`. + +* **log file** is whatever file you want to use for the logs. + +* **router** specifies the routing protocol. + +* **ospf router-id** is any 32-bit number. An IP address of the router is good enough. + +* **network** defines the networks your router advertises. + +* The **access-list** entries restrict `vtysh`, the Quagga command shell, to the local machine, and deny remote administration. + +### Debian/Ubuntu + +Debian, Ubuntu, and possibly other Debian derivatives require one more step before you can launch the daemon. Edit `/etc/quagga/daemons` so that all lines say `no` except `zebra`=yes and `ospfd=yes`. + +Then, to launch `ospfd` on Debian launch Quagga: + +``` +# systemctl start quagga +``` + +On most other Linuxes, including Fedora and openSUSE, start `ospfd`: + +``` +# systemctl start ospfd +``` + +Now Host 1 and Host 2 should ping each other, and the router. + +That was a lot of words to describe a fairly simple setup. In real life the router will connect to two switches and provide a gateway for all the computers attached to those switches. You could add more network interfaces to your router to provide routing for more networks, or connect directly to another router, or to a LAN backbone that connects to other routers. + +You probably don't want to hassle with configuring network interfaces manually. The easy way is to advertise your router with your DHCP server. If you use Dnsmasq then you get DHCP and DNS all in one. + +There are many more configuration options, such as encrypted password protection. See the official documentation at [Quagga Routing Suite][7]. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/3/dynamic-linux-routing-quagga + +作者:[CARLA SCHRODER ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/cschroder +[1]:https://www.linux.com/licenses/category/creative-commons-attribution +[2]:https://commons.wikimedia.org/wiki/File:Network_Visualization.png +[3]:https://www.linux.com/files/images/networkvisualizationpng +[4]:https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginners-part-1 +[5]:https://www.linux.com/learn/intro-to-linux/2018/3/linux-lan-routing-beginners-part-2 +[6]:https://www.quagga.net/ +[7]:https://www.quagga.net/ From 4f63c0f6d8c1598fe1933e86814d10e2595ada4c Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 21:50:29 +0800 Subject: [PATCH 0308/1057] =?UTF-8?q?20180406-2=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Linux LAN Routing for Beginners- Part 1.md | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md diff --git a/sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md b/sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md new file mode 100644 index 0000000000..98bfab1445 --- /dev/null +++ b/sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md @@ -0,0 +1,106 @@ +Linux LAN Routing for Beginners: Part 1 +============================================================ + + +![Linux routing](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/traffic_warder.jpeg?itok=hZxS_PB4 "Linux routing") +Carla Schroder offers an overview of hardware and operating systems, plus IPv4 addressing basics, in this tutorial.[Creative Commons Attribution][1][Wikimedia Commons: Public Domain][2] + +Once upon a time we learned about [IPv6 routing][4]. Now we're going to dig into the basics of IPv4 routing with Linux. We'll start with an overview of hardware and operating systems, and IPv4 addressing basics, and next week we'll setup and test routing. + +### LAN Router Hardware + +Linux is a real networking operating system, and always has been, with network functionality built-in from the beginning. Building a LAN router is simple compared to building a gateway router that connects your LAN to the Internet. You don't have to hassle with security or firewall rules, which are still complicated by having to deal with NAT, network address translation, an affliction of IPv4\. Why do we not drop IPv4 and migrate to IPv6? The life of the network administrator would be ever so much simpler. + +But I digress. Ideally, your Linux router is a small machine with at least two network interfaces. Linux Gizmos has a great roundup of single-board computers here: [Catalog of 98 open-spec, hacker friendly SBCs][5]. You could use an old laptop or desktop PC. You could use a compact computer, like the ZaReason Zini or the System76 Meerkat, though these are a little pricey at nearly $600\. But they are stout and reliable, and you're not wasting money on a Windows license. + +The Raspberry Pi 3 Model B is great for lower-demand routing. It has a single 10/100 Ethernet port, onboard 2.4GHz 802.11n wireless, and four USB ports, so you can plug in more USB network interfaces. USB 2.0 and the slower onboard network interfaces make the Pi a bit of a network bottleneck, but you can't beat the price ($35 without storage or power supply). It supports a couple dozen Linux flavors, so chances are you can have your favorite. The Debian-based Raspbian is my personal favorite. + +### Operating System + +You might as well stuff the smallest version of your favorite Linux on your chosen hardware thingy, because the specialized router operating systems such as OpenWRT, Tomato, DD-WRT, Smoothwall, Pfsense, and so on all have their own non-standard interfaces. In my admirable opinion this is an unnecessary complication that gets in the way rather than helping. Use the standard Linux tools and learn them once. + +The Debian net install image is about 300MB and supports multiple architectures, including ARM, i386, amd64, and armhf. Ubuntu's server net installation image is under 50MB, giving you even more control over what packages you install. Fedora, Mageia, and openSUSE all offer compact net install images. If you need inspiration browse [Distrowatch][6]. + +### What Routers Do + +Why do we even need network routers? A router connects different networks. Without routing every network space is isolated, all sad and alone with no one to talk to but the same boring old nodes. Suppose you have a 192.168.1.0/24 and a 192.168.2.0/24 network. Your two networks cannot talk to each other without a router connecting them. These are Class C private networks with 254 usable addresses each. Use ipcalc to get nice visual information about them: + +``` +$ ipcalc 192.168.1.0/24 +Address: 192.168.1.0 11000000.10101000.00000001\. 00000000 +Netmask: 255.255.255.0 = 24 11111111.11111111.11111111\. 00000000 +Wildcard: 0.0.0.255 00000000.00000000.00000000\. 11111111 +=> +Network: 192.168.1.0/24 11000000.10101000.00000001\. 00000000 +HostMin: 192.168.1.1 11000000.10101000.00000001\. 00000001 +HostMax: 192.168.1.254 11000000.10101000.00000001\. 11111110 +Broadcast: 192.168.1.255 11000000.10101000.00000001\. 11111111 +Hosts/Net: 254 Class C, Private Internet +``` + +I like that ipcalc's binary output makes a visual representation of how the netmask works. The first three octets are the network address, and the fourth octet is the host address, so when you are assigning host addresses you "mask" out the network portion and use the leftover. Your two networks have different network addresses, and that is why they cannot communicate without a router in between them. + +Each octet is 256 bytes, but that does not give you 256 host addresses because the first and last values, 0 and 255, are reserved. 0 is the network identifier, and 255 is the broadcast address, so that leaves 254 host addresses. ipcalc helpfully spells all of this out. + +This does not mean that you never have a host address that ends in 0 or 255\. Suppose you have a 16-bit prefix: + +``` +$ ipcalc 192.168.0.0/16 +Address: 192.168.0.0 11000000.10101000\. 00000000.00000000 +Netmask: 255.255.0.0 = 16 11111111.11111111\. 00000000.00000000 +Wildcard: 0.0.255.255 00000000.00000000\. 11111111.11111111 +=> +Network: 192.168.0.0/16 11000000.10101000\. 00000000.00000000 +HostMin: 192.168.0.1 11000000.10101000\. 00000000.00000001 +HostMax: 192.168.255.254 11000000.10101000\. 11111111.11111110 +Broadcast: 192.168.255.255 11000000.10101000\. 11111111.11111111 +Hosts/Net: 65534 Class C, Private Internet +``` + +ipcalc lists your first and last host addresses, 192.168.0.1 and 192.168.255.254\. You may have host addresses that end in 0 and 255, for example 192.168.1.0 and 192.168.0.255, because those fall in between the HostMin and HostMax. + +The same principles apply regardless of your address blocks, whether they are private or public, and don't be shy about using ipcalc to help you understand. + +### CIDR + +CIDR (Classless Inter-Domain Routing) was created to extend IPv4 by providing variable-length subnet masking. CIDR allows finer slicing-and-dicing of your network space. Let ipcalc demonstrate: + +``` +$ ipcalc 192.168.1.0/22 +Address: 192.168.1.0 11000000.10101000.000000 01.00000000 +Netmask: 255.255.252.0 = 22 11111111.11111111.111111 00.00000000 +Wildcard: 0.0.3.255 00000000.00000000.000000 11.11111111 +=> +Network: 192.168.0.0/22 11000000.10101000.000000 00.00000000 +HostMin: 192.168.0.1 11000000.10101000.000000 00.00000001 +HostMax: 192.168.3.254 11000000.10101000.000000 11.11111110 +Broadcast: 192.168.3.255 11000000.10101000.000000 11.11111111 +Hosts/Net: 1022 Class C, Private Internet +``` + +The netmask is not limited to whole octets, but rather crosses the boundary between the third and fourth octets, and the subnet portion ranges from 0 to 3, and not from 0 to 255\. The number of available hosts is not a multiple of 8 as it is when the netmask is defined by whole octets. + +Your homework is to review CIDR and how the IPv4 address space is allocated between public, private, and reserved blocks, as this is essential to understanding routing. Setting up routes is not complicated as long as you have a good knowledge of addressing. + +Start with [Understanding IP Addressing and CIDR Charts][7], [IPv4 Private Address Space and Filtering][8], and [IANA IPv4 Address Space Registry][9]. Then come back next week to learn how to create and manage routes. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginners-part-1 + +作者:[CARLA SCHRODER ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/cschroder +[1]:https://www.linux.com/licenses/category/creative-commons-attribution +[2]:https://commons.wikimedia.org/wiki/File:Traffic_warder.jpeg +[3]:https://www.linux.com/files/images/trafficwarderjpeg +[4]:https://www.linux.com/learn/intro-to-linux/2017/7/practical-networking-linux-admins-ipv6-routing +[5]:http://linuxgizmos.com/catalog-of-98-open-spec-hacker-friendly-sbcs/#catalog +[6]:http://distrowatch.org/ +[7]:https://www.ripe.net/about-us/press-centre/understanding-ip-addressing +[8]:https://www.arin.net/knowledge/address_filters.html +[9]:https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml From e31bd508da1d10bf815301743511dc4af2e4ad9c Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 21:51:44 +0800 Subject: [PATCH 0309/1057] =?UTF-8?q?20180406-3=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Linux LAN Routing for Beginners- Part 2.md | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md diff --git a/sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md b/sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md new file mode 100644 index 0000000000..2173a6a4a2 --- /dev/null +++ b/sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md @@ -0,0 +1,120 @@ +Linux LAN Routing for Beginners: Part 2 +============================================================ + + +![Routing](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dortmund-hbf-1259559_1920.jpg?itok=mdkNQRkS "Routing") +In this tutorial, we show how to manually configure LAN routers.[Creative Commons Zero][1] + +Last week [we reviewed IPv4 addressing][3] and using the network admin's indispensible ipcalc tool: Now we're going to make some nice LAN routers. + +VirtualBox and KVM are wonderful for testing routing, and the examples in this article are all performed in KVM. If you prefer to use physical hardware, then you need three computers: one to act as the router, and the other two to represent two different networks. You also need two Ethernet switches and cabling. + +The examples assume a wired Ethernet LAN, and we shall pretend there are some bridged wireless access points for a realistic scenario, although we're not going to do anything with them. (I have not yet tried all-WiFi routing and have had mixed success with connecting a mobile broadband device to an Ethernet LAN, so look for those in a future installment.) + +### Network Segments + +The simplest network segment is two computers in the same address space connected to the same switch. These two computers do not need a router to communicate with each other. A useful term is  _broadcast domain_ , which describes a group of hosts that are all in the same network. They may be all connected to a single Ethernet switch, or multiple switches. A broadcast domain may include two different networks connected by an Ethernet bridge, which makes the two networks behave as a single network. Wireless access points are typically bridged to a wired Ethernetwork. + +A broadcast domain can talk to a different broadcast domain only when they are connected by a network router. + +### Simple Network + +The following example commands are not persistent, and your changes will vanish with a restart. + +A broadcast domain needs a router to talk to other broadcast domains. Let's illustrate this with two computers and the `ip` command. Our two computers are 192.168.110.125 and 192.168.110.126, and they are plugged into the same Ethernet switch. In VirtualBox or KVM, you automatically create a virtual switch when you configure a new network, so when you assign a network to a virtual machine it's like plugging it into a switch. Use `ip addr show` to see your addresses and network interface names. The two hosts can ping each other. + +Now add an address in a different network to one of the hosts: + +``` +# ip addr add 192.168.120.125/24 dev ens3 +``` + +You have to specify the network interface name, which in the example is ens3\. It is not required to add the network prefix, in this case /24, but it never hurts to be explicit. Check your work with `ip`. The example output is trimmed for clarity: + +``` +$ ip addr show +ens3: + inet 192.168.110.125/24 brd 192.168.110.255 scope global dynamic ens3 + valid_lft 875sec preferred_lft 875sec + inet 192.168.120.125/24 scope global ens3 + valid_lft forever preferred_lft forever +``` + +The host at 192.168.120.125 can ping itself (`ping 192.168.120.125`), and that is a good basic test to verify that your configuration is working correctly, but the second computer can't ping that address. + +Now we need to do bit of network juggling. Start by adding a third host to act as the router. This needs two virtual network interfaces and a second virtual network. In real life you want your router to have static IP addresses, but for now we'll let the KVM DHCP server do the work of assigning addresses, so you only need these two virtual networks: + +* First network: 192.168.110.0/24 + +* Second network: 192.168.120.0/24 + +Then your router must be configured to forward packets. Packet forwarding should be disabled by default, which you can check with `sysctl`: + +``` +$ sysctl net.ipv4.ip_forward +net.ipv4.ip_forward = 0 +``` + +The zero means it is disabled. Enable it with this command: + +``` +# echo 1 > /proc/sys/net/ipv4/ip_forward +``` + +Then configure one of your other hosts to play the part of the second network by assigning the 192.168.120.0/24 virtual network to it in place of the 192.168.110.0/24 network, and then reboot the two "network" hosts, but not the router. (Or restart networking; I'm old and lazy and don't care what weird commands are required to restart services when I can just reboot.) The addressing should look something like this: + +* Host 1: 192.168.110.125 + +* Host 2: 192.168.120.135 + +* Router: 192.168.110.126 and 192.168.120.136 + +Now go on a ping frenzy, and ping everyone from everyone. There are some quirks with virtual machines and the various Linux distributions that produce inconsistent results, so some pings will succeed and some will not. Not succeeding is good, because it means you get to practice creating a static route. First, view the existing routing tables. The first example is from Host 1, and the second is from the router: + +``` +$ ip route show +default via 192.168.110.1 dev ens3 proto static metric 100 +192.168.110.0/24 dev ens3 proto kernel scope link src 192.168.110.164 metric 100 +``` + +``` +$ ip route show +default via 192.168.110.1 dev ens3 proto static metric 100 +default via 192.168.120.1 dev ens3 proto static metric 101 +169.254.0.0/16 dev ens3 scope link metric 1000 +192.168.110.0/24 dev ens3 proto kernel scope link + src 192.168.110.126 metric 100 +192.168.120.0/24 dev ens9 proto kernel scope link + src 192.168.120.136 metric 100 +``` + +This shows us that the default routes are the ones assigned by KVM. The 169.* address is the automatic link local address, and we can ignore it. Then we see two more routes, the two that belong to our router. You can have multiple routes, and this example shows how to add a non-default route to Host 1: + +``` +# ip route add 192.168.120.0/24 via 192.168.110.126 dev ens3 +``` + +This means Host 1 can access the 192.168.110.0/24 network via the router interface 192.168.110.126\. See how it works? Host 1 and the router need to be in the same address space to connect, then the router forwards to the other network. + +This command deletes a route: + +``` +# ip route del 192.168.120.0/24 +``` + +In real life, you're not going to be setting up routes manually like this, but rather using a router daemon and advertising your router via DHCP but understanding the fundamentals is key. Come back next week to learn how to set up a nice easy router daemon that does the work for you. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/3/linux-lan-routing-beginners-part-2 + +作者:[CARLA SCHRODER ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/cschroder +[1]:https://www.linux.com/licenses/category/creative-commons-zero +[2]:https://www.linux.com/files/images/dortmund-hbf-12595591920jpg +[3]:https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginners-part-1 From 8289ec5340e171bc5637455d10582c6ca7c07042 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 21:55:41 +0800 Subject: [PATCH 0310/1057] =?UTF-8?q?20180406-4=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180301 The Cost of Cloud Computing.md | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 sources/tech/20180301 The Cost of Cloud Computing.md diff --git a/sources/tech/20180301 The Cost of Cloud Computing.md b/sources/tech/20180301 The Cost of Cloud Computing.md new file mode 100644 index 0000000000..b6c96c3c56 --- /dev/null +++ b/sources/tech/20180301 The Cost of Cloud Computing.md @@ -0,0 +1,153 @@ +The Cost of Cloud Computing +============================================================ + +### A day in the life of two development teams + + +![](https://cdn-images-1.medium.com/max/2000/1*nBZJgNXl54jzFKa91s1KfQ.png) + +Over the last few months, I’ve talked with a number people who are concerned about the cost of public cloud services in comparison to the price of traditional on-premises infrastructure. To provide some insights from the discussion, let’s follow two development teams within an enterprise — and compare how they would approach building a similar service. + +The first team will deploy their application using traditional on-premises infrastructure, while the second will leverage some of the public cloud services available on AWS. + +The two teams are being asked to develop a new service for a global enterprise company that currently serves millions of consumers worldwide. This new service will need to meet theses basic requirements: + +1. The ability to scale to meet elastic demands + +2. Provide resiliency in response to a datacenter failure + +3. Ensure data is secure and protected + +4. Provide in-depth debugging for troubleshooting + +5. The project must be delivered quickly + +6. The service be cost-efficient to build and maintain + +As far as new services go, this seems to be a fairly standard set of requirements — nothing that would intrinsically favor either traditional on-premises infrastructure over the public cloud. + +![](https://cdn-images-1.medium.com/max/1600/1*DgnAPA6P5R0yQiV8n6siJw.png) + +* * * + +#### 1 —Scaling to meet customer demands + +When it comes to scalability, this new service needs to scale to meet the variable demands of consumers. We can’t build a service that might drop requests and cost our company money and cause reputational risk. + +The Traditional Team With on-premises infrastructure, the architectural approach dictates that compute capacity needs to be sized to match your peak data demands. For services that features a variable workload, this will leave you with a lot of excess and expensive compute capacity in times of low utilization. + +This approach is wasteful — and the capital expense will eat into your profits. In addition, there is a heavy operational costs with maintaining your fleet of underutilized servers. This is a cost that is often overlooked — and I cannot emphasize enough how much money and time will be wasted supporting a rack of bare-metal servers for a single service. + +The Cloud Team With a cloud-based autoscaling solution, your application scales up and down in-line with demand. This means that you’re only paying for the compute resources that you consume. + +A well-architected cloud-based application enables the act of scaling up and down to be seamless — and automatic. The development team defines auto-scaling groups that spin up more instances of your application based on high-CPU utilization, or a large number of requests per second, and you can customize these rules to your heart’s content. + +* * * + +#### 2- Resiliency in response to failure + +When it comes to resiliency, hosting a service on infrastructure that resides within the same four walls isn’t an option. If your application resides within a single datacenter — then you are stuffed when ( _not if_ ) something fails. + +The Traditional Team To meet basic resiliency criteria for an on-premises solution, this team would a minimum of two servers for local resiliency — replicated in a second data center for geographic redundancy. + +The development team will need to identify a load balancing solution that automatically redirects traffic between sites in the event of saturation or failure — and ensure that the mirror site is continually synchronized with the entire stack. + +The Cloud Team Within each of their 50 regions worldwide, AWS provides multiple  _availability zones_ . Each zone consists of one of more fault-tolerant data centers — with automated failover capabilities that can seamlessly transition AWS services to other zones within the region. + +Defining your _ infrastructure as code_  within a CloudFormation template ensures your infrastructure resources remain consistent across the zones during autoscaling events — and the AWS load balancer service requires minimal effort to setup and manage the traffic flow. + + +* * * + +#### 3 — Secure and protect your data + +Security is be a fundamental requirement of any system being developed within an organization. You really don’t want to be one of the unfortunate companies dealing with fallout from a security breach. + +The Traditional Team The traditional team will incur the ongoing costs of ensuring that the bare-metal servers that’s running their services is secure. This means investing in a team that is trying to monitor, identify, and patch security threats across multiple vendor solutions from a variety of unique data sources. + +The Cloud Team Leveraging the public cloud does not exempt yourself from security. The cloud team still has to remain vigilant, but doesn’t have to worry about patching the underlying infrastructure. AWS actively works combat against zero-day exploits — most recently with Spectre and Meltdown. + +Leveraging the identify management and encryption security services from AWS allows the cloud team to focus on their application — and not the undifferentiated security management. The API calls to AWS services are fully audited using CloudTrail, which provides transparent monitoring. + +* * * + +#### 4 — Monitoring and logging + +Every infrastructure and application service being deployed need to be closely monitored with aggregated realtime data. The teams should have access to dashboards that provide alerts when thresholds are exceeded, and offer the ability to leverage logs for event correlation for troubleshooting. + +The Traditional Team For traditional infrastructure, you will have to set up monitoring and alerting solutions across disparate vendors and snowflake solutions. Setting this up takes a hell of a lot of time — and effort and getting it right is incredibly difficult. + +For many applications deployed on-premises, you may find yourself searching through log files stored on your server’s file-system in order to make sense of why your application is crashing. A lot of time will be wasted as teams need to ssh into the server, navigate to the unique directory of log files, and then grep through potentially hundreds of files. Having done this for an application that was deployed across 60 servers — I can tell you that this isn’t a pretty solution. + +The Cloud Team Native AWS services such as CloudWatch and CloudTrail make monitoring cloud applications an absolute breeze. Without much setup, the development team can monitor a wide variety of different metrics for each of the deployed services — making the process of debugging issues an absolute dream. + +With traditional infrastructure, teams need build their own solution, and configure their REST API or service to push log files to an aggregator. Getting this ‘out-of-the-box’ is an insane improvement fo productivity. + +* * * + +#### 5 — Accelerate the development + +The ability to accelerate time-to-market is increasingly important in today’s business environment. The lost opportunity costs for delayed implementations can have a major impact on bottom-line profits. + +The Traditional Team For most organizations, it takes a long time to purchase, configure and deploy hardware needed for new projects — and procuring extra capacity in advance leads to massive waste due to poor forecasting. + +Most likely, the traditional development team will spend months working across the myriad of silos and hand-offs to create the services. Each step of the project will require a distinct work request to database, system, security, and network administrators. + +The Cloud Team When it comes to developing new features in a timely manner, having a massive suite of production-ready services at the disposal of your keyboard is a developer’s paradise. Each of the AWS services is typically well documented and can be accessed programmatically via your language of choice. + +With new cloud architectures such a serverless, development teams can build and deploy a scalable solution with minimal friction. For example, in just a couple of days I recently built a [serverless clone of Imgur][4] that features image recognition, a production-ready monitoring/logging solution built-in, and is incredibly resilient. + +![](https://cdn-images-1.medium.com/max/1600/1*jHmtrp1OKM4mZVn-gSNoQg.png) + +If I had to engineer the resiliency and scalability myself, I can guarantee you that I would still be developing this project — and the final product would have been nowhere near as good as it currently is. + +Using serverless architecture, I experimented and delivered the solution in a less time that it takes to provision hardware in most companies. I simply glued together a series of AWS services with Lambda functions — and ta-da! I focused on developing the solution, while the undifferentiated scalability and resiliency is handled for me by AWS. + +* * * + +#### The cost verdict on cloud computing + +When it comes to scalability, the cloud team is the clear winner with demand-drive elasticity — thus only paying for compute power that they need. The team no longer needs dedicated resources devoted to maintaining and patching the underlying physical infrastructure. + +The cloud also provides development teams a resilient architecture with multiple availability zones, security features built into each service, consistent tools for logging and monitoring, pay-as-you-go services, and low-cost experimentation for accelerated delivery. + +More often than not, the absolute cost of cloud will amount to less than the cost of buying, supporting, maintaining, and designing the on-premises infrastructure needed for your application to run — with minimal fuss. + +By leveraging cloud we can move faster and with the minimal upfront capital investment needed. Overall, the economics of the cloud will actively work in your favor when developing and deploying your business services. + +There will always be a couple of niche examples where the cost of cloud is prohibitively more expensive than traditional infrastructure, and a few situations where you end up forgetting that you have left some incredibly expensive test boxes running over the weekend. + +[Dropbox saved almost $75 million over two years by building its own tech infrastructure +After making the decision to roll its own infrastructure and reduce its dependence on Amazon Web Services, Dropbox…www.geekwire.com][5][][6] + +However, these cases remain few and far between. Not to mention that Dropbox initially started out life on AWS — and it was only after they had reached a critical mass that they decided to migrate off the platform. Even now, they are overflowing into the cloud and retain 40% of their infrastructure on AWS and GCP. + +The idea of comparing cloud services to traditional infrastructure-based of a single “cost” metric is incredibly naive — it blatantly disregards some of the major advantages the cloud offers development teams and your business. + +In the rare cases when cloud services result in a greater absolute cost than your more traditional infrastructure offering — it still represents a better value in terms of developer productivity, speed, and innovation. + +![](https://cdn-images-1.medium.com/max/1600/1*IlrOdfYiujggbsYynTzzEQ.png) + +Customers don’t give a shit about your data centers + + _I’m very interested in hearing your own experiences and feedback related to the true cost of developing in cloud! Please drop a comment below, on Twitter at _ [_@_ _Elliot_F_][7] _, or connect with me directly on _ [_LinkedIn_][8] _._ + +-------------------------------------------------------------------------------- + +via: https://read.acloud.guru/the-true-cost-of-cloud-a-comparison-of-two-development-teams-edc77d3dc6dc + +作者:[Elliot Forbes][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://read.acloud.guru/@elliot_f?source=post_header_lockup +[1]:https://info.acloud.guru/faas-and-furious?utm_campaign=FaaS%20and%20Furious +[2]:https://read.acloud.guru/building-an-imgur-clone-part-2-image-rekognition-and-a-dynamodb-backend-abc9af300123 +[3]:https://read.acloud.guru/customers-dont-give-a-shit-about-your-devops-pipeline-51a2342cc0f5 +[4]:https://read.acloud.guru/building-an-imgur-clone-part-2-image-rekognition-and-a-dynamodb-backend-abc9af300123 +[5]:https://www.geekwire.com/2018/dropbox-saved-almost-75-million-two-years-building-tech-infrastructure/ +[6]:https://www.geekwire.com/2018/dropbox-saved-almost-75-million-two-years-building-tech-infrastructure/ +[7]:https://twitter.com/Elliot_F +[8]:https://www.linkedin.com/in/elliotforbes/ From 518cb22c08234be8c4044e969780dd67f6015f17 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 21:57:45 +0800 Subject: [PATCH 0311/1057] =?UTF-8?q?20180406-6=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ications on an embedded key value store.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 sources/tech/20180225 What I learnt from building 3 high traffic web applications on an embedded key value store.md diff --git a/sources/tech/20180225 What I learnt from building 3 high traffic web applications on an embedded key value store.md b/sources/tech/20180225 What I learnt from building 3 high traffic web applications on an embedded key value store.md new file mode 100644 index 0000000000..756b9ca878 --- /dev/null +++ b/sources/tech/20180225 What I learnt from building 3 high traffic web applications on an embedded key value store.md @@ -0,0 +1,93 @@ +What I learnt from building 3 high traffic web applications on an embedded key value store. +============================================================ + + +![](https://cdn-images-1.medium.com/max/1600/1*_sXlAxit3i2M-FFaK_OQVg.png) + +I grew up as part of the fad that all web applications must be built on proper architecture, usually involving a well tested and stable sql database like postgres, or in some stretch cases a nosql database like mongodb. The reasons were simple: + +* They can be scaled and scaled and scaled. Very important when your application gets it’s first one billion users overnight. + +* SQL is the best way to access your data. And you always need a complicated message layer to access that data. + +* If you don’t use sql, how will you perform joins? How will you build in complicated search? How will you prevent your code from going so large with complexity that it falls and kills your cat? + + +![](https://cdn-images-1.medium.com/max/1600/1*UZfVU70VqwzFbbp50mRarQ.png) +Your cat is scared of your code. + +* Why build an application where you won’t need to employ an experienced database administrator to create your complicated schemas and perform the very important and complicated database maintenance tasks. + +In 2015, I stumbled on the golang [BoltDB database library][1], and first used to save state in basic server-side applications. Then I stumbled on [blevesearch][2], and it dawned on me. The most basic thing most databases offer is storage, and flexible search over stored data. With boltdb, I could store my data efficiently, and with bleve I could search and access my data in interesting ways. + +![](https://cdn-images-1.medium.com/max/1600/1*CAgNR4s10WtvV4CG9AFFQg.png) +blevesearch + +On this basis, I built and launched [Calabar Yellow Pages][3] on just boltDB and blevesearch, and then when I saw how smoothly it worked and scaled in production, I went on to build [Shop440][4] (A merge between Shopify and Aliexpress) on badger DB (A much faster alternative to boltdb) and blevesearch for indexing. + +### What I learnt: + +### Key Value Stores are fast + +Firstly, a NoSQL key value store is fast, much faster than a comparable relational database. Its speed comes from its simplicity. A key value database stores a data record using one primary key. The key means the record is uniquely identifiable, and can be directly accessed. Other than this, it’s up to the developer to architect any more complexity in accessing data. + + +![](https://cdn-images-1.medium.com/max/1600/1*zTzSNjtU-kudy78iZss1vw.png) + +Also, since the key value stores I used were embedded databases, I was able to strike off some of the processing that comes with more established databases. In a database like mongoDB, A lot of resources and latency goes into serializing data and passing it over the wire to the client application which then deserializes and decodes it. This is a waste of resources, especially when the client and the database are running on the same server, and not on separate servers where they would benefit from communicating over http. An embedded database strikes out all these extra serialization and even tcp transport costs. + +### Great Scalability — What About Consistency? + +Secondly, a NoSQL key value database is also highly scalable. This too is a function of its simplicity. Unlike a relational database, a NoSQL key value database is not obliged to scale vertically. It can scale over several machines or devices by several orders of magnitude, without the need for significant redesign. Financially, this is a big advantage too. + +![](https://cdn-images-1.medium.com/max/1600/1*seBbyRHICKfN87y7zq8I4A.png) + +But in my case, since using an embedded key value store, most scaling happened vertically and even sustained for a very long time. At the moment, even with a database size of almost a terabyte, the application is still holding strong. With badger, I came up with a strategy of having multiple badger databases, each representing a collection. This way, if I ever have a need to scale the system beyond a single server, I could isolate each individual database and it’s corresponding program logic into a separate micro-service. (I will write more about this in the future. ) + +### Cheap on time and effort + + +![](https://cdn-images-1.medium.com/max/1600/1*U-XNO_Q3wVffyYxpEVpfvA.png) + +Scaling a relational database solution often means that cost increases dis-proportionally; it also requires time and effort (and server downtime) to change your database schema. By comparison, a key value database keeps the price curve linear rather than exponential, and it is designed to handle data without any predefined schema. Some (not all) key value databases, like other NoSQL databases, are also designed for ‘eventual consistency’. This means that data are synchronized ‘at some point’ between copies on different machines, but not immediately. + +### Schema-Free Rows and Columns + +![](https://cdn-images-1.medium.com/max/1600/1*57qoZRSyu6H4zQHs8p3qJQ.png) + +### A case for Embedded Key Value Stores + +According to [https://www.sqlite.org/whentouse.html][5] + +> SQLite works great as the database engine for most low to medium traffic websites (which is to say, most websites). The amount of web traffic that SQLite can handle depends on how heavily the website uses its database. Generally speaking, any site that gets fewer than 100K hits/day should work fine with SQLite. The 100K hits/day figure is a conservative estimate, not a hard upper bound. SQLite has been demonstrated to work with 10 times that amount of traffic. + +> The SQLite website ([https://www.sqlite.org/][6]) uses SQLite itself, of course, and as of this writing (2015) it handles about 400K to 500K HTTP requests per day, about 15–20% of which are dynamic pages touching the database. Dynamic content uses [about 200 SQL statements per webpage][7]. This setup runs on a single VM that shares a physical server with 23 others and yet still keeps the load average below 0.1 most of the time. + +Most embedded key value stores like badger are very very much more efficient and performant than sqlite, so this could go to show how much more is possible with embedded key value stores, if sqlite can handle so much hits per day. + +Also, using an embedded key value store alongside an embedded indexing engine like Blevesearch in a compiled language like Golang, means you can truly deploy single binaries with no external dependencies and no need for post deployment setups. + +### In a nutshell + +Embedded key value stores give you all the advantages of a nosql database, but where it is lacking is in search, since you’re only able to query for items by their keys and key’s prefix. But when paired with an indexing engine like blevesearch in golang, or elasicsearch and lucene, the pair gives you a very capable database with features like full text search, location based search, etc in a very resource efficient package and scales well. + +I believe this pair should have more popularity than it actually currently has, and go a long in reducing server expenses especially with applications which never expect facebook level scale. + +-------------------------------------------------------------------------------- + +via: https://hackernoon.com/what-i-learnt-from-building-3-high-traffic-web-applications-on-an-embedded-key-value-store-68d47249774f + +作者:[Anthony Alaribe ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://hackernoon.com/@tonyalaribe?source=post_header_lockup +[1]:https://github.com/boltdb/bolt +[2]:https://github.com/blevesearch/bleve +[3]:http://calabarpages.com/ +[4]:https://shop440.com/ +[5]:https://www.sqlite.org/whentouse.html +[6]:https://www.sqlite.org/ +[7]:https://www.sqlite.org/np1queryprob.html From 57be4a7d00a906713f621cb2c48439a0c0d11e2c Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 21:59:45 +0800 Subject: [PATCH 0312/1057] =?UTF-8?q?20180406-7=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20180211 Latching Mutations with GitOps.md | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sources/tech/20180211 Latching Mutations with GitOps.md diff --git a/sources/tech/20180211 Latching Mutations with GitOps.md b/sources/tech/20180211 Latching Mutations with GitOps.md new file mode 100644 index 0000000000..b9f6f48c23 --- /dev/null +++ b/sources/tech/20180211 Latching Mutations with GitOps.md @@ -0,0 +1,60 @@ +Latching Mutations with GitOps +============================================================ + +Immutable Infrastructure has become a hot topic recently. I’ve written a [couple][1] of [posts][2] about it, and I think the term should be more strict than how it’s usually used. In my opinion, total immutability of infrastructure is a good aspiration, but not very practical. + +The definition of “infrastructure” itself is blurred. Your app devs are now operators; [they operate their own code, on top of a platform you provide][3]. They specify the version and size and number of the containers running their product code. That’s  _their_  infrastructure, and no-one would argue that a new cluster should be stood up every time they want to push a new version. The raison d’être of the cloud-native movement is to enable them to do that  _more_ and  _faster_ . + +No system really can be fully immutable (are  _you_  writing everything in Haskell?). [Cindy Sridharan notes][4] that entropy will always build up, and one major source of that is the churn of the apps running atop your platform. It makes sense to let these apps change in place. (Immutable Architecture is a different beast — never changing the set of  _services _ provided by those apps by e.g. using protobuf to make sure the total API set only grows). + +In response to a new build of an app, or adding one to its replica count, its cluster can be completely replaced with one containing the new version/scale, or it can be mutated in place (i.e. Pods replaced or added). While the latter might seem eminently more sensible, whichever you chose is kind of irrelevant to the argument I’m about to make. That said, I think it’s important to talk about the following in the context of the current conversation around immutable infrastructure. + +* * * + +[Alexis Richardson][5] has been posting a phenomenal series about “[GitOps][6]”*, providing great processes for controllable changes to infrastructure. Kelsey Hightower [has spoken about][7] applying the same principles to app deployment — a separate “infrastructure” repo for the Kubernetes definitions behind your apps, and deployments thereof by Pull Request. + + _*(In short: his thesis is that everything you run should be declared in git. Automated tooling keeps your clusters in sync with that single declaration of truth. All changes are mediated and discussed through Pull Requests coming in from dev branches.)_ + +If a cluster catches fire, so be it. A new one is started, and Weave Flux re-deploys everything that was previously running, because it’s all declared in git. Right? Well, should  _everything _ about the system be declared in git? My first reaction was “yes” — declare everything in git, bring it all under control. But what about something like application scale? We can  _guess_  at this a priori, but it’s ultimately a function of the environment — of actual user traffic rates — not of some engineering best-practice. And we certainly don’t want it done ad-hoc, with a dev watching CPU loads in grafana and raising a PR every minute. + +Let’s consider the opposite: what if scale isn’t declared at all? Kelsey Hightower has said it shouldn’t be, so that an HPA can be used. But what if a system has traffic necessitating 10,000 Pods? If that cluster needs recovering, the result will be a Deployment of  _one_  Pod. That will be totally overwhelmed by the traffic, probably compound the problem by failing its healthcheck, and certainly offer no useful service to its users. + +So I assert that we do want the scale declared in git. And, although the required scale is a function of the environment and can only be known empirically, that loop should be automated too; this is the essence of DevOps. Consider a tool that watches the Deployment and auto-commits each new scale (like a reverse Weave Flux). Even with a separate (app) infrastructure repo, that would be so noisy that actual version upgrades wouldn’t be easily spotted. + +With dynamic properties like scale, being roughly right is good enough. The CPU target is always 70 or 80%, so there’s headroom. It’s sufficient just to declare a nearby round number: a multiple of 10, or an order of magnitude. This is what I suggest; auto-committing the closest round number of your current scale. This will get the system back to a place where it can  _cope._  It might be a bit slow, or a bit wasteful, but it won’t die. Declare enough to get the system back up with one click, and let the HPA take the fine-tuning from there. + +From a manageability point-of-view, this “latching” behaviour keeps systems declared  _well enough_  in git, whilst not overloading operators with commits so numerous that they cease to have any value. This way, for example, they still function as audit logs — 3 users but a replica count of 10k probably means a computational complexity problem (or DoS attack) deserving attention. The automated tool could even PR each latch so it can be eyeballed to decide if its intentions are pure. + +In GitOps terms, the “desired state”, i.e. that declared in git, is a rollback checkpoint; some things  _are_  meant to change, but if those changes go wrong, git will always describe the last, good, consistent state that you should go back to. All I’m saying is that a scale from 1 to 10,000 is something that’s material and should be checkpointed along the way. Think of it as a write-back cache maybe. + +Clearly tools like kubediff either need to ignore this field, or understand the round-numbers latching policy. + +Minimum scale should still be specified (it’s a function of your users’ SLAs, though it lived in the infra repo not code repo, as it’s the empirical result of that SLA married to a load test). Similarly, max scalecan and should also be specified, again as a result of load testing (the point at which you’ve determined that 2nd order effects and the Universal scalability law kill you). These bounds are a function of the users’ requirements and the codebase, whereas run-time scale results from the environment. + +As a further example, take blue-green rollouts. If a cluster is recovered from git that was an unknown way through a roll-out, what state should be recreated? It’s wasteful to go back to 100% v1, if it was 90% through upgrading to v2\. Conversely, it’s unsafe to go all-out with v2 if the scant 1% that had been rolled out had failed their health-checks. I posit that the in-flight ReplicaSets should be watched their major progress milestones latched in git. + +* * * + +In conclusion, changes are inevitable. Whether you scale apps by adding more Pods to an existing cluster, or even if you do make a whole new cluster of  _n_ Pods every time, the problem is the same: some changes have to happen in response to the environment, rather than by operator diktat. Even with a mutating cluster, for purposes of recovery, audit, and easy roll-forwards, you still want an up-to-date description of every material aspect of it in git, but without overwhelming your tooling or operators. By  _latching_ , you capture the important details, while being pragmatic about the amount of incidental churn you want to be bothered by. + +matt. @[mt165pro][8] + +-------------------------------------------------------------------------------- + +via: https://medium.com/@mt165/latching-mutations-with-gitops-92155e84a404 + +作者:[Matt Turner ][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/@mt165?source=post_header_lockup +[1]:https://medium.com/@mt165/immutable-definitions-f7e61593e3b0 +[2]:https://medium.com/@mt165/a-spectrum-of-mutability-3f527268a146 +[3]:https://www.youtube.com/watch?v=nMLyr8q5AWE +[4]:https://twitter.com/copyconstruct/status/954133874002477056 +[5]:https://twitter.com/monadic +[6]:https://www.weave.works/blog/gitops-operations-by-pull-request +[7]:https://youtu.be/07jq-5VbBVQ?t=900 +[8]:https://twitter.com/mt165pro From 8b0ef70c24f08465f3415ee29065d3a63d87f17c Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 22:02:26 +0800 Subject: [PATCH 0313/1057] =?UTF-8?q?20180406-8=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...IoT using Android Things and TensorFlow.md | 311 ++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..60119f96c6 --- /dev/null +++ b/sources/tech/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md @@ -0,0 +1,311 @@ +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 From 8dd4390b47fad8989d0776b15c98182d7ab3f387 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 22:05:34 +0800 Subject: [PATCH 0314/1057] =?UTF-8?q?20180406-9=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180301 How to add fonts to Fedora.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sources/tech/20180301 How to add fonts to Fedora.md diff --git a/sources/tech/20180301 How to add fonts to Fedora.md b/sources/tech/20180301 How to add fonts to Fedora.md new file mode 100644 index 0000000000..4269e78fc0 --- /dev/null +++ b/sources/tech/20180301 How to add fonts to Fedora.md @@ -0,0 +1,51 @@ +How to add fonts to Fedora +=================== + +![](https://fedoramagazine.org/wp-content/uploads/2017/11/install-fonts-1024x433.jpg) + +Fonts help you express your thoughts in creative ways through design. Whether you’re captioning an image, building a presentation, or designing a greeting or advertisement, fonts can boost your idea to the next level. It’s easy to fall in love with them just for their own aesthetic qualities. Fortunately, Fedora makes installation easy. Here’s how to do it. + +### System-wide installation + +If you install a font system-wide, it becomes available to all users. The best way to take advantage of this method is by using RPM packages from the official software repositories. + +To get started, open the  _Software_  tool in your Fedora Workstation, or other tool that uses the official repositories. Choose the  _Add-ons_  category in the group of banners shown. Then in the add-on categories, select  _Fonts._  You’ll see a list of available fonts similar to this screenshot: + + [![](https://fedoramagazine.org/wp-content/uploads/2017/11/Software-fonts-1024x768.png)][1] + +When you select a font, some details appear. Depending on several conditions, you may be able to preview how the font looks with some example text. Select the  _Install_ button to add it to your system. It may take a few moments for the process to complete, based on your system speed and network bandwidth. + +You can also remove previously installed font packages, shown with a check mark, with the  _Remove_  button shown in the font details. + +### Personal installation + +This method works better if you have a font you’ve downloaded in a compatible format:  _.ttf_ ,  _otf_ ,  _.ttc_ ,  _.pfa_ ,  _.pfb_  or . _pcf._  These font extensions shouldn’t be installed system-wide by dropping them into a system folder. Non-packaged fonts of this type can’t be updated automatically. They also can potentially interfere with some software operations later. The best way to install these fonts is in your own personal data directory. + +Open the  _Files_  application in your Fedora Workstation, or a similar file manager app of your choice. If you’re using  _Files_ , you may need to use the  _Ctrl+H_  key combination to show hidden files and folders. Look for the  _.fonts_  folder and open it. If you don’t have a  _.fonts_  folder, create it. (Remember the leading dot and to use all lowercase.) + +Copy the font file you’ve downloaded to your  _.fonts_  folder. You can close the file manager at this point. Open a terminal and type the following command: + +``` +fc-cache +``` + +This will rebuild font caches that help Fedora locate and reference the fonts it can use. You may also need to restart an application such as Inkscape or LibreOffice in which you want to use the new font. Once you restart, the new font should be available. + +* * * + +Photo by [Raphael Schaller][2] on [Unsplash][3]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/add-fonts-fedora/ + +作者:[ Paul W. Frields ][a] +译者:[译者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/pfrields/ +[1]:https://fedoramagazine.org/wp-content/uploads/2017/11/Software-fonts.png +[2]:https://unsplash.com/photos/GkinCd2enIY?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]:https://unsplash.com/search/photos/fonts?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText From b944033d3cd11dd0b3b6af0493e9e9e055ba9bab Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 22:06:55 +0800 Subject: [PATCH 0315/1057] =?UTF-8?q?20180406-9=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20180301 How to add fonts to Fedora.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sources/tech/20180301 How to add fonts to Fedora.md b/sources/tech/20180301 How to add fonts to Fedora.md index 4269e78fc0..61efbb4a98 100644 --- a/sources/tech/20180301 How to add fonts to Fedora.md +++ b/sources/tech/20180301 How to add fonts to Fedora.md @@ -37,6 +37,13 @@ Photo by [Raphael Schaller][2] on [Unsplash][3]. -------------------------------------------------------------------------------- +作者简介: + +Paul W. Frields +Paul W. Frields has been a Linux user and enthusiast since 1997, and joined the Fedora Project in 2003, shortly after launch. He was a founding member of the Fedora Project Board, and has worked on documentation, website publishing, advocacy, toolchain development, and maintaining software. He joined Red Hat as Fedora Project Leader from February 2008 to July 2010, and remains with Red Hat as an engineering manager. He currently lives with his wife and two children in Virginia. + +----------------------------- + via: https://fedoramagazine.org/add-fonts-fedora/ 作者:[ Paul W. Frields ][a] From 8b2b803fa1264a35ef9a150a5e3a5b3540832e09 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 22:25:06 +0800 Subject: [PATCH 0316/1057] =?UTF-8?q?20180406-10=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0180226 How to Use WSL Like a Linux Pro.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 sources/tech/20180226 How to Use WSL Like a Linux Pro.md diff --git a/sources/tech/20180226 How to Use WSL Like a Linux Pro.md b/sources/tech/20180226 How to Use WSL Like a Linux Pro.md new file mode 100644 index 0000000000..34934030be --- /dev/null +++ b/sources/tech/20180226 How to Use WSL Like a Linux Pro.md @@ -0,0 +1,104 @@ +How to Use WSL Like a Linux Pro +============================================================ + +![WSL](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/wsl-pro.png?itok=e65wEEAw "WSL") +Learn how to perform tasks like mounting USB drives and manipulating files in this WSL tutorial. (Image courtesy: Microsoft)[Used with permission][1][Microsoft][2] + +In the [previous tutorial][4], we learned about setting up WSL on your Windows 10 system. You can perform a lot of Linux command like tasks in Windows 10 using WSL. Many sysadmin tasks are done inside a terminal, whether it’s a Linux based system or macOS. Windows 10, however, lacks such capabilities. You want to run a cron job? No. You want to ssh into your server and then rsync files? No way. How about managing your local files with powerful command line utilities instead of using slow and unreliable GUI utilities? + +In this tutorial, you’ll see how to perform additional tasks beyond managing your servers using WSL - things like mounting USB drives and manipulating files. You need to be running a fully updated Windows 10 and the Linux distro of your choice. I covered these steps in the [previous article][5], so begin there if you need to catch up. Let’s get started. + +### Keep your Linux system updated + +The fact is there is no Linux kernel running under the hood when you run Ubuntu or openSUSE through WSL. Yet, you must keep your distros fully updated to keep your system protected from any new known vulnerabilities. Since only two free community distributions are officially available in Windows Store, out tutorial will cover only those two: openSUSE and Ubuntu. + +Update your Ubuntu system: + +``` +# sudo apt-get update + +# sudo apt-get dist-upgrade +``` + +To run updates for openSUSE: + +``` +# zypper up +``` + +You can also upgrade openSUSE to the latest version with the  _dup_  command. But before running the system upgrade, please run updates using the previous command. + +``` +# zypper dup +``` + +**Note: **openSUSE defaults to the root user. If you want to perform any non-administrative tasks, please switch to a non-privileged user. You can learn how to create a user on openSUSE in this [article][6]. + +### Manage local files + +If you want to use great Linux command line utilities to manage your local files, you can easily do that with WSL. Unfortunately, WSL doesn’t yet support things like _lsblk_ or  _mnt_  to mount local drives. You can, however,  _cd _ to the C drive and manage files: + +/mnt/c/Users/swapnil/Music + +I am now in the Music directory of the C drive. + +To mount other drives, partitions, and external USB drives, you will need to create a mount point and then mount that drive. + +Open File Explorer and check the mount point of that drive. Let’s assume it’s mounted in Windows as S:\ + +In the Ubuntu/openSUSE terminal, create a mount point for the drive. + +``` +sudo mkdir /mnt/s +``` + +Now mount the drive: + +``` +mount -f drvfs S: /mnt/s +``` + +Once mounted, you can now access that drive from your distro. Just bear in mind that distro running with WSL will see what Windows can see. So you can’t mount ext4 drives that can’t be mounted on Windows natively. + +You can now use all those magical Linux commands here. Want to copy or move files from one folder to another? Just run the  _cp_  or  _mv_ command. + +``` +cp /source-folder/source-file.txt /destination-folder/ + +cp /music/classical/Beethoven/symphony-2.mp3 /plex-media/music/classical/ +``` + +If you want to move folders or large files, I would recommend  _rsync_ instead of the  _cp_  command: + +``` +rsync -avzP /music/classical/Beethoven/symphonies/ /plex-media/music/classical/ +``` + +Yay! + +Want to create new directories in Windows drives, just use the awesome  _mkdir_ command. + +Want to set up a cron job to automate a task at certain time? Go ahead and create a cron job with  _crontab -e_ . Easy peasy. + +You can also mount network/remote folders in Linux so you can manage them with better tools. All of my drives are plugged into either a Raspberry Pi powered server or a live server, so I simply ssh into that machine and manage the drive. Transferring files between the local machine and remote system can be done using, once again, the  _rsync_  command. + +WSL is now out of beta, and it will continue to get more new features. Two features that I am excited about are the lsblk command and the dd command that allow me to natively manage my drives and create bootable drives of Linux from within Windows. If you are new to the Linux command line, this [previous tutorial ][7]will help you get started with some of the most basic commands. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2018/2/how-use-wsl-linux-pro + +作者:[SWAPNIL BHARTIYA][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/arnieswap +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://blogs.msdn.microsoft.com/commandline/learn-about-windows-console-and-windows-subsystem-for-linux-wsl/ +[3]:https://www.linux.com/files/images/wsl-propng +[4]:https://www.linux.com/blog/learn/2018/2/how-get-started-using-wsl-windows-10 +[5]:https://www.linux.com/blog/learn/2018/2/how-get-started-using-wsl-windows-10 +[6]:https://www.linux.com/blog/learn/2018/2/how-get-started-using-wsl-windows-10 +[7]:https://www.linux.com/learn/how-use-linux-command-line-basics-cli From 2e9959f1fac748eaaea6842d5190d44831403360 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 22:29:55 +0800 Subject: [PATCH 0317/1057] =?UTF-8?q?20180406-11=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Importer Tool Rewritten in C plus plus.md | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sources/tech/20180403 Open Source Accounting Program GnuCash 3.0 Released With a New CSV Importer Tool Rewritten in C plus plus.md diff --git a/sources/tech/20180403 Open Source Accounting Program GnuCash 3.0 Released With a New CSV Importer Tool Rewritten in C plus plus.md b/sources/tech/20180403 Open Source Accounting Program GnuCash 3.0 Released With a New CSV Importer Tool Rewritten in C plus plus.md new file mode 100644 index 0000000000..b7148b4e56 --- /dev/null +++ b/sources/tech/20180403 Open Source Accounting Program GnuCash 3.0 Released With a New CSV Importer Tool Rewritten in C plus plus.md @@ -0,0 +1,70 @@ +Open Source Accounting Program GnuCash 3.0 Released With a New CSV Importer Tool Rewritten in C++ +============================================================ + +The free and open source accounting software, [GnuCash][10] has released its version 3.0\. The software that was first released in 1998 under the GNU General Public License (GPL) is available for GNU/Linux, Solaris, BSD, Microsoft and Mac OSX. + +The featured change to be seen in GnuCash 3.0 is that it now uses Gtk3 Toolkit and WebKit2Gtk API. According to John Ralls,  _“This change was forced on us by some major Linux distributions dropping support for the WebKit1 API.”_ + +[Suggested readGNU Khata: Open Source Accounting Software][11] + +Some major featured changes include a new user interface to manage transaction files, improvement in the removal of old prices from the price database as well as deleted files can now be removed from the history list. + +![GnuCash 3.0 Released](https://itsfoss.com/wp-content/uploads/2018/04/gnucash-3-released-featured.jpeg) + + +### New Features and Improvements in GnuCash 3.0 + +The new features come on two fronts, for the Users and for the Developers. + +* Gtk+-3.0 Toolkit and WebKit2Gtk API: GnuCash 3.0 now uses Gtk+-3.0 Toolkit and WebKit2Gtk API. This is because some some major Linux Distros have dropped support for the WebKit1 API. It should also be noted that the WebKit project does not support Microsoft Windows so it can only use WebKit1 API alongside Gtk3. + +* Database Management Changes: A new user interface is now available for users to manage transaction files. New editors are now able to remove old or incorrect match data from import maps. There is an improvement in the tool used to remove old prices from the database as well as clear deleted files in the file menu’s history list. + +* CSV Importer: A new feature that has been partly rewritten in [C++][1] is now available whereby users can re-import CSV files that were exported from GnuCash. This works alongside a separate CSV price importer. + +* Each operating system now has data file directories allocated appropriately by default. For Linux, it is $XDG_CONFIG_HOME/gnucash (or the default $HOME/.config/gnucash). However, it is possible for users to override it with the environment variable, GNC_DOC_PATH which has replaced GNC_DOT_DIR in older versions of GnuCash. + +* GnuCash has dropped Guile-1.8 and now supports Guile-2.2 + +* The appearance of chart reports have been improved and now comes with modern chart colors. + +* Transaction Report: Improvements have also been made in transaction reporting with a “Subtotal Summary Grid” now included. + +Other changes include an improvement in the dialog box layout which now includes the detected Finance::Quote version; the maximum fraction digit has been increased from 6 to 9 and prices can now go up to 18-digit precision. Checkout the [release note][13] for other improvements and new features for developers. + +### Download and installation of GnuCash 3.0 + +Though GnuCash is available in the software repositories of all major Linux distributions, it will take some time before it gets updated to the latest version 3.0.  + +Till then, either you wait or you download the [source code][14] and build it yourself. + +[Download GnuCash 3.0 Source Code][15] + +Have you used GnuCash before for personal accounting or for business? Share your experience with us in the comment section below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gnucash-3-release/ + +作者:[ Derick Sullivan M. Lobga][a] +译者:[译者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/derick/ +[1]:https://itsfoss.com/c-plus-plus-ubuntu/ +[2]:https://itsfoss.com/author/derick/ +[3]:https://itsfoss.com/gnucash-3-release/#comments +[4]:https://www.facebook.com/share.php?u=https%3A%2F%2Fitsfoss.com%2Fgnucash-3-release%2F%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[5]:https://twitter.com/share?original_referer=/&text=Open+Source+Accounting+Program+GnuCash+3.0+Released+With+a+New+CSV+Importer+Tool+Rewritten+in+C%2B%2B&url=https://itsfoss.com/gnucash-3-release/%3Futm_source%3Dtwitter%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare&via=itsfoss2 +[6]:https://plus.google.com/share?url=https%3A%2F%2Fitsfoss.com%2Fgnucash-3-release%2F%3Futm_source%3DgooglePlus%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[7]:https://www.linkedin.com/cws/share?url=https%3A%2F%2Fitsfoss.com%2Fgnucash-3-release%2F%3Futm_source%3DlinkedIn%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[8]:http://www.stumbleupon.com/submit?url=https://itsfoss.com/gnucash-3-release/&title=Open+Source+Accounting+Program+GnuCash+3.0+Released+With+a+New+CSV+Importer+Tool+Rewritten+in+C%2B%2B +[9]:https://www.reddit.com/submit?url=https://itsfoss.com/gnucash-3-release/&title=Open+Source+Accounting+Program+GnuCash+3.0+Released+With+a+New+CSV+Importer+Tool+Rewritten+in+C%2B%2B +[10]:https://www.gnucash.org/ +[11]:https://itsfoss.com/using-gnu-khata/ +[12]:http://pinterest.com/pin/create/bookmarklet/?media=https://itsfoss.com/wp-content/uploads/2018/04/gnucash-3-released-featured.jpeg&url=https://itsfoss.com/gnucash-3-release/?utm_source=newsletter&utm_medium=email&utm_campaign=linux_and_open_source_articles_this_week&utm_term=2018-04-05&is_video=false&description=GnuCash%203.0%20Released +[13]:https://lists.gnucash.org/pipermail/gnucash-user/2018-April/075866.html +[14]:https://itsfoss.com/install-software-from-source-code/ +[15]:http://downloads.sourceforge.net/sourceforge/gnucash/gnucash-3.0.tar.bz2 From b25cf0a5b5198c41f38448f5663f235abe12b705 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 22:41:13 +0800 Subject: [PATCH 0318/1057] =?UTF-8?q?20180406-12=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tech/20180327 Anna A KVS for any scale.md | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 sources/tech/20180327 Anna A KVS for any scale.md diff --git a/sources/tech/20180327 Anna A KVS for any scale.md b/sources/tech/20180327 Anna A KVS for any scale.md new file mode 100644 index 0000000000..eb6bfa95b3 --- /dev/null +++ b/sources/tech/20180327 Anna A KVS for any scale.md @@ -0,0 +1,139 @@ +Anna: A KVS for any scale +============================================================ +[Anna: A KVS for any scale][8] Wu et al.,  _ICDE’18_ + +This work comes out of the [RISE][9] project at Berkeley, and regular readers of The Morning Paper will be familiar with much of the background. Here’s how Joe Hellerstein puts it in his [blog post][10] introducing the work: + +> As researchers, we asked the counter-cultural question: what would it take to build a key-value store that would excel across many orders of magnitude of scale, from a single multicore box to the global cloud? Turns out this kind of curiosity can lead to a system with pretty interesting practical implications. The key design point for answering our question centered on an ongoing theme in my research group over the last many years: designing distributed systems that avoid coordination. We’ve developed fundamental theory (the [CALM Theorem][1]), language design ([Bloom][2]), program checkers ([Blazes][3]), and transactional protocols ([HATs][4], [Invariant Confluence][5]). But until now we hadn’t demonstrated the kind of performance and scale these principles can achieve across both multicore and cloud environments. Consider that domino fallen. + +At it’s core Anna uses coordination-free actors. Each actor is a single thread of execution, and is mapped to a single core (see e.g. [FFWD][11] that we looked at recently). The coordination-free part comes from managing all state in lattice-based composite data structures (think [Bloom][12] and [CRDTs][13]). There is  _communication_  between actors that happens at the end of every epoch (epochs determine the limit of staleness for GET operations), but this is asynchronous gossip and not on the critical path of request handling. + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-1.jpeg?w=480) + +The success of the design in scaling across orders of magnitude is shown in the following results, where Anna outperforms Redis (and Redis Cluster) on a single node: + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-8a.jpeg?w=520) + +And also outperforms Cassandra in a distributed setting: + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-9.jpeg?w=520) + +It’s got a way to go to trouble [KV-Direct][14] though ;). + +### Design goals for Anna + +The high-level goal for Anna was to provide excellent performance on a single multi-core machine, while also being able to scale up elastically to geo-distributed cloud deployment. The system should support a range of consistency semantics to match application needs. From this, four design requirements emerged: + +1. The key space needs to be **partitioned**, not just across nodes when distributed, but also across cores within a node. + +2. To scale workloads (especially those with highly skewed distributions, aka. ‘hot keys’) the system should use **multi-master** replication to concurrently serve puts and gets against a single key from multiple threads. + +3. For maximum hardware utilisation and performance, the system should have **wait-free execution** such that a thread is never blocked on other threads. This rules out locking, consensus protocols, and even ‘lock-free’ retries. + +4. To support a wide-range of application semantics without compromising the other goals, the system should have a unified implementation for a wide range of **coordination-free consistency models**. + +> Perhaps the primary lesson of this work is that our scalability goals led us by necessity to good software engineering discipline. + +### Lattices + +The key to achieving coordination-free progress is the use of lattice-based composition (strictly,  _bounded join semi-lattices_ ). Such lattices operate over some domain  _S_  (the set of possible states), with a binary ‘least upper bound’ operator,  +![\sqcup](https://s0.wp.com/latex.php?latex=%5Csqcup&bg=ffffff&fg=333333&s=0 "\sqcup") +, and a bottom value  +![\perp](https://s0.wp.com/latex.php?latex=%5Cperp&bg=ffffff&fg=333333&s=0 "\perp") +. The least upper bound operator must be associative, commutative, and idempotent ($\perp(a,a) = a,\ \forall a \in S$). Collectively these are known as the ACI properties. Such lattices are also the foundation of CRDTs. + +> Lattices prove important to Anna for two reasons. First, lattices are insensitive to the order in which they merge updates. This means they can guarantee consistency across replicas even if the actors managing those replicas receive updates in different orders…. Second, simple lattice building blocks can be composed to achieve a range of coordination-free consistency levels. + +Anna adopts the lattice composition approach of [Bloom][15], in which simple lattice-based (ACI) building blocks such as counters, maps, and pairs can be composed into higher-order structures with ACI properties checkable by induction. If each building block has ACI properties, and the composition rules preserve ACI properties, then we can validate composed data structures without needing to directly verify them. + +> The private state of each worker in Anna is represented as a lattice-valued map lattice (MapLattice) template, parameterized by the types of its keys and values…. User’s PUT requests are merged into the MapLattice. The merge operator of MapLattice takes the union of the key sets of both input hash maps. If a key appears in both inputs then the values associated with the key are merged using the ValueLattice’s merge function. + +Different lattice compositions can be used to support different consistency levels. For example, the lattice below supports causal consistency. The vector clock is itself a MapLattice with client proxy ids as keys and version numbers as values. + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-2.jpeg?w=480) + +Merge operations take a (vector clock, value) pair and use the least upper bound function to merge incomparable concurrent writes. + +It takes only a very few lines of code to change the implementation to support other consistency models. Starting with simple eventual consistency, the following table shows the number of additional C++ loc needed to implement a variety of coordination-free consistency levels. + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-3.jpeg?w=480) + +### Design and implementation + +On a given node, an Anna server consists of a collection of independent threads, each of which runs the coordination-free actor model. The state of each actor is maintained in a lattice-based data structure. Each actor/thread is pinned to a unique CPU core in a 1:1 correspondence. There is no shared key-value state: consistent hashing is used to partition the key space across actors. Multi-master replication is used to replicate data partitions across actors. + +Processing happens in time-based  _multicast epochs_  (of e.g. 100ms). During an epoch any updates to a key-value pair owned by an actor are added to a local changeset. At the end of the epoch, local updates in the change set are merged using the merge operator of the lattice, and then multicast to the relevant masters for those keys. Actors also check for incoming multicast messages from other actors, and merge key-value updates from those into their own local state. The staleness of GET responses is bounded by the (configurable) multicast period. + +Communication between actors is done using ZeroMQ. Within a node this will be via the intra-process transport, between it will be via protocol buffers over a tcp transport. + +Actors may join and leave dynamically. See section VII.C in the paper for details. + +The entire codebase, excluding third-party libraries such as ZeroMQ, but including the lattice library, support for all consistency levels, and the client proxy code, is around 2000 lines of C++. + +### Evaluation + +Starting with performance on a single node, Anna’s performance really shines under high-contention workloads when using full replication across all actors, and spends the vast majority of its time actually processing requests (as opposed to waiting). + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-4a.jpeg?w=480) + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-5a.jpeg?w=480) + +Under low contention workloads though, it’s much more efficient to use a lower replication factor (e.g., 3 masters per key): + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-4b.jpeg?w=480) + +> The lesson learned from this experiment is that for systems that support multi-master replication, having a high replication factor under low contention workloads can hurt performance. Instead, we want to dynamically monitor the data’s contention level and selectively replicate the highly contented keys across threads. + +As another reference point, here’s the single node comparison to Redis under high and low contention workloads: + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-8.jpeg?w=520) + +Anna scales well when adding threads across multiple servers (the slight drop at the 33rd thread in the chart below is because this is first thread residing on a second node, triggering distributed multicast across the network): + +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-6.jpeg?w=520) + +As we saw previously, in the distributed setting, Anna compares very favourably against Cassandra: + +* +![](https://adriancolyer.files.wordpress.com/2018/03/anna-fig-9.jpeg?w=520) + +In summary: + +* Anna can significantly outperform Redis Cluster by replicating hot keys under high contention. + +* Anna can match the performance of Redis Cluster under low contention. + +* Anna can outperform Cassandra by up to 10x when permitted to use all 32 available cores on each of its nodes. + +### The last word + +I’m going to leave the last word to Joe Hellerstein, from his blog post: + +> Anna is a prototype and we learned a ton doing it. I think the lessons of what we did apply well beyond key-value databases to any distributed system that manages internal state—basically everything. We’re now actively working on an extended system, codename Bedrock, based on Anna. Bedrock will provide a hands-off, cost-effective version of this design in the cloud, which we’ll be open-sourcing and supporting more aggressively. Watch this space! + +-------------------------------------------------------------------------------- + +via: https://blog.acolyer.org/2018/03/27/anna-a-kvs-for-any-scale/ + +作者:[adriancolyer,][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://twitter.com/adriancolyer +[1]:https://blog.acolyer.org/2015/03/16/consistency-analysis-in-bloom-a-calm-and-collected-approach/ +[2]:https://blog.acolyer.org/2015/03/16/consistency-analysis-in-bloom-a-calm-and-collected-approach/ +[3]:https://blog.acolyer.org/2015/01/05/blazes-coordination-analysis-for-distributed-programs/ +[4]:https://blog.acolyer.org/2014/11/07/highly-available-transactions-virtues-and-limitations/ +[5]:https://blog.acolyer.org/2015/03/19/coordination-avoidance-in-database-systems/ +[6]:https://blog.acolyer.org/tag/datastores/ +[7]:https://blog.acolyer.org/tag/distributed-systems/ +[8]:http://db.cs.berkeley.edu/jmh/papers/anna_ieee18.pdf +[9]:https://rise.cs.berkeley.edu/ +[10]:https://rise.cs.berkeley.edu/blog/anna-kvs/ +[11]:https://blog.acolyer.org/2017/12/04/ffwd-delegation-is-much-faster-than-you-think/ +[12]:https://blog.acolyer.org/2015/03/16/consistency-analysis-in-bloom-a-calm-and-collected-approach/ +[13]:https://blog.acolyer.org/2015/03/18/a-comprehensive-study-of-convergent-and-commutative-replicated-data-types/ +[14]:https://blog.acolyer.org/2017/11/23/kv-direct-high-performance-in-memory-key-value-store-with-programmable-nic/ +[15]:https://blog.acolyer.org/2015/03/16/consistency-analysis-in-bloom-a-calm-and-collected-approach/ From 7ea747b174941b71ce5296c8f702acc4fd5ad04e Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 23:00:52 +0800 Subject: [PATCH 0319/1057] =?UTF-8?q?20180406-13=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tech/20180402 Advanced SSH Cheat Sheet.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/tech/20180402 Advanced SSH Cheat Sheet.md diff --git a/sources/tech/20180402 Advanced SSH Cheat Sheet.md b/sources/tech/20180402 Advanced SSH Cheat Sheet.md new file mode 100644 index 0000000000..51cb79e741 --- /dev/null +++ b/sources/tech/20180402 Advanced SSH Cheat Sheet.md @@ -0,0 +1,74 @@ +Opensource.com: Advanced SSH Cheat Sheet +=========================== + +Most people know SSH as a tool for remote login, which it is, but it can be used in many other ways. + +``` +Create a SOCKS proxy to tunnel your web traffic (like when you’re traveling) +ssh -D +Set your web browser to use localhost: as the proxy. + +Connect to a Windows RDP host behind a bastion server +ssh -L ::3389 +Set your RDP client to connect to localhost: + +Connect to your remote machine’s VNC server without opening the VNC port +ssh -L 5901:localhost:5901 +Set your VNC client to to connect to localhost:5901 +You can follow this pattern with other ports you don’t want to open to the world: LDAP (389), 631 (CUPS), 8080 (alternate HTTP), and so on. + +Generate a new SSH key pair +ssh-keygen + +Update the passphrase on an existing SSH key-pair +ssh-keygen -p + +Copy a public SSH key to a remote host +ssh-copy-id -i + +SSH has a lot of command-line options, but if you use the same options for a host regularly, you can put an entry in the SSH configuration file (${HOME}/.ssh/config) instead. For example: +host myhouse + User itsme + HostName house.example.com +Then you can type ssh myhouse instead of ssh itsme@house.example.com. +``` + +Here are common command-line options and their configuration file equivalents. Some are simplified for common use cases. See the ssh(1) and ssh_config(5) manual pages for full details. + + +|Command Line| Configuration File|Description +|:--|:--|:--| +|-l \| User \The login name on the remote machine. +|-i \ |IdentityFile \ |The identity file (SSH keypair) to use for authentication. | +|-p \| Port \|The port on which the remote SSH daemon is listening. (default: 22) | +|-C|Compression \|Compress traffic between hosts. (default: no) | +|-D \|DynamicForward \|Forward traffic on the local port to the remote machine. | +|-X|ForwardX11 \|Display X11 graphical programs from your remote host on the local host. (default: no) | +|-A|ForwardAgent \|Forward the authentication agent to the remote host. This is helpful if you’ll then connect to a third host. (default: no) | +|-4 (use IPv4 only) -6 (use IPv6 only)|AddressFamily \ |Specify whether to use IPv4 or IPv6 only. | +|-L \:\:\ |LocalForward \:\:\ |Forward local traffic on the specified to port to the remote host and port. | + +opensource.com + +Twitter @opensourceway | facebook.com/opensourceway | IRC: #opensource.com on Freenode + + + +-------------------------------------------------------------------------------- + +作者简介: + +Ben Cotton is a meteorologist by training and a high-performance computing engineer by trade. Ben works as a product marketing manger at Microsoft Azure focused on high performance computing. He is a Fedora user and contributor, co-founded a local open source meetup group, and is a member of the Open Source Initiative and a supporter of Software Freedom Conservancy. Find him on Twitter (@FunnelFiasco) or at FunnelFiasco.com. + +------------- + +via: https://opensource.com/sites/default/files/gated-content/cheat_sheet_ssh_v03.pdf + +作者:[ BEN COTTON ][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/bcotton +[1]:https://web.kamihq.com/web/upgrade.html From ef7b84fa058908f0d5bc499ea4eb6b716df7f253 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 00:19:58 +0800 Subject: [PATCH 0320/1057] Delete 20170927 Best Linux Distros for the Enterprise.md --- ...7 Best Linux Distros for the Enterprise.md | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100644 sources/tech/20170927 Best Linux Distros for the Enterprise.md diff --git a/sources/tech/20170927 Best Linux Distros for the Enterprise.md b/sources/tech/20170927 Best Linux Distros for the Enterprise.md deleted file mode 100644 index 36411a9bfe..0000000000 --- a/sources/tech/20170927 Best Linux Distros for the Enterprise.md +++ /dev/null @@ -1,84 +0,0 @@ -Best Linux Distros for the Enterprise -====== -In this article, I'll share the top Linux distros for enterprise environments. Some of these distros are used in server and cloud environments along with desktop duties. The one constant that all of these Linux options have is that they are enterprise grade Linux distributions -- so you can expect a high greater degree of functionality and, of course, support. - -### What is an enterprise grade Linux distribution? - -An enterprise grade Linux distribution comes down to the following - stability and support. Both of these components must be met to take any Linux distribution seriously in an enterprise environment. Stability means that the packages provided are both stable to use, while still maintaining an expected level of security. - -The support element of an enterprise grade distribution means that there is a reliable support mechanism in place. Sometimes this is a single (official) source such as a company. In other instances, it might be a governing not-for-profit that provides reliable recommendations to good third party support vendors. Obviously the former option is the best one, however both are acceptable. - -### Red Hat Enterprise Linux - -[Red Hat][1] has a number of great offerings, all with enterprise grade support made available. Their core focuses are as follows: - -\- Red Hat Enterprise Linux Server: This is a group of server offerings that includes everything from container hosting down to SAP server, among other server variants. - -\- Red Hat Enterprise Linux Desktop: These are tightly controlled user environments running Red Hat Linux that provide basic desktop functionality. This functionality includes access to the latest applications such as a web browser, email, LibreOffice and more. - -\- Red Hat Enterprise Linux Workstation: This is basically Red Hat Enterprise Linux Desktop, but optimized for high-performance tasks. It's also best suited for larger deployments and ongoing administration. - -### Why Red Hat Enterprise Linux? - -Red Hat is a large, highly successful company that sells services around Linux. Basically Red Hat makes their money from companies that want to avoid vendor lock-in and other related headaches. These companies see the value in hiring open source software experts to manage their servers and other computing needs. A company need only buy a subscription and let Red Hat do the rest in terms of support. - -Red Hat is also a solid social citizen. They sponsor open source projects, FoSS advocate websites like OpenSource.com and also provide support to the Fedora project. Fedora is not owned by Red Hat, rather its development is sponsored instead. This allows Fedora to grow while also benefiting Red Hat who then can take what they like from the Fedora project and use it in their enterprise Linux offerings. As things stand now, Fedora acts as an upstream channel of sorts for Red Hat's Enterprise Linux. - -### SUSE Linux Enterprise - -[SUSE][2] is a fantastic company that provides enterprise users with solid Linux options. SUSE offerings are similar to Red Hat in that both the desktop and server are both focused on by the company. Speaking from my own experiences with SUSE, I believe that YaST has proven to be a huge asset for non-Linux administrators looking to implement Linux boxes into their workplace. YaST provides a friendly GUI for tasks that would otherwise require some basic Linux command line knowledge. - -SUSE's core focuses are as follows: - -\- SUSE Linux Enterprise Server: This includes task specific solutions ranging from cloud to SAP options, as well as, mission critical computing and software-based data storage. - -\- SUSE Linux Enterprise Desktop: For those companies looking to have a solid Linux workstation for their employees, SUSE Linux Enterprise Desktop is a great option. And like Red Hat, SUSE provides access to their support offerings via a subscription model. You can choose three different levels of support. - -Why SUSE Linux Enterprise? - -SUSE is a company that sells services around Linux, but they do so by focusing on keeping it simple. From their website down to the distribution of Linux offered by SUSE, the focus is ease of use without sacrificing security or reliability. While there is no question at least here in the States that Red Hat is the standard for servers, SUSE has done quite well for themselves both as a company and as contributing members of the open source community. - -I'll also go on record in suggesting that SUSE doesn't take themselves too seriously, which is a great thing when you're making connections in the world of IT. From their fun music videos about Linux down to the Gecko used in SUSE trade booths for fun photo opportunities, SUSE presents themselves as simple to understand and approachable. - -### Ubuntu LTS Linux - -[Ubuntu Long Term Release][3] (LTS) Linux is a simple to use enterprise grade Linux distribution. Ubuntu sees more frequent (and sometimes less stable) updates than the other distros mentioned above. Don't misunderstand, Ubuntu LTS editions are considered to be quite stable. However I think some experts may disagree if you were to suggest that they're bullet proof. - -Ubuntu's core focuses are as follows: - -\- Ubuntu Desktop: Without question, the Ubuntu desktop is dead simple to learn and get running quickly. What it may lack in advanced installation features, it makes up for with straight forward simplicity. As an added bonus, Ubuntu has more packages available than anyone (except for its father distribution, Debian). I think where Ubuntu really shines is that you can find a number of vendors online that sell Ubuntu pre-installed. This includes servers, desktops and notebooks. - -\- Ubuntu Server: This includes server, cloud and container offerings. Ubuntu also provides an interesting concept with their Juju cloud "app store" offering. Ubuntu Server makes a lot of sense for anyone who is familiar with Ubuntu or Debian. For these individuals, it fits like a glove and provides you with the command line tools you already know and love. - -Ubuntu IoT: Most recently, Ubuntu's development team has taken aim at creation solutions for the "Internet of Things" (IoT). This includes digital signage, robotics and the IoT gateways themselves. My guess is that the bulk of the IoT growth we'll see with Ubuntu will come from enterprise users and not so much from casual home users. - -Why Ubuntu LTS? - -Community is Ubuntu's greatest strength. Both with casual users, in addition to their tremendous growth in the already crowded server market. The development and user communities using Ubuntu are rock solid. So while it may be considered more unstable than other enterprise distros, I've found that locking an Ubuntu LTS installation into a 'security updates only' mode provides a very stable experience. - -### What about CentOS or Scientific Linux? - -First off let's address [CentOS][4] as an enterprise distribution. If you have your own in-house support team to maintain it, then a CentOS installation is a fantastic option. After all, it's compatible with Red Hat Enterprise Linux and offers the same level of stability as Red Hat's offering. Unfortunately it's not going to completely replace a Red Hat support subscription. - -And [Scientific Linux][5]? What about that distribution? Well it's like CentOS, it's based on Red Hat Linux. But unlike CentOS, there is no affiliation with Red Hat. Scientific Linux has one mission from its inception - to provide a common Linux distribution for labs across the world. Today, Scientific Linux is basically Red Hat minus the trademark material included. - -Neither of these distros are truly interchangeable with Red Hat as they lack the Red Hat support component. - -Which of these is the top distro for enterprise? I think that depends on a number of factors that you'd need to figure out for yourself: subscription coverage, availability, cost, services and features offered. These are all considerations each company must determine for themselves. Speaking for myself personally, I think Red Hat wins on the server while SUSE easily wins on the desktop environment. But that's just my opinion - do you disagree? Hit the Comments section below and let's talk about it. - --------------------------------------------------------------------------------- - -via: https://www.datamation.com/open-source/best-linux-distros-for-the-enterprise.html - -作者:[Matt Hartley][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.datamation.com/author/Matt-Hartley-3080.html -[1]:https://www.redhat.com/en -[2]:https://www.suse.com/ -[3]:http://releases.ubuntu.com/16.04/ -[4]:https://www.centos.org/ -[5]:https://www.scientificlinux.org/ From f30e5e82675fc03b309f86d54a56018fa9906736 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 00:20:55 +0800 Subject: [PATCH 0321/1057] Create 20170927 Best Linux Distros for the Enterprise.md --- ...7 Best Linux Distros for the Enterprise.md | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 translated/tech/20170927 Best Linux Distros for the Enterprise.md diff --git a/translated/tech/20170927 Best Linux Distros for the Enterprise.md b/translated/tech/20170927 Best Linux Distros for the Enterprise.md new file mode 100644 index 0000000000..204aa2137c --- /dev/null +++ b/translated/tech/20170927 Best Linux Distros for the Enterprise.md @@ -0,0 +1,82 @@ +面向企业的最佳 Linux 发行版 +==== + +在这篇文章中,我将分享企业环境下顶级的 Linux 发行版。其中一些发行版与桌面任务一起用于服务器和云环境。所有这些 Linux 选项具有的一个共同点是它们都是企业级 Linux 发行版 -- 所以你可以期待更高程度的功能,当然还有支持。 + +### 什么是企业级的 Linux 发行版? + +一个企业级的 Linux 发行版可以归结为以下内容 - 稳定性和支持。在企业环境中,使用的 Linux 版本必须满足这两点。稳定性意味着所提供的软件包既稳定又可用,同时仍然保持预期的安全性。 + +企业级的支持因素意味着有一个可靠的支持机制。有时这是单一的(官方)来源,如公司。在其他情况下,它可能是一个非营利性的执政机构,向优秀的第三方支持供应商提供可靠的建议。很明显,前者是最好的选择,但两者都可以接受。 + +### Red Hat 企业级 Linux + +[Red Hat][1] 有很多很棒的产品,都有企业级的支持来保证可用。其核心重点如下: + +- Red Hat 企业级 Linux 服务器:这是一组服务器产品,包括从容器托管到 SAP 服务的所有内容,还有其他衍生的服务器。 +- Red Hat 企业级 Linux 桌面:这些是严格控制的用户环境,运行 Red Hat Linux,提供基本的桌面功能。这些功能包括访问最新的应用程序,如 web 浏览器、电子邮件、LibreOffice 等。 +- Red Hat 企业级 Linux 工作站:这基本上是 Red Hat 企业级 Linux 桌面,但针对高性能任务进行了优化。它也非常适合于大型部署和持续管理。 + +### 为什么选择 Red Hat 企业级 Linux? + +Red Hat 是一家大型的、非常成功的公司,销售围绕 Linux 的服务。基本上,Red Hat 从那些想要避免供应商锁定和其他相关问题的公司赚钱。这些公司认识到聘用开源软件专家和管理他们的服务器和其他计算需求的价值。一家公司只需要购买订阅,Red Hat 会在支持方面做其余的工作。 + +Red Hat 也是一个可靠的社会公民。他们赞助开源项目,FoSS 支持网站(译注:FoSS 是 Free and Open Source Software 的缩写,意为自由及开源软件),像OpenSource.com 这样的网站,并为 Fedora 项目提供支持。Fedora 不是由 Red Hat 所有,而是它赞助开发的。这使 Fedora 得以发展,同时也使 Red Hat 受益匪浅。Red Hat 可以从 Fedora 项目中获得他们想要的,并将其用于他们的企业级 Linux 产品中。 就目前来看,Fedora 充当了红帽企业 Linux 的上游渠道。 + +### SUSE Linux 企业版本 + +[SUSE][2] 是一家非常棒的公司,为企业用户提供了可靠的 Linux 选项。SUSE 的产品类似于 Red Hat,因为桌面和服务器都是公司关注的。从我自己使用 SUSE 的经验来看,我相信 YaST 已经证明对于希望在工作场所使用 Linux 操作系统的非 Linux 管理员而言,它是一笔巨大的资产。YaST 为那些需要一些基本的 Linux 命令行知识的任务提供了一个友好的 GUI。 + +SUSE 的核心重点如下: + +- SUSE Linux 企业级服务器:包括任务特定的解决方案,从云到 SAP 选项,以及任务关键计算和基于软件的数据存储。 +- SUSE Linux 企业级桌面:对于那些希望为员工提供可靠的 Linux 工作站的公司来说,SUSE Linux 企业级桌面是一个不错的选择。和 Red Hat 一样,SUSE 通过订阅模式来提供对其支持产品的访问。你可以选择三个不同级别的支持。 + +为什么选择 SUSE Linux 企业版? + +SUSE 是一家围绕 Linux 销售服务的公司,但他们仍然通过专注于简化操作来实现这一目标。从他们的网站到 SUSE 提供的 Linux 发行版,重点是易用性,而不会牺牲安全性或可靠性。尽管在美国毫无疑问 Red Hat 是服务器的标准,但 SUSE 作为公司和开源社区贡献成员都做得很好。 + +我还会继续说,SUSE 不会把自己太当回事。当你在 IT 领域建立联系的时候,这是一件很棒的事情。从他们关于 Linux 的有趣音乐视频到 SUSE 贸易展位中使用的 Gecko 以获得有趣的照片机会,SUSE 将自己描述成简单易懂和平易近人的形象。 + +### Ubuntu LTS Linux + +[Ubuntu Long Term Release][3] (LTS) Linux 是一个简单易用的企业级 Linux 发行版。Ubuntu 看起来比上面提到的其他发行版更新更频繁(有时候也更不稳定)。不要误解,Ubuntu LTS 版本被认为是相当稳定的,不过,我认为一些专家可能不同意你的观点,如果你认为他们是防弹的。(这句不太理解) + +Ubuntu 的核心重点如下: + +- Ubuntu 桌面版:毫无疑问,Ubuntu 桌面非常简单,可以快速学习和快速运行。它在高级安装选项中可能缺少一些东西,但它有一种直截了当的弥补。作为额外的奖励,Ubuntu 相比比其他版本有更多的软件包(除了它的父亲,Debian 发行版)。我认为 Ubuntu 真正的亮点在于,你可以在网上找到许多销售 Ubuntu 的厂商,包括服务器,台式机和笔记本电脑。 +- Ubuntu 服务器版:这包括服务器,云和容器产品。Ubuntu 还提供了 Juju 云“应用商店”这样一个有趣的概念。对于任何熟悉 Ubuntu 或 Debian 的人来说,Ubuntu 服务器都很有意义。对于这些人来说,它就像手套一样,为你提供你已经知道并喜爱的命令行工具。 + +Ubuntu IoT:最近,Ubuntu 的开发团队已经把目标瞄准了“物联网”(IoT)的创建解决方案。包括数字标识、机器人技术和物联网网关。我的猜测是,我们将在 Ubuntu 中看到物联网增长的大部分来自企业用户,而不是普通家庭用户。 + +为什么选择 Ubuntu LTS? + +社区是 Ubuntu 最大的优点。除了在已经拥挤的服务器市场上的巨大增长之外,它还与普通用户在一起。使用 Ubuntu 开发者和社区用户是坚如磐石的。因此,虽然它可能被认为比其他企业版更不稳定,但是我发现将 Ubuntu LTS 安装锁定到到 “security updates only” 模式下提供了非常稳定的体验。 + +### CentOS 或者 Scientific Linux 怎么样呢? + +首先,让我们把 [CentOS][4] 作为一个企业发行版,如果你有自己的内部支持团队来维护它,那么安装 CentOS 是一个很好的选择。毕竟,它与 Red Hat 企业级 Linux 兼容,并提供了与 Red Hat 产品相同级别的稳定性。不幸的是,它不会完全取代 Red Hat 支持订阅。 + +那么 [Scientific Linux][5] 呢?它的发行版怎么样?好吧,它就像 CentOS,它是基于 Red Hat Linux 的。但与 CentOS 不同的是,它与 Red Hat 没有任何关系。 Scientific Linux 从一开始就有一个目标 - 为世界各地的实验室提供一个通用的 Linux 发行版。今天,Scientific Linux 基本上是 Red Hat 减去包含的商标资料。 + +这两种发行版都不能真正地与 Red Hat 互换,因为他们缺少 Red Hat 支持组件。 + +哪一个是顶级企业发行版?我认为这取决于你需要为自己确定的许多因素:订阅范围,可用性,成本,服务和提供的功能。这些是每个公司必须自己决定的因素。就我个人而言,我认为 Red Hat 在服务器上获胜,而 SUSE 在桌面环境中轻松获胜,但这只是我的意见 - 你不同意?点击下面的评论部分,让我们来谈谈它。 + + +-------------------------------------------------------------------------------- + +via: https://www.datamation.com/open-source/best-linux-distros-for-the-enterprise.html + +作者:[Matt Hartley][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.datamation.com/author/Matt-Hartley-3080.html +[1]:https://www.redhat.com/en +[2]:https://www.suse.com/ +[3]:http://releases.ubuntu.com/16.04/ +[4]:https://www.centos.org/ +[5]:https://www.scientificlinux.org/ From 1c9f83879479c1ff166667465afc41790f32d0da Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 00:23:03 +0800 Subject: [PATCH 0322/1057] Delete 20170927 Best Linux Distros for the Enterprise.md --- ...7 Best Linux Distros for the Enterprise.md | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 translated/tech/20170927 Best Linux Distros for the Enterprise.md diff --git a/translated/tech/20170927 Best Linux Distros for the Enterprise.md b/translated/tech/20170927 Best Linux Distros for the Enterprise.md deleted file mode 100644 index 204aa2137c..0000000000 --- a/translated/tech/20170927 Best Linux Distros for the Enterprise.md +++ /dev/null @@ -1,82 +0,0 @@ -面向企业的最佳 Linux 发行版 -==== - -在这篇文章中,我将分享企业环境下顶级的 Linux 发行版。其中一些发行版与桌面任务一起用于服务器和云环境。所有这些 Linux 选项具有的一个共同点是它们都是企业级 Linux 发行版 -- 所以你可以期待更高程度的功能,当然还有支持。 - -### 什么是企业级的 Linux 发行版? - -一个企业级的 Linux 发行版可以归结为以下内容 - 稳定性和支持。在企业环境中,使用的 Linux 版本必须满足这两点。稳定性意味着所提供的软件包既稳定又可用,同时仍然保持预期的安全性。 - -企业级的支持因素意味着有一个可靠的支持机制。有时这是单一的(官方)来源,如公司。在其他情况下,它可能是一个非营利性的执政机构,向优秀的第三方支持供应商提供可靠的建议。很明显,前者是最好的选择,但两者都可以接受。 - -### Red Hat 企业级 Linux - -[Red Hat][1] 有很多很棒的产品,都有企业级的支持来保证可用。其核心重点如下: - -- Red Hat 企业级 Linux 服务器:这是一组服务器产品,包括从容器托管到 SAP 服务的所有内容,还有其他衍生的服务器。 -- Red Hat 企业级 Linux 桌面:这些是严格控制的用户环境,运行 Red Hat Linux,提供基本的桌面功能。这些功能包括访问最新的应用程序,如 web 浏览器、电子邮件、LibreOffice 等。 -- Red Hat 企业级 Linux 工作站:这基本上是 Red Hat 企业级 Linux 桌面,但针对高性能任务进行了优化。它也非常适合于大型部署和持续管理。 - -### 为什么选择 Red Hat 企业级 Linux? - -Red Hat 是一家大型的、非常成功的公司,销售围绕 Linux 的服务。基本上,Red Hat 从那些想要避免供应商锁定和其他相关问题的公司赚钱。这些公司认识到聘用开源软件专家和管理他们的服务器和其他计算需求的价值。一家公司只需要购买订阅,Red Hat 会在支持方面做其余的工作。 - -Red Hat 也是一个可靠的社会公民。他们赞助开源项目,FoSS 支持网站(译注:FoSS 是 Free and Open Source Software 的缩写,意为自由及开源软件),像OpenSource.com 这样的网站,并为 Fedora 项目提供支持。Fedora 不是由 Red Hat 所有,而是它赞助开发的。这使 Fedora 得以发展,同时也使 Red Hat 受益匪浅。Red Hat 可以从 Fedora 项目中获得他们想要的,并将其用于他们的企业级 Linux 产品中。 就目前来看,Fedora 充当了红帽企业 Linux 的上游渠道。 - -### SUSE Linux 企业版本 - -[SUSE][2] 是一家非常棒的公司,为企业用户提供了可靠的 Linux 选项。SUSE 的产品类似于 Red Hat,因为桌面和服务器都是公司关注的。从我自己使用 SUSE 的经验来看,我相信 YaST 已经证明对于希望在工作场所使用 Linux 操作系统的非 Linux 管理员而言,它是一笔巨大的资产。YaST 为那些需要一些基本的 Linux 命令行知识的任务提供了一个友好的 GUI。 - -SUSE 的核心重点如下: - -- SUSE Linux 企业级服务器:包括任务特定的解决方案,从云到 SAP 选项,以及任务关键计算和基于软件的数据存储。 -- SUSE Linux 企业级桌面:对于那些希望为员工提供可靠的 Linux 工作站的公司来说,SUSE Linux 企业级桌面是一个不错的选择。和 Red Hat 一样,SUSE 通过订阅模式来提供对其支持产品的访问。你可以选择三个不同级别的支持。 - -为什么选择 SUSE Linux 企业版? - -SUSE 是一家围绕 Linux 销售服务的公司,但他们仍然通过专注于简化操作来实现这一目标。从他们的网站到 SUSE 提供的 Linux 发行版,重点是易用性,而不会牺牲安全性或可靠性。尽管在美国毫无疑问 Red Hat 是服务器的标准,但 SUSE 作为公司和开源社区贡献成员都做得很好。 - -我还会继续说,SUSE 不会把自己太当回事。当你在 IT 领域建立联系的时候,这是一件很棒的事情。从他们关于 Linux 的有趣音乐视频到 SUSE 贸易展位中使用的 Gecko 以获得有趣的照片机会,SUSE 将自己描述成简单易懂和平易近人的形象。 - -### Ubuntu LTS Linux - -[Ubuntu Long Term Release][3] (LTS) Linux 是一个简单易用的企业级 Linux 发行版。Ubuntu 看起来比上面提到的其他发行版更新更频繁(有时候也更不稳定)。不要误解,Ubuntu LTS 版本被认为是相当稳定的,不过,我认为一些专家可能不同意你的观点,如果你认为他们是防弹的。(这句不太理解) - -Ubuntu 的核心重点如下: - -- Ubuntu 桌面版:毫无疑问,Ubuntu 桌面非常简单,可以快速学习和快速运行。它在高级安装选项中可能缺少一些东西,但它有一种直截了当的弥补。作为额外的奖励,Ubuntu 相比比其他版本有更多的软件包(除了它的父亲,Debian 发行版)。我认为 Ubuntu 真正的亮点在于,你可以在网上找到许多销售 Ubuntu 的厂商,包括服务器,台式机和笔记本电脑。 -- Ubuntu 服务器版:这包括服务器,云和容器产品。Ubuntu 还提供了 Juju 云“应用商店”这样一个有趣的概念。对于任何熟悉 Ubuntu 或 Debian 的人来说,Ubuntu 服务器都很有意义。对于这些人来说,它就像手套一样,为你提供你已经知道并喜爱的命令行工具。 - -Ubuntu IoT:最近,Ubuntu 的开发团队已经把目标瞄准了“物联网”(IoT)的创建解决方案。包括数字标识、机器人技术和物联网网关。我的猜测是,我们将在 Ubuntu 中看到物联网增长的大部分来自企业用户,而不是普通家庭用户。 - -为什么选择 Ubuntu LTS? - -社区是 Ubuntu 最大的优点。除了在已经拥挤的服务器市场上的巨大增长之外,它还与普通用户在一起。使用 Ubuntu 开发者和社区用户是坚如磐石的。因此,虽然它可能被认为比其他企业版更不稳定,但是我发现将 Ubuntu LTS 安装锁定到到 “security updates only” 模式下提供了非常稳定的体验。 - -### CentOS 或者 Scientific Linux 怎么样呢? - -首先,让我们把 [CentOS][4] 作为一个企业发行版,如果你有自己的内部支持团队来维护它,那么安装 CentOS 是一个很好的选择。毕竟,它与 Red Hat 企业级 Linux 兼容,并提供了与 Red Hat 产品相同级别的稳定性。不幸的是,它不会完全取代 Red Hat 支持订阅。 - -那么 [Scientific Linux][5] 呢?它的发行版怎么样?好吧,它就像 CentOS,它是基于 Red Hat Linux 的。但与 CentOS 不同的是,它与 Red Hat 没有任何关系。 Scientific Linux 从一开始就有一个目标 - 为世界各地的实验室提供一个通用的 Linux 发行版。今天,Scientific Linux 基本上是 Red Hat 减去包含的商标资料。 - -这两种发行版都不能真正地与 Red Hat 互换,因为他们缺少 Red Hat 支持组件。 - -哪一个是顶级企业发行版?我认为这取决于你需要为自己确定的许多因素:订阅范围,可用性,成本,服务和提供的功能。这些是每个公司必须自己决定的因素。就我个人而言,我认为 Red Hat 在服务器上获胜,而 SUSE 在桌面环境中轻松获胜,但这只是我的意见 - 你不同意?点击下面的评论部分,让我们来谈谈它。 - - --------------------------------------------------------------------------------- - -via: https://www.datamation.com/open-source/best-linux-distros-for-the-enterprise.html - -作者:[Matt Hartley][a] -译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.datamation.com/author/Matt-Hartley-3080.html -[1]:https://www.redhat.com/en -[2]:https://www.suse.com/ -[3]:http://releases.ubuntu.com/16.04/ -[4]:https://www.centos.org/ -[5]:https://www.scientificlinux.org/ From 7b171d13f463a46da02b3a38e62d1651f7e2b6fa Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 00:24:00 +0800 Subject: [PATCH 0323/1057] Create 20170927 Best Linux Distros for the Enterprise.md --- ...7 Best Linux Distros for the Enterprise.md | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 sources/tech/20170927 Best Linux Distros for the Enterprise.md diff --git a/sources/tech/20170927 Best Linux Distros for the Enterprise.md b/sources/tech/20170927 Best Linux Distros for the Enterprise.md new file mode 100644 index 0000000000..797ed71ff2 --- /dev/null +++ b/sources/tech/20170927 Best Linux Distros for the Enterprise.md @@ -0,0 +1,86 @@ +Translating by MjSeven + +Best Linux Distros for the Enterprise +====== +In this article, I'll share the top Linux distros for enterprise environments. Some of these distros are used in server and cloud environments along with desktop duties. The one constant that all of these Linux options have is that they are enterprise grade Linux distributions -- so you can expect a high greater degree of functionality and, of course, support. + +### What is an enterprise grade Linux distribution? + +An enterprise grade Linux distribution comes down to the following - stability and support. Both of these components must be met to take any Linux distribution seriously in an enterprise environment. Stability means that the packages provided are both stable to use, while still maintaining an expected level of security. + +The support element of an enterprise grade distribution means that there is a reliable support mechanism in place. Sometimes this is a single (official) source such as a company. In other instances, it might be a governing not-for-profit that provides reliable recommendations to good third party support vendors. Obviously the former option is the best one, however both are acceptable. + +### Red Hat Enterprise Linux + +[Red Hat][1] has a number of great offerings, all with enterprise grade support made available. Their core focuses are as follows: + +\- Red Hat Enterprise Linux Server: This is a group of server offerings that includes everything from container hosting down to SAP server, among other server variants. + +\- Red Hat Enterprise Linux Desktop: These are tightly controlled user environments running Red Hat Linux that provide basic desktop functionality. This functionality includes access to the latest applications such as a web browser, email, LibreOffice and more. + +\- Red Hat Enterprise Linux Workstation: This is basically Red Hat Enterprise Linux Desktop, but optimized for high-performance tasks. It's also best suited for larger deployments and ongoing administration. + +### Why Red Hat Enterprise Linux? + +Red Hat is a large, highly successful company that sells services around Linux. Basically Red Hat makes their money from companies that want to avoid vendor lock-in and other related headaches. These companies see the value in hiring open source software experts to manage their servers and other computing needs. A company need only buy a subscription and let Red Hat do the rest in terms of support. + +Red Hat is also a solid social citizen. They sponsor open source projects, FoSS advocate websites like OpenSource.com and also provide support to the Fedora project. Fedora is not owned by Red Hat, rather its development is sponsored instead. This allows Fedora to grow while also benefiting Red Hat who then can take what they like from the Fedora project and use it in their enterprise Linux offerings. As things stand now, Fedora acts as an upstream channel of sorts for Red Hat's Enterprise Linux. + +### SUSE Linux Enterprise + +[SUSE][2] is a fantastic company that provides enterprise users with solid Linux options. SUSE offerings are similar to Red Hat in that both the desktop and server are both focused on by the company. Speaking from my own experiences with SUSE, I believe that YaST has proven to be a huge asset for non-Linux administrators looking to implement Linux boxes into their workplace. YaST provides a friendly GUI for tasks that would otherwise require some basic Linux command line knowledge. + +SUSE's core focuses are as follows: + +\- SUSE Linux Enterprise Server: This includes task specific solutions ranging from cloud to SAP options, as well as, mission critical computing and software-based data storage. + +\- SUSE Linux Enterprise Desktop: For those companies looking to have a solid Linux workstation for their employees, SUSE Linux Enterprise Desktop is a great option. And like Red Hat, SUSE provides access to their support offerings via a subscription model. You can choose three different levels of support. + +Why SUSE Linux Enterprise? + +SUSE is a company that sells services around Linux, but they do so by focusing on keeping it simple. From their website down to the distribution of Linux offered by SUSE, the focus is ease of use without sacrificing security or reliability. While there is no question at least here in the States that Red Hat is the standard for servers, SUSE has done quite well for themselves both as a company and as contributing members of the open source community. + +I'll also go on record in suggesting that SUSE doesn't take themselves too seriously, which is a great thing when you're making connections in the world of IT. From their fun music videos about Linux down to the Gecko used in SUSE trade booths for fun photo opportunities, SUSE presents themselves as simple to understand and approachable. + +### Ubuntu LTS Linux + +[Ubuntu Long Term Release][3] (LTS) Linux is a simple to use enterprise grade Linux distribution. Ubuntu sees more frequent (and sometimes less stable) updates than the other distros mentioned above. Don't misunderstand, Ubuntu LTS editions are considered to be quite stable. However I think some experts may disagree if you were to suggest that they're bullet proof. + +Ubuntu's core focuses are as follows: + +\- Ubuntu Desktop: Without question, the Ubuntu desktop is dead simple to learn and get running quickly. What it may lack in advanced installation features, it makes up for with straight forward simplicity. As an added bonus, Ubuntu has more packages available than anyone (except for its father distribution, Debian). I think where Ubuntu really shines is that you can find a number of vendors online that sell Ubuntu pre-installed. This includes servers, desktops and notebooks. + +\- Ubuntu Server: This includes server, cloud and container offerings. Ubuntu also provides an interesting concept with their Juju cloud "app store" offering. Ubuntu Server makes a lot of sense for anyone who is familiar with Ubuntu or Debian. For these individuals, it fits like a glove and provides you with the command line tools you already know and love. + +Ubuntu IoT: Most recently, Ubuntu's development team has taken aim at creation solutions for the "Internet of Things" (IoT). This includes digital signage, robotics and the IoT gateways themselves. My guess is that the bulk of the IoT growth we'll see with Ubuntu will come from enterprise users and not so much from casual home users. + +Why Ubuntu LTS? + +Community is Ubuntu's greatest strength. Both with casual users, in addition to their tremendous growth in the already crowded server market. The development and user communities using Ubuntu are rock solid. So while it may be considered more unstable than other enterprise distros, I've found that locking an Ubuntu LTS installation into a 'security updates only' mode provides a very stable experience. + +### What about CentOS or Scientific Linux? + +First off let's address [CentOS][4] as an enterprise distribution. If you have your own in-house support team to maintain it, then a CentOS installation is a fantastic option. After all, it's compatible with Red Hat Enterprise Linux and offers the same level of stability as Red Hat's offering. Unfortunately it's not going to completely replace a Red Hat support subscription. + +And [Scientific Linux][5]? What about that distribution? Well it's like CentOS, it's based on Red Hat Linux. But unlike CentOS, there is no affiliation with Red Hat. Scientific Linux has one mission from its inception - to provide a common Linux distribution for labs across the world. Today, Scientific Linux is basically Red Hat minus the trademark material included. + +Neither of these distros are truly interchangeable with Red Hat as they lack the Red Hat support component. + +Which of these is the top distro for enterprise? I think that depends on a number of factors that you'd need to figure out for yourself: subscription coverage, availability, cost, services and features offered. These are all considerations each company must determine for themselves. Speaking for myself personally, I think Red Hat wins on the server while SUSE easily wins on the desktop environment. But that's just my opinion - do you disagree? Hit the Comments section below and let's talk about it. + +-------------------------------------------------------------------------------- + +via: https://www.datamation.com/open-source/best-linux-distros-for-the-enterprise.html + +作者:[Matt Hartley][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.datamation.com/author/Matt-Hartley-3080.html +[1]:https://www.redhat.com/en +[2]:https://www.suse.com/ +[3]:http://releases.ubuntu.com/16.04/ +[4]:https://www.centos.org/ +[5]:https://www.scientificlinux.org/ From 83ecd09f3246863c28dd1a434321daac2de3fba9 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 00:24:59 +0800 Subject: [PATCH 0324/1057] Delete 20170927 Best Linux Distros for the Enterprise.md --- ...7 Best Linux Distros for the Enterprise.md | 86 ------------------- 1 file changed, 86 deletions(-) delete mode 100644 sources/tech/20170927 Best Linux Distros for the Enterprise.md diff --git a/sources/tech/20170927 Best Linux Distros for the Enterprise.md b/sources/tech/20170927 Best Linux Distros for the Enterprise.md deleted file mode 100644 index 797ed71ff2..0000000000 --- a/sources/tech/20170927 Best Linux Distros for the Enterprise.md +++ /dev/null @@ -1,86 +0,0 @@ -Translating by MjSeven - -Best Linux Distros for the Enterprise -====== -In this article, I'll share the top Linux distros for enterprise environments. Some of these distros are used in server and cloud environments along with desktop duties. The one constant that all of these Linux options have is that they are enterprise grade Linux distributions -- so you can expect a high greater degree of functionality and, of course, support. - -### What is an enterprise grade Linux distribution? - -An enterprise grade Linux distribution comes down to the following - stability and support. Both of these components must be met to take any Linux distribution seriously in an enterprise environment. Stability means that the packages provided are both stable to use, while still maintaining an expected level of security. - -The support element of an enterprise grade distribution means that there is a reliable support mechanism in place. Sometimes this is a single (official) source such as a company. In other instances, it might be a governing not-for-profit that provides reliable recommendations to good third party support vendors. Obviously the former option is the best one, however both are acceptable. - -### Red Hat Enterprise Linux - -[Red Hat][1] has a number of great offerings, all with enterprise grade support made available. Their core focuses are as follows: - -\- Red Hat Enterprise Linux Server: This is a group of server offerings that includes everything from container hosting down to SAP server, among other server variants. - -\- Red Hat Enterprise Linux Desktop: These are tightly controlled user environments running Red Hat Linux that provide basic desktop functionality. This functionality includes access to the latest applications such as a web browser, email, LibreOffice and more. - -\- Red Hat Enterprise Linux Workstation: This is basically Red Hat Enterprise Linux Desktop, but optimized for high-performance tasks. It's also best suited for larger deployments and ongoing administration. - -### Why Red Hat Enterprise Linux? - -Red Hat is a large, highly successful company that sells services around Linux. Basically Red Hat makes their money from companies that want to avoid vendor lock-in and other related headaches. These companies see the value in hiring open source software experts to manage their servers and other computing needs. A company need only buy a subscription and let Red Hat do the rest in terms of support. - -Red Hat is also a solid social citizen. They sponsor open source projects, FoSS advocate websites like OpenSource.com and also provide support to the Fedora project. Fedora is not owned by Red Hat, rather its development is sponsored instead. This allows Fedora to grow while also benefiting Red Hat who then can take what they like from the Fedora project and use it in their enterprise Linux offerings. As things stand now, Fedora acts as an upstream channel of sorts for Red Hat's Enterprise Linux. - -### SUSE Linux Enterprise - -[SUSE][2] is a fantastic company that provides enterprise users with solid Linux options. SUSE offerings are similar to Red Hat in that both the desktop and server are both focused on by the company. Speaking from my own experiences with SUSE, I believe that YaST has proven to be a huge asset for non-Linux administrators looking to implement Linux boxes into their workplace. YaST provides a friendly GUI for tasks that would otherwise require some basic Linux command line knowledge. - -SUSE's core focuses are as follows: - -\- SUSE Linux Enterprise Server: This includes task specific solutions ranging from cloud to SAP options, as well as, mission critical computing and software-based data storage. - -\- SUSE Linux Enterprise Desktop: For those companies looking to have a solid Linux workstation for their employees, SUSE Linux Enterprise Desktop is a great option. And like Red Hat, SUSE provides access to their support offerings via a subscription model. You can choose three different levels of support. - -Why SUSE Linux Enterprise? - -SUSE is a company that sells services around Linux, but they do so by focusing on keeping it simple. From their website down to the distribution of Linux offered by SUSE, the focus is ease of use without sacrificing security or reliability. While there is no question at least here in the States that Red Hat is the standard for servers, SUSE has done quite well for themselves both as a company and as contributing members of the open source community. - -I'll also go on record in suggesting that SUSE doesn't take themselves too seriously, which is a great thing when you're making connections in the world of IT. From their fun music videos about Linux down to the Gecko used in SUSE trade booths for fun photo opportunities, SUSE presents themselves as simple to understand and approachable. - -### Ubuntu LTS Linux - -[Ubuntu Long Term Release][3] (LTS) Linux is a simple to use enterprise grade Linux distribution. Ubuntu sees more frequent (and sometimes less stable) updates than the other distros mentioned above. Don't misunderstand, Ubuntu LTS editions are considered to be quite stable. However I think some experts may disagree if you were to suggest that they're bullet proof. - -Ubuntu's core focuses are as follows: - -\- Ubuntu Desktop: Without question, the Ubuntu desktop is dead simple to learn and get running quickly. What it may lack in advanced installation features, it makes up for with straight forward simplicity. As an added bonus, Ubuntu has more packages available than anyone (except for its father distribution, Debian). I think where Ubuntu really shines is that you can find a number of vendors online that sell Ubuntu pre-installed. This includes servers, desktops and notebooks. - -\- Ubuntu Server: This includes server, cloud and container offerings. Ubuntu also provides an interesting concept with their Juju cloud "app store" offering. Ubuntu Server makes a lot of sense for anyone who is familiar with Ubuntu or Debian. For these individuals, it fits like a glove and provides you with the command line tools you already know and love. - -Ubuntu IoT: Most recently, Ubuntu's development team has taken aim at creation solutions for the "Internet of Things" (IoT). This includes digital signage, robotics and the IoT gateways themselves. My guess is that the bulk of the IoT growth we'll see with Ubuntu will come from enterprise users and not so much from casual home users. - -Why Ubuntu LTS? - -Community is Ubuntu's greatest strength. Both with casual users, in addition to their tremendous growth in the already crowded server market. The development and user communities using Ubuntu are rock solid. So while it may be considered more unstable than other enterprise distros, I've found that locking an Ubuntu LTS installation into a 'security updates only' mode provides a very stable experience. - -### What about CentOS or Scientific Linux? - -First off let's address [CentOS][4] as an enterprise distribution. If you have your own in-house support team to maintain it, then a CentOS installation is a fantastic option. After all, it's compatible with Red Hat Enterprise Linux and offers the same level of stability as Red Hat's offering. Unfortunately it's not going to completely replace a Red Hat support subscription. - -And [Scientific Linux][5]? What about that distribution? Well it's like CentOS, it's based on Red Hat Linux. But unlike CentOS, there is no affiliation with Red Hat. Scientific Linux has one mission from its inception - to provide a common Linux distribution for labs across the world. Today, Scientific Linux is basically Red Hat minus the trademark material included. - -Neither of these distros are truly interchangeable with Red Hat as they lack the Red Hat support component. - -Which of these is the top distro for enterprise? I think that depends on a number of factors that you'd need to figure out for yourself: subscription coverage, availability, cost, services and features offered. These are all considerations each company must determine for themselves. Speaking for myself personally, I think Red Hat wins on the server while SUSE easily wins on the desktop environment. But that's just my opinion - do you disagree? Hit the Comments section below and let's talk about it. - --------------------------------------------------------------------------------- - -via: https://www.datamation.com/open-source/best-linux-distros-for-the-enterprise.html - -作者:[Matt Hartley][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.datamation.com/author/Matt-Hartley-3080.html -[1]:https://www.redhat.com/en -[2]:https://www.suse.com/ -[3]:http://releases.ubuntu.com/16.04/ -[4]:https://www.centos.org/ -[5]:https://www.scientificlinux.org/ From 17773db1468d59b728e4b12febfd0194019de017 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 00:25:32 +0800 Subject: [PATCH 0325/1057] Create 20170927 Best Linux Distros for the Enterprise.md --- ...7 Best Linux Distros for the Enterprise.md | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 translated/tech/20170927 Best Linux Distros for the Enterprise.md diff --git a/translated/tech/20170927 Best Linux Distros for the Enterprise.md b/translated/tech/20170927 Best Linux Distros for the Enterprise.md new file mode 100644 index 0000000000..204aa2137c --- /dev/null +++ b/translated/tech/20170927 Best Linux Distros for the Enterprise.md @@ -0,0 +1,82 @@ +面向企业的最佳 Linux 发行版 +==== + +在这篇文章中,我将分享企业环境下顶级的 Linux 发行版。其中一些发行版与桌面任务一起用于服务器和云环境。所有这些 Linux 选项具有的一个共同点是它们都是企业级 Linux 发行版 -- 所以你可以期待更高程度的功能,当然还有支持。 + +### 什么是企业级的 Linux 发行版? + +一个企业级的 Linux 发行版可以归结为以下内容 - 稳定性和支持。在企业环境中,使用的 Linux 版本必须满足这两点。稳定性意味着所提供的软件包既稳定又可用,同时仍然保持预期的安全性。 + +企业级的支持因素意味着有一个可靠的支持机制。有时这是单一的(官方)来源,如公司。在其他情况下,它可能是一个非营利性的执政机构,向优秀的第三方支持供应商提供可靠的建议。很明显,前者是最好的选择,但两者都可以接受。 + +### Red Hat 企业级 Linux + +[Red Hat][1] 有很多很棒的产品,都有企业级的支持来保证可用。其核心重点如下: + +- Red Hat 企业级 Linux 服务器:这是一组服务器产品,包括从容器托管到 SAP 服务的所有内容,还有其他衍生的服务器。 +- Red Hat 企业级 Linux 桌面:这些是严格控制的用户环境,运行 Red Hat Linux,提供基本的桌面功能。这些功能包括访问最新的应用程序,如 web 浏览器、电子邮件、LibreOffice 等。 +- Red Hat 企业级 Linux 工作站:这基本上是 Red Hat 企业级 Linux 桌面,但针对高性能任务进行了优化。它也非常适合于大型部署和持续管理。 + +### 为什么选择 Red Hat 企业级 Linux? + +Red Hat 是一家大型的、非常成功的公司,销售围绕 Linux 的服务。基本上,Red Hat 从那些想要避免供应商锁定和其他相关问题的公司赚钱。这些公司认识到聘用开源软件专家和管理他们的服务器和其他计算需求的价值。一家公司只需要购买订阅,Red Hat 会在支持方面做其余的工作。 + +Red Hat 也是一个可靠的社会公民。他们赞助开源项目,FoSS 支持网站(译注:FoSS 是 Free and Open Source Software 的缩写,意为自由及开源软件),像OpenSource.com 这样的网站,并为 Fedora 项目提供支持。Fedora 不是由 Red Hat 所有,而是它赞助开发的。这使 Fedora 得以发展,同时也使 Red Hat 受益匪浅。Red Hat 可以从 Fedora 项目中获得他们想要的,并将其用于他们的企业级 Linux 产品中。 就目前来看,Fedora 充当了红帽企业 Linux 的上游渠道。 + +### SUSE Linux 企业版本 + +[SUSE][2] 是一家非常棒的公司,为企业用户提供了可靠的 Linux 选项。SUSE 的产品类似于 Red Hat,因为桌面和服务器都是公司关注的。从我自己使用 SUSE 的经验来看,我相信 YaST 已经证明对于希望在工作场所使用 Linux 操作系统的非 Linux 管理员而言,它是一笔巨大的资产。YaST 为那些需要一些基本的 Linux 命令行知识的任务提供了一个友好的 GUI。 + +SUSE 的核心重点如下: + +- SUSE Linux 企业级服务器:包括任务特定的解决方案,从云到 SAP 选项,以及任务关键计算和基于软件的数据存储。 +- SUSE Linux 企业级桌面:对于那些希望为员工提供可靠的 Linux 工作站的公司来说,SUSE Linux 企业级桌面是一个不错的选择。和 Red Hat 一样,SUSE 通过订阅模式来提供对其支持产品的访问。你可以选择三个不同级别的支持。 + +为什么选择 SUSE Linux 企业版? + +SUSE 是一家围绕 Linux 销售服务的公司,但他们仍然通过专注于简化操作来实现这一目标。从他们的网站到 SUSE 提供的 Linux 发行版,重点是易用性,而不会牺牲安全性或可靠性。尽管在美国毫无疑问 Red Hat 是服务器的标准,但 SUSE 作为公司和开源社区贡献成员都做得很好。 + +我还会继续说,SUSE 不会把自己太当回事。当你在 IT 领域建立联系的时候,这是一件很棒的事情。从他们关于 Linux 的有趣音乐视频到 SUSE 贸易展位中使用的 Gecko 以获得有趣的照片机会,SUSE 将自己描述成简单易懂和平易近人的形象。 + +### Ubuntu LTS Linux + +[Ubuntu Long Term Release][3] (LTS) Linux 是一个简单易用的企业级 Linux 发行版。Ubuntu 看起来比上面提到的其他发行版更新更频繁(有时候也更不稳定)。不要误解,Ubuntu LTS 版本被认为是相当稳定的,不过,我认为一些专家可能不同意你的观点,如果你认为他们是防弹的。(这句不太理解) + +Ubuntu 的核心重点如下: + +- Ubuntu 桌面版:毫无疑问,Ubuntu 桌面非常简单,可以快速学习和快速运行。它在高级安装选项中可能缺少一些东西,但它有一种直截了当的弥补。作为额外的奖励,Ubuntu 相比比其他版本有更多的软件包(除了它的父亲,Debian 发行版)。我认为 Ubuntu 真正的亮点在于,你可以在网上找到许多销售 Ubuntu 的厂商,包括服务器,台式机和笔记本电脑。 +- Ubuntu 服务器版:这包括服务器,云和容器产品。Ubuntu 还提供了 Juju 云“应用商店”这样一个有趣的概念。对于任何熟悉 Ubuntu 或 Debian 的人来说,Ubuntu 服务器都很有意义。对于这些人来说,它就像手套一样,为你提供你已经知道并喜爱的命令行工具。 + +Ubuntu IoT:最近,Ubuntu 的开发团队已经把目标瞄准了“物联网”(IoT)的创建解决方案。包括数字标识、机器人技术和物联网网关。我的猜测是,我们将在 Ubuntu 中看到物联网增长的大部分来自企业用户,而不是普通家庭用户。 + +为什么选择 Ubuntu LTS? + +社区是 Ubuntu 最大的优点。除了在已经拥挤的服务器市场上的巨大增长之外,它还与普通用户在一起。使用 Ubuntu 开发者和社区用户是坚如磐石的。因此,虽然它可能被认为比其他企业版更不稳定,但是我发现将 Ubuntu LTS 安装锁定到到 “security updates only” 模式下提供了非常稳定的体验。 + +### CentOS 或者 Scientific Linux 怎么样呢? + +首先,让我们把 [CentOS][4] 作为一个企业发行版,如果你有自己的内部支持团队来维护它,那么安装 CentOS 是一个很好的选择。毕竟,它与 Red Hat 企业级 Linux 兼容,并提供了与 Red Hat 产品相同级别的稳定性。不幸的是,它不会完全取代 Red Hat 支持订阅。 + +那么 [Scientific Linux][5] 呢?它的发行版怎么样?好吧,它就像 CentOS,它是基于 Red Hat Linux 的。但与 CentOS 不同的是,它与 Red Hat 没有任何关系。 Scientific Linux 从一开始就有一个目标 - 为世界各地的实验室提供一个通用的 Linux 发行版。今天,Scientific Linux 基本上是 Red Hat 减去包含的商标资料。 + +这两种发行版都不能真正地与 Red Hat 互换,因为他们缺少 Red Hat 支持组件。 + +哪一个是顶级企业发行版?我认为这取决于你需要为自己确定的许多因素:订阅范围,可用性,成本,服务和提供的功能。这些是每个公司必须自己决定的因素。就我个人而言,我认为 Red Hat 在服务器上获胜,而 SUSE 在桌面环境中轻松获胜,但这只是我的意见 - 你不同意?点击下面的评论部分,让我们来谈谈它。 + + +-------------------------------------------------------------------------------- + +via: https://www.datamation.com/open-source/best-linux-distros-for-the-enterprise.html + +作者:[Matt Hartley][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.datamation.com/author/Matt-Hartley-3080.html +[1]:https://www.redhat.com/en +[2]:https://www.suse.com/ +[3]:http://releases.ubuntu.com/16.04/ +[4]:https://www.centos.org/ +[5]:https://www.scientificlinux.org/ From 8c33d1a6e504cfc15a8c3c3aa6d0d9490cde8df5 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 10:31:29 +0800 Subject: [PATCH 0326/1057] PRF:20150703 Let-s Build A Simple Interpreter. Part 2..md @BriFuture --- ...t-s Build A Simple Interpreter. Part 2..md | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/translated/tech/20150703 Let-s Build A Simple Interpreter. Part 2..md b/translated/tech/20150703 Let-s Build A Simple Interpreter. Part 2..md index a22a94bae0..e9591cddd1 100644 --- a/translated/tech/20150703 Let-s Build A Simple Interpreter. Part 2..md +++ b/translated/tech/20150703 Let-s Build A Simple Interpreter. Part 2..md @@ -1,9 +1,9 @@ -让我们做个简单的解释器(2) +让我们做个简单的解释器(二) ====== -在一本叫做 《高效思考的 5 要素》 的书中,作者 Burger 和 Starbird 讲述了一个关于他们如何研究 Tony Plog 的故事,一个举世闻名的交响曲名家,为一些有才华的演奏者开创了一个大师班。这些学生一开始演奏复杂的乐曲,他们演奏的非常好。然后他们被要求演奏非常基础简单的乐曲。当他们演奏这些乐曲时,与之前所演奏的相比,听起来非常幼稚。在他们结束演奏后,老师也演奏了同样的乐曲,但是听上去非常娴熟。差别令人震惊。Tony 解释道,精通简单符号可以让人更好的掌握复杂的部分。这个例子很清晰 - 要成为真正的名家,必须要掌握简单基础的思想。 +在一本叫做 《高效思考的 5 要素》 的书中,作者 Burger 和 Starbird 讲述了一个关于他们如何研究 Tony Plog 的故事,他是一位举世闻名的交响曲名家,为一些有才华的演奏者开创了一个大师班。这些学生一开始演奏复杂的乐曲,他们演奏的非常好。然后他们被要求演奏非常基础简单的乐曲。当他们演奏这些乐曲时,与之前所演奏的相比,听起来非常幼稚。在他们结束演奏后,老师也演奏了同样的乐曲,但是听上去非常娴熟。差别令人震惊。Tony 解释道,精通简单音符可以让人更好的掌握复杂的部分。这个例子很清晰 —— 要成为真正的名家,必须要掌握简单基础的思想。 -故事中的例子明显不仅仅适用于音乐,而且适用于软件开发。这个故事告诉我们不要忽视繁琐工作中简单基础的概念的重要性,哪怕有时候这让人感觉是一种倒退。尽管熟练掌握一门工具或者框架非常重要,了解他们背后的原理也是极其重要的。正如 Palph Waldo Emerson 所说: +故事中的例子明显不仅仅适用于音乐,而且适用于软件开发。这个故事告诉我们不要忽视繁琐工作中简单基础的概念的重要性,哪怕有时候这让人感觉是一种倒退。尽管熟练掌握一门工具或者框架非常重要,了解它们背后的原理也是极其重要的。正如 Palph Waldo Emerson 所说: > “如果你只学习方法,你就会被方法束缚。但如果你知道原理,就可以发明自己的方法。” @@ -15,11 +15,11 @@ 2. 识别输入字符串中的多位整数 3. 做两个整数之间的减法(目前它仅能加减整数) - 新版本计算器的源代码在这里,它可以做到上述的所有事情: + ``` # 标记类型 -# EOF (end-of-file 文件末尾) 标记是用来表示所有输入都解析完成 +# EOF (end-of-file 文件末尾)标记是用来表示所有输入都解析完成 INTEGER, PLUS, MINUS, EOF = 'INTEGER', 'PLUS', 'MINUS', 'EOF' @@ -168,9 +168,10 @@ if __name__ == '__main__': main() ``` -把上面的代码保存到 calc2.py 文件中,或者直接从 [GitHub][2] 上下载。试着运行它。看看它是不是正常工作:它应该能够处理输入中任意位置的空白符;能够接受多位的整数,并且能够对两个整数做减法和加法。 +把上面的代码保存到 `calc2.py` 文件中,或者直接从 [GitHub][2] 上下载。试着运行它。看看它是不是正常工作:它应该能够处理输入中任意位置的空白符;能够接受多位的整数,并且能够对两个整数做减法和加法。 这是我在自己的笔记本上运行的示例: + ``` $ python calc2.py calc> 27 + 3 @@ -182,21 +183,21 @@ calc> 与 [第一部分][1] 的版本相比,主要的代码改动有: - 1. get_next_token 方法重写了很多。增加指针位置的逻辑之前是放在一个单独的方法中。 - 2. 增加了一些方法:skip_whitespace 用于忽略空白字符,integer 用于处理输入字符的多位整数。 - 3. expr 方法修改成了可以识别 “整数 -> 减号 -> 整数” 词组和 “整数 -> 加号 -> 整数” 词组。在成功识别相应的词组后,这个方法现在可以解释加法和减法。 + 1. `get_next_token` 方法重写了很多。增加指针位置的逻辑之前是放在一个单独的方法中。 + 2. 增加了一些方法:`skip_whitespace` 用于忽略空白字符,`integer` 用于处理输入字符的多位整数。 + 3. `expr` 方法修改成了可以识别 “整数 -> 减号 -> 整数” 词组和 “整数 -> 加号 -> 整数” 词组。在成功识别相应的词组后,这个方法现在可以解释加法和减法。 -[第一部分][1] 中你学到了两个重要的概念,叫做 **标记** 和 **词法分析**。现在我想谈一谈 **词法**, **解析**,和**解析器**。 +[第一部分][1] 中你学到了两个重要的概念,叫做 标记token词法分析lexical analyzer。现在我想谈一谈词法lexeme解析parsing解析器parser。 -你已经知道标记。但是为了让我详细的讨论标记,我需要谈一谈词法。词法是什么?**词法** 是一个标记中的字符序列。在下图中你可以看到一些关于标记的例子,还好这可以让它们之间的关系变得清晰: +你已经知道了标记。但是为了让我详细的讨论标记,我需要谈一谈词法。词法是什么?词法lexeme是一个标记token中的字符序列。在下图中你可以看到一些关于标记的例子,这可以让它们之间的关系变得清晰: ![][3] -现在还记得我们的朋友,expr 方法吗?我之前说过,这是数学表达式实际被解释的地方。但是你要先识别这个表达式有哪些词组才能解释它,比如它是加法还是减法。expr 方法最重要的工作是:它从 get_next_token 方法中得到流,并找出标记流的结构然后解释已经识别出的词组,产生数学表达式的结果。 +现在还记得我们的朋友,`expr` 方法吗?我之前说过,这是数学表达式实际被解释的地方。但是你要先识别这个表达式有哪些词组才能解释它,比如它是加法还是减法。`expr` 方法最重要的工作是:它从 `get_next_token` 方法中得到流,并找出该标记流的结构,然后解释已经识别出的词组,产生数学表达式的结果。 -在标记流中找出结构的过程,或者换种说法,识别标记流中的词组的过程就叫 **解析**。解释器或者编译器中执行这个任务的部分就叫做 **解析器**。 +在标记流中找出结构的过程,或者换种说法,识别标记流中的词组的过程就叫解析parsing。解释器或者编译器中执行这个任务的部分就叫做解析器parser。 -现在你知道 expr 方法就是你的解释器的部分,**解析** 和 **解释** 都在这里发生 - expr 方法首先尝试识别(**解析**)标记流里的 “整数 -> 加法 -> 整数” 或者 “整数 -> 减法 -> 整数” 词组,成功识别后 (**解析**) 其中一个词组,这个方法就开始解释它,返回两个整数的和或差。 +现在你知道 `expr` 方法就是你的解释器的部分,解析parsing解释interpreting都在这里发生 —— `expr` 方法首先尝试识别(解析)标记流里的 “整数 -> 加法 -> 整数” 或者 “整数 -> 减法 -> 整数” 词组,成功识别后 (解析了) 其中一个词组,这个方法就开始解释它,返回两个整数的和或差。 又到了练习的时间。 @@ -206,15 +207,12 @@ calc> 2. 扩展这个计算器,让它能够计算两个整数的除法 3. 修改代码,让它能够解释包含了任意数量的加法和减法的表达式,比如 “9 - 5 + 3 + 11” - - **检验你的理解:** 1. 词法是什么? 2. 找出标记流结构的过程叫什么,或者换种说法,识别标记流中一个词组的过程叫什么? 3. 解释器(编译器)执行解析的部分叫什么? - 希望你喜欢今天的内容。在该系列的下一篇文章里你就能扩展计算器从而处理更多复杂的算术表达式。敬请期待。 -------------------------------------------------------------------------------- @@ -223,12 +221,12 @@ via: https://ruslanspivak.com/lsbasi-part2/ 作者:[Ruslan Spivak][a] 译者:[BriFuture](https://github.com/BriFuture) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://ruslanspivak.com -[1]:http://ruslanspivak.com/lsbasi-part1/ (Part 1) +[1]:https://linux.cn/article-9399-1.html [2]:https://github.com/rspivak/lsbasi/blob/master/part2/calc2.py [3]:https://ruslanspivak.com/lsbasi-part2/lsbasi_part2_lexemes.png [4]:https://ruslanspivak.com/lsbasi-part2/lsbasi_part2_exercises.png From 91826f93d9103e745cad28cdaa35497091d917b1 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 10:31:51 +0800 Subject: [PATCH 0327/1057] PUB:20150703 Let-s Build A Simple Interpreter. Part 2..md @BriFuture https://linux.cn/article-9520-1.html --- .../20150703 Let-s Build A Simple Interpreter. Part 2..md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20150703 Let-s Build A Simple Interpreter. Part 2..md (100%) diff --git a/translated/tech/20150703 Let-s Build A Simple Interpreter. Part 2..md b/published/20150703 Let-s Build A Simple Interpreter. Part 2..md similarity index 100% rename from translated/tech/20150703 Let-s Build A Simple Interpreter. Part 2..md rename to published/20150703 Let-s Build A Simple Interpreter. Part 2..md From a067e4a2c2a15fb4781cfd3110f0f4761d2ce225 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 11:04:05 +0800 Subject: [PATCH 0328/1057] PRF:20150812 Let-s Build A Simple Interpreter. Part 3..md @BriFuture --- ...t-s Build A Simple Interpreter. Part 3..md | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/translated/tech/20150812 Let-s Build A Simple Interpreter. Part 3..md b/translated/tech/20150812 Let-s Build A Simple Interpreter. Part 3..md index d50e5ce8f4..a70c10f9b0 100644 --- a/translated/tech/20150812 Let-s Build A Simple Interpreter. Part 3..md +++ b/translated/tech/20150812 Let-s Build A Simple Interpreter. Part 3..md @@ -1,11 +1,11 @@ -让我们做个简单的解释器(3) +让我们做个简单的解释器(三) ====== 早上醒来的时候,我就在想:“为什么我们学习一个新技能这么难?” 我不认为那是因为它很难。我认为原因可能在于我们花了太多的时间,而这件难事需要有丰富的阅历和足够的知识,然而我们要把这样的知识转换成技能所用的练习时间又不够。 -拿游泳来说,你可以花上几天时间来阅读很多有关游泳的书籍,花几个小时和资深的游泳者和教练交流,观看所有可以获得的训练视频,但你第一次跳进水池的时候,仍然会像一个石头那样沉入水中, +拿游泳来说,你可以花上几天时间来阅读很多有关游泳的书籍,花几个小时和资深的游泳者和教练交流,观看所有可以获得的训练视频,但你第一次跳进水池的时候,仍然会像一个石头那样沉入水中, 要点在于:你认为自己有多了解那件事都无关紧要 —— 你得通过练习把知识变成技能。为了帮你练习,我把训练放在了这个系列的 [第一部分][1] 和 [第二部分][2] 了。当然,你会在今后的文章中看到更多练习,我保证 :) @@ -17,7 +17,7 @@ ![][3] -什么是语法图? **语法图** 是对一门编程语言中的语法规则进行图像化的表示。基本上,一个语法图就能告诉你哪些语句可以在程序中出现,哪些不能出现。 +什么是语法图syntax diagram? **语法图** 是对一门编程语言中的语法规则进行图像化的表示。基本上,一个语法图就能告诉你哪些语句可以在程序中出现,哪些不能出现。 语法图很容易读懂:按照箭头指向的路径。某些路径表示的是判断,有些表示的是循环。 @@ -28,9 +28,7 @@ * 它们用图形的方式表示一个编程语言的特性(语法)。 * 它们可以用来帮你写出解析器 —— 你可以根据下列简单规则把图片转换成代码。 - - -你已经知道,识别出记号流中的词组的过程就叫做 **解析**。解释器或者编译器执行这个任务的部分叫做 **解析器**。解析也称为 **语法分析**,并且解析器这个名字很合适,你猜的对,就是 **语法分析**。 +你已经知道,识别出记号流中的词组的过程就叫做 **解析**。解释器或者编译器执行这个任务的部分叫做 **解析器**。解析也称为 **语法分析**,并且解析器这个名字很合适,你猜的对,就是 **语法分析器**。 根据上面的语法图,下面这些表达式都是合法的: @@ -38,9 +36,8 @@ * 3 + 4 * 7 - 3 + 2 - 1 - - 因为算术表达式的语法规则在不同的编程语言里面是很相近的,我们可以用 Python shell 来“测试”语法图。打开 Python shell,运行下面的代码: + ``` >>> 3 3 @@ -53,6 +50,7 @@ 意料之中。 表达式 “3 + ” 不是一个有效的数学表达式,根据语法图,加号后面必须要有个 term (整数),否则就是语法错误。然后,自己在 Python shell 里面运行: + ``` >>> 3 + File "", line 1 @@ -63,9 +61,10 @@ SyntaxError: invalid syntax 能用 Python shell 来做这样的测试非常棒,让我们把上面的语法图转换成代码,用我们自己的解释器来测试,怎么样? -从之前的文章里([第一部分][1] 和 [第二部分][2])你知道 expr 方法包含了我们的解析器和解释器。再说一遍,解析器仅仅识别出结构,确保它与某些特性对应,而解释器实际上是在解析器成功识别(解析)特性之后,就立即对表达式进行评估。 +从之前的文章里([第一部分][1] 和 [第二部分][2])你知道 `expr` 方法包含了我们的解析器和解释器。再说一遍,解析器仅仅识别出结构,确保它与某些特性对应,而解释器实际上是在解析器成功识别(解析)特性之后,就立即对表达式进行评估。 以下代码片段显示了对应于图表的解析器代码。语法图里面的矩形方框(term)变成了 term 方法,用于解析整数,expr 方法和语法图的流程一致: + ``` def term(self): self.eat(INTEGER) @@ -85,9 +84,10 @@ def expr(self): self.term() ``` -你能看到 expr 首先调用了 term 方法。然后 expr 方法里面的 while 循环可以执行 0 或多次。在循环里面解析器基于标记做出判断(是加号还是减号)。花一些时间,你就知道,上述代码确实是遵循着语法图的算术表达式流程。 +你能看到 `expr` 首先调用了 `term` 方法。然后 `expr` 方法里面的 `while` 循环可以执行 0 或多次。在循环里面解析器基于标记做出判断(是加号还是减号)。花一些时间,你就知道,上述代码确实是遵循着语法图的算术表达式流程。 + +解析器并不解释任何东西:如果它识别出了一个表达式,它就静默着,如果没有识别出来,就会抛出一个语法错误。改一下 `expr` 方法,加入解释器的代码: -解析器并不解释任何东西:如果它识别出了一个表达式,它就静默着,如果没有识别出来,就会抛出一个语法错误。改一下 expr 方法,加入解释器的代码: ``` def term(self): """Return an INTEGER token value""" @@ -113,14 +113,16 @@ def expr(self): return result ``` -因为解释器需要评估一个表达式, term 方法被改成返回一个整型值,expr 方法被改成在合适的地方执行加法或减法操作,并返回解释的结果。尽管代码很直白,我建议花点时间去理解它。 +因为解释器需要评估一个表达式, `term` 方法被改成返回一个整型值,`expr` 方法被改成在合适的地方执行加法或减法操作,并返回解释的结果。尽管代码很直白,我建议花点时间去理解它。 + 进行下一步,看看完整的解释器代码,好不? -这时新版计算器的源代码,它可以处理包含有任意多个加法和减法运算的有效的数学表达式。 +这是新版计算器的源代码,它可以处理包含有任意多个加法和减法运算的有效的数学表达式。 + ``` # 标记类型 # -# EOF (end-of-file 文件末尾) 标记是用来表示所有输入都解析完成 +# EOF (end-of-file 文件末尾)标记是用来表示所有输入都解析完成 INTEGER, PLUS, MINUS, EOF = 'INTEGER', 'PLUS', 'MINUS', 'EOF' @@ -265,9 +267,10 @@ if __name__ == '__main__': main() ``` -把上面的代码保存到 calc3.py 文件中,或者直接从 [GitHub][4] 上下载。试着运行它。看看它能不能处理我之前给你看过的语法图里面派生出的数学表达式。 +把上面的代码保存到 `calc3.py` 文件中,或者直接从 [GitHub][4] 上下载。试着运行它。看看它能不能处理我之前给你看过的语法图里面派生出的数学表达式。 这是我在自己的笔记本上运行的示例: + ``` $ python calc3.py calc> 3 @@ -297,15 +300,13 @@ Traceback (most recent call last): Exception: Invalid syntax ``` - -记得我在文章开始时提过的练习吗:他们在这儿,我保证过的:) +记得我在文章开始时提过的练习吗:它们在这儿,我保证过的:) ![][5] * 画出只包含乘法和除法的数学表达式的语法图,比如 “7 * 4 / 2 * 3”。认真点,拿只钢笔或铅笔,试着画一个。 修改计算器的源代码,解释只包含乘法和除法的数学表达式。比如 “7 * 4 / 2 * 3”。 - * 从头写一个可以处理像 “7 - 3 + 2 - 1” 这样的数学表达式的解释器。用你熟悉的编程语言,不看示例代码自己思考着写出代码。做的时候要想一想这里面包含的组件:一个 lexer,读取输入并转换成标记流,一个解析器,从 lexer 提供的记号流中取食,并且尝试识别流中的结构,一个解释器,在解析器成功解析(识别)有效的数学表达式后产生结果。把这些要点串起来。花一点时间把你获得的知识变成一个可以运行的数学表达式的解释器。 - + * 从头写一个可以处理像 “7 - 3 + 2 - 1” 这样的数学表达式的解释器。用你熟悉的编程语言,不看示例代码自己思考着写出代码。做的时候要想一想这里面包含的组件:一个词法分析器,读取输入并转换成标记流,一个解析器,从词法分析器提供的记号流中获取,并且尝试识别流中的结构,一个解释器,在解析器成功解析(识别)有效的数学表达式后产生结果。把这些要点串起来。花一点时间把你获得的知识变成一个可以运行的数学表达式的解释器。 **检验你的理解。** @@ -314,8 +315,6 @@ Exception: Invalid syntax 3. 什么是语法分析器? - - 嘿,看!你看完了所有内容。感谢你们坚持到今天,而且没有忘记练习。:) 下次我会带着新的文章回来,尽请期待。 -------------------------------------------------------------------------------- @@ -323,14 +322,14 @@ Exception: Invalid syntax via: https://ruslanspivak.com/lsbasi-part3/ 作者:[Ruslan Spivak][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[BriFuture](https://github.com/BriFuture) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://ruslanspivak.com -[1]:http://ruslanspivak.com/lsbasi-part1/ (Part 1) -[2]:http://ruslanspivak.com/lsbasi-part2/ (Part 2) +[1]:https://linux.cn/article-9399-1.html +[2]:https://linux.cn/article-9520-1.html [3]:https://ruslanspivak.com/lsbasi-part3/lsbasi_part3_syntax_diagram.png [4]:https://github.com/rspivak/lsbasi/blob/master/part3/calc3.py [5]:https://ruslanspivak.com/lsbasi-part3/lsbasi_part3_exercises.png From 4f6c499249fa181d8a14a99830baa22a1f96328c Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 11:04:27 +0800 Subject: [PATCH 0329/1057] PUB:20150812 Let-s Build A Simple Interpreter. Part 3..md @BriFuture --- .../20150812 Let-s Build A Simple Interpreter. Part 3..md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20150812 Let-s Build A Simple Interpreter. Part 3..md (100%) diff --git a/translated/tech/20150812 Let-s Build A Simple Interpreter. Part 3..md b/published/20150812 Let-s Build A Simple Interpreter. Part 3..md similarity index 100% rename from translated/tech/20150812 Let-s Build A Simple Interpreter. Part 3..md rename to published/20150812 Let-s Build A Simple Interpreter. Part 3..md From e100846f6be8b21415109b5384f84998ddbb368b Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 11:37:56 +0800 Subject: [PATCH 0330/1057] PRF:20171207 How to use KVM cloud images on Ubuntu Linux.md @MjSeven --- ...to use KVM cloud images on Ubuntu Linux.md | 96 +++++++++++++------ 1 file changed, 69 insertions(+), 27 deletions(-) diff --git a/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md b/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md index f96a1d1125..4358b13428 100644 --- a/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md +++ b/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md @@ -1,15 +1,16 @@ 如何在 Ubuntu Linux 上使用 KVM 云镜像 ===== -基于内核的虚拟机(KVM)时 Linux 内核的虚拟化模块,可将其转变为虚拟机管理程序。你可以使用 Ubuntu 虚拟化前端为 libvirt 和 KVM 在命令行中使用 KVM 创建 Ubuntu 云镜像。 +如何下载并使用运行在 Ubuntu Linux 服务器上的 KVM 云镜像?如何在 Ubuntu Linux 16.04 LTS 服务器上无需完整安装即可创建虚拟机?如何在 Ubuntu Linux 上使用 KVM 云镜像? -如何下载并使用运行在 Ubuntu Linux 服务器上的 KVM 云镜像?如何在 Ubuntu Linux 16.04 LTS 服务器上无需完整安装即可创建虚拟机?基于内核的虚拟机(KVM)时 Linux 内核的虚拟化模块,可将其转变为虚拟机管理程序。你可以使用 Ubuntu 虚拟化前端为 libvirt 和 KVM 在命令行中使用 KVM 创建 Ubuntu 云镜像。 +基于内核的虚拟机(KVM)是 Linux 内核的虚拟化模块,可将其转变为虚拟机管理程序。你可以在命令行使用 Ubuntu 为 libvirt 和 KVM 提供的虚拟化前端通过 KVM 创建 Ubuntu 云镜像。 这个快速教程展示了如何安装和使用 uvtool,它为 Ubuntu 云镜像下载,libvirt 和 clout_int 提供了统一的集成虚拟机前端。 ### 步骤 1 - 安装 KVM 你必须安装并配置 KVM。使用 [apt 命令][1]/[apt-get 命令][2],如下所示: + ``` $ sudo apt install qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker $ kvm-ok @@ -19,16 +20,18 @@ $ sudo systemctl restart networking $ sudo brctl show ``` -参阅[如何在 Ubuntu 16.04 LTS Headless 服务器上安装 KVM][4] 以获得更多信息。(译注:Headless 服务器是指没有本地接口的计算设备,专用于向其他计算机及其用户提供服务。) +参阅[如何在 Ubuntu 16.04 LTS Headless 服务器上安装 KVM][4] 以获得更多信息。(LCTT 译注:Headless 服务器是指没有本地接口的计算设备,专用于向其他计算机及其用户提供服务。) ### 步骤 2 - 安装 uvtool 键入以下 [apt 命令][1]/[apt-get 命令][2]: + ``` $ sudo apt install uvtool ``` 示例输出: + ``` [sudo] password for vivek: Reading package lists... Done @@ -100,19 +103,32 @@ Setting up uvtool-libvirt (0~git122-0ubuntu1) ... ### 步骤 3 - 下载 Ubuntu 云镜像 -你需要使用 uvt-simplestreams-libvirt 命令。它维护一个 libvirt 容量存储池,作为一个简单流源的图像子集的本地镜像,比如 Ubuntu 云镜像。要使用当前所有 amd64 镜像更新 uvtool 的 libvirt 容量存储此,运行: -`$ uvt-simplestreams-libvirt sync arch=amd64` +你需要使用 `uvt-simplestreams-libvirt` 命令。它维护一个 libvirt 容量存储池,作为一个简单流simplestreams源的镜像子集的本地镜像,比如 Ubuntu 云镜像。要使用当前所有 amd64 镜像更新 uvtool 的 libvirt 容量存储池,运行: + +``` +$ uvt-simplestreams-libvirt sync arch=amd64 +``` + 要更新/获取 Ubuntu 16.04 LTS (xenial/amd64) 镜像,运行: -`$ uvt-simplestreams-libvirt --verbose sync release=xenial arch=amd64` + +``` +$ uvt-simplestreams-libvirt --verbose sync release=xenial arch=amd64 +``` 示例输出: + ``` Adding: com.ubuntu.cloud:server:16.04:amd64 20171121.1 ``` 通过 query 选项查询本地镜像: -`$ uvt-simplestreams-libvirt query` + +``` +$ uvt-simplestreams-libvirt query +``` + 示例输出: + ``` release=xenial arch=amd64 label=release (20171121.1) ``` @@ -121,22 +137,30 @@ release=xenial arch=amd64 label=release (20171121.1) ### 步骤 4 - 创建 SSH 密钥 -你需要使用 SSH 密钥才能登录到 KVM 虚拟机。如果你根本没有任何密钥,请使用 ssh-keygen 命令创建一个新的密钥。 -`$ ssh-keygen` +你需要使用 SSH 密钥才能登录到 KVM 虚拟机。如果你根本没有任何密钥,请使用 `ssh-keygen` 命令创建一个新的密钥。 + +``` +$ ssh-keygen +``` + 参阅“[如何在 Linux / Unix 系统上设置 SSH 密钥][5]” 和 “[Linux / UNIX: 生成 SSH 密钥][6]” 以获取更多信息。 ### 步骤 5 - 创建 VM -是时候创建虚拟机了,它叫 vm1,即创建一个 Ubuntu Linux 16.04 LTS 虚拟机: -`$ uvt-kvm create vm1` +是时候创建虚拟机了,它叫 vm1,即创建一个 Ubuntu Linux 16.04 LTS 虚拟机: + +``` +$ uvt-kvm create vm1 +``` 默认情况下 vm1 使用以下配置创建: - 1. RAM/memory : 512M - 2. Disk size: 8GiB - 3. CPU: 1 vCPU core + 1. 内存:512M + 2. 磁盘大小:8GiB + 3. CPU:1 vCPU core + +要控制内存、磁盘、CPU 和其他配置,使用以下语法: -要控制 ram,disk,cpu 和其他配置,使用以下语法: ``` $ uvt-kvm create vm1 \ --memory MEMORY \ @@ -151,11 +175,12 @@ $ uvt-kvm create vm1 \ 其中 - 1. **\--password PASSWORD** : 设置 ubuntu 用户的密码和允许使用 ubuntu 的用户登录(不推荐使用 ssh 密钥)。 - 2. **\--run-script-once RUN_SCRIPT_ONCE** : 第一次启动时,在虚拟机上以 root 身份运行 RUN_SCRIPT_ONCE 脚本,但再也不会运行。这里给出完整的路径。这对于在虚拟机上运行自定义任务时非常有用,例如设置安全性或其他内容。 - 3. **\--packages PACKAGES1, PACKAGES2, ..** : 在第一次启动时安装逗号分隔的软件包。 + 1. `--password PASSWORD`:设置 ubuntu 用户的密码和允许使用 ubuntu 的用户登录(不推荐,使用 ssh 密钥)。 + 2. `--run-script-once RUN_SCRIPT_ONCE` : 第一次启动时,在虚拟机上以 root 身份运行 `RUN_SCRIPT_ONCE` 脚本,但再也不会运行。这里给出完整的路径。这对于在虚拟机上运行自定义任务时非常有用,例如设置安全性或其他内容。 + 3. `--packages PACKAGES1, PACKAGES2, ..` : 在第一次启动时安装以逗号分隔的软件包。 要获取帮助,运行: + ``` $ uvt-kvm -h $ uvt-kvm create -h @@ -164,17 +189,26 @@ $ uvt-kvm create -h #### 如何删除虚拟机? 要销毁/删除名为 vm1 的虚拟机,运行(请小心使用以下命令,因为没有确认框): -`$ uvt-kvm destroy vm1` + +``` +$ uvt-kvm destroy vm1 +``` #### 获取 vm1 的 IP 地址,运行: -`$ uvt-kvm ip vm1` +``` +$ uvt-kvm ip vm1 192.168.122.52 +``` #### 列出所有运行的虚拟机 -`$ uvt-kvm list` +``` +$ uvt-kvm list +``` + 示例输出: + ``` vm1 freebsd11.1 @@ -183,8 +217,13 @@ freebsd11.1 ### 步骤 6 - 如何登录 vm1 语法是: -`$ uvt-kvm ssh vm1` + +``` +$ uvt-kvm ssh vm1 +``` + 示例输出: + ``` Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64) @@ -200,21 +239,24 @@ Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64) Last login: Thu Dec 7 09:55:06 2017 from 192.168.122.1 - ``` 另一个选择是从 macOS/Linux/Unix/Windows 客户端使用常规的 ssh 命令: + ``` $ ssh ubuntu@192.168.122.52 $ ssh -i ~/.ssh/id_rsa ubuntu@192.168.122.52 ``` -(上面的是根据原文修改的) + 示例输出: + [![Connect to the running VM using ssh][8]][8] -一旦创建了 vim,你可以照常使用 virsh 命令: -`$ virsh list` +一旦创建了 vim,你可以照常使用 `virsh` 命令: +``` +$ virsh list +``` -------------------------------------------------------------------------------- @@ -222,7 +264,7 @@ via: https://www.cyberciti.biz/faq/how-to-use-kvm-cloud-images-on-ubuntu-linux/ 作者:[Vivek Gite][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 48701eec0a6803f3fb521f2cfa8b443d3a2e8d6d Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 11:38:23 +0800 Subject: [PATCH 0331/1057] PUB:20171207 How to use KVM cloud images on Ubuntu Linux.md @MjSeven https://linux.cn/article-9522-1.html --- .../20171207 How to use KVM cloud images on Ubuntu Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171207 How to use KVM cloud images on Ubuntu Linux.md (100%) diff --git a/translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md b/published/20171207 How to use KVM cloud images on Ubuntu Linux.md similarity index 100% rename from translated/tech/20171207 How to use KVM cloud images on Ubuntu Linux.md rename to published/20171207 How to use KVM cloud images on Ubuntu Linux.md From 6896b017b63ed90b8a66800e59b5303085b0cb0f Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sat, 7 Apr 2018 14:36:44 +0800 Subject: [PATCH 0332/1057] Translating by kennethXia --- sources/tech/20180402 Advanced SSH Cheat Sheet.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180402 Advanced SSH Cheat Sheet.md b/sources/tech/20180402 Advanced SSH Cheat Sheet.md index 51cb79e741..d5cd25dcea 100644 --- a/sources/tech/20180402 Advanced SSH Cheat Sheet.md +++ b/sources/tech/20180402 Advanced SSH Cheat Sheet.md @@ -1,3 +1,5 @@ +Translating by KennethXia + Opensource.com: Advanced SSH Cheat Sheet =========================== From c61fd63251e15d3028eb0811f675019c75d61855 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sat, 7 Apr 2018 15:44:24 +0800 Subject: [PATCH 0333/1057] Update 20180402 Advanced SSH Cheat Sheet.md --- .../tech/20180402 Advanced SSH Cheat Sheet.md | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/sources/tech/20180402 Advanced SSH Cheat Sheet.md b/sources/tech/20180402 Advanced SSH Cheat Sheet.md index d5cd25dcea..6e304c5ac6 100644 --- a/sources/tech/20180402 Advanced SSH Cheat Sheet.md +++ b/sources/tech/20180402 Advanced SSH Cheat Sheet.md @@ -1,54 +1,56 @@ Translating by KennethXia -Opensource.com: Advanced SSH Cheat Sheet +Opensource.com: 高级 SSH 用法表 =========================== +所有人都知道 SSH 是一种远程登录工具,但它也有多种其他用途。 Most people know SSH as a tool for remote login, which it is, but it can be used in many other ways. ``` -Create a SOCKS proxy to tunnel your web traffic (like when you’re traveling) -ssh -D -Set your web browser to use localhost: as the proxy. +创建一个 SOCKS 代理来浏览网页(也就是翻墙啦) +ssh -D +设置 localhost: 作为你浏览器的代理 +连接一个躲在防御服务器背后的 Windows RDP 主机 Connect to a Windows RDP host behind a bastion server ssh -L ::3389 +让你的 RDP 客户端连接到 localhost: Set your RDP client to connect to localhost: -Connect to your remote machine’s VNC server without opening the VNC port +在不使用 VNC 端口的情况下,连接远程 VNC 主机 ssh -L 5901:localhost:5901 -Set your VNC client to to connect to localhost:5901 -You can follow this pattern with other ports you don’t want to open to the world: LDAP (389), 631 (CUPS), 8080 (alternate HTTP), and so on. +让你的 VNC 客户端连接到 localhost:5901 +按照这个思路,你可以映射任意端口: LDAP (389), 631 (CUPS), 8080 (alternate HTTP),等等 -Generate a new SSH key pair +产生一个新的 SSH 密钥对 ssh-keygen -Update the passphrase on an existing SSH key-pair +更新密钥对的密码 ssh-keygen -p -Copy a public SSH key to a remote host +把公钥复制到远程主机上 ssh-copy-id -i -SSH has a lot of command-line options, but if you use the same options for a host regularly, you can put an entry in the SSH configuration file (${HOME}/.ssh/config) instead. For example: +SSH 有一堆命令行选项,但是如果有一些是你经常使用的,你可以为他们在 SSH 配置文件 (${HOME}/.ssh/config) 里创建一个入口。比如: host myhouse User itsme - HostName house.example.com -Then you can type ssh myhouse instead of ssh itsme@house.example.com. +    HostName house.example.com +那么你就可以输入 ssh myhouse 来代替 ssh itsme@house.example.com. ``` -Here are common command-line options and their configuration file equivalents. Some are simplified for common use cases. See the ssh(1) and ssh_config(5) manual pages for full details. - +以下是常用的命令行选项和他们的配置文件写法。一些是常用的简化写法。请查看 ssh(1) 和 ssh_config(5) 的手册页来获取详尽信息。 |Command Line| Configuration File|Description |:--|:--|:--| -|-l \| User \The login name on the remote machine. -|-i \ |IdentityFile \ |The identity file (SSH keypair) to use for authentication. | -|-p \| Port \|The port on which the remote SSH daemon is listening. (default: 22) | -|-C|Compression \|Compress traffic between hosts. (default: no) | -|-D \|DynamicForward \|Forward traffic on the local port to the remote machine. | -|-X|ForwardX11 \|Display X11 graphical programs from your remote host on the local host. (default: no) | -|-A|ForwardAgent \|Forward the authentication agent to the remote host. This is helpful if you’ll then connect to a third host. (default: no) | -|-4 (use IPv4 only) -6 (use IPv6 only)|AddressFamily \ |Specify whether to use IPv4 or IPv6 only. | -|-L \:\:\ |LocalForward \:\:\ |Forward local traffic on the specified to port to the remote host and port. | +|-l \| User \|远程主机的登录用户名。| +|-i \ |IdentityFile \ |指定要使用的鉴权文件(SSH 密码对)。 | +|-p \| Port \|远程 SSH 守护进程监听的端口号。 (默认为 22) | +|-C|Compression \|压缩往来信息。 (默认为 no) | +|-D \|DynamicForward \|把本地端口的报文转发到远程主机。 | +|-X|ForwardX11 \|把 X11 的图像数据转发到远程主机的端口. (默认为 no) | +|-A|ForwardAgent \|把授权代理的报文转发给远程主机。如果你使用第三方主机登录,这个功能将很有用。 (默认为 no) | +|-4 (use IPv4 only) -6 (use IPv6 only)|AddressFamily \ |指定仅使用 IPv4 或者 IPv6. | +|-L \:\:\ |LocalForward \:\:\ |把本地主机指定端口的报文转发到远程主机的某个端口。| opensource.com From bc4f706df79071ba9a1f0747856a15d9a36fd768 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sat, 7 Apr 2018 16:35:24 +0800 Subject: [PATCH 0334/1057] Update and rename sources/tech/20180402 Advanced SSH Cheat Sheet.md to translated/tech/20180402 Advanced SSH Cheat Sheet.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 --- .../tech/20180402 Advanced SSH Cheat Sheet.md | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) rename {sources => translated}/tech/20180402 Advanced SSH Cheat Sheet.md (71%) diff --git a/sources/tech/20180402 Advanced SSH Cheat Sheet.md b/translated/tech/20180402 Advanced SSH Cheat Sheet.md similarity index 71% rename from sources/tech/20180402 Advanced SSH Cheat Sheet.md rename to translated/tech/20180402 Advanced SSH Cheat Sheet.md index 6e304c5ac6..78ba5c12d9 100644 --- a/sources/tech/20180402 Advanced SSH Cheat Sheet.md +++ b/translated/tech/20180402 Advanced SSH Cheat Sheet.md @@ -3,44 +3,41 @@ Translating by KennethXia Opensource.com: 高级 SSH 用法表 =========================== -所有人都知道 SSH 是一种远程登录工具,但它也有多种其他用途。 -Most people know SSH as a tool for remote login, which it is, but it can be used in many other ways. +所有人都知道 SSH 是一种远程登录工具,然而它也有许多其他用途。 ``` -创建一个 SOCKS 代理来浏览网页(也就是翻墙啦) +创建一个 SOCKS 代理来浏览网页(也就是翻墙啦): ssh -D 设置 localhost: 作为你浏览器的代理 -连接一个躲在防御服务器背后的 Windows RDP 主机 -Connect to a Windows RDP host behind a bastion server +连接一个躲在防御服务器背后的 Windows RDP 主机: ssh -L ::3389 让你的 RDP 客户端连接到 localhost: -Set your RDP client to connect to localhost: -在不使用 VNC 端口的情况下,连接远程 VNC 主机 +在不使用 VNC 端口的情况下,连接远程 VNC 主机: ssh -L 5901:localhost:5901 让你的 VNC 客户端连接到 localhost:5901 -按照这个思路,你可以映射任意端口: LDAP (389), 631 (CUPS), 8080 (alternate HTTP),等等 +按照这个思路,你可以映射任意端口: LDAP (389), 631 (CUPS), 8080 (alternate HTTP),等等。 -产生一个新的 SSH 密钥对 +产生一个新的 SSH 密钥对: ssh-keygen -更新密钥对的密码 +更新密钥对的密码: ssh-keygen -p -把公钥复制到远程主机上 +把公钥复制到远程主机上: ssh-copy-id -i SSH 有一堆命令行选项,但是如果有一些是你经常使用的,你可以为他们在 SSH 配置文件 (${HOME}/.ssh/config) 里创建一个入口。比如: host myhouse User itsme    HostName house.example.com -那么你就可以输入 ssh myhouse 来代替 ssh itsme@house.example.com. +那么你就可以输入 'ssh myhouse' 来代替 'ssh itsme@house.example.com'. ``` 以下是常用的命令行选项和他们的配置文件写法。一些是常用的简化写法。请查看 ssh(1) 和 ssh_config(5) 的手册页来获取详尽信息。 -|Command Line| Configuration File|Description +|命令行|配置文件|描述 |:--|:--|:--| |-l \| User \|远程主机的登录用户名。| |-i \ |IdentityFile \ |指定要使用的鉴权文件(SSH 密码对)。 | @@ -62,14 +59,14 @@ Twitter @opensourceway | facebook.com/opensourceway | IRC: #opensource.com o 作者简介: -Ben Cotton is a meteorologist by training and a high-performance computing engineer by trade. Ben works as a product marketing manger at Microsoft Azure focused on high performance computing. He is a Fedora user and contributor, co-founded a local open source meetup group, and is a member of the Open Source Initiative and a supporter of Software Freedom Conservancy. Find him on Twitter (@FunnelFiasco) or at FunnelFiasco.com. +Ben Cotton是业余气象学家和专业高性能计算工程师。Ben 是微软 Azure 的产品营销经理,专注于高性能计算。他是一个Fedora用户和贡献者,共同创立了一个当地的开放源码群,并且是开源促进会的成员和保护自由软件的支持者。通过以下方式联系他 Twitter (@FunnelFiasco) 或者 FunnelFiasco.com. ------------- via: https://opensource.com/sites/default/files/gated-content/cheat_sheet_ssh_v03.pdf 作者:[ BEN COTTON ][a] -译者:[译者ID](https://github.com/译者ID) +译者:[kennethXia](https://github.com/kennethXia) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 02bd98b89966cd3a6a5106607727f45500c26ae7 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sat, 7 Apr 2018 16:35:48 +0800 Subject: [PATCH 0335/1057] Update 20180402 Advanced SSH Cheat Sheet.md --- translated/tech/20180402 Advanced SSH Cheat Sheet.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/translated/tech/20180402 Advanced SSH Cheat Sheet.md b/translated/tech/20180402 Advanced SSH Cheat Sheet.md index 78ba5c12d9..31af6d3875 100644 --- a/translated/tech/20180402 Advanced SSH Cheat Sheet.md +++ b/translated/tech/20180402 Advanced SSH Cheat Sheet.md @@ -1,5 +1,3 @@ -Translating by KennethXia - Opensource.com: 高级 SSH 用法表 =========================== From 523ed420025088a728f297193d416f47c6b5bcfe Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sat, 7 Apr 2018 16:40:42 +0800 Subject: [PATCH 0336/1057] translated by kennethXia --- translated/tech/20180402 Advanced SSH Cheat Sheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20180402 Advanced SSH Cheat Sheet.md b/translated/tech/20180402 Advanced SSH Cheat Sheet.md index 31af6d3875..f24286c92d 100644 --- a/translated/tech/20180402 Advanced SSH Cheat Sheet.md +++ b/translated/tech/20180402 Advanced SSH Cheat Sheet.md @@ -57,7 +57,7 @@ Twitter @opensourceway | facebook.com/opensourceway | IRC: #opensource.com o 作者简介: -Ben Cotton是业余气象学家和专业高性能计算工程师。Ben 是微软 Azure 的产品营销经理,专注于高性能计算。他是一个Fedora用户和贡献者,共同创立了一个当地的开放源码群,并且是开源促进会的成员和保护自由软件的支持者。通过以下方式联系他 Twitter (@FunnelFiasco) 或者 FunnelFiasco.com. +Ben Cotton是业余的气象学家和职业的高性能计算工程师。Ben 是微软 Azure 的产品营销经理,专注于高性能计算。他是一个 Fedora 用户和贡献者,共同创立了一个当地的开放源码群,并且是开源促进会的成员和保护自由软件的支持者。通过以下方式联系他 Twitter (@FunnelFiasco) 或者 FunnelFiasco.com. ------------- From ac631ed535119878f3a23615bfd2b99876279d00 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Sat, 7 Apr 2018 17:11:11 +0800 Subject: [PATCH 0337/1057] translating by kennethXia --- sources/talk/20180226 5 keys to building open hardware.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180226 5 keys to building open hardware.md b/sources/talk/20180226 5 keys to building open hardware.md index 7819149996..fbeb1c0460 100644 --- a/sources/talk/20180226 5 keys to building open hardware.md +++ b/sources/talk/20180226 5 keys to building open hardware.md @@ -1,3 +1,5 @@ +translating by kennethXia + 5 keys to building open hardware ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openhardwaretools.png?itok=DC1RC_1f) From 84efcb5b572b1831ede052723d445f544d0244da Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 21:33:12 +0800 Subject: [PATCH 0338/1057] Update 20180102 The Uniq Command Tutorial With Examples For Beginners.md --- ...02 The Uniq Command Tutorial With Examples For Beginners.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md b/sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md index 26dd736d07..9eb32dc44f 100644 --- a/sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md +++ b/sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + The Uniq Command Tutorial With Examples For Beginners ====== If you're working mostly on command line and dealing with a lot of text files every day, you should be aware of **Uniq** command. This command helps you to find repeated/duplicate lines from a file easily. It is not just for finding duplicates, but also we can use uniq command to remove the duplicates, display the number of occurrences of the duplicate lines, display only the repeated lines and display only the unique lines etc. Since the uniq command is part of GNU coreutils package, it comes preinstalled in most Linux distributions. Let us not bother with installation and see some practical examples. From 2c96e3d4d70ddfef860077c09068040b3021c5d9 Mon Sep 17 00:00:00 2001 From: zyk Date: Sat, 7 Apr 2018 23:14:37 +0800 Subject: [PATCH 0339/1057] Delete 20180318 How To Manage Disk Partitions Using Parted Command.md --- ...ge Disk Partitions Using Parted Command.md | 437 ------------------ 1 file changed, 437 deletions(-) delete mode 100644 sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md diff --git a/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md b/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md deleted file mode 100644 index 804a31fa52..0000000000 --- a/sources/tech/20180318 How To Manage Disk Partitions Using Parted Command.md +++ /dev/null @@ -1,437 +0,0 @@ -How To Manage Disk Partitions Using Parted Command -====== -Translating by zyk2290 - -We all knows disk partitions is one of the important task for Linux administrator. They can not survive without knowing this. - -In worst cases, at least once in a week they would get this request from dependent team but in big environment admins used to get this request very often. - -You may ask why we need to use parted instead of fdisk? What is the difference? It’s a good question, i will give you more details about this. - - * Parted allow users to create a partition when the disk size is larger than 2TB but fdisk doesn’t allow. - * Parted is a higher-level tool than fdisk. - * It supports multiple partition table which includes GPT. - * It allows users to resize the partition but while shrinking the partition it does not worked as expected and i got error most of the time so, i would advise users to do not shrink the partition. - - - -### What Is Parted - -Parted is a program to manipulate disk partitions. It supports multiple partition table formats, including MS-DOS and GPT. - -It allows user to create, delete, resize, shrink, move and copy partitions, reorganizing disk usage, and copying data to new hard disks. GParted is a GUI frontend of parted. - -### How To Install Parted - -Parted package is pre-installed on most of the Linux distribution. If not, use the following commands to install parted package. - -For **`Debian/Ubuntu`** , use [APT-GET Command][1] or [APT Command][2] to install parted. -``` -$ sudo apt install parted - -``` - -For **`RHEL/CentOS`** , use [YUM Command][3] to install parted. -``` -$ sudo yum install parted - -``` - -For **`Fedora`** , use [DNF Command][4] to install parted. -``` -$ sudo dnf install parted - -``` - -For **`Arch Linux`** , use [Pacman Command][5] to install parted. -``` -$ sudo pacman -S parted - -``` - -For **`openSUSE`** , use [Zypper Command][6] to install parted. -``` -$ sudo zypper in parted - -``` - -### How To Launch Parted - -The below parted command picks the `/dev/sda` disk automatically, because this is the first hard drive in this system. -``` -$ sudo parted -GNU Parted 3.2 -Using /dev/sda -Welcome to GNU Parted! Type 'help' to view a list of commands. -(parted) - -``` - -Also we can go to the corresponding disk by selecting the appropriate disk using below command. -``` -(parted) select /dev/sdb -Using /dev/sdb -(parted) - -``` - -If you wants to go to particular disk, use the following format. In our case we are going to use `/dev/sdb`. -``` -$ sudo parted [Device Name] - -$ sudo parted /dev/sdb -GNU Parted 3.2 -Using /dev/sdb -Welcome to GNU Parted! Type 'help' to view a list of commands. -(parted) - -``` - -### How To List Available Disks Using Parted Command - -If you don’t know what are the disks are added in your system. Just run the following command, which will display all the available disks name, and other useful information such as Disk Size, Model, Sector Size, Partition Table, Disk Flags, and partition information. -``` -$ sudo parted -l -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sda: 32.2GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 1 1049kB 32.2GB 32.2GB primary ext4 boot - - -Error: /dev/sdb: unrecognised disk label -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: unknown -Disk Flags: - -``` - -The above error message clearly shows there is no valid disk label for the disk `/dev/sdb`. Hence, we have to set `disk label` first as it doesn’t take any label automatically. - -### How To Create Disk Partition Using Parted Command - -Parted allows us to create primary or extended partition. Procedure is same for both but make sure you have to pass an appropriate partition type like `primary` or `extended` while creating the partition. - -To perform this activity, we have added a new `50GB` hard disk in the system, which falls under `/dev/sdb`. - -In two ways we can create a partition, one is detailed way and other one is single command. In the below example we are going to add one primary partition in detailed way. Make a note, we should set `disk label` first as it doesn’t take any label automatically. - -We are going to create a new partition with `10GB` of disk in the below example. -``` -$ sudo parted /dev/sdb -GNU Parted 3.2 -Using /dev/sdb -Welcome to GNU Parted! Type 'help' to view a list of commands. -(parted) mklabel msdos -(parted) unit GB -(parted) mkpart -Partition type? primary/extended? primary -File system type? [ext2]? ext4 -Start? 0.00GB -End? 10.00GB -(parted) print -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 1 0.00GB 10.0GB 10.0GB primary ext4 lba - -(parted) quit -Information: You may need to update /etc/fstab. - -``` - -Alternatively we can create a new partition using single parted command. - -We are going to create second partition with `10GB` of disk in the below example. -``` -$ sudo parted [Disk Name] [mkpart] [Partition Type] [Filesystem Type] [Partition Start Size] [Partition End Size] - -$ sudo parted /dev/sdb mkpart primary ext4 10.0GB 20.0GB -Information: You may need to update /etc/fstab. - -``` - -### How To Create A Partition With All Remaining Space - -You have created all required partitions except `/home` and you wants to use all the remaining space to `/home` partition, how to do that? use the following command to create a partition. - -The below command create a new partition with 33.7GB, which starts from `20GB` and ends with `53GB`. `100%` end size will allow users to create a new partition with remaining all available space in the disk. -``` -$ sudo parted [Disk Name] [mkpart] [Partition Type] [Filesystem Type] [Partition Start Size] [Partition End Size] - -$ sudo parted /dev/sdb mkpart primary ext4 20.0GB 100% -Information: You may need to update /etc/fstab. - -``` - -### How To List All Partitions using Parted - -As you aware of, we have created three partitions in the above step and if you want to list all available partitions on the disk use the print command. -``` -$ sudo parted /dev/sdb print -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 1 1049kB 10.0GB 9999MB primary ext4 - 2 10.0GB 20.0GB 9999MB primary ext4 - 3 20.0GB 53.7GB 33.7GB primary ext4 - -``` - -### How To Create A File System On Partition Using mkfs - -Users can create a file system on the partition using mkfs. Follow the below procedure to create a filesystem using mkfs. -``` -$ sudo mkfs.ext4 /dev/sdb1 -mke2fs 1.43.4 (31-Jan-2017) -Creating filesystem with 2621440 4k blocks and 656640 inodes -Filesystem UUID: 415cf467-634c-4403-8c9f-47526bbaa381 -Superblock backups stored on blocks: - 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 - -Allocating group tables: done -Writing inode tables: done -Creating journal (16384 blocks): done -Writing superblocks and filesystem accounting information: done - -``` - -Do the same for other partitions as well. -``` -$ sudo mkfs.ext4 /dev/sdb2 -$ sudo mkfs.ext4 /dev/sdb3 - -``` - -Create necessary folders and mount the partitions on that. -``` -$ sudo mkdir /par1 /par2 /par3 - -$ sudo mount /dev/sdb1 /par1 -$ sudo mount /dev/sdb2 /par2 -$ sudo mount /dev/sdb3 /par3 - -``` - -Run the following command to check newly mounted partitions. -``` -$ df -h /dev/sdb[1-3] -Filesystem Size Used Avail Use% Mounted on -/dev/sdb1 9.2G 37M 8.6G 1% /par1 -/dev/sdb2 9.2G 37M 8.6G 1% /par2 -/dev/sdb3 31G 49M 30G 1% /par3 - -``` - -### How To Check Free Space On The Disk - -Run the following command to check available free space on the disk. This disk has `25.7GB` of free disk space. -``` -$ sudo parted /dev/sdb print free -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 32.3kB 1049kB 1016kB Free Space - 1 1049kB 10.0GB 9999MB primary ext4 - 2 10.0GB 20.0GB 9999MB primary ext4 - 3 20.0GB 28.0GB 8001MB primary ext4 - 28.0GB 53.7GB 25.7GB Free Space - -``` - -### How To Resize Partition Using Parted Command - -Parted allow users to resize the partitions to big and smaller size. As i told in the beginning of the article, do not shrink partitions because this leads to face disk error issue. - -Run the following command to check disk partitions and available free space. I could see `25.7GB` of free space on this disk. -``` -$ sudo parted /dev/sdb print free -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 32.3kB 1049kB 1016kB Free Space - 1 1049kB 10.0GB 9999MB primary ext4 - 2 10.0GB 20.0GB 9999MB primary ext4 - 3 20.0GB 28.0GB 8001MB primary ext4 - 28.0GB 53.7GB 25.7GB Free Space - -``` - -Run the following command to resize the partition. We are going to resize (increase) the partition 3 end size from `28GB to 33GB`. -``` -$ sudo parted [Disk Name] [resizepart] [Partition Number] [Partition New End Size] - -$ sudo parted /dev/sdb resizepart 3 33.0GB -Information: You may need to update /etc/fstab. - -``` - -Run the following command to verify whether this partition is increased or not. Yes, i could see the partition 3 got increased from `8GB to 13GB`. -``` -$ sudo parted /dev/sdb print -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 1 1049kB 10.0GB 9999MB primary ext4 - 2 10.0GB 20.0GB 9999MB primary ext4 - 3 20.0GB 33.0GB 13.0GB primary ext4 - -``` - -Resize the file system to grow the resized partition. -``` -$ sudo resize2fs /dev/sdb3 -resize2fs 1.43.4 (31-Jan-2017) -Resizing the filesystem on /dev/sdb3 to 3173952 (4k) blocks. -The filesystem on /dev/sdb3 is now 3173952 (4k) blocks long. - -``` - -Finally, check whether the mount point has been successfully increased or not. -``` -$ df -h /dev/sdb[1-3] -Filesystem Size Used Avail Use% Mounted on -/dev/sdb1 9.2G 5.1G 3.6G 59% /par1 -/dev/sdb2 9.2G 2.1G 6.6G 24% /par2 -/dev/sdb3 12G 1.1G 11G 10% /par3 - -``` - -### How To Remove Partition Using Parted Command - -We can simple remove the unused partition (if the partition is no longer use) using rm command. See the procedure below. We are going to remove partition 3 `/dev/sdb3` in this example. -``` -$ sudo parted [Disk Name] [rm] [Partition Number] - -$ sudo parted /dev/sdb rm 3 -Warning: Partition /dev/sdb3 is being used. Are you sure you want to continue? -Yes/No? Yes -Error: Partition(s) 3 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. -You should reboot now before making further changes. -Ignore/Cancel? Ignore -Information: You may need to update /etc/fstab. - -``` - -We can check the same using below command. Yes, i could see that partition 3 has been removed successfully. -``` -$ sudo parted /dev/sdb print -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 1 1049kB 10.0GB 9999MB primary ext4 - 2 10.0GB 20.0GB 9999MB primary ext4 - -``` - -### How To Set/Change Partition Flag Using Parted Command - -We can easily change the partition flag using below command. We are going to set `lvm` flag to partition 2 `/dev/sdb2`. -``` -$ sudo parted [Disk Name] [set] [Partition Number] [Flags Name] [Flag On/Off] - -$ sudo parted /dev/sdb set 2 lvm on -Information: You may need to update /etc/fstab. - -``` - -We can verify this modification by listing disk partitions. -``` -$ sudo parted /dev/sdb print -Model: ATA VBOX HARDDISK (scsi) -Disk /dev/sdb: 53.7GB -Sector size (logical/physical): 512B/512B -Partition Table: msdos -Disk Flags: - -Number Start End Size Type File system Flags - 1 1049kB 10.0GB 9999MB primary ext4 - 2 10.0GB 20.0GB 9999MB primary ext4 lvm - -``` - -To know list of available flags, use the following command. -``` -$ (parted) help set - set NUMBER FLAG STATE change the FLAG on partition NUMBER - - NUMBER is the partition number used by Linux. On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards. - FLAG is one of: boot, root, swap, hidden, raid, lvm, lba, hp-service, palo, prep, msftres, bios_grub, atvrecv, diag, legacy_boot, msftdata, irst, esp - STATE is one of: on, off - -``` - -If you want to know the available options in parted, just navigate to `help` page. -``` -$ sudo parted -GNU Parted 3.2 -Using /dev/sda -Welcome to GNU Parted! Type 'help' to view a list of commands. -(parted) help - align-check TYPE N check partition N for TYPE(min|opt) alignment - help [COMMAND] print general help, or help on COMMAND - mklabel,mktable LABEL-TYPE create a new disklabel (partition table) - mkpart PART-TYPE [FS-TYPE] START END make a partition - name NUMBER NAME name partition NUMBER as NAME - print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition - quit exit program - rescue START END rescue a lost partition near START and END - resizepart NUMBER END resize partition NUMBER - rm NUMBER delete partition NUMBER - select DEVICE choose the device to edit - disk_set FLAG STATE change the FLAG on selected device - disk_toggle [FLAG] toggle the state of FLAG on selected device - set NUMBER FLAG STATE change the FLAG on partition NUMBER - toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER - unit UNIT set the default unit to UNIT - version display the version number and copyright information of GNU Parted -(parted) quit - -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/how-to-manage-disk-partitions-using-parted-command/ - -作者:[Magesh Maruthamuthu][a] -译者:[译者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/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ -[2]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ -[3]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ -[4]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ -[5]:https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ -[6]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ From 2176568eed69c48e7245055d061953b02e299341 Mon Sep 17 00:00:00 2001 From: zyk Date: Sat, 7 Apr 2018 23:17:47 +0800 Subject: [PATCH 0340/1057] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BF=BB=E8=AF=91z?= =?UTF-8?q?yk2290?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ge Disk Partitions Using Parted Command.md | 454 ++++++++++++++++++ 1 file changed, 454 insertions(+) create mode 100644 translated/tech/20180318 How To Manage Disk Partitions Using Parted Command.md diff --git a/translated/tech/20180318 How To Manage Disk Partitions Using Parted Command.md b/translated/tech/20180318 How To Manage Disk Partitions Using Parted Command.md new file mode 100644 index 0000000000..7b2d594fe4 --- /dev/null +++ b/translated/tech/20180318 How To Manage Disk Partitions Using Parted Command.md @@ -0,0 +1,454 @@ +怎样用 Parted 管理硬盘分区 +====== +Translating by zyk2290 + +众所周知,硬盘分区对Linux管理员来说是其中一项最重要的管理任务,他们不能不知道这个。 + +在最糟糕的时候,你至少每周一次会收到从依赖小组的请求,在大的环境里会更加频繁 。 + +你可能会问为什么我们要用Parted而不是fdisk? 有什么区别? 好问题, 我会告诉你这两者的区别。 + + * Parted支持用户在大于2TB的硬盘上创建硬盘分区, 但fdisk命令不支持 + * 对比fdisk来说, Parted是一个更高级的工具 + * 支持更多的分区表类型,包括GPT ( LCTT译者注:全局唯一标识分区表 )。 + * 它允许用户调整分区大小, 但当缩减分区空间的时候,它没有在我意料之内工作, 在大部分时候, 我会得到错误。 所以 我会建议用户不要用Parted来缩减分区大小。 + + + +### 什么是 Parted + +Parted 是一个操作硬盘分区的程序. 它支持多种分区表类型,包括 MS-DOS和 GPT . + +它允许用户创建, 删除, 调整 ,缩减,移动和复制分区 ,以及重新组织硬盘的使用, 复制数据到新的硬盘上。GParted是parted的图形界面前端。 + +### 怎样安装Parted + +大部分发行版已经预安装了Parted 如果没有, 用下列命令来安装Parted. + +对于 **`Debian/Ubuntu`** 用户, 使用 [APT-GET Command][1] 或者 [APT Command][2] 来安装Parted。 +``` +$ sudo apt install parted + +``` + +对于 **`RHEL/CentOS`** , 用 [YUM Command][3] 来安装parted。 +``` +$ sudo yum install parted + +``` + +对于 **`Fedora`** , 用 [DNF Command][4] 命令来安装parted。 +``` +$ sudo dnf install parted + +``` + +对于 **`Arch Linux`** , 用 [Pacman Command][5] 命令来安装parted。 +``` +$ sudo pacman -S parted + +``` + +对于 **`openSUSE`** , 用 [Zypper Command][6] 命令来安装parted。 +``` +$ sudo zypper in parted + +``` + +### 怎样启动Parted + +下面的parted命令会自动选择 `/dev/sda` , 因为这是系统的第一个硬盘。 +``` +$ sudo parted +GNU Parted 3.2 +Using /dev/sda +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) + +``` + +同时我们也可以用下面的命令来重新选择对应的的硬盘。 +``` +(parted) select /dev/sdb +Using /dev/sdb +(parted) + +``` + +如果你想选择特定的硬盘, 用下列的格式来输入命令。 这次 ,我们将选择`/dev/sdb`. +``` +$ sudo parted [Device Name] + +$ sudo parted /dev/sdb +GNU Parted 3.2 +Using /dev/sdb +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) + +``` + +### 怎样用 Parted列出所有可用的硬盘 + +如果你不知道你的电脑上有什么硬盘, 只需要运行下列命令,该命令会显示所有可用硬盘的名字, 以及其它的有用信息比如储存空间, 型号, 扇区大小,硬盘旗帜以及分区信息。 +``` +$ sudo parted -l +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sda: 32.2GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 32.2GB 32.2GB primary ext4 boot + + +Error: /dev/sdb: unrecognised disk label +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: unknown +Disk Flags: + +``` + +上面的错误信息清晰地显示出硬盘 `/dev/sdb` 没有有效的硬盘标签 (disk label) 。 它不会自动选择硬盘标签 (disk label) ,所以, 我们便要自己设置硬盘标签 (disk label) 。 + +### 怎样用Parted创建硬盘分区 + +Parted允许用户创建主分区或者拓展分区。 创建这两种类型的分区的步骤还是一样,但请确保你已经指定了需要的分区类型,比如 `primary` 或者`extended`。 + +为了演示这项操作 ,我们安装了一个新的`50 GB` 的硬盘到到电脑上,挂载在`/dev/sdb`上 + +有两种方法创建分区,第一种是更详细的方法,另一种只是一个命令。 在下面的例子中,我们将用更详细的方法添加一个主分区。提醒一下, 我们应该先设置 `硬盘标签`(disk label),因为它不会自动设置任何标签。 + +在下面的例子中,我们将要创建一个`10 GB` 的分区 + +``` +$ sudo parted /dev/sdb +GNU Parted 3.2 +Using /dev/sdb +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) mklabel msdos +(parted) unit GB +(parted) mkpart +Partition type? primary/extended? primary +File system type? [ext2]? ext4 +Start? 0.00GB +End? 10.00GB +(parted) print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 0.00GB 10.0GB 10.0GB primary ext4 lba + +(parted) quit +Information: You may need to update /etc/fstab. + +``` + +同时,我们也可以使用单条Parted命令 + +在下面的例子中,我们将在硬盘上创建一个`10 GB` 的分区 + +``` +$ sudo parted [Disk Name] [mkpart] [Partition Type] [Filesystem Type] [Partition Start Size] [Partition End Size] + +$ sudo parted /dev/sdb mkpart primary ext4 10.0GB 20.0GB +Information: You may need to update /etc/fstab. + +``` + +### 怎样使用Parted用所有剩余空间创建分区 + +你已经创建了所有要求的分区,除了`/home` ,而且你想要用硬盘上所有剩余的空间来创建`/home`分区,要怎样做?可以使用下面的命令来创建分区。 + +下面的命令创建了一个 33.7 GB 的分区,从 `20 GB` 开始到 `53 GB`结束。 `100%` 使用率允许用户用硬盘上所有剩余的空余空间。 + +``` +$ sudo parted [Disk Name] [mkpart] [Partition Type] [Filesystem Type] [Partition Start Size] [Partition End Size] + +$ sudo parted /dev/sdb mkpart primary ext4 20.0GB 100% +Information: You may need to update /etc/fstab. + +``` + +### 怎样用Parted列出所有的分区 + +你也许注意到了,我们已经在上述步骤中创建了三个分区,如果你想要列出所有在硬盘上可用的分区,可以使用print命令。 + +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 53.7GB 33.7GB primary ext4 + +``` + +### 怎样用mkfs格式化分区 + +用户可以用mkfs命令格式化分区。下面的步骤会用mkfs来格式化分区。 + +``` +$ sudo mkfs.ext4 /dev/sdb1 +mke2fs 1.43.4 (31-Jan-2017) +Creating filesystem with 2621440 4k blocks and 656640 inodes +Filesystem UUID: 415cf467-634c-4403-8c9f-47526bbaa381 +Superblock backups stored on blocks: + 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 + +Allocating group tables: done +Writing inode tables: done +Creating journal (16384 blocks): done +Writing superblocks and filesystem accounting information: done + +``` + +同样的。 + +``` +$ sudo mkfs.ext4 /dev/sdb2 +$ sudo mkfs.ext4 /dev/sdb3 + +``` + +创建必要的文件夹然后将这些分区挂载在上面。 + +``` +$ sudo mkdir /par1 /par2 /par3 + +$ sudo mount /dev/sdb1 /par1 +$ sudo mount /dev/sdb2 /par2 +$ sudo mount /dev/sdb3 /par3 + +``` + +运行下列命令来检查是否成功挂载上新创建的分区。 + +``` +$ df -h /dev/sdb[1-3] +Filesystem Size Used Avail Use% Mounted on +/dev/sdb1 9.2G 37M 8.6G 1% /par1 +/dev/sdb2 9.2G 37M 8.6G 1% /par2 +/dev/sdb3 31G 49M 30G 1% /par3 + +``` + +### 怎样检查硬盘空闲空间 + +运行下列命令来检查硬盘上的空闲空间,这块硬盘上有`25.7 GB`的空闲空间。 + +``` +$ sudo parted /dev/sdb print free +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 32.3kB 1049kB 1016kB Free Space + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 28.0GB 8001MB primary ext4 + 28.0GB 53.7GB 25.7GB Free Space + +``` + +### 怎样使用Parted命令来重新调整分区大小 + +Parted 允许用户重新调整分区大小。不过我已在文章的开头说了,不要缩小分区大小,不然会有许多错误。 + +运行下列命令来检查硬盘分区以及所有可用空间。 可以看到硬盘上有`25.7GB` 的可用空间 + +``` +$ sudo parted /dev/sdb print free +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 32.3kB 1049kB 1016kB Free Space + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 28.0GB 8001MB primary ext4 + 28.0GB 53.7GB 25.7GB Free Space + +``` + +运行下列命令来重新调整分区大小。 我们将要重新调整(增加)分区 3的结束位置从 `28GB 到 33GB`。 + +``` +$ sudo parted [Disk Name] [resizepart] [Partition Number] [Partition New End Size] + +$ sudo parted /dev/sdb resizepart 3 33.0GB +Information: You may need to update /etc/fstab. + +``` + +运行下列命令来确认分区是否已经扩容。可以看到,分区 3 已经从`8GB`增加到`13GB`。 + +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + 3 20.0GB 33.0GB 13.0GB primary ext4 + +``` + +重新调整文件系统大小。 + +``` +$ sudo resize2fs /dev/sdb3 +resize2fs 1.43.4 (31-Jan-2017) +Resizing the filesystem on /dev/sdb3 to 3173952 (4k) blocks. +The filesystem on /dev/sdb3 is now 3173952 (4k) blocks long. + +``` + +最后,确认分区是否已经扩容。 + +``` +$ df -h /dev/sdb[1-3] +Filesystem Size Used Avail Use% Mounted on +/dev/sdb1 9.2G 5.1G 3.6G 59% /par1 +/dev/sdb2 9.2G 2.1G 6.6G 24% /par2 +/dev/sdb3 12G 1.1G 11G 10% /par3 + +``` + +### 怎样用Parted删除分区 + +我们用rm命令方便地删除未使用的分区(如果该分区不会再被用到了)。下列步骤中,我们将会删除分区 3(`/dev/sdb3`)。 + +``` +$ sudo parted [Disk Name] [rm] [Partition Number] + +$ sudo parted /dev/sdb rm 3 +Warning: Partition /dev/sdb3 is being used. Are you sure you want to continue? +Yes/No? Yes +Error: Partition(s) 3 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. +You should reboot now before making further changes. +Ignore/Cancel? Ignore +Information: You may need to update /etc/fstab. + +``` + +我们也可以用下列的命令检查。可以看到,分区 3 已经被成功移除。 + +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 + +``` + +### 怎样用Parted命令设置/更改分区旗帜 + +我们可以用下列的命令来轻易更改分区的旗帜。 我们将对`/dev/sdb2`设置 `lvm` 旗帜。 +``` +$ sudo parted [Disk Name] [set] [Partition Number] [Flags Name] [Flag On/Off] + +$ sudo parted /dev/sdb set 2 lvm on +Information: You may need to update /etc/fstab. + +``` + +我们可以列出分区来验证这次的更改。 + +``` +$ sudo parted /dev/sdb print +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 53.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 10.0GB 9999MB primary ext4 + 2 10.0GB 20.0GB 9999MB primary ext4 lvm + +``` + +如果你想知道可用的旗帜, 只需要用如下的命令。 +``` +$ (parted) help set + set NUMBER FLAG STATE change the FLAG on partition NUMBER + + NUMBER is the partition number used by Linux. On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards. + FLAG is one of: boot, root, swap, hidden, raid, lvm, lba, hp-service, palo, prep, msftres, bios_grub, atvrecv, diag, legacy_boot, msftdata, irst, esp + STATE is one of: on, off + +``` + +如果你想知道parted的其它可用命令, 只需要去到 `help` 页面. +``` +$ sudo parted +GNU Parted 3.2 +Using /dev/sda +Welcome to GNU Parted! Type 'help' to view a list of commands. +(parted) help + align-check TYPE N check partition N for TYPE(min|opt) alignment + help [COMMAND] print general help, or help on COMMAND + mklabel,mktable LABEL-TYPE create a new disklabel (partition table) + mkpart PART-TYPE [FS-TYPE] START END make a partition + name NUMBER NAME name partition NUMBER as NAME + print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition + quit exit program + rescue START END rescue a lost partition near START and END + resizepart NUMBER END resize partition NUMBER + rm NUMBER delete partition NUMBER + select DEVICE choose the device to edit + disk_set FLAG STATE change the FLAG on selected device + disk_toggle [FLAG] toggle the state of FLAG on selected device + set NUMBER FLAG STATE change the FLAG on partition NUMBER + toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER + unit UNIT set the default unit to UNIT + version display the version number and copyright information of GNU Parted +(parted) quit + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-manage-disk-partitions-using-parted-command/ + +作者:[Magesh Maruthamuthu][a] +译者:[译者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/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[2]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[3]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[4]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[5]:https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[6]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ From f29ce9a9a812537d287e395d66a4edfbc3b9190a Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 23:39:28 +0800 Subject: [PATCH 0341/1057] Delete 20180102 The Uniq Command Tutorial With Examples For Beginners.md --- ...nd Tutorial With Examples For Beginners.md | 163 ------------------ 1 file changed, 163 deletions(-) delete mode 100644 sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md diff --git a/sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md b/sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md deleted file mode 100644 index 9eb32dc44f..0000000000 --- a/sources/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md +++ /dev/null @@ -1,163 +0,0 @@ -Translating by MjSeven - - -The Uniq Command Tutorial With Examples For Beginners -====== -If you're working mostly on command line and dealing with a lot of text files every day, you should be aware of **Uniq** command. This command helps you to find repeated/duplicate lines from a file easily. It is not just for finding duplicates, but also we can use uniq command to remove the duplicates, display the number of occurrences of the duplicate lines, display only the repeated lines and display only the unique lines etc. Since the uniq command is part of GNU coreutils package, it comes preinstalled in most Linux distributions. Let us not bother with installation and see some practical examples. - -Please note that the 'uniq' command will not detect repeated lines unless they are adjacent. So, you might need to sort them first or combine the sort command with uniq to get the results. Allow me to show you some examples. - -First, let us create a file with some duplicate lines. -``` -vi ostechnix.txt -``` -``` -welcome to ostechnix -welcome to ostechnix -Linus is the creator of Linux. -Linux is secure by default -Linus is the creator of Linux. -Top 500 super computers are powered by Linux -``` - -As you see in the above file, we have few repeated lines (the first, second, third, and fifth lines are duplicates). - -### **1\. Remove consecutive duplicate lines in a file using Uniq command** - -If you use 'uniq' command without any arguments, it will remove all consecutive duplicate lines and display only the unique lines. -``` -uniq ostechnix.txt -``` - -Sample output would be: - -[![][1]][2] - -As you can see, uniq command removed all consecutive duplicate lines in the given file. You might also have noticed that the above output still has the duplicates in second and fourth lines. It is because the uniq command will only omit the repeated lines only if they are adjacent. We can, of course, remove that non-consecutive duplicates too. Look at the second example below. - -### **2\. Remove all duplicate lines** -``` -sort ostechnix.txt | uniq -``` - -Sample output would be: - -[![][1]][3] - -See? There are no duplicates or repeated lines. In other words, the above command will display each line once from file ostechnix.txt. We used the sort command in conjunction with uniq, because, as I already mentioned, uniq will not find the duplicate/repeated lines unless they are adjacent. - -### **3\. Display only unique lines from a file** - -To display only the unique lines from a file, the command would be: -``` -sort ostechnix.txt | uniq -u -``` - -Sample output: -``` -Linux is secure by default -Top 500 super computers are powered by Linux -``` - -As you can see, we have only two unique lines in the given file. - -### **4\. Display only duplicate lines** - -Similarly, we can also display duplicates lines from a file like below. -``` -sort ostechnix.txt | uniq -d -``` - -Sample output: -``` -Linus is the creator of Linux. -welcome to ostechnix -``` - -These two are the repeated/duplicated lines in ostechnix.txt file. Please note that -d (small d) will **only print duplicate lines** , **one for each group**. To print **all duplicate lines** , use -D (capital d) like below. -``` -sort ostechnix.txt | uniq -D -``` - -See the difference between both flags in the below screenshot. - -[![][1]][4] - -### **5\. Display number of occurrences of each line in a file -** - -For some reason, you might want to check how many times a line is repeated in the given file. To do so, use **-c** flag like below. -``` -sort ostechnix.txt | uniq -c -``` - -**Sample output:** -``` - 2 Linus is the creator of Linux. - 1 Linux is secure by default - 1 Top 500 super computers are powered by Linux - 2 welcome to ostechnix -``` - -We can also display number of occurrences of each line along with that line, sorted by the most frequent like below. -``` -sort ostechnix.txt | uniq -c | sort -nr -``` - -Sample output: -``` - 2 welcome to ostechnix - 2 Linus is the creator of Linux. - 1 Top 500 super computers are powered by Linux - 1 Linux is secure by default -``` - -### 6\. Limit the comparison to 'N' characters - -We can limit the comparison to a particular number of characters of lines in a file using **-w** flag. For example, let us limit the comparison to first 4 characters of lines in a file and display the repeated lines as shown below. -``` -uniq -d -w 4 ostechnix.txt -``` - -### 7\. Avoid the comparison with the first 'N' characters - -Like limit comparison to N characters of lines in a file, we can also avoid comparing the first N characters using -s flag. - -The following command will avoid the comparison with the first 4 characters of lines in a file: -``` -uniq -d -s 4 ostechnix.txt -``` - -To avoid comparing the first N fields instead of characters, use '-f' flag in the above command. - -For more details, refer the help section; -``` -uniq --help -``` - -and man pages. -``` -man uniq -``` - -And, that's all for today! I hope you now get a basic idea about uniq command and its purpose. If you find our guides useful, please share them on your social, professional networks and support OSTechNix. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/uniq-command-tutorial-examples-beginners/ - -作者:[][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/2018/01/uniq-2.png () -[3]:http://www.ostechnix.com/wp-content/uploads/2018/01/uniq-1-1.png () -[4]:http://www.ostechnix.com/wp-content/uploads/2018/01/uniq-4.png () From ccecae6dc2957a5a047df6a463f622fecb8c9dcb Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 23:39:58 +0800 Subject: [PATCH 0342/1057] Create 20180102 The Uniq Command Tutorial With Examples For Beginners.md --- ...nd Tutorial With Examples For Beginners.md | 158 ++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 translated/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md diff --git a/translated/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md b/translated/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md new file mode 100644 index 0000000000..b051a0f66e --- /dev/null +++ b/translated/tech/20180102 The Uniq Command Tutorial With Examples For Beginners.md @@ -0,0 +1,158 @@ +为初学者提供的 Uniq 命令教程及示例 +===== + +如果你主要是在命令行上工作,并且每天处理大量的文本文件,那么你应该了解下 **Uniq** 命令。该命令会帮助你轻松地从文件中找到重复的行。它不仅用于查找重复项,而且我们还可以使用它来删除重复项,显示重复项的出现次数,只显示重复的行,只显示唯一的行等。由于 uniq 命令是 GNU coreutils 包的一部分,所以它预装在大多数 Linux 发行版中,让我们不需要费心安装。来看一些实际的例子。 + +请注意,除非重复行是相邻的,否则 'uniq' 不会删除它们。因此,你可能需要先对它们进行排序,或将排序命令与 uniq 组合以获得结果。让我给你看一些例子。 + +首先,让我们创建一个带有一些重复行的文件: +``` +vi ostechnix.txt +``` +``` +welcome to ostechnix +welcome to ostechnix +Linus is the creator of Linux. +Linux is secure by default +Linus is the creator of Linux. +Top 500 super computers are powered by Linux +``` + +正如你在上面的文件中看到的,我们有一些重复的行(第一行和第二行,第三行和第五行是重复的)。 + +### **1\. 使用 Uniq 命令删除文件中的连续重复行** + +如果你在不使用任何参数的情况下使用 'uniq' 命令,它将删除所有连续的重复行,只显示唯一的行。 +``` +uniq ostechnix.txt +``` + +示例输出: + +![][2] + +如你所见, uniq 命令删除了给定文件中的所有连续重复行。你可能还注意到,上面的输出仍然有第二行和第四行重复了。这是因为 uniq 命令只有在相邻的情况下才会删除重复的行,当然,我们也可以删除非连续的重复行。请看下面的第二个例子。 + +### **2\. 删除所有重复的行** +``` +sort ostechnix.txt | uniq +``` + +示例输出: + +![][3] + +看到了吗?没有重复的行。换句话说,上面的命令将显示在 ostechnix.txt 中只出现一次的行。我们使用 sort 命令与 uniq 命令结合,因为,就像我提到的,除非重复行是相邻的,否则 uniq 不会删除它们。 + +### **3\. 只显示文件中唯一的一行** + +为了只显示文件中唯一的一行,可以这样做: +``` +sort ostechnix.txt | uniq -u +``` + +示例输出: +``` +Linux is secure by default +Top 500 super computers are powered by Linux +``` + +如你所见,在给定的文件中只有两行是唯一的。 + +### **4\. 只显示重复的行** + +同样的,我们也可以显示文件中重复的行就像下面这样: +``` +sort ostechnix.txt | uniq -d +``` + +示例输出: +``` +Linus is the creator of Linux. +welcome to ostechnix +``` + +这两行在 ostechnix.txt 文件中是重复的行。请注意 -d(小写 d) 将会**只打印重复的行**,**每组有一个**。打印**所有重复的行**,使用 -D(大写 D),如下所示: +``` +sort ostechnix.txt | uniq -D +``` + +在下面的截图中看两个选项的区别: + +![][4] + +### **5\. 显示文件中每一行的出现次数** + +由于某种原因,你可能想要检查给定文件中每一行重复出现的次数。要做到这一点,使用 **-c** 选项,如下所示: +``` +sort ostechnix.txt | uniq -c +``` + +**示例输出:** +``` + 2 Linus is the creator of Linux. + 1 Linux is secure by default + 1 Top 500 super computers are powered by Linux + 2 welcome to ostechnix +``` + +我们还可以按照每一行的出现次数进行排序,然后显示,如下所示: +``` +sort ostechnix.txt | uniq -c | sort -nr +``` + +示例输出: +``` + 2 welcome to ostechnix + 2 Linus is the creator of Linux. + 1 Top 500 super computers are powered by Linux + 1 Linux is secure by default +``` + +### 6\. 将比较限制为 'N' 个字符 + +我们可以使用 -w 选项来限制对文件中特定数量字符的比较。例如,让我们比较文件中的前四个字符,并显示重复行,如下所示: +``` +uniq -d -w 4 ostechnix.txt +``` + +### 7\. 忽略比较指定的 'N' 个字符 + +像对文件中行的 N 个字符进行限制比较一样,我们也可以使用 -s 选项来忽略比较前 N 个字符。 + +下面的命令将忽略在文件中每行的前四个字符进行比较: +``` +uniq -d -s 4 ostechnix.txt +``` + +为了忽略比较前 N 字段(译者注:即前几列)而不是字符,在上面的命令中使用 '-f' 选项。 + +欲了解更多详情,请参考帮助部分: +``` +uniq --help +``` + +也可以使用 man 命令查看: +``` +man uniq +``` + +今天就到这里!我希望你现在对 uniq 命令及其目的有一个基本的了解。如果你发现我们的指南有用,请在你的社交网络上分享,并继续支持 OSTechNix。更多好东西要来了,请继续关注! + +干杯! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/uniq-command-tutorial-examples-beginners/ + +作者:[][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者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/2018/01/uniq-2.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/01/uniq-1-1.png +[4]:http://www.ostechnix.com/wp-content/uploads/2018/01/uniq-4.png From 33a353c7ddfaf32ed92078053db27da78d6c09fe Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 23:44:37 +0800 Subject: [PATCH 0343/1057] PRF:20180314 Playing with water.md @geekpi --- translated/tech/20180314 Playing with water.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/translated/tech/20180314 Playing with water.md b/translated/tech/20180314 Playing with water.md index 88adcebd32..f4b275d3cd 100644 --- a/translated/tech/20180314 Playing with water.md +++ b/translated/tech/20180314 Playing with water.md @@ -1,26 +1,27 @@ -尝试 H2o +尝试 H2o 做机器学习 ====== + ![H2o Flow gradient boosting job][1] -我目前正在参加一个机器学习班,虽然有疯狂的工作量,但我非常喜欢。我最初计划使用 [R][2] 来训练我的数据库,但老师建议我使用一个 FOSS 机器学习框架 [H2o][3]。 +我目前正在参加一个机器学习班,虽然工作量很疯狂,但我非常喜欢。我最初计划使用 [R][2] 来训练我的数据库,但老师建议我使用一个 FOSS 机器学习框架 [H2o][3]。 起初我有点怀疑,因为我已经对 R 掌握得不错了,但后来我发现你可以简单地将 H2o 作为 R 库导入。H2o 将大多数 R 函数替换为其自己的并行化函数,以减少处理时间(不再需要 `doParallel` 调用),并且使用“外部”服务端来运行,而不是直接调用 R。 ![H2o Flow gradient boosting model][4] -直到我真正在实际中开始在 H2o 中使用 R 时,我对这种情况都非常满意。我在使用非常大得数据库时,库变得笨重,我几乎不能做任何有用得事情。大多数时候,我最后只是得到一个很长的 Java 回溯调用。 +直到我真正在实际中开始在 H2o 中使用 R 时,我对这种情况都非常满意。我在使用非常大的数据库时,库变得笨重,我几乎不能做任何有用得事情。大多数时候,我最后只是得到一个很长的 Java 回溯调用。 -我相信正确地将 H2o 作为一个库使用将非常强大,但可惜的是,它似乎在我的 R-fu 中无效。 +我相信正确地将 H2o 作为一个库使用将非常强大,但可惜的是,它似乎在我的 R 技能中无效。 ![H2o Flow variable importance weights][5] -我至少有一整天都很生气 - 无法实现我想做的事 - 直到我意识到 H2o 有一个名为 Flow 的 WebUI。我通常不喜欢使用 web 来完成重要的工作,比如编写代码,但是 Flow 简直太不可思议了。 +我生了一整天的气 —— 无法实现我想做的事 —— 直到我意识到 H2o 有一个名为 Flow 的 WebUI。我通常不喜欢使用 web 来完成重要的工作,比如编写代码,但是 Flow 简直太不可思议了。 自动绘图功能,运行资源密集模型时集成 ETA(预计剩余时间),每个模型参数的描述(这些参数甚至会根据您熟悉的统计模型分成不同部分),Flow 似乎拥有所有功能。我很快就能够运行 3 种基本的机器学习模型并获得实际可解释的结果。 所以,如果你一直渴望使用最先进的机器学习模型分析非常大的数据库,我会推荐使用 H2o。首先尝试使用 Flow,而不是 Python 或 R 的钩子,来看看它能做什么。 -唯一缺点是,H2o 是用 Java 编写的,并依赖 Java 1.7 来运行。并且需要警告:它需要非常强大的处理器和大量的内存。即使有 10 个可用的内核和 10Gb 的 RAM,我可怜的服务器也苦苦挣扎了一段时间。 +唯一缺点是,H2o 是用 Java 编写的,并依赖 Java 1.7 来运行。并且需要警告的是:它需要非常强大的处理器和大量的内存。即使有 10 个可用的内核和 10Gb 的 RAM,我可怜的服务器也苦苦挣扎了一段时间。 -------------------------------------------------------------------------------- @@ -28,7 +29,7 @@ via: https://veronneau.org/playing-with-water.html 作者:[Louis-Philippe Véronneau][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 e767bf2bfe9f90b4e05b2e7d028a9c71cdd07fb8 Mon Sep 17 00:00:00 2001 From: wxy Date: Sat, 7 Apr 2018 23:45:03 +0800 Subject: [PATCH 0344/1057] PUB:20180314 Playing with water.md @geekpi --- {translated/tech => published}/20180314 Playing with water.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180314 Playing with water.md (100%) diff --git a/translated/tech/20180314 Playing with water.md b/published/20180314 Playing with water.md similarity index 100% rename from translated/tech/20180314 Playing with water.md rename to published/20180314 Playing with water.md From c950d5dadc3509f90155b90b8afcdeeae16dbb14 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 7 Apr 2018 23:48:14 +0800 Subject: [PATCH 0345/1057] Update 20180327 Loop better- A deeper look at iteration in Python.md --- ...0180327 Loop better- A deeper look at iteration in Python.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180327 Loop better- A deeper look at iteration in Python.md b/sources/tech/20180327 Loop better- A deeper look at iteration in Python.md index 1d4d627a80..9951cf2a02 100644 --- a/sources/tech/20180327 Loop better- A deeper look at iteration in Python.md +++ b/sources/tech/20180327 Loop better- A deeper look at iteration in Python.md @@ -1,3 +1,5 @@ +Translating by MjSeven + Loop better: A deeper look at iteration in Python ====== From ab6162c92b37d7d1720515daecb9e394456e2c91 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 00:21:36 +0800 Subject: [PATCH 0346/1057] PRF:20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md @kimii --- ... PGP - Part 1- Basic Concepts and Tools.md | 202 ++++++------------ 1 file changed, 66 insertions(+), 136 deletions(-) diff --git a/translated/tech/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md b/translated/tech/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md index 87cd2d7e1f..abf68aeb2b 100644 --- a/translated/tech/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md +++ b/translated/tech/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md @@ -1,267 +1,197 @@ -用 PGP 保护代码完整性 - 第一部分: 基本概念和工具 +用 PGP 保护代码完整性(一): 基本概念和工具 ====== ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/pgp-security.jpg?itok=lulwyzYc) 在本系列文章中,我们将深度探讨如何使用 PGP 确保软件完整性。这些文章将为工作于自由软件项目的开发者提供实用指南,并且将包含以下主题: - - 1. PGP 基础和最佳实践 - + 1. PGP 基础和最佳实践 2. 如何用 Git 使用 PGP - 3. 如何保护你的开发者账户 - -我们使用与“Freedom”含义相同的词项“Free”,但这个系列中列出的指南也可以被任何其它类型的依赖于分布式团队开发者贡献的软件中。如果你编写进入公共源仓库的代码,你可以从了解和遵循这篇指南中受益。 +我们使用与“Freedom”含义相同的词项 “Free”,但这个系列中列出的指南也可以被任何其它类型的依赖于分布式团队开发者贡献的软件中。如果你编写进入公共源仓库的代码,你可以从了解和遵循这篇指南中受益。 ### 结构 每节分为两个部分: * 适用于你项目需求的清单 - - * 自由形式的考虑事项的列表,解释这些决定取决于什么,并伴随着配置指令 - - - + * 形式自由的考虑事项的列表,解释这些决定取决于什么,并伴随着配置指令 #### 清单优先级 每个清单中各项包含着优先级,用来帮助指导你的决定: - * (ESSENTIAL) 该项一定要排在考虑事项列表的前面。如果没有这样做,它们将给提交到开源项目中的代码带来高风险。 - - * (NICE) 包含该项将提升整体安全性,但会影响你与工作环境的交互方式,并且可能需要学习新的习惯或者放弃旧的习惯。 - - - + * (必要)该项一定要排在考虑事项列表的前面。如果没有这样做,它们将给提交到开源项目中的代码带来高风险。 + * (推荐)包含该项将提升整体安全性,但会影响你与工作环境的交互方式,并且可能需要学习新的习惯或者放弃旧的习惯。 记住,这些只是指导。如果你感到这些优先级不能反映你项目提交的安全,你应该根据自己的需要调整它们。 -## PGP 基本概念和工具 +### PGP 基本概念和工具 -### 清单 +#### 清单 - 1. 理解 PGP 在自由软件开发中的作用 (ESSENTIAL) - - 2. 理解公钥密码学(Public Key Cryptography)的基础知识 (ESSENTIAL) - - 3. 理解 PGP 加密和签名的不同 (ESSENTIAL) - - 4. 理解 PGP 密钥身份(key identities) (ESSENTIAL) - - 5. 理解 PGP 密钥有效性(key validity) (ESSENTIAL) - - 6. 安装 GnuPG 工具(版本 2.x) (ESSENTIAL) + 1. 理解 PGP 在自由软件开发中的作用 (必要) + 2. 理解公钥密码学Public Key Cryptography的基础知识 (必要) + 3. 理解 PGP 加密和签名的不同 (必要) + 4. 理解 PGP 密钥身份key identities (必要) + 5. 理解 PGP 密钥有效性key validity (必要) + 6. 安装 GnuPG 工具(版本 2.x) (必要) +#### 考虑事项 - - -### 考虑事项 - -自由软件社区长期依赖于 PGP 确保它生产的软件产品的真实性和完整性。你可能没有注意到,但无论你是一个 linux,Mac 和 Windowas 用户,你都曾依赖 PGP 来确保你电脑环境的完整性: +自由软件社区长期依赖于 PGP 确保它生产的软件产品的真实性和完整性。你可能没有注意到,但无论你是一个 Linux +、Mac 和 Windowas 用户,你都曾依赖 PGP 来确保你电脑环境的完整性: * Linux 发行版依赖 PGP 来确保当二进制或者原代码包从被生产出来到被终端用户安装之间没被更改过 - - * 自由软件项目通常会提供分离的 PGP 签名以伴随发行软件存档,使得下游的项目可以把下载的版本集成到自己的分布式下载之前,验证下载版本的完整性。 - + * 自由软件项目通常会伴随发行软件的存档提供分离的 PGP 签名,使得下游的项目可以在把下载的版本集成到自己的分布式下载之前,验证下载版本的完整性。 * 自由软件项目通常依赖代码本身的 PGP 签名来跟踪起源,并验证项目开发者提交的代码的完整性 - - - - -这与工作于专有平台的程序员使用的开发者证书或代码签名机制非常相似。实际上,这两种技术背后的核心概念非常相似 -- 尽管它们在实现的技术层面和它们委托信任方式的大多不同。PGP 不依赖于集中式认证机构,而是让每个用户为每个证书分配自己的信任。 +这与工作于专有平台的程序员使用的开发者证书或代码签名机制非常相似。实际上,这两种技术背后的核心概念非常相似 —— 尽管它们在实现的技术层面和它们委托信任方式的大多不同。PGP 不依赖于集中式认证机构,而是让每个用户为每个证书赋予自己的信任。 我们的目标是使你的项目通过使用 PGP 来进行代码起源和完整性追踪,遵循最佳实践并遵守基本的安全预防措施。 -### 极其基本的 PGP 操作概括 +#### 极其基本的 PGP 操作概括 -你不需要知道 PGP 如何工作的具体细节 -- 理解核心概念足以成功地达到我们的目的。PGP 依赖于公钥密码学来将明文转换为密文。这个过程需要两种不同的密钥: +你不需要知道 PGP 如何工作的具体细节 —— 理解核心概念足以成功地达到我们的目的。PGP 依赖于公钥密码学来将明文转换为密文。这个过程需要两种不同的密钥: * 公钥,被所有人知道 - * 私钥,只被拥有者知道 - - - -#### 加密 +##### 加密 对加密来说,PGP 使用拥有者的公钥创造一条只能通过拥有者私钥解密的消息: - 1. 发送者生成一条随机的加密密钥(“会话密钥”) - - 2. 发送者使用该会话密钥(使用对称密码)加密内容 - + 1. 发送者生成一个随机的加密密钥(“会话密钥”) + 2. 发送者使用该会话密钥(使用对称算法)加密内容 3. 发送者使用接收者的 PGP 公钥加密会话密钥 - 4. 发送者向接收者发送加密后的内容和加密后的会话密钥 +要解密: + 1. 接收者使用他们的 PGP 私钥解密会话密钥 + 2. 接收者使用会话密钥解密消息的内容 +##### 签名 -对于解密: - - 1. 接受者使用他们的 PGP 私钥解密会话密钥 - - 2. 接受者使用会话密钥解密消息的内容 - - - - -#### 签名 为了创建签名,PGP 私钥或公钥会以相反的方式使用: 1. 签名者生成内容的校检和哈希 2. 签名者使用自己的 PGP 私钥来加密该校检和 3. 签名者伴随内容提供加密后的校检和 - - - -为了验证签名: +要验证签名: 1. 验证者生成自己的内容校检和哈希 - 2. 验证者使用签名者的 PGP 公钥来解密提供的校检和 - 3. 如果校检和匹配,就验证了内容的完整性 - - - - +##### 结合使用 通常,加密消息也被发送者自己的 PGP 密钥签名。无论何时使用加密消息,这应当是默认的,因为没有认证的加密没有很大意义(除非你是一个告密者或秘密代理并且需要可行的可否认性) -``` -Bob Designer (obsolete 1024-bit key) +#### 理解密钥身份 -``` -### 理解密钥身份 +每个 PGP 密钥必须有一个或多个与之关联的身份。通常,“身份Identity”指的是以下格式中的人物全名和邮件地址: -每个 PGP 密钥必须有一个或多个与之关联的身份。通常,一个“身份”指的是以下格式中的人物全名和邮件地址: ``` Alice Engineer - ``` 有时也会在括号中包含说明,来告诉终端用户关于该特定密钥的更多信息: + ``` Bob Designer (obsolete 1024-bit key) - ``` - - 由于人们可以和多个职业和个人实体相关联,因此在同一密钥上可以有多个身份: + ``` Alice Engineer Alice Engineer Alice Engineer - ``` -当使用多个身份时,其中之一将被标记为“primary identity”(主要身份)来让检索更简单。 +当使用多个身份时,其中之一将被标记为“primary identity主要身份”来让检索更简单。 -### 理解密钥有效性 +#### 理解密钥有效性 -为了能使用其他人的公钥来加密或验证,你需要确保它确实属于正确的人(Alice)而不属于冒牌的(Eve)。在 PGP 中,这被称为密钥有效性: +为了能使用其他人的公钥来加密或验证,你需要确保它确实属于正确的人(Alice)而不属于冒牌的(Eve)。在 PGP 中,这被称为“密钥有效性”: - * Validity: full -- 意味着非常确认该密钥属于 Alice - * Validity: marginal -- 意味着大致确认该密钥属于 Alice - * Validity: unknown -- 意味着不确认该密钥是否属于 Alice + * 有效性:完全full -- 意味着非常确认该密钥属于 Alice + * 有效性:临界marginal -- 意味着大致确认该密钥属于 Alice + * 有效性:未知unknown -- 意味着不确认该密钥是否属于 Alice + +#### Web of Trust (WOT) 与 Trust on First Use (TOFU) +PGP 使用了一种信任委托机制叫“Web of Trust”。它的核心是尝试替代 HTTPS/TLS 世界中对集中式认证机构的需求。PGP 把这个责任交给了每个用户,而不是各种软件开发商来决定谁应该是你的可信认证实体。 - -#### Web of Trust (WOT) vs. Trust on First Use (TOFU) - -PGP 使用了一种信任委托机制叫“Web of Trust”。它的核心是尝试替代 HTTPS/TLS 世界中对集中式认证机构的需求。PGP 把这个责任交给了每个用户,而非各种软件制作商来决定谁应该是你的可信认证实体。 - -不幸的是,很少有人理解 Web of Trust 的是如何工作的,能让继续工作的人更少。它仍然是 OpenPGP 规范的一个重要方面,但 GnuPG 的近期版本(2.2 及以上)已经实现了一种替代机制叫“Trust on First Use”(TOFU)。 +不幸的是,很少有人理解 Web of Trust 的是如何工作的,能使用它的人更少。它仍然是 OpenPGP 规范的一个重要方面,但 GnuPG 的近期版本(2.2 及以上)已经实现了一种替代机制叫“Trust on First Use”(TOFU)。 你可以把 TOFU 当作类似 SSH 的信任方式。使用 SSH,当你第一次连接到远程系统,它的密钥指纹会被记录和保存。如果将来密钥改变,SSH 客户端将会提醒你并拒绝连接,迫使你决定是否信任已改变的的密钥。 同样,当你第一次导入某人的 PGP 密钥,它被假定可信。如果在将来的任何时候,GnuPG 碰巧发现另一同样身份的密钥,过去导入的密钥和新密钥都将被标记为无效,并且你需要手动指出保留哪个。 +#### 安装 OpenPGP 软件 -### 安装 OpenPGP 软件 +首先,理解 PGP、OpenPGP、GnuPG 和 gpg 之间的不同很重要: -首先,理解 PGP, OpenPGP, GnuPG 和 gpg 之间的不同很重要: - - * PGP ("Pretty Good Privacy") 是原始商业软件的名字 - - * OpenPGP 是与原始 PGP 工具兼容的 IETF 标准 - - * GnuPG ("Gnu Privacy Guard")是实现了 OpenPGP 标准的自由软件 - + * PGP (“Pretty Good Privacy”) 是最初商业软件的名字 + * OpenPGP 是与最初 PGP 工具兼容的 IETF 标准 + * GnuPG (“Gnu Privacy Guard”)是实现了 OpenPGP 标准的自由软件 * GnuPG 的命令行工具称为 “gpg” +今天,“PGP”这个词几乎被普遍用来表示开放的 OpenPGP 标准,而不是最初的商业软件,因此“PGP”和“OpenPGP”是可以互换的。“GnuPG”和“pgp”这两个词应该仅在提及工具时使用,而不用于它们产生的输出或它们实现的 OpenPGP 功能。举例: - - - -今天,“PGP”这个词几乎被普遍用来表示开放的 OpenPGP 标准,而不是原始的商业软件,因此“PGP”和“OpenPGP”是可以互换的。“GnuPG”和“pgp”这两个词应该仅在提及工具时使用,而不用于它们产生的输出或它们实现的 OpenPGP 功能。举例: - - * PGP(而非 GnuPG 或 GPG)密钥 - - * PGP(而非 GnuPG 或 GPG)签名 - - * PGP(而非 GnuPG 或 GPG)密钥服务器 - - - + * PGP(而非 GnuPG 或 GPG)密钥 + * PGP(而非 GnuPG 或 GPG)签名 + * PGP(而非 GnuPG 或 GPG)密钥服务器 理解这一点应该可以保护你免受来自你遇到的其他 PGP 用户“实际上”不可避免的迂腐。 -#### 安装 GnuPG +##### 安装 GnuPG -如果你正在使用 Linux,你应该已经安装过了 GnuPG。在 Mac 上,你应该安装[GPG-Suite][1],或者使用 brew 安装 gnupg2。在 windows 上,你应该安装[GPG4Win][2],并且为了奏效你可能需要调整指南中的部分命令,除非你设置了类似 unix 的环境。对其他平台来说,你需要自行查找正确的地址来下载和安装 GnuPG。 +如果你正在使用 Linux,你应该已经安装过了 GnuPG。在 Mac 上,你应该安装 [GPG-Suite][1],或者使用 `brew` 安装 `gnupg2`。在 Windows 上,你应该安装 [GPG4Win][2],并且为了可以工作,你可能需要调整指南中的部分命令,除非你设置了类似 Unix 的环境。对其他平台来说,你需要自行查找正确的地址来下载和安装 GnuPG。 -#### GnuPG 1 vs. 2 +##### GnuPG 1 vs. 2 -GnuPG v.1 和 GnuPG v.2 都实现了同样的标准,但它们提供不兼容的库和命令行工具,所以许多发行版都发布了旧版本 1 和最新版本 2。你需要确保你总是使用 GnuPG v.2。 +GnuPG v.1 和 GnuPG v.2 都实现了同样的标准,但它们提供不兼容的库和命令行工具,所以许多发行版都带有了旧的版本 1 和最新的版本 2。你需要确保你总是使用 GnuPG v.2。 首先,运行: + ``` $ gpg --version | head -n1 - ``` -如果你看到 gpg (GnuPG) 1.4.x,说明你正使用 GnuPG v.1。尝试 gpg2 命令: +如果你看到 `gpg (GnuPG) 1.4.x`,说明你正使用 GnuPG v.1。尝试下 `gpg2` 命令: + ``` $ gpg2 --version | head -n1 - ``` -如果你看到 gpg (GnuPG) 2.x.x,说明你可以继续了。这篇指南将假设你使用 GnuPG 2.2 版本(或更晚)。如果你正使用 GnuPG 的 2.0 版本,本指南中某些命令可能无效,你应该考虑安装 GnuPG 最新的 2.2 版本 +如果你看到 `gpg (GnuPG) 2.x.x`,说明你可以继续了。这篇指南将假设你使用 GnuPG 2.2 版本(或更新)。如果你正使用 GnuPG 的 2.0 版本,本指南中某些命令可能无效,你应该考虑安装 GnuPG 最新的 2.2 版本 -#### 确保你总是使用 GnuPG v.2 +##### 确保你总是使用 GnuPG v.2 + +如果你 `gpg` 和 `gpg2` 命令都有,你应该确保总是使用 GnuPG v.2,而不是旧的版本。你可以通过设置别名来确保这一点: -如果你 gpg 和 gpg2 命令都有,你应该确保总是使用 GnuPG v.2,而不是旧的版本。你可以通过设置别名来确保这一点: ``` $ alias gpg=gpg2 - ``` -你可以把它放在你的 .bashrc 中,以确保它在你使用 gpg 命令时总是被加载。 +你可以把它放在你的 `.bashrc` 中,以确保它在你使用 `gpg` 命令时总是被加载。 在本系列的第 2 部分中,我们将介绍生成和保护你的 PGP 主密钥的基本步骤。 通过 Linux 基金会和 edX 的免费[“Introduction to Linux” ][3]课程了解关于 Linux 的更多信息。 - - - -------------------------------------------------------------------------------- via: https://www.linux.com/blog/learn/2018/2/protecting-code-integrity-pgp-part-1-basic-pgp-concepts-and-tools 作者:[Konstantin Ryabitsev][a] 译者:[kimii](https://github.com/kimii) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0f379a391df4ef7ae2b50c64689c79fa4e7c20e0 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 00:22:05 +0800 Subject: [PATCH 0347/1057] PUB:20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md @kimii https://linux.cn/article-9524-1.html --- ... Code Integrity with PGP - Part 1- Basic Concepts and Tools.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md (100%) diff --git a/translated/tech/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md b/published/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md similarity index 100% rename from translated/tech/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md rename to published/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md From 248add7f52676326e7730c577a4e30dcb549bed5 Mon Sep 17 00:00:00 2001 From: geekpi Date: Sun, 8 Apr 2018 08:41:27 +0800 Subject: [PATCH 0348/1057] translated --- ...line note-taking applications for Linux.md | 70 ------------------- ...line note-taking applications for Linux.md | 68 ++++++++++++++++++ 2 files changed, 68 insertions(+), 70 deletions(-) delete mode 100644 sources/tech/20180326 4 command line note-taking applications for Linux.md create mode 100644 translated/tech/20180326 4 command line note-taking applications for Linux.md diff --git a/sources/tech/20180326 4 command line note-taking applications for Linux.md b/sources/tech/20180326 4 command line note-taking applications for Linux.md deleted file mode 100644 index f2d06d50e5..0000000000 --- a/sources/tech/20180326 4 command line note-taking applications for Linux.md +++ /dev/null @@ -1,70 +0,0 @@ -translating---geekpi - -4 command line note-taking applications for Linux -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/note-taking.jpeg?itok=fiF5EBEb) -When you need to save a code snippet or a URL, an idea or a quote, you probably fire up a text editor or turn to a [desktop][1] or [web-based][2] note-taking tool. But those aren't your only options. If you spend time working in terminal windows, you can use one of the many note-taking tools available for the Linux command line. - -Let's take a look at of those four apps. - -### tnote - -[tnote][3] makes taking notes in a terminal window very simple—almost too simple. - -tnote is a single Python script. When you start it for the first time, it asks you to enter a password and a passphrase to encrypt the [SQLite database][4] that stores your notes. Once you've done that, press "A" to create a note. Type your note, then press CTRL-D to save it. - -Once you have a few (or more than a few) notes, you can view them or search for specific ones, words or phrases, or tags. tnote doesn't pack a lot of features, but it does get the job done. - -### Terminal Velocity - -If you've used Mac OS, you might have come across a popular open source note-taking application called [Notational Velocity][5], a simple and effective way to take notes. [Terminal Velocity][6] does a good job of bringing the Notational Velocity experience to the command line. - -Terminal Velocity opens your default text editor (set by the `$EDITOR` variable in your `.profile` or `.bashrc` file). Type your note, then save it. The note appears in the list in the Terminal Velocity window. - -Use the arrow keys on your keyboard to scroll through your list of notes. To view or edit a note, press Enter. If you have a long list of notes, you can enter the first few characters of the note's title in the `Find or Create` field to narrow down the list. From there, scroll to the note and press Enter to open it. - -### pygmynote - -Of the four applications in this article, [pygmynote][7] is probably the least user-friendly. It is, however, the most flexible. - -Like tnote, pygmynote saves your notes and attachments in an SQLite database. When you fire it up, pygmynote doesn’t look particularly useful. At any time, type `help` and press Enter to get a list of commands. - -You can add and edit notes, view and search for them, and add [tags][8] to your notes. Tags make finding notes easier, especially if you have a lot of them. - -What gives pygmynote flexibility is its ability to add attachments to your notes. Those attachments can be anything: an image, a text or word processor file, a PDF, a spreadsheet, or anything else relevant to the note. - -### jrnl - -[jrnl][9] is the odd application out here. As you've probably guessed from its name, jrnl is intended to be a journaling tool. But that doesn't mean you can't take notes with it. jrnl does that job very well. - -When you first start jrnl, it asks you where you want to put the file `journal.txt` (which stores your notes), and if you want to password-protect the file. If you decide to add a password, you need to enter it whenever you do anything with the application. - -You can enter notes in two ways: directly from the command line, or with your computer's default editor. You can add tags—for example,`@opensource.com`—to your notes, and give them a date and timestamp. Adding tags and dates can help you search for your notes (jrnl has a pretty decent search feature) if you have a lot of them. - -Since jrnl saves your notes in a plain text file, you can sync it across your devices using [ownCloud][10], [Nextcloud][11], or whatever file sharing/syncing service your prefer. - -Do you have a favorite tool or hack for taking notes at the command line? Feel free to share it with the community by leaving a comment. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/command-line-note-taking-applications - -作者:[Scott Nesbitt][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/scottnesbitt -[1]:https://opensource.com/life/16/9/4-desktop-note-taking-applications -[2]:https://opensource.com/alternatives/evernote -[3]:https://github.com/tasdikrahman/tnote -[4]:http://en.wikipedia.org/wiki/SQLite -[5]:http://notational.net/ -[6]:https://vhp.github.io/terminal_velocity/ -[7]:https://github.com/dmpop/pygmynote -[8]:https://en.wikipedia.org/wiki/Tag_(metadata) -[9]:http://jrnl.sh/ -[10]:https://owncloud.com/ -[11]:https://nextcloud.com/ diff --git a/translated/tech/20180326 4 command line note-taking applications for Linux.md b/translated/tech/20180326 4 command line note-taking applications for Linux.md new file mode 100644 index 0000000000..d948ae0798 --- /dev/null +++ b/translated/tech/20180326 4 command line note-taking applications for Linux.md @@ -0,0 +1,68 @@ +Linux 下的 4 个命令行笔记记录程序 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/note-taking.jpeg?itok=fiF5EBEb) +当你需要保存代码段或 URL、想法或引用时,可能会启动文本编辑器或使用[桌面][1]或[基于 Web 的] [2]笔记记录工具。但那些不是你唯一的选择。如果你在终端窗口中工作,则可以使用 Linux 命令行下的许多笔记记录工具之一。 + +我们来看看这四个程序。 + +### tnote + +[tnote][3] 使在终端窗口中记笔记很简单 - 几乎太简单了。 + +tnote 是一个 Python 脚本。首次启动时,它会要求你输入密码和口令来加密存储笔记的[ SQLite 数据库][4]。完成之后,按 “A” 创建一个笔记。输入你的笔记,然后按 CTRL-D 保存。 + +一旦你有几个(或多个)笔记,你可以查看它们或搜索特定的笔记,单词或短语或标签。tnote 不包含很多功能,但它确实实现了任务。 + +### Terminal Velocity + +如果你使用的是 Mac OS,你可能会看到一个名为 [Notational Velocity][5] 的流行开源笔记程序,这是一种记录笔记的简单有效方法。[Terminal Velocity][6] 在将 Notational Velocity 体验带入命令行方面做得很好。 + +Terminal Velocity 打开你的默认文本编辑器(由你的 `.profile` 或 `.bashrc` 文件中的 `$EDITOR` 变量设置)。输入你的笔记,然后保存。该笔记出现在 Terminal Velocity 窗口的列表中。 + +使用键盘上的箭头键滚动查看你的笔记列表。要查看或编辑笔记,请按 Enter 键。如果你有一长串笔记,则可以在 `Find or Create` 字段中输入笔记标题的前几个字符以缩小列表的范围。在那里滚动笔记并按下 Enter 键将其打开。 + +### pygmynote + +在本文中的四个应用中,[pygmynote][7] 可能是最不用户友好的。然而,它是最灵活的。 + +像 tnote 一样,pygmynote 将你的笔记和附件保存在 SQLite 数据库中。当你启动它时,pygmynote 看起来并不特别有用。在任何时候,输入 `help` 并按下 Enter 键获取命令列表。 + +你可以添加、编辑、查看和搜索笔记,并在笔记中添加[标签][8]。标签使找到笔记更容易,特别是如果你有很多笔记的时候。 + +pygmynote 的灵活性在于它能够将附件添加到笔记中。这些附件可以是任何东西:图像、文本、word、PDF、电子表格或与笔记相关的任何其他内容。 + +### jrnl + +[jrnl][9] 是这里的一个奇怪应用。正如你可能从它的名字中猜到的那样,jrnl 意在成为一种日记工具。但这并不意味着你不能记笔记。 jrnl 做得很好。 + +当你第一次启动 jrnl 时,它会询问你想把文件 `journal.txt` (它存储你的笔记)保存的位置以及是否需要密码保护。如果你决定添加密码,那么你在应用内的操作都需要输入密码。 + +你可以通过两种方式输入笔记:直接从命令行或使用计算机的默认编辑器。你可以将标签(例如,`@opensource.com`)添加到笔记中,并指定日期和时间戳。如果你有很多笔记的话,添加标签和日期可以帮助搜索你的笔记(jrnl 有一个相当不错的搜索功能)。 + +由于 jrnl 将你的笔记保存为纯文本文件,因此你可以使用 [ownCloud][10]、[Nextcloud][11] 或任何你喜欢的文件共享/同步服务在设备间同步它。 + +你有没有喜欢的工具或自制的命令行笔记工具?请发表评论,随时与社区分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/command-line-note-taking-applications + +作者:[Scott Nesbitt][a] +译者:[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/scottnesbitt +[1]:https://opensource.com/life/16/9/4-desktop-note-taking-applications +[2]:https://opensource.com/alternatives/evernote +[3]:https://github.com/tasdikrahman/tnote +[4]:http://en.wikipedia.org/wiki/SQLite +[5]:http://notational.net/ +[6]:https://vhp.github.io/terminal_velocity/ +[7]:https://github.com/dmpop/pygmynote +[8]:https://en.wikipedia.org/wiki/Tag_(metadata) +[9]:http://jrnl.sh/ +[10]:https://owncloud.com/ +[11]:https://nextcloud.com/ From a169404429d116849b726ea23a66bee2d1e265b2 Mon Sep 17 00:00:00 2001 From: geekpi Date: Sun, 8 Apr 2018 08:47:13 +0800 Subject: [PATCH 0349/1057] translating --- sources/tech/20180301 How to add fonts to Fedora.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180301 How to add fonts to Fedora.md b/sources/tech/20180301 How to add fonts to Fedora.md index 61efbb4a98..958da77029 100644 --- a/sources/tech/20180301 How to add fonts to Fedora.md +++ b/sources/tech/20180301 How to add fonts to Fedora.md @@ -1,3 +1,5 @@ +translating---geekpi + How to add fonts to Fedora =================== From a89d729baedb6bb906dde666cf6a07b26e91156a Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 09:48:49 +0800 Subject: [PATCH 0350/1057] PRF:20180129 A look inside Facebooks open source program.md @geekpi --- ...ok inside Facebooks open source program.md | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180129 A look inside Facebooks open source program.md b/translated/tech/20180129 A look inside Facebooks open source program.md index 87749076fb..1684d005bb 100644 --- a/translated/tech/20180129 A look inside Facebooks open source program.md +++ b/translated/tech/20180129 A look inside Facebooks open source program.md @@ -1,51 +1,45 @@ -深入看看 Facebook 的开源计划 +Facebook 的开源计划一窥 ============================================================ -### Facebook 开发人员 Christine Abernathy 讨论了开源如何帮助公司分享见解并推动创新。 +> Facebook 开发人员 Christine Abernathy 讨论了开源如何帮助公司分享见解并推动创新。 ![A look inside Facebook's open source program](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe "A look inside Facebook's open source program") + 图像来源:opensource.com +开源逐年变得无处不在,从[政府直辖市][11]到[大学][12]都有。各种规模的公司也越来越多地转向开源软件。事实上,一些公司正在通过财务支持项目或与开发人员合作进一步推进开源。 -开源每年在变得无处不在,从[政府直辖市][11]到[大学] [12]都有。各种规模的公司也越来越多地转向开源软件。事实上,一些公司正在通过财务支持项目或与开发人员合作进一步推进开源。 - -例如,Facebook 的开源计划鼓励其他人开源发布他们的代码,同时与社区合作支持开源项目。 [Christine Abernathy][13],一名 Facebook 开发者,开源支持者,公司开源团队成员,去年 11 月访问了罗切斯特理工学院,在[ 11 月][14] 的 FOSS 系列演讲中发表了演讲。在她的演讲中,Abernathy 解释了 Facebook 如何开源以及为什么它是公司所做工作的重要组成部分。 +例如,Facebook 的开源计划鼓励其他人开源发布他们的代码,同时与社区合作支持开源项目。 [Christine Abernathy][13],是一名 Facebook 开发者、开源支持者,也是该公司开源团队成员,去年 11 月访问了罗切斯特理工学院,在 [11 月][14] 的 FOSS 系列演讲中发表了演讲。在她的演讲中,Abernathy 解释了 Facebook 如何开源以及为什么它是公司所做工作的重要组成部分。 ### Facebook 和开源 -Abernathy 说,开源在 Facebook 创建社区和使世界更加紧密的使命中扮演着重要的角色。这种意识形态的匹配是 Facebook 参与开源的一个激励因素。此外,Facebook 面临着独特的基础设施和开发挑战,而开源则为公司提供了一个平台,以共享可帮助他人的解决方案。开源还提供了一种加速创新和创建更好软件的方法,帮助工程团队生产更好的软件并更透明地工作。今天,Facebook 在 GitHub 上有 443个 项目包括 122,000 个分支,292,000 个提交和 732,000 个关注。 - +Abernathy 说,开源在 Facebook 创建社区并使世界更加紧密的使命中扮演着重要的角色。这种意识形态的匹配是 Facebook 参与开源的一个激励因素。此外,Facebook 面临着独特的基础设施和开发挑战,而开源则为公司提供了一个平台,以共享可帮助他人的解决方案。开源还提供了一种加速创新和创建更好软件的方法,帮助工程团队生产更好的软件并更透明地工作。今天,Facebook 在 GitHub 的 443 个项目有 122,000 个分支、292,000 个提交和 732,000 个关注。 ![open source projects by Facebook](https://opensource.com/sites/default/files/images/life-uploads/blog-article-facebook-open-source-projects.png "open source projects by Facebood") -一些以开源方式发布的 Facebook 项目包括 React、GraphQL、Caffe2 等等。(图片提供:Christine Abernathy 图片,经许可使用) +*一些以开源方式发布的 Facebook 项目包括 React、GraphQL、Caffe2 等等。(图片提供:Christine Abernathy 图片,经许可使用)* ### 得到的教训 Abernathy 强调说 Facebook 已经从开源社区吸取了很多教训,并期待学到更多。她明确了三个最重要的: * 分享有用的东西 - * 突出你的英雄 - * 修复常见的痛点 - _Christine Abernathy 作为 FOSS 演讲系列的嘉宾一员参观了 RIT。每个月,来自开源世界的演讲嘉宾都会与对免费和开源软件感兴趣的学生分享关于开源世界智慧、见解、建议。 [FOSS @MAGIC][3]社区感谢 Abernathy 作为演讲嘉宾出席。_ + _Christine Abernathy 作为 FOSS 演讲系列的嘉宾一员参观了 RIT。每个月,来自开源世界的演讲嘉宾都会与对自由和开源软件感兴趣的学生分享关于开源世界智慧、见解、建议。 [FOSS @MAGIC][3]社区感谢 Abernathy 作为演讲嘉宾出席。_ ### 关于作者 - [![Picture of Justin W. Flory](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/october_2017_cropped_0.jpg?itok=gV-RgINC)][15] -Justin 是[罗切斯特理工学院][4]主修网络与系统管理的学生。他目前是 [Fedora Project][5] 的贡献者。在 Fedora 中,Justin 是 [Fedora Magazine][6] 的主编,[社区的领导][7]。。。[更多关于 Justin W. Flory]​​[8] - -[关于我更多][9] +Justin 是[罗切斯特理工学院][4]主修网络与系统管理的学生。他目前是 [Fedora Project][5] 的贡献者。在 Fedora 中,Justin 是 [Fedora Magazine][6] 的主编,[社区的领导][7]... [更多关于 Justin W. Flory]​​[8] -------------------------------------------------------------------------------- via: https://opensource.com/article/18/1/inside-facebooks-open-source-program -作者:[Justin W. Flory ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +作者:[Justin W. Flory][a] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0bb673e9fce5bb27d12540577878059228e058f8 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 09:49:08 +0800 Subject: [PATCH 0351/1057] PUB:20180129 A look inside Facebooks open source program.md @geekpi --- .../20180129 A look inside Facebooks open source program.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180129 A look inside Facebooks open source program.md (100%) diff --git a/translated/tech/20180129 A look inside Facebooks open source program.md b/published/20180129 A look inside Facebooks open source program.md similarity index 100% rename from translated/tech/20180129 A look inside Facebooks open source program.md rename to published/20180129 A look inside Facebooks open source program.md From dead45ddc26ad3231f73926e5530bb172bccdd16 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 10:12:15 +0800 Subject: [PATCH 0352/1057] PRF:20171205 7 rules for avoiding documentation pitfalls.md @lujun9972 --- ...les for avoiding documentation pitfalls.md | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/translated/tech/20171205 7 rules for avoiding documentation pitfalls.md b/translated/tech/20171205 7 rules for avoiding documentation pitfalls.md index 596997b8cb..76cc9b6eaf 100644 --- a/translated/tech/20171205 7 rules for avoiding documentation pitfalls.md +++ b/translated/tech/20171205 7 rules for avoiding documentation pitfalls.md @@ -1,58 +1,61 @@ 防止文档陷阱的 7 条准则 ====== -英语是开源社区的通用语言。为了减少翻译成本,很多团队都改成用英语来写他们的文档。 但奇怪的是,为国际读者写英语并不一定就意味着英语为母语的人就占据更多的优势。 相反, 他们往往忘记了写文档用的语言可能并不是读者的母语。 +> 让我们了解一下如何使国外读者更容易理解你的技术文章。 -我们以下面这个简单的句子为例: "Encrypt the password using the `foo bar` command。" 语法上来说,这个句子是正确的。 鉴于动名词的 '-ing' 形式在英语中很常见,大多数的母语人士都认为这是一种优雅的表达方式, 他们通常会很自然的写出这样的句子。 但是仔细观察, 这个句子存在歧义因为 "using" 可能指的宾语 ("the password") 也可能指的动词 ("encrypt")。 因此这个句子有两种解读方式: +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-docdish-typewriterkeys-4-series.png?itok=ccZISDxR) - * "加密使用了 `foo bar` 命令的密码。" - * "使用命令 `foo bar` 来加密密码。" +英语是开源社区的通用语言。为了减少翻译成本,很多团队都改成用英语来写他们的文档。 但奇怪的是,为国际读者写英语并不一定就意味着以英语为母语的人就占据更多的优势。 相反, 他们往往忘记了该文档用的语言可能并不是读者的母语。 -如果你有相关的先验知识 (密码加密或这 `foo bar` 命令),你可以消除这种不确定性并且明白第二种方式才是真正的意思。 但是若你没有足够深入的知识怎么办呢? 如果你并不是这方面的专家,而只是一个拥有泛泛相关知识的翻译者而已怎么办呢? 再或者,如果你只是个非母语人士且对像动名词这种高级语法不熟悉怎么办呢? +我们以下面这个简单的句子为例: “Encrypt the password using the `foo bar` command。”语法上来说,这个句子是正确的。 鉴于动名词的 “-ing” 形式在英语中很常见,大多数的母语人士都认为这是一种优雅的表达方式, 他们通常会很自然的写出这样的句子。 但是仔细观察, 这个句子存在歧义因为 “using” 可能指的宾语(“the password”)也可能指的动词(“encrypt”)。 因此这个句子有两种解读方式: + + * “加密使用了 `foo bar` 命令的密码。” + * “使用命令 `foo bar` 来加密密码。” + +如果你有相关的先验知识(密码加密或者 `foo bar` 命令),你可以消除这种不确定性并且明白第二种方式才是真正的意思。 但是若你没有足够深入的知识怎么办呢? 如果你并不是这方面的专家,而只是一个拥有泛泛相关知识的翻译者而已怎么办呢? 再或者,如果你只是个非母语人士且对像动名词这种高级语法不熟悉怎么办呢? 即使是英语为母语的人也需要经过训练才能写出清晰直接的技术文档。训练的第一步就是提高对文本可用性以及潜在问题的警觉性, 下面让我们来看一下可以帮助避免常见陷阱的 7 条规则。 -### 1。了解你的目标读者并代入其中。 +### 1、了解你的目标读者并代入其中。 -如果你是一名开发者,而写作的对象是终端用户, 那么你需要站在他们的角度来看这个产品。 文档的结构是否反映了用户的目标? [人格面具 (persona) 技术][1] 能帮你专注于目标受众并为你的读者提供合适层次的细节。 +如果你是一名开发者,而写作的对象是最终用户, 那么你需要站在他们的角度来看这个产品。 文档的结构是否反映了用户的目标? [人格面具persona 技术][1] 能帮你专注于目标受众并为你的读者提供合适层次的细节。 -### 2。准训 KISS 原则--保持文档简短而简单 +### 2、遵循 KISS 原则——保持文档简短而简单 这个原则适用于多个层次,从语法,句子到单词。 比如: * 使用合适的最简单时态。比如, 当提到一个动作的结果时使用现在时: - * " ~~Click 'OK。' The 'Printer Options' dialog will appear。~~" -> "Click 'OK。' The 'Printer Options' dialog appears。" - * 按经验来说,一个句子表达一个主题; 然而, 短句子并不一定就容易理解(尤其当这些句子都是由名词组成时)。 有时, 将句子裁剪过度可能会引起歧义,而反过来太多单词则又难以理解。 + * " ~~Click 'OK.' The 'Printer Options' dialog will appear.~~ " -> "Click 'OK.' The 'Printer Options' dialog appears." + * 按经验来说,一个句子表达一个主题;然而, 短句子并不一定就容易理解(尤其当这些句子都是由名词组成时)。 有时, 将句子裁剪过度可能会引起歧义,而反过来太多单词则又难以理解。 * 不常用的以及很长的单词会降低阅读速度,而且可能成为非母语人士的障碍。 使用更简单的替代词语: * " ~~utilize~~ " -> "use" - * " ~~indicate~~ " -> "show," "tell," or "say" + * " ~~indicate~~ " -> "show","tell" 或 "say" * " ~~prerequisite~~ " -> "requirement" -### 3。不要干扰阅读流 +### 3、不要干扰阅读流 将虚词和较长的插入语移到句子的首部或者尾部: - * " ~~They are not,however, marked as installed。~~ " -> "However, they are not marked as installed。" + * " ~~They are not, however, marked as installed.~~ " -> "However, they are not marked as installed." 将长命令放在句子的末尾可以让自动/半自动的翻译拥有更好的断句。 -### 4。区别对待两种基本的信息类型 +### 4、区别对待两种基本的信息类型 -描述型信息以及任务导向型信息有必要区分开来。描述型信息的一个典型例子就是命令行参考, 而 how-to 则是属于基于任务的信息; 然而, 技术写作中都会涉及这两种类型的信息。 仔细观察, 就会发现许多文本都同时包含了两种类型的信息。 然而如果能够清晰地划分这两种类型的信息那必是极好的。 为了跟好地区分他们,可以对他们进行分别标记(For better orientation, label them accordingly)。 标题应该能够反应章节的内容以及信息的类型。 对描述性章节使用基于名词的标题(比如"Types of Frobnicators"),而对基于任务的章节使用口头表达式的标题(例如"Installing Frobnicators")。 这可以让读者快速定位感兴趣的章节而跳过他无用的章节。 +描述型信息以及任务导向型信息有必要区分开来。描述型信息的一个典型例子就是命令行参考, 而 HOWTO 则是属于基于任务的信息;(LCTT 译注:HOWTO 文档是 Linux 文档中的一种)然而, 技术写作中都会涉及这两种类型的信息。 仔细观察, 就会发现许多文本都同时包含了两种类型的信息。 然而如果能够清晰地划分这两种类型的信息那必是极好的。 为了更好地区分它们,可以对它们进行分别标记。 标题应该能够反映章节的内容以及信息的类型。 对描述性章节使用基于名词的标题(比如“Types of Frobnicators”),而对基于任务的章节使用口头表达式的标题(例如“Installing Frobnicators”)。 这可以让读者快速定位感兴趣的章节而跳过对他无用的章节。 -### 5。考虑不同的阅读场景和阅读模式 +### 5、考虑不同的阅读场景和阅读模式 -有些读者在转向阅读产品文档时会由于自己搞不定而感到十分的沮丧。他们也在一个嘈杂的环境中工作,很难专注于阅读。 同时,不要期望你的读者会一页一页的进行阅读,很多人都是快速浏览文本搜索关键字或者通过表格,索引以及全文搜索的方式来查找主题。 请牢记这一点, 从不同的角度来看待你的文字。 通常需要妥协才能找到一种适合多种情况的文本结构。 +有些读者在阅读产品文档时会由于自己搞不定而感到十分的沮丧。他们在一个嘈杂的环境中工作,也很难专注于阅读。 同时,不要期望你的读者会一页一页的进行阅读,很多人都是快速浏览文本,搜索关键字或者通过表格、索引以及全文搜索的方式来查找主题。 请牢记这一点, 从不同的角度来看待你的文字。 通常需要折中才能找到一种适合多种情况的文本结构。 -### 6。将复杂的信息分成小块。 +### 6、将复杂的信息分成小块 -这会让读者更容易记住和吸收信息。例如, 过程不应该超过 7 到 10 个步骤(根据认知心理学中的 [Miller's Law][2])。 如果需要更多的步骤, 那么就将任务分拆成不同的过程。 +这会让读者更容易记住和吸收信息。例如, 过程不应该超过 7 到 10 个步骤(根据认知心理学中的 [米勒法则][2])。 如果需要更多的步骤, 那么就将任务分拆成不同的过程。 -### 7。形式遵循功能 +### 7、形式遵循功能 -根据以下问题检查你的文字: 某句话/段落/章节的 _目的_ (功能)是什么?比如, 它是一个指令呢?还是一个结果呢?还是一个警告呢?如果是指令, 使用主动语气: "Configure the system。" 被动语气可能适合于进行描述: "The system is configured automatically。" 将警告放在危险操作的 _前面_ 。 专注于目的还有助于发现冗余的内容,可以清除类似 "basically" 或者 "easily" 这一类的填充词,类似 " ~~already~~ existing " or " ~~completely~~ new" 这一类的不必要的修改, 以及任何与你的目标大众无关的内容。 - -你现在可能已经猜到了,写作就是一个不断重写的过程。 好的写作需要付出努力和练习。 即使你只是偶尔写点东西, 你也可以通过关注目标大众并遵循上述规则来显著地改善你的文字。 文字的可读性越好, 理解就越容易, 这一点对不同语言能力的读者来说都是适合的。 尤其是当进行本地化时, 高质量的原始文本至关重要: "垃圾进, 垃圾出"。 如果原始文本就有缺陷, 翻译所需要的时间就会变长, 从而导致更高的成本。 最坏的情况下, 翻译会导致缺陷成倍增加,需要在不同的语言版本中修正这个缺陷。 +根据以下问题检查你的文字:某句话/段落/章节的 _目的_(功能)是什么?比如,它是一个指令呢?还是一个结果呢?还是一个警告呢?如果是指令, 使用主动语气: “Configure the system.” 被动语气可能适合于进行描述: “The system is configured automatically.” 将警告放在危险操作的 _前面_ 。 专注于目的还有助于发现冗余的内容,可以清除类似 “basically” 或者 “easily” 这一类的填充词,类似 “~~already~~ existing ” 或“ ~~completely~~ new” 这一类的不必要的修饰, 以及任何与你的目标大众无关的内容。 +你现在可能已经猜到了,写作就是一个不断重写的过程。 好的写作需要付出努力和练习。 即使你只是偶尔写点东西, 你也可以通过关注目标大众并遵循上述规则来显著地改善你的文字。 文字的可读性越好, 理解就越容易, 这一点对不同语言能力的读者来说都是适合的。 尤其是当进行本地化时, 高质量的原始文本至关重要:“垃圾进, 垃圾出”。 如果原始文本就有缺陷, 翻译所需要的时间就会变长, 从而导致更高的成本。 最坏的情况下, 翻译会导致缺陷成倍增加,需要在不同的语言版本中修正这个缺陷。 -------------------------------------------------------------------------------- @@ -60,7 +63,7 @@ via: https://opensource.com/article/17/12/7-rules 作者:[Tanja Roth][a] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0a10000facd20a0663515a33a83370f7f72cef3c Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 10:12:39 +0800 Subject: [PATCH 0353/1057] PUB:20171205 7 rules for avoiding documentation pitfalls.md @lujun9972 https://linux.cn/article-9526-1.html --- .../20171205 7 rules for avoiding documentation pitfalls.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171205 7 rules for avoiding documentation pitfalls.md (100%) diff --git a/translated/tech/20171205 7 rules for avoiding documentation pitfalls.md b/published/20171205 7 rules for avoiding documentation pitfalls.md similarity index 100% rename from translated/tech/20171205 7 rules for avoiding documentation pitfalls.md rename to published/20171205 7 rules for avoiding documentation pitfalls.md From 3c4ba304e55c93e8366fad3fd860b1c0cd507ab3 Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 8 Apr 2018 13:00:10 +0800 Subject: [PATCH 0354/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Bring=20some=20?= =?UTF-8?q?JavaScript=20to=20your=20Java=20enterprise=20with=20Vert.x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ipt to your Java enterprise with Vert.x.md | 362 ++++++++++++++++++ 1 file changed, 362 insertions(+) create mode 100644 sources/tech/20190404 Bring some JavaScript to your Java enterprise with Vert.x.md diff --git a/sources/tech/20190404 Bring some JavaScript to your Java enterprise with Vert.x.md b/sources/tech/20190404 Bring some JavaScript to your Java enterprise with Vert.x.md new file mode 100644 index 0000000000..01ddf2d293 --- /dev/null +++ b/sources/tech/20190404 Bring some JavaScript to your Java enterprise with Vert.x.md @@ -0,0 +1,362 @@ +Bring some JavaScript to your Java enterprise with Vert.x +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_blue.png?itok=IfckxN48) +If you are a Java programmer, chances are that you've either used JavaScript in the past or will in the near future. Not only is it one of the most popular (and useful) programming languages, understanding some of JavaScript's features could help you build the next uber-popular web application. + +### JavaScript on the server + +The idea to run JavaScript on the server is not new; in fact, in December 1995, soon after releasing JavaScript for browsers, Netscape introduced an implementation of the language for server-side scripting with Netscape Enterprise Server. Microsoft also adopted it on Internet Information Server as JScript, a reverse-engineered implementation of Netscape's JavaScript. + +The seed was planted, but the real boom happened in 2009 when Ryan Dahl introduced Node.js. Node's success was not based on the language but on the runtime itself. It introduced a single process event loop that followed the reactive programming principles and could scale like other platforms couldn't. + +### The enterprise and the JVM + +Many enterprises have standardized on the Java virtual machine (JVM) as the platform of choice to run their mission-critical business applications, and large investments have been made on the JVM, so it makes sense for those organizations to look for a JVM-based JavaScript runtime. + +[Eclipse Vert.x][1] is a polyglot-reactive runtime that runs on the JVM. Using Eclipse Vert.x with JavaScript is not much different from what you would expect from Node.js. There are limitations, such as that the JVM JavaScript engine is not fully compatible with the ES6 standard and not all Node.js package manager (npm) modules can be used with it. But it can still do interesting things. + +### Why Eclipse Vert.x? + +Having a large investment in the JVM and not wanting to switch to a different runtime might be reason enough for an enterprise to be interested in Eclipse Vert.x. But other benefits are that it can interact with any existing Java application and offers one of the best performances possible on the JVM. + +To demonstrate, let's look at how Vert.x works with an existing business rules management system. Imagine for a moment that our fictional enterprise has a mission-critical application running inside JBoss Drools. We now need to create a new web application that can interact with this legacy app. + +For the sake of simplicity, let's say our existing rules are a simple Hello World: +``` +package drools + + + +//list any import classes here. + + + +//declare any global variables here + + + +rule "Greetings" + +    when + +        greetingsReferenceObject: Greeting( message == "Hello World!" ) + +    then + +        greetingsReferenceObject.greet(); + +    end + +``` + +When this engine runs, we get "Drools Hello World!" This is not amazing, but let's imagine this was a really complex process. + +### Implementing the Eclipse Vert.x JavaScript project + +Like with any other JavaScript project, we'll use the standard npm commands to bootstrap a project. Here's how to bootstrap the project `drools-integration` and prepare it to use Vert.x: +``` +# create an empty project directory + +mkdir drools-integration + +cd drools-integration + + + +# create the initial package.json + +npm init -y + + + +# add a couple of dependencies + +npm add vertx-scripts --save-dev + +# You should see a tip like: + +#Please add the following scripts to your 'package.json': + +# "scripts": { + +#   "postinstall": "vertx-scripts init", + +#   "test": "vertx-scripts launcher test -t", + +#   "start": "vertx-scripts launcher run", + +#   "package": "vertx-scripts package" + +# } + + + +# add + +npm add @vertx/web --save-prod + +``` + +We have initialized a bare-bones project so we can start writing the JavaScript code. We'll start by adding a simple HTTP server that exposes a simple API. Every time a request is made to the URL `http://localhost:8080/greetings`, we should see the existing Drools engine's execution result in the terminal. + +Start by creating an `index.js` file. If you're using VisualStudio Code, it's wise to add the following two lines to the beginning of your file: +``` +/// + +/// @ts-check + +``` + +These lines will enable full support and check the code for syntax errors. They aren't required, but they sure help during the development phase. + +Next, add the simple HTTP server. Running on the JVM is not exactly the same as running on Node, and many libraries will not be available. Think of the JVM as a headless browser, and in many cases, code that runs in a browser can run on the JVM. This does not mean we can't have a high-performance HTTP server; in fact, this is exactly what Vert.x does. Let's start writing our server: +``` +import { Router } from '@vertx/web'; + + + +// route all request based on the request path + +const app = Router.router(vertx); + + + +app.get('/greetings').handler(function (ctx) { + +    // will invoke our existing drools engine here... + +}); + + + +vertx + +// create a HTTP server + +.createHttpServer() + +// on each request pass it to our APP + +.requestHandler(function (req) { + +    app.accept(req); + +}) + +// listen on port 8080 + +.listen(8080); + +``` + +The code is not complicated and should be self-explanatory, so let's focus on the integration with existing JVM code and libraries in the form of a Drools rule. Since Drools is a Java-based tool, we should build our application with a `java` build tool. Fortunately, because, behind the scenes, `vertx-scripts` delegates the JVM bits to Apache Maven, our work is easy. +``` +mkdir -p src/main/java/drools + +mkdir -p src/main/resources/drools + +``` + +Next, we add the file `src/main/resources/drools/rules.drl` with the following content: +``` +package drools + + + +//list any import classes here. + + + +//declare any global variables here + + + +rule "Greetings" + +    when + +        greetingsReferenceObject: Greeting( message == "Hello World!" ) + +    then + +        greetingsReferenceObject.greet(); + +    end + +``` + +Then we'll add the file `src/main/java/drools/Greeting.java` with the following content: +``` +package drools; + + + +public interface Greeting { + + + +  (); + + + +  void greet(); + +}Greeting String getMessagegreet + +``` + +Finally, we'll add the helper utility class `src/main/java/drools/DroolsHelper.java`: +``` +package drools; + + + +import org.drools.compiler.compiler.*; + +import org.drools.core.*; + +import java.io.*; + + + +public final class DroolsHelper { + + + +  /** + +   * Simple factory to create a Drools WorkingMemory from the given `drl` file. + +   */ + +  public static WorkingMemory load( drl) throws { + +    PackageBuilder packageBuilder = new PackageBuilder(); + +    packageBuilder.addPackageFromDrl(new StringReader(drl)); + +    RuleBase ruleBase = RuleBaseFactory.newRuleBase(); + +    ruleBase.addPackage(packageBuilder.getPackage()); + +    return ruleBase.newStatefulSession(); + +  } + + + +  /** + +   * Simple factory to create a Greeting objects. + +   */ + +  public static Greeting createGreeting( message, ) { + +    return new Greeting() { + +      @Override + +      public () { + +        return message; + +      } + + + +      @Override + +      public void greet() { + +        andThen.run(); + +      } + +    }; + +  } + +}DroolsHelperWorkingMemory load String drl IOException , DroolsParserExceptionPackageBuilder packageBuilderPackageBuilderpackageBuilder.drlRuleBase ruleBaseRuleBaseFactory.ruleBase.packageBuilder.ruleBase.Greeting createGreeting String message, Runnable andThenGreeting@Override String getMessagemessage@OverridegreetandThen. + +``` + +We cannot use the file directly; we need to have `drools`. To do this, we add a custom property to our `package.json` named `mvnDependencies` (following the usual pattern): +``` +{ + +    "mvnDependencies": { + +        "org.drools:drools-compiler": "6.0.1.Final" + +    } + +} + +``` + +Of course, since we updated the project file, we should update npm: +``` +npm install + +``` + +We are now entering the final step of this project, where we mix Java and JavaScript. We had a placeholder before, so let's fill in the gaps. We first use the helper Java class to create an engine (you can now see the power of Vert.x, a truly polyglot runtime), then invoke our engine whenever an HTTP request arrives. +``` +// get a reference from Java to the JavaScript runtime + +const DroolsHelper = Java.type('drools.DroolsHelper'); + +// get a drools engine instance + +const engine = DroolsHelper.load(vertx.fileSystem().readFileBlocking("drools/rules.drl")); + + + +app.get('/greetings').handler(function (ctx) { + +  // create a greetings message + +  var greeting = DroolsHelper.createGreeting('Hello World!', function () { + +    // when a match happens you should see this message + +    console.log('Greetings from Drools!'); + +  }); + + + +  // run the engine + +  engine.insert(greeting); + +  engine.fireAllRules(); + + + +  // complete the HTTP response + +  ctx.response().end(); + +}); + +``` + +### Conclusion + +As this simple example shows, Vert.x allows you to be truly polyglot. The reason to choose Vert.x is not because it's another JavaScript runtime, rather it's a runtime that allows you to reuse what you already have and quickly build new code using the tools and language that run the internet. We didn't touch on performance here (as it is a topic on its own), but I encourage you to look at independent benchmarks such as [TechEmpower][2] to explore that topic. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/benefits-javascript-vertx + +作者:[Paulo Lopes][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/pml0pes +[1]:http://vertx.io/ +[2]:https://www.techempower.com/benchmarks/#section=data-r15 From 8249ec26eed60a269cd17dcda5cc30c97d5aafd3 Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 8 Apr 2018 13:05:03 +0800 Subject: [PATCH 0355/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=2010=20fundamenta?= =?UTF-8?q?l=20commands=20for=20new=20Linux=20users?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...undamental commands for new Linux users.md | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 sources/tech/20180403 10 fundamental commands for new Linux users.md diff --git a/sources/tech/20180403 10 fundamental commands for new Linux users.md b/sources/tech/20180403 10 fundamental commands for new Linux users.md new file mode 100644 index 0000000000..ef0872e799 --- /dev/null +++ b/sources/tech/20180403 10 fundamental commands for new Linux users.md @@ -0,0 +1,129 @@ +10 fundamental commands for new Linux users +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_terminals.png?itok=CfBqYBah) +You may think you're new to Linux, but you're really not. There are [3.74 billion][1] global internet users, and all of them use Linux in some way since Linux servers power 90% of the internet. Most modern routers run Linux or Unix, and the [TOP500 supercomputers][2] also rely on Linux. If you own an Android smartphone, your operating system is constructed from the Linux kernel. + +In other words, Linux is everywhere. + +But there's a difference between using Linux-based technologies and using Linux itself. If you're interested in Linux, but have been using a PC or Mac desktop, you may be wondering what you need to know to use the Linux command line interface (CLI). You've come to the right place. + +The following are the fundamental Linux commands you need to know. Each is simple and easy to commit to memory. In other words, you don't have to be Bill Gates to understand them. + +### 1\. ls + +You're probably thinking, "Is what?" No, that wasn't a typographical error – I really intended to type a lower-case L. `ls`, or "list," is the number one command you need to know to use the Linux CLI. This list command functions within the Linux terminal to reveal all the major directories filed under a respective filesystem. For example, this command: + +`ls /applications` + +shows every folder stored in the applications folder. You'll use it to view files, folders, and directories. + +All hidden files are viewable by using the command `ls -a`. + +### 2\. cd + +This command is what you use to go (or "change") to a directory. It is how you navigate from one folder to another. Say you're in your Downloads folder, but you want to go to a folder called Gym Playlist. Simply typing `cd Gym Playlist` won't work, as the shell won't recognize it and will report the folder you're looking for doesn't exist. To bring up that folder, you'll need to include a backslash. The command should look like this: + +`cd Gym\ Playlist` + +To go back from the current folder to the previous one, you can type in the folder name followed by `cd ..`. Think of the two dots like a back button. + +### 3\. mv + +This command transfers a file from one folder to another; `mv` stands for "move." You can use this short command like you would drag a file to a folder on a PC. + +For example, if I create a file called `testfile` to demonstrate all the basic Linux commands, and I want to move it to my Documents folder, I would issue this command: + +`mv /home/sam/testfile /home/sam/Documents/` + +The first piece of the command (`mv`) says I want to move a file, the second part (`home/sam/testfile`) names the file I want to move, and the third part (`/home/sam/Documents/`) indicates the location where I want the file transferred. + +### 4\. Keyboard shortcuts + +Okay, this is more than one command, but I couldn't resist including them all here. Why? Because they save time and take the headache out of your experience. + +`CTRL+K` Cuts text from the cursor until the end of the line + +`CTRL+Y` Pastes text + +`CTRL+E` Moves the cursor to the end of the line + +`CTRL+A` Moves the cursor to the beginning of the line + +`ALT+F`Jumps forward to the next space + +`ALT+B` Skips back to the previous space + +`ALT+Backspace` Deletes the previous word + +`CTRL+W` Cuts the word behind the cursor + +`Shift+Insert` Pastes text into the terminal + +`Ctrl+D` Logs you out + +These commands come in handy in many ways. For example, imagine you misspell a word in your command text: + +`sudo apt-get intall programname` + +You probably noticed "install" is misspelled, so the command won't work. But keyboard shortcuts make it easy to go back and fix it. If my cursor is at the end of the line, I can click `ALT+B` twice to move the cursor to the place noted below with the `^` symbol: + +`sudo apt-get^intall programname` + +Now, we can quickly add the letter `s` to fix `install`. Easy peasy! + +### 5\. mkdir + +This is the command you use to make a directory or a folder in the Linux environment. For example, if you're big into DIY hacks like I am, you could enter `mkdir DIY` to make a directory for your DIY projects. + +### 6\. at + +If you want to run a Linux command at a certain time, you can add `at` to the equation. The syntax is `at` followed by the date and time you want the command to run. Then the command prompt changes to `at>` so you can enter the command(s) you want to run at the time you specified above + +For example: + +`at 4:08 PM Sat` +`at> cowsay 'hello'` +`at> CTRL+D` + +This will run the program cowsay at 4:08 p.m. on Saturday night. + +### 7\. rmdir + +This command allows you to remove a directory through the Linux CLI. For example: + +`rmdir testdirectory` + +Bear in mind that this command will not remove a directory that has files inside. This only works when removing empty directories. + +### 8\. rm + +If you want to remove files, the `rm` command is what you want. It can delete files and directories. To delete a single file, type `rm testfile`, or to delete a directory and the files inside it, type `rm -r`. + +### 9\. touch + +The `touch` command, otherwise known as the "make file command," allows you to create new, empty files using the Linux CLI. Much like `mkdir` creates directories, `touch` creates files. For example, `touch testfile` will make an empty file named testfile. + +### 10\. locate + +This command is what you use to find a file in a Linux system. Think of it like search in Windows. It's very useful if you forget where you stored a file or what you named it. + +For example, if you have a document about blockchain use cases, but you can't think of the title, you can punch in `locate -blockchain`or you can look for "blockchain use cases" by separating the words with an asterisk or asterisks (`*`). For example: + +`locate -i*blockchain*use*cases*`. + +There are tons of other helpful Linux CLI commands, like the `pkill` command, which is great if you start a shutdown and realize you didn't mean to. But the 10 simple and useful commands described here are the essentials you need to get started using the Linux command line. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/10-commands-new-linux-users + +作者:[Sam Bocetta][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/sambocetta +[1]:https://hostingcanada.org/state-of-the-internet/ +[2]:https://www.top500.org/statistics/details/osfam/1 From 7838f22c7d081ca598c9507661d47314ee4caa6b Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 8 Apr 2018 14:23:18 +0800 Subject: [PATCH 0356/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=2017=20Ways=20To?= =?UTF-8?q?=20Check=20Size=20Of=20Physical=20Memory=20(RAM)=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Size Of Physical Memory (RAM) In Linux.md | 459 ++++++++++++++++++ 1 file changed, 459 insertions(+) create mode 100644 sources/tech/20180403 17 Ways To Check Size Of Physical Memory (RAM) In Linux.md diff --git a/sources/tech/20180403 17 Ways To Check Size Of Physical Memory (RAM) In Linux.md b/sources/tech/20180403 17 Ways To Check Size Of Physical Memory (RAM) In Linux.md new file mode 100644 index 0000000000..eeba3dce06 --- /dev/null +++ b/sources/tech/20180403 17 Ways To Check Size Of Physical Memory (RAM) In Linux.md @@ -0,0 +1,459 @@ +17 Ways To Check Size Of Physical Memory (RAM) In Linux +====== +Most of the system administrators checks CPU & Memory utilization when they were facing some performance issue. + +There is lot of utilities are available in Linux to check physical memory. + +These commands are help us to check the physical RAM present in system, also allow users to check memory utilization in varies aspect. + +Most of us know only few commands and we are trying to include all the possible commands in this article. + +You may think, why i want to know all these commands instead of knowing some of the specific and routine commands. + +Don’t think bad or don’t take in negative way because each one has different requirement and perception so, who’s looking for other purpose then this will very helpful for them. + +### What Is RAM + +Computer memory is a physical device which capable to store information temporarily or permanently. RAM stands for Random Access Memory is a volatile memory that stores information used by the operating system, software, and hardware. + +Two types of memory is available. + + * Primary Memory + * Secondary Memory + + + +Primary memory is the main memory of the computer. CPU can directly read or write on this memory. It is fixed on the motherboard of the computer. + + * **`RAM:`** Random Access Memory is a temporary memory. This information will go away when the computer is turned off. + * **`ROM:`** Read Only Memory is permanent memory, that holds the data even if the system is switched off. + + + +### Method-1 : Using free Command + +free displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The information is gathered by parsing /proc/meminfo. + +**Suggested Read :** [free – A Standard Command to Check Memory Usage Statistics (Free & Used) in Linux][1] +``` +$ free -m + total used free shared buff/cache available +Mem: 1993 1681 82 81 228 153 +Swap: 12689 1213 11475 + +$ free -g + total used free shared buff/cache available +Mem: 1 1 0 0 0 0 +Swap: 12 1 11 + +``` + +### Method-2 : Using /proc/meminfo file + +/proc/meminfo is a virtual text file that contains a large amount of valuable information about the systems RAM usage. + +It’s report the amount of free and used memory (both physical and swap) on the system. +``` +$ grep MemTotal /proc/meminfo +MemTotal: 2041396 kB + +$ grep MemTotal /proc/meminfo | awk '{print $2 / 1024}' +1993.55 + +$ grep MemTotal /proc/meminfo | awk '{print $2 / 1024 / 1024}' +1.94683 + +``` + +### 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][2] +``` +$ top + +top - 14:38:36 up 1:59, 1 user, load average: 1.83, 1.60, 1.52 +Tasks: 223 total, 2 running, 221 sleeping, 0 stopped, 0 zombie +%Cpu(s): 48.6 us, 11.2 sy, 0.0 ni, 39.3 id, 0.3 wa, 0.0 hi, 0.5 si, 0.0 st +MiB Mem : 1993.551 total, 94.184 free, 1647.367 used, 252.000 buff/cache +MiB Swap: 12689.58+total, 11196.83+free, 1492.750 used. 306.465 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 9908 daygeek 20 0 2971440 649324 39700 S 55.8 31.8 11:45.74 Web Content +21942 daygeek 20 0 2013760 308700 69272 S 35.0 15.1 4:13.75 Web Content + 4782 daygeek 20 0 3687116 227336 39156 R 14.5 11.1 16:47.45 gnome-shell + +``` + +### Method-4 : Using vmstat Command + +vmstat is a standard nifty tool that report virtual memory statistics of Linux system. vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. It helps Linux administrator to identify system bottlenecks while troubleshooting the issues. + +**Suggested Read :** [vmstat – A Standard Nifty Tool to Report Virtual Memory Statistics][3] +``` +$ vmstat -s | grep "total memory" + 2041396 K total memory + +$ vmstat -s -S M | egrep -ie 'total memory' + 1993 M total memory + +$ vmstat -s | awk '{print $1 / 1024 / 1024}' | head -1 +1.94683 + +``` + +### Method-5 : Using nmon Command + +nmon is a another nifty tool to monitor various system resources such as CPU, memory, network, disks, file systems, NFS, top processes, Power micro-partition and resources (Linux version & processors) on Linux terminal. + +Just press `m` key to see memory utilization stats (cached, active, inactive, buffered, free in MB & free percent) + +**Suggested Read :** [nmon – A Nifty Tool To Monitor System Resources On Linux][4] +``` +┌nmon─14g──────[H for help]───Hostname=2daygeek──Refresh= 2secs ───07:24.44─────────────────┐ +│ Memory Stats ─────────────────────────────────────────────────────────────────────────────│ +│ RAM High Low Swap Page Size=4 KB │ +│ Total MB 32079.5 -0.0 -0.0 20479.0 │ +│ Free MB 11205.0 -0.0 -0.0 20479.0 │ +│ Free Percent 34.9% 100.0% 100.0% 100.0% │ +│ MB MB MB │ +│ Cached= 19763.4 Active= 9617.7 │ +│ Buffers= 172.5 Swapcached= 0.0 Inactive = 10339.6 │ +│ Dirty = 0.0 Writeback = 0.0 Mapped = 11.0 │ +│ Slab = 636.6 Commit_AS = 118.2 PageTables= 3.5 │ +│───────────────────────────────────────────────────────────────────────────────────────────│ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└───────────────────────────────────────────────────────────────────────────────────────────┘ + +``` + +### Method-6 : Using dmidecode Command + +Dmidecode is a tool which reads a computer’s DMI (stands for Desktop Management Interface) +(some say SMBIOS – stands for System Management BIOS) table contents and display system hardware information in a human-readable format. + +This table contains a description of the system’s hardware components, as well as other useful information such as serial number, Manufacturer information, Release Date, and BIOS revision, etc,. + +**Suggested Read :** +[Dmidecode – Easy Way To Get Linux System Hardware Information][5] +``` +# dmidecode -t memory | grep Size: + Size: 8192 MB + Size: No Module Installed + Size: No Module Installed + Size: 8192 MB + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: 8192 MB + Size: No Module Installed + Size: No Module Installed + Size: 8192 MB + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + Size: No Module Installed + +``` + +Print only installed RAM modules. +``` + +# dmidecode -t memory | grep Size: | grep -v "No Module Installed" + Size: 8192 MB + Size: 8192 MB + Size: 8192 MB + Size: 8192 MB + +``` + +Sum all the installed RAM modules. +``` +# dmidecode -t memory | grep Size: | grep -v "No Module Installed" | awk '{sum+=$2}END{print sum}' +32768 + +``` + +### Method-7 : Using hwinfo Command + +hwinfo stands for hardware information tool is another great utility that used to probe for the hardware present in the system and display detailed information about varies hardware components in human readable format. + +It reports information about CPU, RAM, keyboard, mouse, graphics card, sound, storage, network interface, disk, partition, bios, and bridge, etc,. + +**Suggested Read :** [hwinfo (Hardware Info) – A Nifty Tool To Detect System Hardware Information On Linux][6] +``` +$ hwinfo --memory +01: None 00.0: 10102 Main Memory + [Created at memory.74] + Unique ID: rdCR.CxwsZFjVASF + Hardware Class: memory + Model: "Main Memory" + Memory Range: 0x00000000-0x7a4abfff (rw) + Memory Size: 1 GB + 896 MB + Config Status: cfg=new, avail=yes, need=no, active=unknown + +``` + +### Method-8 : Using lshw Command + +lshw (stands for Hardware Lister) is a small nifty tool that generates detailed reports about various hardware components on the machine such as memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, usb, network card, graphics cards, multimedia, printers, bus speed, etc. + +It’s generating hardware information by reading varies files under /proc directory and DMI table. + +**Suggested Read :** [LSHW (Hardware Lister) – A Nifty Tool To Get A Hardware Information On Linux][7] +``` +$ sudo lshw -short -class memory +[sudo] password for daygeek: +H/W path Device Class Description +================================================== +/0/0 memory 128KiB BIOS +/0/1 memory 1993MiB System memory + +``` + +### Method-9 : Using inxi Command + +inxi is a nifty tool to check hardware information on Linux and offers wide range of option to get all the hardware information on Linux system that i never found in any other utility which are available in Linux. It was forked from the ancient and mindbendingly perverse yet ingenius infobash, by locsmif. + +inxi is a script that quickly shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, GCC version(s), Processes, RAM usage, and a wide variety of other useful information, also used for forum technical support & debugging tool. + +**Suggested Read :** [inxi – A Great Tool to Check Hardware Information on Linux][8] +``` +$ inxi -F | grep "Memory" +Info: Processes: 234 Uptime: 3:10 Memory: 1497.3/1993.6MB Client: Shell (bash) inxi: 2.3.37 + +``` + +### Method-10 : Using screenfetch Command + +screenFetch is a bash script. It will auto-detect your distribution and display an ASCII art version of that distribution’s logo and some valuable information to the right. + +**Suggested Read :** [ScreenFetch – Display Linux System Information On Terminal With Distribution ASCII Art Logo][9] +``` +$ screenfetch + ./+o+- [email protected] + yyyyy- -yyyyyy+ OS: Ubuntu 17.10 artful + ://+//////-yyyyyyo Kernel: x86_64 Linux 4.13.0-37-generic + .++ .:/++++++/-.+sss/` Uptime: 44m + .:++o: /++++++++/:--:/- Packages: 1831 + o:+o+:++.`..```.-/oo+++++/ Shell: bash 4.4.12 + .:+o:+o/. `+sssoo+/ Resolution: 1920x955 + .++/+:+oo+o:` /sssooo. DE: GNOME + /+++//+:`oo+o /::--:. WM: GNOME Shell + \+/+o+++`o++o ++////. WM Theme: Adwaita + .++.o+++oo+:` /dddhhh. GTK Theme: Azure [GTK2/3] + .+.o+oo:. `oddhhhh+ Icon Theme: Papirus-Dark + \+.++o+o``-````.:ohdhhhhh+ Font: Ubuntu 11 + `:o+++ `ohhhhhhhhyo++os: CPU: Intel Core i7-6700HQ @ 2x 2.592GHz + .o:`.syhhhhhhh/.oo++o` GPU: llvmpipe (LLVM 5.0, 256 bits) + /osyyyyyyo++ooo+++/ RAM: 1521MiB / 1993MiB + ````` +oo+++o\: + `oo++. + +``` + +### Method-11 : Using neofetch Command + +Neofetch is a cross-platform and easy-to-use command line (CLI) script that collects your Linux system information and display it on the terminal next to an image, either your distributions logo or any ascii art of your choice. + +**Suggested Read :** [Neofetch – Shows Linux System Information With ASCII Distribution Logo][10] +``` +$ neofetch + .-/+oossssoo+/-. [email protected] + `:+ssssssssssssssssss+:` -------------- + -+ssssssssssssssssssyyssss+- OS: Ubuntu 17.10 x86_64 + .ossssssssssssssssssdMMMNysssso. Host: VirtualBox 1.2 + /ssssssssssshdmmNNmmyNMMMMhssssss/ Kernel: 4.13.0-37-generic + +ssssssssshmydMMMMMMMNddddyssssssss+ Uptime: 47 mins + /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Packages: 1832 +.ssssssssdMMMNhsssssssssshNMMMdssssssss. Shell: bash 4.4.12 ++sssshhhyNMMNyssssssssssssyNMMMysssssss+ Resolution: 1920x955 +ossyNMMMNyMMhsssssssssssssshmmmhssssssso DE: ubuntu:GNOME +ossyNMMMNyMMhsssssssssssssshmmmhssssssso WM: GNOME Shell ++sssshhhyNMMNyssssssssssssyNMMMysssssss+ WM Theme: Adwaita +.ssssssssdMMMNhsssssssssshNMMMdssssssss. Theme: Azure [GTK3] + /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ Icons: Papirus-Dark [GTK3] + +sssssssssdmydMMMMMMMMddddyssssssss+ Terminal: gnome-terminal + /ssssssssssshdmNNNNmyNMMMMhssssss/ CPU: Intel i7-6700HQ (2) @ 2.591GHz + .ossssssssssssssssssdMMMNysssso. GPU: VirtualBox Graphics Adapter + -+sssssssssssssssssyyyssss+- Memory: 1620MiB / 1993MiB + `:+ssssssssssssssssss+:` + .-/+oossssoo+/-. + +``` + +### Method-12 : Using dmesg Command + +dmesg (stands for display message or driver message) is a command on most Unix-like operating systems that prints the message buffer of the kernel. +``` +$ dmesg | grep "Memory" +[ 0.000000] Memory: 1985916K/2096696K available (12300K kernel code, 2482K rwdata, 4000K rodata, 2372K init, 2368K bss, 110780K reserved, 0K cma-reserved) +[ 0.012044] x86/mm: Memory block size: 128MB + +``` + +### Method-13 : Using atop Command + +Atop is an ASCII full-screen system performance monitoring tool for Linux that is capable of reporting the activity of all server processes (even if processes have finished during the interval). + +It’s logging of system and process activity for long-term analysis (By default, the log files are preserved for 28 days), highlighting overloaded system resources by using colors, etc. It shows network activity per process/thread with combination of the optional kernel module netatop. + +**Suggested Read :** [Atop – Monitor real time system performance, resources, process & check resource utilization history][11] +``` +$ atop -m + +ATOP - ubuntu 2018/03/31 19:34:08 ------------- 10s elapsed +PRC | sys 0.47s | user 2.75s | | | #proc 219 | #trun 1 | #tslpi 802 | #tslpu 0 | #zombie 0 | clones 7 | | | #exit 4 | +CPU | sys 7% | user 22% | irq 0% | | | idle 170% | wait 0% | | steal 0% | guest 0% | | curf 2.59GHz | curscal ?% | +cpu | sys 3% | user 11% | irq 0% | | | idle 85% | cpu001 w 0% | | steal 0% | guest 0% | | curf 2.59GHz | curscal ?% | +cpu | sys 4% | user 11% | irq 0% | | | idle 85% | cpu000 w 0% | | steal 0% | guest 0% | | curf 2.59GHz | curscal ?% | +CPL | avg1 1.98 | | avg5 3.56 | avg15 3.20 | | | csw 14894 | | intr 6610 | | | numcpu 2 | | +MEM | tot 1.9G | free 101.7M | cache 244.2M | dirty 0.2M | buff 6.9M | slab 92.9M | slrec 35.6M | shmem 97.8M | shrss 21.0M | shswp 3.2M | vmbal 0.0M | hptot 0.0M | hpuse 0.0M | +SWP | tot 12.4G | free 11.6G | | | | | | | | | vmcom 7.9G | | vmlim 13.4G | +PAG | scan 0 | steal 0 | | stall 0 | | | | | | | swin 3 | | swout 0 | +DSK | sda | busy 0% | | read 114 | write 37 | KiB/r 21 | KiB/w 6 | | MBr/s 0.2 | MBw/s 0.0 | avq 6.50 | | avio 0.26 ms | +NET | transport | tcpi 11 | tcpo 17 | udpi 4 | udpo 8 | tcpao 3 | tcppo 0 | | tcprs 3 | tcpie 0 | tcpor 0 | udpnp 0 | udpie 0 | +NET | network | ipi 20 | | ipo 33 | ipfrw 0 | deliv 20 | | | | | icmpi 5 | | icmpo 0 | +NET | enp0s3 0% | pcki 11 | pcko 28 | sp 1000 Mbps | si 1 Kbps | so 1 Kbps | | coll 0 | mlti 0 | erri 0 | erro 0 | drpi 0 | drpo 0 | +NET | lo ---- | pcki 9 | pcko 9 | sp 0 Mbps | si 0 Kbps | so 0 Kbps | | coll 0 | mlti 0 | erri 0 | erro 0 | drpi 0 | drpo 0 | + + PID TID MINFLT MAJFLT VSTEXT VSLIBS VDATA VSTACK VSIZE RSIZE PSIZE VGROW RGROW SWAPSZ RUID EUID MEM CMD 1/1 + 2536 - 941 0 188K 127.3M 551.2M 144K 2.3G 281.2M 0K 0K 344K 6556K daygeek daygeek 14% Web Content + 2464 - 75 0 188K 187.7M 680.6M 132K 2.3G 226.6M 0K 0K 212K 42088K daygeek daygeek 11% firefox + 2039 - 4199 6 16K 163.6M 423.0M 132K 3.5G 220.2M 0K 0K 2936K 109.6M daygeek daygeek 11% gnome-shell + 10822 - 1 0 4K 16680K 377.0M 132K 3.4G 193.4M 0K 0K 0K 0K root root 10% java + +``` + +### Method-14 : 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][12] +``` +$ htop + + 1 [||||||||||||| 13.0%] Tasks: 152, 587 thr; 1 running + 2 [||||||||||||||||||||||||| 25.0%] Load average: 0.91 2.03 2.66 + Mem[||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||1.66G/1.95G] Uptime: 01:14:53 + Swp[|||||| 782M/12.4G] + + PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command + 2039 daygeek 20 0 3541M 214M 46728 S 36.6 10.8 22:36.77 /usr/bin/gnome-shell + 2045 daygeek 20 0 3541M 214M 46728 S 10.3 10.8 3:02.92 /usr/bin/gnome-shell + 2046 daygeek 20 0 3541M 214M 46728 S 8.3 10.8 3:04.96 /usr/bin/gnome-shell + 6080 daygeek 20 0 807M 37228 24352 S 2.1 1.8 0:11.99 /usr/lib/gnome-terminal/gnome-terminal-server + 2880 daygeek 20 0 2205M 164M 17048 S 2.1 8.3 7:16.50 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51:0|57:128|58:10000|63:0|65:400|66 + 6125 daygeek 20 0 1916M 159M 92352 S 2.1 8.0 2:09.14 /usr/lib/firefox/firefox -contentproc -childID 7 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51:0|57:128|58:10000|63:0|65:400|66 + 2536 daygeek 20 0 2335M 243M 26792 S 2.1 12.2 6:25.77 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51:0|57:128|58:10000|63:0|65:400|66 + 2653 daygeek 20 0 2237M 185M 20788 S 1.4 9.3 3:01.76 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -intPrefs 6:50|7:-1|19:0|34:1000|42:20|43:5|44:10|51:0|57:128|58:10000|63:0|65:400|66 + +``` + +### Method-15 : Using corefreq Utility + +CoreFreq is a CPU monitoring software designed for Intel 64-bits Processors and supported architectures are Atom, Core2, Nehalem, SandyBridge and superior, AMD Family 0F. + +CoreFreq provides a framework to retrieve CPU data with a high degree of precision. + +**Suggested Read :** [CoreFreq – A Powerful CPU monitoring Tool for Linux Systems][13] +``` +$ ./corefreq-cli -k +Linux: +|- Release [4.13.0-37-generic] +|- Version [#42-Ubuntu SMP Wed Mar 7 14:13:23 UTC 2018] +|- Machine [x86_64] +Memory: +|- Total RAM 2041396 KB +|- Shared RAM 99620 KB +|- Free RAM 108428 KB +|- Buffer RAM 8108 KB +|- Total High 0 KB +|- Free High 0 KB + +$ ./corefreq-cli -k | grep "Total RAM" | awk '{print $4 / 1024 }' +1993.55 + +$ ./corefreq-cli -k | grep "Total RAM" | awk '{print $4 / 1024 / 1024}' +1.94683 + +``` + +### Method-16 : 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][14] +``` +$ glances + +ubuntu (Ubuntu 17.10 64bit / Linux 4.13.0-37-generic) - IP 192.168.1.6/24 Uptime: 1:08:40 + +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-17 : Using gnome-system-monitor + +System Monitor is a tool to manage running processes and monitor system resources. It shows you what programs are running and how much processor time, memory, and disk space are being used. +![][16] + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/easy-ways-to-check-size-of-physical-memory-ram-in-linux/ + +作者:[Ramya Nuvvula][a] +译者:[译者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/ramya/ +[1]:https://www.2daygeek.com/free-command-to-check-memory-usage-statistics-in-linux/ +[2]:https://www.2daygeek.com/top-command-examples-to-monitor-server-performance/ +[3]:https://www.2daygeek.com/linux-vmstat-command-examples-tool-report-virtual-memory-statistics/ +[4]:https://www.2daygeek.com/nmon-system-performance-monitor-system-resources-on-linux/ +[5]:https://www.2daygeek.com/dmidecode-get-print-display-check-linux-system-hardware-information/ +[6]:https://www.2daygeek.com/hwinfo-check-display-detect-system-hardware-information-linux/ +[7]:https://www.2daygeek.com/lshw-find-check-system-hardware-information-details-linux/ +[8]:https://www.2daygeek.com/inxi-system-hardware-information-on-linux/ +[9]:https://www.2daygeek.com/screenfetch-display-linux-systems-information-ascii-distribution-logo-terminal/ +[10]:https://www.2daygeek.com/neofetch-display-linux-systems-information-ascii-distribution-logo-terminal/ +[11]:https://www.2daygeek.com/atop-system-process-performance-monitoring-tool/ +[12]:https://www.2daygeek.com/htop-command-examples-to-monitor-system-resources/ +[13]:https://www.2daygeek.com/corefreq-linux-cpu-monitoring-tool/ +[14]:https://www.2daygeek.com/install-glances-advanced-real-time-linux-system-performance-monitoring-tool-on-centos-fedora-ubuntu-debian-opensuse-arch-linux/ +[15]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[16]:https://www.2daygeek.com/wp-content/uploads/2018/03/check-memory-information-using-gnome-system-monitor.png From 32c16c677034cd777fd73eca470d3b5327d167b1 Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 8 Apr 2018 14:27:56 +0800 Subject: [PATCH 0357/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=209=20Useful=20to?= =?UTF-8?q?uch=20command=20examples=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Useful touch command examples in Linux.md | 255 ++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 sources/tech/20180401 9 Useful touch command examples in Linux.md diff --git a/sources/tech/20180401 9 Useful touch command examples in Linux.md b/sources/tech/20180401 9 Useful touch command examples in Linux.md new file mode 100644 index 0000000000..35537d9ffb --- /dev/null +++ b/sources/tech/20180401 9 Useful touch command examples in Linux.md @@ -0,0 +1,255 @@ +9 Useful touch command examples in Linux +====== +Touch command is used to create empty files and also changes the timestamps of existing files on Unix & Linux System. Changing timestamps here means updating the access and modification time of files and directories. + +[![touch-command-examples-linux][1]![touch-command-examples-linux][2]][2] + +Let’s have a look on the syntax and options used in touch command, + +**Syntax** : # touch {options} {file} + +Options used in touch command, + +![touch-command-options][1] + +![touch-command-options][3] + +In this article we will walk through 9 useful touch command examples in Linux, + +### Example:1 Create an empty file using touch + +To create an empty file using touch command on Linux systems, type touch followed by the file name, example is shown below, +``` +[root@linuxtechi ~]# touch devops.txt +[root@linuxtechi ~]# ls -l devops.txt +-rw-r--r--. 1 root root 0 Mar 29 22:39 devops.txt +[root@linuxtechi ~]# + +``` + +### Example:2 Create empty files in bulk using touch + +There can be some scenario where we have to create lots of empty files for some testing, this can be easily achieved using touch command, +``` +[root@linuxtechi ~]# touch sysadm-{1..20}.txt + +``` + +In the above example we have created 20 empty files with name sysadm-1.txt to sysadm-20.txt, you can change the name and numbers based on your requirements. + +### Example:3 Change / Update access time of a file and directory + +Let’s assume we want to change access time of a file called “ **devops.txt** “, to do this use ‘ **-a** ‘ option in touch command followed by file name, example is shown below, +``` +[root@linuxtechi ~]# touch -a devops.txt +[root@linuxtechi ~]# + +``` + +Now verify whether access time of a file has been updated or not using ‘stat’ command +``` +[root@linuxtechi ~]# stat devops.txt +  File: ‘devops.txt’ +  Size: 0               Blocks: 0          IO Block: 4096   regular empty file +Device: fd00h/64768d    Inode: 67324178    Links: 1 +Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) +Context: unconfined_u:object_r:admin_home_t:s0 +Access: 2018-03-29 23:03:10.902000000 -0400 +Modify: 2018-03-29 22:39:29.365000000 -0400 +Change: 2018-03-29 23:03:10.902000000 -0400 + Birth: - +[root@linuxtechi ~]# + +``` + +**Change access time of a directory** , + +Let’s assume we have a ‘nfsshare’ folder under /mnt, Let’s change the access time of this folder using the below command, +``` +[root@linuxtechi ~]# touch -m /mnt/nfsshare/ +[root@linuxtechi ~]# + +[root@linuxtechi ~]# stat /mnt/nfsshare/ +  File: ‘/mnt/nfsshare/’ +  Size: 6               Blocks: 0          IO Block: 4096   directory +Device: fd00h/64768d    Inode: 2258        Links: 2 +Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root) +Context: unconfined_u:object_r:mnt_t:s0 +Access: 2018-03-29 23:34:38.095000000 -0400 +Modify: 2018-03-03 10:42:45.194000000 -0500 +Change: 2018-03-29 23:34:38.095000000 -0400 + Birth: - +[root@linuxtechi ~]# + +``` + +### Example:4 Change Access time without creating new file + +There can be some situations where we want to change access time of a file if it exists and avoid creating the file. Using ‘ **-c** ‘ option in touch command, we can change access time of a file if it exists and will not a create a file, if it doesn’t exist. +``` +[root@linuxtechi ~]# touch -c sysadm-20.txt +[root@linuxtechi ~]# touch -c winadm-20.txt +[root@linuxtechi ~]# ls -l winadm-20.txt +ls: cannot access winadm-20.txt: No such file or directory +[root@linuxtechi ~]# + +``` + +### Example:5 Change Modification time of a file and directory + +Using ‘ **-m** ‘ option in touch command, we can change the modification time of a file and directory, + +Let’s change the modification time of a file called “devops.txt”, +``` +[root@linuxtechi ~]# touch -m devops.txt +[root@linuxtechi ~]# + +``` + +Now verify whether modification time has been changed or not using stat command, +``` +[root@linuxtechi ~]# stat devops.txt +  File: ‘devops.txt’ +  Size: 0               Blocks: 0          IO Block: 4096   regular empty file +Device: fd00h/64768d    Inode: 67324178    Links: 1 +Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) +Context: unconfined_u:object_r:admin_home_t:s0 +Access: 2018-03-29 23:03:10.902000000 -0400 +Modify: 2018-03-29 23:59:49.106000000 -0400 +Change: 2018-03-29 23:59:49.106000000 -0400 + Birth: - +[root@linuxtechi ~]# + +``` + +Similarly, we can change modification time of a directory, +``` +[root@linuxtechi ~]# touch -m /mnt/nfsshare/ +[root@linuxtechi ~]# + +``` + +### Example:6 Changing access and modification time in one go + +Use “ **-am** ” option in touch command to change the access and modification together or in one go, example is shown below, +``` +[root@linuxtechi ~]# touch -am devops.txt +[root@linuxtechi ~]# + +``` + +Cross verify the access and modification time using stat, +``` +[root@linuxtechi ~]# stat devops.txt +  File: ‘devops.txt’ +  Size: 0               Blocks: 0          IO Block: 4096   regular empty file +Device: fd00h/64768d    Inode: 67324178    Links: 1 +Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) +Context: unconfined_u:object_r:admin_home_t:s0 +Access: 2018-03-30 00:06:20.145000000 -0400 +Modify: 2018-03-30 00:06:20.145000000 -0400 +Change: 2018-03-30 00:06:20.145000000 -0400 + Birth: - +[root@linuxtechi ~]# + +``` + +### Example:7 Set the Access & modification time to a specific date and time + +Whenever we do change access and modification time of a file & directory using touch command, then it set the current time as access & modification time of that file or directory, + +Let’s assume we want to set specific date and time as access & modification time of a file, this is can be achieved using ‘-c’ & ‘-t’ option in touch command, + +Date and Time can be specified in the format: {CCYY}MMDDhhmm.ss + +Where: + + * CC – First two digits of a year + * YY – Second two digits of a year + * MM – Month of the Year (01-12) + * DD – Day of the Month (01-31) + * hh – Hour of the day (00-23) + * mm – Minutes of the hour (00-59) + + + +Let’s set the access & modification time of devops.txt file for future date and time( 2025 year, 10th Month, 19th day of month, 18th hours and 20th minute) +``` +[root@linuxtechi ~]# touch -c -t 202510191820 devops.txt + +``` + +Use stat command to view the update access & modification time, + +![stat-command-output-linux][1] + +![stat-command-output-linux][4] + +Set the Access and Modification time based on date string, Use ‘-d’ option in touch command and then specify the date string followed by the file name, example is shown below, +``` +[root@linuxtechi ~]# touch -c -d "2010-02-07 20:15:12.000000000 +0530" sysadm-29.txt +[root@linuxtechi ~]# + +``` + +Verify the status using stat command, +``` +[root@linuxtechi ~]# stat sysadm-20.txt +  File: ‘sysadm-20.txt’ +  Size: 0               Blocks: 0          IO Block: 4096   regular empty file +Device: fd00h/64768d    Inode: 67324189    Links: 1 +Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) +Context: unconfined_u:object_r:admin_home_t:s0 +Access: 2010-02-07 20:15:12.000000000 +0530 +Modify: 2010-02-07 20:15:12.000000000 +0530 +Change: 2018-03-30 10:23:31.584000000 +0530 + Birth: - +[root@linuxtechi ~]# + +``` + +**Note:** In above commands, if we don’t specify ‘-c’ then touch command will create a new file in case it doesn’t exist on the system and will set the timestamps whatever is mentioned in the command. + +### Example:8 Set the timestamps to a file using a reference file (-r) + +In touch command we can use a reference file for setting the timestamps of file or directory. Let’s assume I want to set the same timestamps of file “sysadm-20.txt” on “devops.txt” file. This can be easily achieved using ‘-r’ option in touch. + +**Syntax:** # touch -r {reference-file} actual-file +``` +[root@linuxtechi ~]# touch -r sysadm-20.txt devops.txt +[root@linuxtechi ~]# + +``` + +### Example:9 Change Access & Modification time on symbolic link file + +By default, whenever we try to change timestamps of a symbolic link file using touch command then it will change the timestamps of original file only, In case you want to change timestamps of a symbolic link file then this can be achieved using ‘-h’ option in touch command, + +**Syntax:** # touch -h {symbolic link file} +``` +[root@linuxtechi opt]# ls -l /root/linuxgeeks.txt +lrwxrwxrwx. 1 root root 15 Mar 30 10:56 /root/linuxgeeks.txt -> linuxadmins.txt +[root@linuxtechi ~]# touch -t 203010191820 -h linuxgeeks.txt +[root@linuxtechi ~]# ls -l linuxgeeks.txt +lrwxrwxrwx. 1 root root 15 Oct 19  2030 linuxgeeks.txt -> linuxadmins.txt +[root@linuxtechi ~]# + +``` + +That’s all from this tutorial, I hope these examples help you to understand touch command. Please do share your valuable feedback and comments. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/9-useful-touch-command-examples-linux/ + +作者:[Pradeep Kumar][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linuxtechi.com/author/pradeep/ +[1]:https://www.linuxtechi.com/wp-content/plugins/lazy-load/images/1x1.trans.gif +[2]:https://www.linuxtechi.com/wp-content/uploads/2018/03/touch-command-examples-linux.jpg +[3]:https://www.linuxtechi.com/wp-content/uploads/2018/03/touch-command-options.jpg +[4]:https://www.linuxtechi.com/wp-content/uploads/2018/03/stat-command-output-linux.jpg From e072a058a9bac5af17366be31aadce340dd70f46 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 15:19:17 +0800 Subject: [PATCH 0358/1057] PRF:20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md @geekpi --- ...orial- Intorduction to simple Ansible commands.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename {translated/tech => published}/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md (88%) diff --git a/translated/tech/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md b/published/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md similarity index 88% rename from translated/tech/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md rename to published/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md index 5af00db0f9..6b31355f02 100644 --- a/translated/tech/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md +++ b/published/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md @@ -39,7 +39,7 @@ $ ansible -m setup -a "filter=ansible_distribution" ### 传输文件 -对于传输文件,我们使用模块 “copy” ,完整的命令是这样的: +对于传输文件,我们使用模块 `copy` ,完整的命令是这样的: ``` $ ansible -m copy -a "src=/home/dan dest=/tmp/home" @@ -47,7 +47,7 @@ $ ansible -m copy -a "src=/home/dan dest=/tmp/home" ### 管理用户 -要管理已连接主机上的用户,我们使用一个名为 “user” 的模块,并如下使用它。 +要管理已连接主机上的用户,我们使用一个名为 `user` 的模块,并如下使用它。 #### 创建新用户 @@ -65,7 +65,7 @@ $ ansible -m user -a "name=testuser state=absent" ### 更改权限和所有者 -要改变已连接主机文件的所有者,我们使用名为 ”file“ 的模块,使用如下。 +要改变已连接主机文件的所有者,我们使用名为 `file` 的模块,使用如下。 #### 更改文件权限 @@ -81,7 +81,7 @@ $ ansible -m file -a "dest=/home/dan/file1.txt mode=777 owner=dan group= ### 管理软件包 -我们可以通过使用 ”yum“ 和 ”apt“ 模块来管理所有已连接主机的软件包,完整的命令如下: +我们可以通过使用 `yum` 和 `apt` 模块来管理所有已连接主机的软件包,完整的命令如下: #### 检查包是否已安装并更新 @@ -109,7 +109,7 @@ $ ansible -m yum -a "name=ntp state=absent" ### 管理服务 -要管理服务,我们使用模块 “service” ,完整命令如下: +要管理服务,我们使用模块 `service` ,完整命令如下: #### 启动服务 @@ -129,7 +129,7 @@ $ ansible -m service -a "name=httpd state=stopped" $ ansible -m service -a "name=httpd state=restarted" ``` -这样我们简单的,单行 Ansible 命令的教程就完成了。此外,在未来的教程中,我们将学习创建 playbook,来帮助我们更轻松高效地管理主机。 +这样我们简单的、单行 Ansible 命令的教程就完成了。此外,在未来的教程中,我们将学习创建 playbook,来帮助我们更轻松高效地管理主机。 -------------------------------------------------------------------------------- From 0475bd4714ffd1dd76cb4bc03de9889cb8a7cf4a Mon Sep 17 00:00:00 2001 From: qhwdw Date: Sun, 8 Apr 2018 17:32:25 +0800 Subject: [PATCH 0359/1057] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Linux LAN Routing for Beginners- Part 2.md | 120 ------------------ 1 file changed, 120 deletions(-) delete mode 100644 sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md diff --git a/sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md b/sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md deleted file mode 100644 index 2173a6a4a2..0000000000 --- a/sources/tech/20180301 Linux LAN Routing for Beginners- Part 2.md +++ /dev/null @@ -1,120 +0,0 @@ -Linux LAN Routing for Beginners: Part 2 -============================================================ - - -![Routing](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dortmund-hbf-1259559_1920.jpg?itok=mdkNQRkS "Routing") -In this tutorial, we show how to manually configure LAN routers.[Creative Commons Zero][1] - -Last week [we reviewed IPv4 addressing][3] and using the network admin's indispensible ipcalc tool: Now we're going to make some nice LAN routers. - -VirtualBox and KVM are wonderful for testing routing, and the examples in this article are all performed in KVM. If you prefer to use physical hardware, then you need three computers: one to act as the router, and the other two to represent two different networks. You also need two Ethernet switches and cabling. - -The examples assume a wired Ethernet LAN, and we shall pretend there are some bridged wireless access points for a realistic scenario, although we're not going to do anything with them. (I have not yet tried all-WiFi routing and have had mixed success with connecting a mobile broadband device to an Ethernet LAN, so look for those in a future installment.) - -### Network Segments - -The simplest network segment is two computers in the same address space connected to the same switch. These two computers do not need a router to communicate with each other. A useful term is  _broadcast domain_ , which describes a group of hosts that are all in the same network. They may be all connected to a single Ethernet switch, or multiple switches. A broadcast domain may include two different networks connected by an Ethernet bridge, which makes the two networks behave as a single network. Wireless access points are typically bridged to a wired Ethernetwork. - -A broadcast domain can talk to a different broadcast domain only when they are connected by a network router. - -### Simple Network - -The following example commands are not persistent, and your changes will vanish with a restart. - -A broadcast domain needs a router to talk to other broadcast domains. Let's illustrate this with two computers and the `ip` command. Our two computers are 192.168.110.125 and 192.168.110.126, and they are plugged into the same Ethernet switch. In VirtualBox or KVM, you automatically create a virtual switch when you configure a new network, so when you assign a network to a virtual machine it's like plugging it into a switch. Use `ip addr show` to see your addresses and network interface names. The two hosts can ping each other. - -Now add an address in a different network to one of the hosts: - -``` -# ip addr add 192.168.120.125/24 dev ens3 -``` - -You have to specify the network interface name, which in the example is ens3\. It is not required to add the network prefix, in this case /24, but it never hurts to be explicit. Check your work with `ip`. The example output is trimmed for clarity: - -``` -$ ip addr show -ens3: - inet 192.168.110.125/24 brd 192.168.110.255 scope global dynamic ens3 - valid_lft 875sec preferred_lft 875sec - inet 192.168.120.125/24 scope global ens3 - valid_lft forever preferred_lft forever -``` - -The host at 192.168.120.125 can ping itself (`ping 192.168.120.125`), and that is a good basic test to verify that your configuration is working correctly, but the second computer can't ping that address. - -Now we need to do bit of network juggling. Start by adding a third host to act as the router. This needs two virtual network interfaces and a second virtual network. In real life you want your router to have static IP addresses, but for now we'll let the KVM DHCP server do the work of assigning addresses, so you only need these two virtual networks: - -* First network: 192.168.110.0/24 - -* Second network: 192.168.120.0/24 - -Then your router must be configured to forward packets. Packet forwarding should be disabled by default, which you can check with `sysctl`: - -``` -$ sysctl net.ipv4.ip_forward -net.ipv4.ip_forward = 0 -``` - -The zero means it is disabled. Enable it with this command: - -``` -# echo 1 > /proc/sys/net/ipv4/ip_forward -``` - -Then configure one of your other hosts to play the part of the second network by assigning the 192.168.120.0/24 virtual network to it in place of the 192.168.110.0/24 network, and then reboot the two "network" hosts, but not the router. (Or restart networking; I'm old and lazy and don't care what weird commands are required to restart services when I can just reboot.) The addressing should look something like this: - -* Host 1: 192.168.110.125 - -* Host 2: 192.168.120.135 - -* Router: 192.168.110.126 and 192.168.120.136 - -Now go on a ping frenzy, and ping everyone from everyone. There are some quirks with virtual machines and the various Linux distributions that produce inconsistent results, so some pings will succeed and some will not. Not succeeding is good, because it means you get to practice creating a static route. First, view the existing routing tables. The first example is from Host 1, and the second is from the router: - -``` -$ ip route show -default via 192.168.110.1 dev ens3 proto static metric 100 -192.168.110.0/24 dev ens3 proto kernel scope link src 192.168.110.164 metric 100 -``` - -``` -$ ip route show -default via 192.168.110.1 dev ens3 proto static metric 100 -default via 192.168.120.1 dev ens3 proto static metric 101 -169.254.0.0/16 dev ens3 scope link metric 1000 -192.168.110.0/24 dev ens3 proto kernel scope link - src 192.168.110.126 metric 100 -192.168.120.0/24 dev ens9 proto kernel scope link - src 192.168.120.136 metric 100 -``` - -This shows us that the default routes are the ones assigned by KVM. The 169.* address is the automatic link local address, and we can ignore it. Then we see two more routes, the two that belong to our router. You can have multiple routes, and this example shows how to add a non-default route to Host 1: - -``` -# ip route add 192.168.120.0/24 via 192.168.110.126 dev ens3 -``` - -This means Host 1 can access the 192.168.110.0/24 network via the router interface 192.168.110.126\. See how it works? Host 1 and the router need to be in the same address space to connect, then the router forwards to the other network. - -This command deletes a route: - -``` -# ip route del 192.168.120.0/24 -``` - -In real life, you're not going to be setting up routes manually like this, but rather using a router daemon and advertising your router via DHCP but understanding the fundamentals is key. Come back next week to learn how to set up a nice easy router daemon that does the work for you. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/3/linux-lan-routing-beginners-part-2 - -作者:[CARLA SCHRODER ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/licenses/category/creative-commons-zero -[2]:https://www.linux.com/files/images/dortmund-hbf-12595591920jpg -[3]:https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginners-part-1 From 42557f6a6e4ffcbaa31e8411d0a8ba9335f8fa97 Mon Sep 17 00:00:00 2001 From: Xu_fuyong Date: Sun, 8 Apr 2018 17:46:30 +0800 Subject: [PATCH 0360/1057] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E4=B8=AD=20By=20fu?= =?UTF-8?q?ryongXU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 申领by fuyongXu --- ...hes TensorFlow-based vision recognition kit for RPi Zero W.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md b/sources/tech/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md index 5bf32964e4..469a81d71a 100644 --- a/sources/tech/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md +++ b/sources/tech/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md @@ -1,3 +1,4 @@ +#fuyongXu 翻译中 # [Google launches TensorFlow-based vision recognition kit for RPi Zero W][26] From 5db3f06b07b304a5d93528f0a5da6c9b50f9b23f Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 8 Apr 2018 18:50:42 +0800 Subject: [PATCH 0361/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Memories=20of?= =?UTF-8?q?=20writing=20a=20parser=20for=20man=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ories of writing a parser for man pages.md | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 sources/tech/20180324 Memories of writing a parser for man pages.md diff --git a/sources/tech/20180324 Memories of writing a parser for man pages.md b/sources/tech/20180324 Memories of writing a parser for man pages.md new file mode 100644 index 0000000000..fb53aed395 --- /dev/null +++ b/sources/tech/20180324 Memories of writing a parser for man pages.md @@ -0,0 +1,109 @@ +Memories of writing a parser for man pages +====== + +I generally enjoy being bored, but sometimes enough is enough—that was the case a Sunday afternoon of 2015 when I decided to start an open source project to overcome my boredom. + +In my quest for ideas, I stumbled upon a request to build a [“Man page viewer built with web standards”][1] by [Mathias Bynens][2] and without thinking too much, I started coding a man page parser in JavaScript, which after a lot of back and forths, ended up being [Jroff][3]. + +Back then, I was familiar with manual pages as a concept and used them a fair amount of times, but that was all I knew, I had no idea how they were generated or if there was a standard in place. Two years later, here are some thoughts on the matter. + +### How man pages are written + +The first thing that surprised me at the time, was the notion that manpages at their core are just plain text files stored somewhere in the system (you can check this directory using the `manpath` command). + +This files not only contain the documentation, but also formatting information using a typesetting system from the 1970s called `troff`. + +> troff, and its GNU implementation groff, are programs that process a textual description of a document to produce typeset versions suitable for printing. **It’s more ‘What you describe is what you get’ rather than WYSIWYG.** +> +> — extracted from [troff.org][4] + +If you are totally unfamiliar with typesetting formats, you can think of them as Markdown on steroids, but in exchange for the flexibility you have a more complex syntax: + +![groff-compressor][5] + +The `groff` file can be written manually, or generated from other formats such as Markdown, Latex, HTML, and so on with many different tools. + +Why `groff` and man pages are tied together has to do with history, the format has [mutated along time][6], and his lineage is composed of a chain of similarly-named programs: RUNOFF > roff > nroff > troff > groff. + +But this doesn’t necessarily mean that `groff` is strictly related to man pages, it’s a general-purpose format that has been used to [write books][7] and even for [phototypesetting][8]. + +Moreover, It’s worth noting that `groff` can also call a postprocessor to convert its intermediate output to a final format, which is not necessarily ascii for terminal display! some of the supported formats are: TeX DVI, HTML, Canon, HP LaserJet4 compatible, PostScript, utf8 and many more. + +### Macros + +Other of the cool features of the format is its extensibility, you can write macros that enhance the basic functionalities. + +With the vast history of *nix systems, there are several macro packages that group useful macros together for specific functionalities according to the output that you want to generate, examples of macro packages are `man`, `mdoc`, `mom`, `ms`, `mm`, and the list goes on. + +Manual pages are conventionally written using `man` and `mdoc`. + +You can easily distinguish native `groff` commands from macros by the way standard `groff` packages capitalize their macro names. For `man`, each macro’s name is uppercased, like .PP, .TH, .SH, etc. For `mdoc`, only the first letter is uppercased: .Pp, .Dt, .Sh. + +![groff-example][9] + +### Challenges + +Whether you are considering to write your own `groff` parser, or just curious, these are some of the problems that I have found more challenging. + +#### Context-sensitive grammar + +Formally, `groff` has a context-free grammar, unfortunately, since macros describe opaque bodies of tokens, the set of macros in a package may not itself implement a context-free grammar. + +This kept me away (for good or bad) from the parser generators that were available at the time. + +#### Nested macros + +Most of the macros in `mdoc` are callable, this roughly means that macros can be used as arguments of other macros, for example, consider this: + + * The macro `Fl` (Flag) adds a dash to its argument, so `Fl s` produces `-s` + * The macro `Ar` (Argument) provides facilities to define arguments + * The `Op` (Optional) macro wraps its argument in brackets, as this is the standard idiom to define something as optional. + * The following combination `.Op Fl s Ar file` produces `[-s file]` because `Op` macros can be nested. + + + +#### Lack of beginner-friendly resources + +Something that really confused me was the lack of a canonical, well defined and clear source to look at, there’s a lot of information in the web which assumes a lot about the reader that it takes time to grasp. + +### Interesting macros + +To wrap up, I will offer to you a very short list of macros that I found interesting while developing jroff: + +**man** + + * TH: when writing manual pages with `man` macros, your first line that is not a comment must be this macro, it accepts five parameters: title section date source manual + * BI: bold alternating with italics (especially useful for function specifications) + * BR: bold alternating with Roman (especially useful for referring to other manual pages) + + + +**mdoc** + + * .Dd, .Dt, .Os: similar to how `man` macros require the `.TH` the `mdoc` macros require these three macros, in that particular order. Their initials stand for: Document date, Document title and Operating system. + * .Bl, .It, .El: these three macros are used to create list, their names are self-explanatory: Begin list, Item and End list. + + + + +-------------------------------------------------------------------------------- + +via: https://monades.roperzh.com/memories-writing-parser-man-pages/ + +作者:[Roberto Dip][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://monades.roperzh.com +[1]:https://github.com/h5bp/lazyweb-requests/issues/114 +[2]:https://mathiasbynens.be/ +[3]:jroff +[4]:https://www.troff.org/ +[5]:https://user-images.githubusercontent.com/4419992/37868021-2e74027c-2f7f-11e8-894b-80829ce39435.gif +[6]:https://manpages.bsd.lv/history.html +[7]:https://rkrishnan.org/posts/2016-03-07-how-is-gopl-typeset.html +[8]:https://en.wikipedia.org/wiki/Phototypesetting +[9]:https://user-images.githubusercontent.com/4419992/37866838-e602ad78-2f6e-11e8-97a9-2a4494c766ae.jpg From f2ce41ae432686df6f789a7bfb481f4d388b3879 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 19:18:05 +0800 Subject: [PATCH 0362/1057] PRF:20090211 Page Cache the Affair Between Memory and Files.md @qhwdw --- ...che the Affair Between Memory and Files.md | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/translated/tech/20090211 Page Cache the Affair Between Memory and Files.md b/translated/tech/20090211 Page Cache the Affair Between Memory and Files.md index 644cb1c33b..726ea23041 100644 --- a/translated/tech/20090211 Page Cache the Affair Between Memory and Files.md +++ b/translated/tech/20090211 Page Cache the Affair Between Memory and Files.md @@ -1,40 +1,50 @@ -[页面缓存,内存和文件之间的那些事][1] +页面缓存、内存和文件之间的那些事 ============================================================ -上一篇文章中我们学习了内核怎么为一个用户进程 [管理虚拟内存][2],而忽略了文件和 I/O。这一篇文章我们将专门去讲这个重要的主题 —— 页面缓存。文件和内存之间的关系常常很不好去理解,而它们对系统性能的影响却是非常大的。 +上一篇文章中我们学习了内核怎么为一个用户进程 [管理虚拟内存][2],而没有提及文件和 I/O。这一篇文章我们将专门去讲这个重要的主题 —— 页面缓存。文件和内存之间的关系常常很不好去理解,而它们对系统性能的影响却是非常大的。 -在面对文件时,有两个很重要的问题需要操作系统去解决。第一个是相对内存而言,慢的让人发狂的硬盘驱动器,[尤其是磁盘查找][3]。第二个是需要将文件内容一次性地加载到物理内存中,以便程序间共享文件内容。如果你在 Windows 中使用 [进程浏览器][4] 去查看它的进程,你将会看到每个进程中加载了大约 ~15MB 的公共 DLLs。我的 Windows 机器上现在大约运行着 100 个进程,因此,如果不共享的话,仅这些公共的 DLLs 就要使用高达 ~1.5 GB 的物理内存。如果是那样的话,那就太糟糕了。同样的,几乎所有的 Linux 进程都需要 [ld.so][5] 和 libc,加上其它的公共库,它们占用的内存数量也不是一个小数目。 +在面对文件时,有两个很重要的问题需要操作系统去解决。第一个是相对内存而言,慢的让人发狂的硬盘驱动器,[尤其是磁盘寻道][3]。第二个是需要将文件内容一次性地加载到物理内存中,以便程序间*共享*文件内容。如果你在 Windows 中使用 [进程浏览器][4] 去查看它的进程,你将会看到每个进程中加载了大约 ~15MB 的公共 DLL。我的 Windows 机器上现在大约运行着 100 个进程,因此,如果不共享的话,仅这些公共的 DLL 就要使用高达 ~1.5 GB 的物理内存。如果是那样的话,那就太糟糕了。同样的,几乎所有的 Linux 进程都需要 ld.so 和 libc,加上其它的公共库,它们占用的内存数量也不是一个小数目。 -幸运的是,所有的这些问题都用一个办法解决了:页面缓存 —— 保存在内存中的页面大小的文件块。为了用图去说明页面缓存,我捏造出一个名为 Render 的 Linux 程序,它打开了文件 scene.dat,并且一次读取 512 字节,并将文件内容存储到一个分配的堆块中。第一次读取的过程如下: +幸运的是,这两个问题都用一个办法解决了:页面缓存 —— 保存在内存中的页面大小的文件块。为了用图去说明页面缓存,我捏造出一个名为 `render` 的 Linux 程序,它打开了文件 `scene.dat`,并且一次读取 512 字节,并将文件内容存储到一个分配到堆中的块上。第一次读取的过程如下: ![Reading and the page cache](http://static.duartes.org/img/blogPosts/readFromPageCache.png) -读取完 12KB 的文件内容以后,Render 程序的堆和相关的页面帧如下图所示: +1. `render` 请求 `scene.dat` 从位移 0 开始的 512 字节。 +2. 内核搜寻页面缓存中 `scene.dat` 的 4kb 块,以满足该请求。假设该数据没有缓存。 +3. 内核分配页面帧,初始化 I/O 请求,将 `scend.dat` 从位移 0 开始的 4kb 复制到分配的页面帧。 +4. 内核从页面缓存复制请求的 512 字节到用户缓冲区,系统调用 `read()` 结束。 + +读取完 12KB 的文件内容以后,`render` 程序的堆和相关的页面帧如下图所示: ![Non-mapped file read](http://static.duartes.org/img/blogPosts/nonMappedFileRead.png) -它看起来很简单,其实这一过程做了很多的事情。首先,虽然这个程序使用了普通的读取调用,但是,已经有三个 4KB 的页面帧将文件 scene.dat 的一部分内容保存在了页面缓存中。虽然有时让人觉得很惊奇,但是,普通的文件 I/O 就是这样通过页面缓存来进行的。在 x86 架构的 Linux 中,内核将文件认为是一系列的 4KB 大小的块。如果你从文件中读取单个字节,包含这个字节的整个 4KB 块将被从磁盘中读入到页面缓存中。这是可以理解的,因为磁盘通常是持续吞吐的,并且程序读取的磁盘区域也不仅仅只保存几个字节。页面缓存知道文件中的每个 4KB 块的位置,在上图中用 #0、#1、等等来描述。Windows 也是类似的,使用 256KB 大小的页面缓存。 +它看起来很简单,其实这一过程做了很多的事情。首先,虽然这个程序使用了普通的读取(`read`)调用,但是,已经有三个 4KB 的页面帧将文件 scene.dat 的一部分内容保存在了页面缓存中。虽然有时让人觉得很惊奇,但是,**普通的文件 I/O 就是这样通过页面缓存来进行的**。在 x86 架构的 Linux 中,内核将文件认为是一系列的 4KB 大小的块。如果你从文件中读取单个字节,包含这个字节的整个 4KB 块将被从磁盘中读入到页面缓存中。这是可以理解的,因为磁盘通常是持续吞吐的,并且程序一般也不会从磁盘区域仅仅读取几个字节。页面缓存知道文件中的每个 4KB 块的位置,在上图中用 `#0`、`#1` 等等来描述。Windows 使用 256KB 大小的视图view,类似于 Linux 的页面缓存中的页面page。 -不幸的是,在一个普通的文件读取中,内核必须拷贝页面缓存中的内容到一个用户缓存中,它不仅花费 CPU 时间和影响 [CPU 缓存][6],在复制数据时也浪费物理内存。如前面的图示,scene.dat 的内存被保存了两次,并且,程序中的每个实例都在另外的时间中去保存了内容。我们虽然解决了从磁盘中读取文件缓慢的问题,但是在其它的方面带来了更痛苦的问题。内存映射文件是解决这种痛苦的一个方法: +不幸的是,在一个普通的文件读取中,内核必须拷贝页面缓存中的内容到用户缓冲区中,它不仅花费 CPU 时间和影响 [CPU 缓存][6],**在复制数据时也浪费物理内存**。如前面的图示,`scene.dat` 的内存被存储了两次,并且,程序中的每个实例都用另外的时间去存储内容。我们虽然解决了从磁盘中读取文件缓慢的问题,但是在其它的方面带来了更痛苦的问题。内存映射文件是解决这种痛苦的一个方法: ![Mapped file read](http://static.duartes.org/img/blogPosts/mappedFileRead.png) -当你使用文件映射时,内核直接在页面缓存上映射你的程序的虚拟页面。这样可以显著提升性能:[Windows 系统编程][7] 的报告指出,在相关的普通文件读取上运行时性能有多达 30% 的提升,在 [Unix 环境中的高级编程][8] 的报告中,文件映射在 Linux 和 Solaris 也有类似的效果。取决于你的应用程序类型的不同,通过使用文件映射,可以节约大量的物理内存。 +当你使用文件映射时,内核直接在页面缓存上映射你的程序的虚拟页面。这样可以显著提升性能:[Windows 系统编程][7] 报告指出,在相关的普通文件读取上运行时性能提升多达 30% ,在 [Unix 环境中的高级编程][8] 的报告中,文件映射在 Linux 和 Solaris 也有类似的效果。这取决于你的应用程序类型的不同,通过使用文件映射,可以节约大量的物理内存。 -对高性能的追求是永衡不变的目标,[测量是很重要的事情][9],内存映射应该是程序员始终要使用的工具。而 API 提供了非常好用的实现方式,它允许你通过内存中的字节去访问一个文件,而不需要为了这种好处而牺牲代码可读性。在一个类 Unix 的系统中,可以使用 [mmap][11] 查看你的 [地址空间][10],在 Windows 中,可以使用 [CreateFileMapping][12],或者在高级编程语言中还有更多的可用封装。当你映射一个文件内容时,它并不是一次性将全部内容都映射到内存中,而是通过 [页面故障][13] 来按需映射的。在 [获取][15] 需要的文件内容的页面帧后,页面故障句柄在页面缓存上 [映射你的虚拟页面][14] 。如果一开始文件内容没有缓存,这还将涉及到磁盘 I/O。 +对高性能的追求是永恒不变的目标,[测量是很重要的事情][9],内存映射应该是程序员始终要使用的工具。这个 API 提供了非常好用的实现方式,它允许你在内存中按字节去访问一个文件,而不需要为了这种好处而牺牲代码可读性。在一个类 Unix 的系统中,可以使用 [mmap][11] 查看你的 [地址空间][10],在 Windows 中,可以使用 [CreateFileMapping][12],或者在高级编程语言中还有更多的可用封装。当你映射一个文件内容时,它并不是一次性将全部内容都映射到内存中,而是通过 [页面故障][13] 来按需映射的。在 [获取][15] 需要的文件内容的页面帧后,页面故障句柄 [映射你的虚拟页面][14] 到页面缓存上。如果一开始文件内容没有缓存,这还将涉及到磁盘 I/O。 -假设我们的 Reader 程序是持续存在的实例,现在出现一个突发的状况。在页面缓存中保存着 scene.dat 内容的页面要立刻释放掉吗?这是一个人们经常要考虑的问题,但是,那样做并不是个好主意。你应该想到,我们经常在一个程序中创建一个文件,退出程序,然后,在第二个程序去使用这个文件。页面缓存正好可以处理这种情况。如果考虑更多的情况,内核为什么要清除页面缓存的内容?请记住,磁盘读取的速度要慢于内存 5 个数量级,因此,命中一个页面缓存是一件有非常大收益的事情。因此,只要有足够大的物理内存,缓存就应该始终完整保存。并且,这一原则适用于所有的进程。如果你现在运行 Render,一周后 scene.dat 的内容还在缓存中,那么应该恭喜你!这就是什么内核缓存越来越大,直至达到最大限制的原因。它并不是因为操作系统设计的太“垃圾”而浪费你的内存,其实这是一个非常好的行为,因为,释放物理内存才是一种“浪费”。(译者注:释放物理内存会导致页面缓存被清除,下次运行程序需要的相关数据,需要再次从磁盘上进行读取,会“浪费” CPU 和 I/O 资源)最好的做法是尽可能多的使用缓存。 +现在出现一个突发的状况,假设我们的 `render` 程序的最后一个实例退出了。在页面缓存中保存着 `scene.dat` 内容的页面要立刻释放掉吗?人们通常会如此考虑,但是,那样做并不是个好主意。你应该想到,我们经常在一个程序中创建一个文件,退出程序,然后,在第二个程序去使用这个文件。页面缓存正好可以处理这种情况。如果考虑更多的情况,内核为什么要清除页面缓存的内容?请记住,磁盘读取的速度要慢于内存 5 个数量级,因此,命中一个页面缓存是一件有非常大收益的事情。因此,只要有足够大的物理内存,缓存就应该保持全满。并且,这一原则适用于所有的进程。如果你现在运行 `render` 一周后, `scene.dat` 的内容还在缓存中,那么应该恭喜你!这就是什么内核缓存越来越大,直至达到最大限制的原因。它并不是因为操作系统设计的太“垃圾”而浪费你的内存,其实这是一个非常好的行为,因为,释放物理内存才是一种“浪费”。(LCTT 译注:释放物理内存会导致页面缓存被清除,下次运行程序需要的相关数据,需要再次从磁盘上进行读取,会“浪费” CPU 和 I/O 资源)最好的做法是尽可能多的使用缓存。 -由于页面缓存架构的原因,当程序调用 [write()][16] 时,字节只是被简单地拷贝到页面缓存中,并将这个页面标记为“赃”页面。磁盘 I/O 通常并不会立即发生,因此,你的程序并不会被阻塞在等待磁盘写入上。如果这时候发生了电脑死机,你的写入将不会被标记,因此,对于至关重要的文件,像数据库事务日志,必须要求 [fsync()][17]ed(仍然还需要去担心磁盘控制器的缓存失败问题),另一方面,读取将被你的程序阻塞,走到数据可用为止。内核采取预加载的方式来缓解这个矛盾,它一般提前预读取几个页面并将它加载到页面缓存中,以备你后来的读取。在你计划进行一个顺序或者随机读取时(请查看 [madvise()][18]、[readahead()][19]、[Windows cache hints][20] ),你可以通过提示(hint)帮助内核去调整这个预加载行为。Linux 会对内存映射的文件进行 [预读取][21],但是,在 Windows 上并不能确保被内存映射的文件也会预读。当然,在 Linux 中它可能会使用 [O_DIRECT][22] 跳过预读取,或者,在 Windows 中使用 [NO_BUFFERING][23] 去跳过预读,一些数据库软件就经常这么做。 +由于页面缓存架构的原因,当程序调用 [write()][16] 时,字节只是被简单地拷贝到页面缓存中,并将这个页面标记为“脏”页面。磁盘 I/O 通常并**不会**立即发生,因此,你的程序并不会被阻塞在等待磁盘写入上。副作用是,如果这时候发生了电脑死机,你的写入将不会完成,因此,对于至关重要的文件,像数据库事务日志,要求必须进行 [fsync()][17](仍然还需要去担心磁盘控制器的缓存失败问题),另一方面,读取将被你的程序阻塞,直到数据可用为止。内核采取预加载的方式来缓解这个矛盾,它一般提前预读取几个页面并将它加载到页面缓存中,以备你后来的读取。在你计划进行一个顺序或者随机读取时(请查看 [madvise()][18]、[readahead()][19]、[Windows 缓存提示][20] ),你可以通过提示hint帮助内核去调整这个预加载行为。Linux 会对内存映射的文件进行 [预读取][21],但是我不确定 Windows 的行为。当然,在 Linux 中它可能会使用 [O_DIRECT][22] 跳过预读取,或者,在 Windows 中使用 [NO_BUFFERING][23] 去跳过预读,一些数据库软件就经常这么做。 -一个内存映射的文件可以是私有的,也可以是共享的。当然,这只是针对内存中内容的更新而言:在一个私有的内存映射文件上,更新并不会提交到磁盘或者被其它进程可见,然而,共享的内存映射文件,则正好相反,它的任何更新都会提交到磁盘上,并且对其它的进程可见。内核在写机制上使用拷贝,这是通过页面表条目来实现这种私有的映射。在下面的例子中,Render 和另一个被称为 render3d 都私有映射到 scene.dat 上。然后 Render 去写入映射的文件的虚拟内存区域: +一个文件映射可以是私有的,也可以是共享的。当然,这只是针对内存中内容的**更新**而言:在一个私有的内存映射上,更新并不会提交到磁盘或者被其它进程可见,然而,共享的内存映射,则正好相反,它的任何更新都会提交到磁盘上,并且对其它的进程可见。内核使用写时复制copy on write(CoW)机制,这是通过页面表条目page table entry(PTE)来实现这种私有的映射。在下面的例子中,`render` 和另一个被称为 `render3d` 的程序都私有映射到 `scene.dat` 上。然后 `render` 去写入映射的文件的虚拟内存区域: ![The Copy-On-Write mechanism](http://static.duartes.org/img/blogPosts/copyOnWrite.png) -上面展示的只读页面表条目并不意味着映射是只读的,它只是内核的一个用于去共享物理内存的技巧,直到尽可能的最后一刻之前。你可以认为“私有”一词用的有点不太恰当,你只需要记住,这个“私有”仅用于更新的情况。这种设计的重要性在于,要想看到被映射的文件的变化,其它程序只能读取它的虚拟页面。一旦“写时复制”发生,从其它地方是看不到这种变化的。但是,内核并不能保证这种行为,因为它是在 x86 中实现的,从 API 的角度来看,这是有意义的。相比之下,一个共享的映射只是将它简单地映射到页面缓存上。更新会被所有的进程看到并被写入到磁盘上。最终,如果上面的映射是只读的,页面故障将触发一个内存段失败而不是写到一个副本。 +1. 两个程序私有地映射 `scene.dat`,内核误导它们并将它们映射到页面缓存,但是使该页面表条目只读。 +2. `render` 试图写入到映射 `scene.dat` 的虚拟页面,处理器发生页面故障。 +3. 内核分配页面帧,复制 `scene.dat` 的第二块内容到其中,并映射故障的页面到新的页面帧。 +4. 继续执行。程序就当做什么都没发生。 -动态加载库是通过文件映射融入到你的程序的地址空间中的。这没有什么可奇怪的,它通过普通的 APIs 为你提供与私有文件映射相同的效果。下面的示例展示了 Reader 程序映射的文件的两个实例运行的地址空间的一部分,以及物理内存,尝试将我们看到的许多概念综合到一起。 +上面展示的只读页面表条目并不意味着映射是只读的,它只是内核的一个用于共享物理内存的技巧,直到尽可能的最后一刻之前。你可以认为“私有”一词用的有点不太恰当,你只需要记住,这个“私有”仅用于更新的情况。这种设计的重要性在于,要想看到被映射的文件的变化,其它程序只能读取它的虚拟页面。一旦“写时复制”发生,从其它地方是看不到这种变化的。但是,内核并不能保证这种行为,因为它是在 x86 中实现的,从 API 的角度来看,这是有意义的。相比之下,一个共享的映射只是将它简单地映射到页面缓存上。更新会被所有的进程看到并被写入到磁盘上。最终,如果上面的映射是只读的,页面故障将触发一个内存段失败而不是写到一个副本。 + +动态加载库是通过文件映射融入到你的程序的地址空间中的。这没有什么可奇怪的,它通过普通的 API 为你提供与私有文件映射相同的效果。下面的示例展示了映射文件的 `render` 程序的两个实例运行的地址空间的一部分,以及物理内存,尝试将我们看到的许多概念综合到一起。 ![Mapping virtual memory to physical memory](http://static.duartes.org/img/blogPosts/virtualToPhysicalMapping.png) @@ -46,13 +56,13 @@ via:https://manybutfinite.com/post/page-cache-the-affair-between-memory-and-file 作者:[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/page-cache-the-affair-between-memory-and-files/ -[2]:https://manybutfinite.com/post/how-the-kernel-manages-your-memory +[2]:https://linux.cn/article-9393-1.html [3]:https://manybutfinite.com/post/what-your-computer-does-while-you-wait [4]:http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx [5]:http://ld.so From e7c4632d9c4815f48b6c9cc01019670ac8f22916 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Apr 2018 19:18:30 +0800 Subject: [PATCH 0363/1057] PUB:20090211 Page Cache the Affair Between Memory and Files.md @qhwdw https://linux.cn/article-9528-1.html --- .../20090211 Page Cache the Affair Between Memory and Files.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20090211 Page Cache the Affair Between Memory and Files.md (100%) diff --git a/translated/tech/20090211 Page Cache the Affair Between Memory and Files.md b/published/20090211 Page Cache the Affair Between Memory and Files.md similarity index 100% rename from translated/tech/20090211 Page Cache the Affair Between Memory and Files.md rename to published/20090211 Page Cache the Affair Between Memory and Files.md From 80febf168e0b1eec2b4a3c541d8452e97d1a90ae Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 9 Apr 2018 08:13:25 +0800 Subject: [PATCH 0364/1057] PRF:20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md @kimii --- ...GP - Part 2- Generating Your Master Key.md | 114 +++++++----------- 1 file changed, 44 insertions(+), 70 deletions(-) diff --git a/translated/tech/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md b/translated/tech/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md index e6e53b1f63..9eb5f84eca 100644 --- a/translated/tech/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md +++ b/translated/tech/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md @@ -1,4 +1,4 @@ -用 PGP 保护代码完整性 - 第二部分:生成你的主密钥 +用 PGP 保护代码完整性(二):生成你的主密钥 ====== ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/binary-1538717_1920.png?itok=kv_sxSnf) @@ -7,127 +7,101 @@ ### 清单 - 1. 生成一个 4096 位的 RSA 主密钥 (ESSENTIAL) - - 2. 使用 paperkey 备份你的 RSA 主密钥 (ESSENTIAL) - - 3. 添加所有相关的身份 (ESSENTIAL) - - - + 1. 生成一个 4096 位的 RSA 主密钥 (必要) + 2. 使用 paperkey 备份你的 RSA 主密钥 (必要) + 3. 添加所有相关的身份 (必要) ### 考虑事项 -#### 理解“主”(认证)密钥 +### 理解“主”(认证)密钥 在本节和下一节中,我们将讨论“主密钥”和“子密钥”。理解以下内容很重要: - 1. 在“主密钥”和“子密钥”之间没有技术上的区别。 - - 2. 在创建时,我们赋予每个密钥特定的能力来分配功能限制 - + 1. 在“主密钥”和“子密钥”之间没有技术上的区别。 + 2. 在创建时,我们赋予每个密钥特定的能力来分配功能限制。 3. 一个 PGP 密钥有四项能力 - * [S] 密钥可以用于签名 - * [E] 密钥可以用于加密 - - * [A] 密钥可以用于身份认证 - + * \[A] 密钥可以用于身份认证 * [C] 密钥可以用于认证其他密钥 - 4. 一个密钥可能有多种能力 - - - -带有[C] (认证)能力的密钥被认为是“主”密钥,因为它是唯一可以用来表明与其他密钥关系的密钥。只有[C]密钥可以被用于: +带有 [C] (认证)能力的密钥被认为是“主”密钥,因为它是唯一可以用来表明与其他密钥关系的密钥。只有 [C] 密钥可以被用于: * 添加或撤销其他密钥(子密钥)的 S/E/A 能力 - - * 添加,更改或撤销密钥关联的身份(uids) - + * 添加、更改或撤销密钥关联的身份(uid) * 添加或更改本身或其他子密钥的到期时间 - * 为了网络信任目的为其它密钥签名 +在自由软件的世界里,[C] 密钥就是你的数字身份。一旦你创建该密钥,你应该格外小心地保护它并且防止它落入坏人的手中。 - - -在自由软件的世界里,[C]密钥就是你的数字身份。一旦你创建该密钥,你应该格外小心地保护它并且防止它落入坏人的手中。 - -#### 在你创建主密钥前 +### 在你创建主密钥前 在你创建的你的主密钥前,你需要选择你的主要身份和主密码。 -##### 主要身份 +#### 主要身份 身份使用邮件中发件人一栏相同格式的字符串: + ``` Alice Engineer - ``` -你可以在任何时候创建新的身份,取消旧的,并且更改你的“主要”身份。由于主要身份在所有 GnuPG 操作中都展示,你应该选择正式的和最有可能用于 PGP 保护通信的名字和邮件地址,比如你的工作地址或者用于在项目提交(commit)时签名的地址。 +你可以在任何时候创建新的身份,取消旧的,并且更改你的“主要”身份。由于主要身份在所有 GnuPG 操作中都展示,你应该选择正式的和最有可能用于 PGP 保护通信的名字和邮件地址,比如你的工作地址或者用于在项目提交commit时签名的地址。 -##### 密码 +#### 密码 -密码(passphrase)专用于在存储在磁盘上时使用对称加密算法对私钥进行加密。如果你的 .gnupg 目录的内容被泄露,那么一个好的密码就是小偷能够在线模拟你的最后一道防线,这就是为什么设置一个好的密码很重要的原因。 +密码passphrase专用于私钥存储在磁盘上时使用对称加密算法对其进行加密。如果你的 `.gnupg` 目录的内容被泄露,那么一个好的密码就是小偷能够在线假冒你的最后一道防线,这就是为什么设置一个好的密码很重要的原因。 -一个强密码的好的指导是用丰富或混合的词典的 3-4 个词,而不引用自流行来源(歌曲,书籍,口号)。由于你将相当频繁地使用该密码,所以它应当易于 输入和记忆。 +一个强密码最好使用丰富或混合的词典的 3-4 个词,而不引用自流行来源(歌曲、书籍、口号)。由于你将相当频繁地使用该密码,所以它应当易于输入和记忆。 -##### 算法和密钥强度 +#### 算法和密钥强度 -尽管现在 GnuPG 已经支持椭圆曲线加密一段时间了,我们仍坚持使用 RSA 密钥,至少稍长一段时间。虽然现在就可以开始使用 ED25519 密钥,但你可能会碰到无法正确处理它们的工具和硬件设备。 +尽管现在 GnuPG 已经支持椭圆曲线加密一段时间了,但我们仍坚持使用 RSA 密钥,至少较长一段时间会这样。虽然现在就可以开始使用 ED25519 密钥,但你可能会碰到无法正确处理它们的工具和硬件设备。 -如果后续的指南中我们说 2048 位的密钥对 RSA 公钥加密的生命周期已经足够,你可能也会好奇主密钥为什么是 4096 位。 原因很大程度是由于社会因素而非技术上的:主密钥在密钥链上恰好是最明显的,同时如果你的主密钥位数比一些你交互的开发者的少,他们将不可避免地负面评价你。 +在后续的指南中我们说 2048 位的密钥对 RSA 公钥加密的生命周期已经足够,你可能也会好奇主密钥为什么是 4096 位。 原因很大程度是由于社会因素而非技术上的:主密钥在密钥链上是最显眼的,如果你的主密钥位数比一些和你交互的开发者的少,他们肯定会鄙视你。 #### 生成主密钥 -为了生成你的主密钥,请使用以下命令,并且将“Alice Engineer:”替换为正确值 +为了生成你的主密钥,请使用以下命令,并且将 “Alice Engineer” 替换为正确值。 + ``` $ gpg --quick-generate-key 'Alice Engineer ' rsa4096 cert - ``` -一个要求输入密码的对话框将弹出。然后,你可能需要移动鼠标或输入一些密钥才能生成足够的熵,直到命令完成。 +这将弹出一个要求输入密码的对话框。然后,你可能需要移动鼠标或随便按一些键才能生成足够的熵,直到该命令完成。 查看命令输出,它就像这样: + ``` pub rsa4096 2017-12-06 [C] [expires: 2019-12-06] 111122223333444455556666AAAABBBBCCCCDDDD uid Alice Engineer - ``` -注意第二行的长字符串 -- 它是你新生成的密钥的完整指纹。密钥 ID(key IDs)可以用以下三种不同形式表达: +注意第二行的长字符串 —— 它是你新生成的密钥的完整指纹。密钥 ID(Key ID)可以用以下三种不同形式表达: - * Fingerprint,一个完整的 40 个字符的密钥标识符 - - * Long,指纹的最后 16 个字符(AAAABBBBCCCCDDDD) - - * Short,指纹的最后 8 个字符(CCCCDDDD) + * 指纹Fingerprint,一个完整的 40 个字符的密钥标识符 + * 长密钥 IDLong,指纹的最后 16 个字符(AAAABBBBCCCCDDDD) + * 短密钥 IDShort,指纹的最后 8 个字符(CCCCDDDD) - - - -你应该避免使用 8 个字符的短密钥 ID(short key IDs),因为它们不足够唯一。 +你应该避免使用 8 个字符的短密钥 ID,因为它们不足够唯一。 这里,我建议你打开一个文本编辑器,复制你新密钥的指纹并粘贴。你需要在接下来几步中用到它,所以将它放在旁边会很方便。 #### 备份你的主密钥 -出于灾后恢复的目的 -- 同时特别的如果你试图使用 Web of Trust 并且收集来自其他项目开发者的密钥签名 -- 你应该创建你的私钥的 硬拷贝备份。万一所有其它的备份机制都失败了,这应当是最后的补救措施。 +出于灾后恢复的目的 —— 同时特别的如果你试图使用 Web of Trust 并且收集来自其他项目开发者的密钥签名 —— 你应该创建你的私钥的硬拷贝备份。万一所有其它的备份机制都失败了,这应当是最后的补救措施。 -创建一个你的私钥的可打印的硬拷贝的最好方法是使用为此而写的软件 paperkey。Paperkey 在所有 Linux 发行版上可用,在 Mac 上也可以通过 brew 安装 paperkey。 +创建一个你的私钥的可打印的硬拷贝的最好方法是使用为此而写的软件 `paperkey`。`paperkey` 在所有 Linux 发行版上可用,在 Mac 上也可以通过 brew 安装 `paperkey`。 + +运行以下命令,用你密钥的完整指纹替换 `[fpr]`: -运行以下命令,用你密钥的完整指纹替换[fpr]: ``` $ gpg --export-secret-key [fpr] | paperkey -o /tmp/key-backup.txt - ``` -输出将采用易于 OCR 或手动输入的格式,以防如果你需要恢复它的话。打印出该文件,然后拿支笔,并在纸的边缘写下密钥的密码。这是必要的一步,因为密钥输出仍然使用密码加密,并且如果你更改了密钥的密码,你不会记得第一次创建的密钥是什么 -- 我保证。 +输出将采用易于 OCR 或手动输入的格式,以防如果你需要恢复它的话。打印出该文件,然后拿支笔,并在纸的边缘写下密钥的密码。这是必要的一步,因为密钥输出仍然使用密码加密,并且如果你更改了密钥的密码,你不会记得第一次创建的密钥是什么 —— 我保证。 将打印结果和手写密码放入信封中,并存放在一个安全且保护好的地方,最好远离你家,例如银行保险库。 @@ -135,26 +109,26 @@ $ gpg --export-secret-key [fpr] | paperkey -o /tmp/key-backup.txt #### 添加相关身份 -如果你有多个相关的邮件地址(个人,工作,开源项目等),你应该将其添加到主密钥中。你不需要为任何你不希望用于 PGP 的地址(例如,可能不是你的校友地址)这样做。 +如果你有多个相关的邮件地址(个人、工作、开源项目等),你应该将其添加到主密钥中。你不需要为任何你不希望用于 PGP 的地址(例如,可能不是你的校友地址)这样做。 + +该命令是(用你完整的密钥指纹替换 `[fpr]`): -该命令是(用你完整的密钥指纹替换[fpr]): ``` $ gpg --quick-add-uid [fpr] 'Alice Engineer ' - ``` -你可以查看你已经使用的 UIDs: +你可以查看你已经使用的 UID: + ``` $ gpg --list-key [fpr] | grep ^uid - ``` -##### 选择主 UID +#### 选择主 UID GnuPG 将会把你最近添加的 UID 作为你的主 UID,如果这与你想的不同,你应该改回来: + ``` $ gpg --quick-set-primary-uid [fpr] 'Alice Engineer ' - ``` 下次,我们将介绍如何生成 PGP 子密钥,它是你实际用于日常工作的密钥。 @@ -167,10 +141,10 @@ via: https://www.linux.com/blog/learn/PGP/2018/2/protecting-code-integrity-pgp-p 作者:[KONSTANTIN RYABITSEV][a] 译者:[kimii](https://github.com/kimii) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://www.linux.com/users/mricon -[1]:https://www.linux.com/blog/learn/2018/2/protecting-code-integrity-pgp-part-1-basic-pgp-concepts-and-tools +[1]:https://linux.cn/article-9524-1.html [2]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 44272349985469b3aec0bafd00b84931feb09156 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 9 Apr 2018 08:13:53 +0800 Subject: [PATCH 0365/1057] PUB:20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md @kimii https://linux.cn/article-9529-1.html --- ...ode Integrity with PGP - Part 2- Generating Your Master Key.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md (100%) diff --git a/translated/tech/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md b/published/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md similarity index 100% rename from translated/tech/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md rename to published/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md From 0818ec549667b47d92c52383c8deceb098999426 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 9 Apr 2018 08:38:21 +0800 Subject: [PATCH 0366/1057] translated --- ...180328 How To Use Instagram In Terminal.md | 69 ------------------- ...180328 How To Use Instagram In Terminal.md | 66 ++++++++++++++++++ 2 files changed, 66 insertions(+), 69 deletions(-) delete mode 100644 sources/tech/20180328 How To Use Instagram In Terminal.md create mode 100644 translated/tech/20180328 How To Use Instagram In Terminal.md diff --git a/sources/tech/20180328 How To Use Instagram In Terminal.md b/sources/tech/20180328 How To Use Instagram In Terminal.md deleted file mode 100644 index a1dc7102c7..0000000000 --- a/sources/tech/20180328 How To Use Instagram In Terminal.md +++ /dev/null @@ -1,69 +0,0 @@ -translating---geekpi - -How To Use Instagram In Terminal -====== -![](https://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-720x340.png) -Instagram doesn’t need introduction. It is one of a popular social network platform, like Facebook and Twitter, to share photos and videos either publicly or privately to pre-approved followers. It was launched in 2010 by two entrepreneurs namely **Kevin Systrom** and **Mike Krieger**. In 2012, the social network giant Facebook has acquired Instagram. Instagram is available for free on Android and iOS devices. We can also use it in desktop systems via a web browser. And, the cool thing is now you can use Instagram in Terminal on any Unix-like operating systems. Are you excited? Well, read on to know how to view your Instagram feed on your Terminal. - -### Instagram In Terminal - -First, install **pip3** as described in the following link. - -Then, git clone the repository of “instagram-terminal-news-feed” script. -``` -$ git clone https://github.com/billcccheng/instagram-terminal-news-feed.git - -``` - -The above command will clone the contents of instagram script in a directory named “instagram-terminal-news-feed” in your current working directory. Cd to that directory: -``` -$ cd instagram-terminal-news-feed/ - -``` - -Then, run the following command to install instagram terminal feed: -``` -$ pip3 install -r requirements.txt - -``` - -Now, run the following command to launch instagram in terminal in your Linux box. -``` -$ python3 start.py - -``` - -Enter your Instagram username and password and browse your Instagram feed right from the Terminal. Your instragram username and password will only be stored locally in the file called **credential.json**. So, you don’t need to worry about it. You can also just don’t save your credentials which is the default option. - -Here is some screenshots of [**My Instagram page**][1]. - -![][3] - -![][4] - -![][5] - -Please note that you can only view your feed. You can’t follow anyone, like or comment posts. This is just a instagram feed reader. - -This project is freely available on GitHub, so you can view the source code, improve it, add more features, fix any bugs if there are any. - -Have fun! Cheers!! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-use-instagram-in-terminal/ - -作者:[SK][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://www.ostechnix.com/author/sk/ -[1]:https://www.instagram.com/ostechnix/ -[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-1.png -[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-2.png -[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-3-2.png diff --git a/translated/tech/20180328 How To Use Instagram In Terminal.md b/translated/tech/20180328 How To Use Instagram In Terminal.md new file mode 100644 index 0000000000..fba319c0a3 --- /dev/null +++ b/translated/tech/20180328 How To Use Instagram In Terminal.md @@ -0,0 +1,66 @@ +如何在终端中使用 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 + +首先,按照以下链接中的说明安装 **pip3**。 + +然后,git clone “instagram-terminal-news-feed” 脚本仓库。 +``` +$ git clone https://github.com/billcccheng/instagram-terminal-news-feed.git + +``` + +以上命令会将 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 页面**][1]的一些截图。 + +![][3] + +![][4] + +![][5] + +请注意,你只能查看你的 feed。你不能关注任何人,喜欢或评论帖子。这只是一个 instagram feed 阅读器。 + +该项目可在 GitHub 上免费获得,因此你可以查看源代码,改进它,添加更多功能,修复任何 bug。 + +玩得开心!干杯!! + + +-------------------------------------------------------------------------------- + +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) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.instagram.com/ostechnix/ +[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-1.png +[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-2.png +[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/instagram-in-terminal-3-2.png From 27d7f4cf87f45110dba603bdbaaf5eedd9525d6e Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 9 Apr 2018 08:43:06 +0800 Subject: [PATCH 0367/1057] translating --- ...iles From Computer To Mobile Devices By Scanning QR Codes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md b/sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md index 2e00904282..df6bd19146 100644 --- a/sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md +++ b/sources/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md @@ -1,3 +1,5 @@ +translating---geekpi + Transfer Files From Computer To Mobile Devices By Scanning QR Codes ====== From 9fec54bf66e44caaa47c33d82df4ee1cf4d43229 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 09:48:19 +0800 Subject: [PATCH 0368/1057] edition 1 --- ...3 How to tell when moving to blockchain is a bad idea.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename {sources => translated}/talk/20180323 How to tell when moving to blockchain is a bad idea.md (89%) diff --git a/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md similarity index 89% rename from sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md rename to translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md index 8e0fa91821..b288532a84 100644 --- a/sources/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -1,11 +1,11 @@ pinewall Translating -How to tell when moving to blockchain is a bad idea +区块链技术不适用的若干场景 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/blocks_building.png?itok=eMOT-ire) -So, there's this thing called "blockchain" that is quite popular… +不错,区块链的概念异常的火热。 -You know that already, of course. I keep wondering whether we've hit "peak hype" for blockchain and related technologies yet, but so far there's no sign of it. When I'm talking about blockchain here, I'm including distributed ledger technologies (DLTs), which are, by some tight definitions of the term, not really blockchains at all. I'm particularly interested, from a professional point of view, in permissioned blockchains. You can read more about how that's defined in my article [Is blockchain a security topic?][1] The key point here is that I'm interested in business applications of blockchain beyond cryptocurrency.1 +众所周知,我一直关注区块链及相关技术的成熟度发展情况,思考其是否达到过高期望的峰值(peak hype);但从目前的情况来看,还没有这个迹象。我在文中所说的区块链技术是广义上的,包含了狭义上不属于区块链的分布式账本技术(DLTs)。我对私有链更感兴趣,其中私有链的定义可以参考我的文章[区块链是安全性方面的话题吗?][1]简而言之,我对加密货币之外的区块链业务应用兴极大^{1}。 And, if the hype is to be believed—and some of it probably should be2—then there is an almost infinite set of applications for blockchain. That's probably correct, but it doesn't mean all of them are good applications for blockchain. Some, in fact, are likely to be very bad applications for blockchain. From c618c29f405a94f0dd05e4a7d637ae33928f740e Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 9 Apr 2018 09:48:43 +0800 Subject: [PATCH 0369/1057] Translating by qhwdw --- ...achine Learning to IoT using Android Things and TensorFlow.md | 1 + ... How to build a digital pinhole camera with a Raspberry Pi.md | 1 + .../tech/20180327 Reliable IoT event logging with syslog-ng.md | 1 + .../tech/20180328 Build a baby monitor with a Raspberry Pi.md | 1 + sources/tech/20180331 How to build a plotter with Arduino.md | 1 + 5 files changed, 5 insertions(+) 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 index 60119f96c6..68ed3bf05f 100644 --- 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 @@ -1,3 +1,4 @@ +Translating by qhwdw How to apply Machine Learning to IoT using Android Things and TensorFlow ============================================================  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 index 60a19fb581..21f64eb3f0 100644 --- 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 @@ -1,3 +1,4 @@ +Translating by qhwdw How to build a digital pinhole camera with a Raspberry Pi ====== diff --git a/sources/tech/20180327 Reliable IoT event logging with syslog-ng.md b/sources/tech/20180327 Reliable IoT event logging with syslog-ng.md index 89ffed382f..eb28c2ac1f 100644 --- a/sources/tech/20180327 Reliable IoT event logging with syslog-ng.md +++ b/sources/tech/20180327 Reliable IoT event logging with syslog-ng.md @@ -1,3 +1,4 @@ +Translating by qhwdw Reliable IoT event logging with syslog-ng ====== diff --git a/sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md b/sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md index 0e83af2d07..0cc6eda540 100644 --- a/sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md +++ b/sources/tech/20180328 Build a baby monitor with a Raspberry Pi.md @@ -1,3 +1,4 @@ +Translating by qhwdw Build a baby monitor with a Raspberry Pi ====== diff --git a/sources/tech/20180331 How to build a plotter with Arduino.md b/sources/tech/20180331 How to build a plotter with Arduino.md index bd7f95c160..daebb3ec54 100644 --- a/sources/tech/20180331 How to build a plotter with Arduino.md +++ b/sources/tech/20180331 How to build a plotter with Arduino.md @@ -1,3 +1,4 @@ +Translating by qhwdw How to build a plotter with Arduino ====== From a485189d88676e003c04248d90968c9a22f8b88a Mon Sep 17 00:00:00 2001 From: qhwdw Date: Mon, 9 Apr 2018 09:54:28 +0800 Subject: [PATCH 0370/1057] =?UTF-8?q?=E9=80=89=E9=A2=98=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Linux LAN Routing for Beginners- Part 1.md | 106 ------------------ 1 file changed, 106 deletions(-) delete mode 100644 sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md diff --git a/sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md b/sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md deleted file mode 100644 index 98bfab1445..0000000000 --- a/sources/tech/20180222 Linux LAN Routing for Beginners- Part 1.md +++ /dev/null @@ -1,106 +0,0 @@ -Linux LAN Routing for Beginners: Part 1 -============================================================ - - -![Linux routing](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/traffic_warder.jpeg?itok=hZxS_PB4 "Linux routing") -Carla Schroder offers an overview of hardware and operating systems, plus IPv4 addressing basics, in this tutorial.[Creative Commons Attribution][1][Wikimedia Commons: Public Domain][2] - -Once upon a time we learned about [IPv6 routing][4]. Now we're going to dig into the basics of IPv4 routing with Linux. We'll start with an overview of hardware and operating systems, and IPv4 addressing basics, and next week we'll setup and test routing. - -### LAN Router Hardware - -Linux is a real networking operating system, and always has been, with network functionality built-in from the beginning. Building a LAN router is simple compared to building a gateway router that connects your LAN to the Internet. You don't have to hassle with security or firewall rules, which are still complicated by having to deal with NAT, network address translation, an affliction of IPv4\. Why do we not drop IPv4 and migrate to IPv6? The life of the network administrator would be ever so much simpler. - -But I digress. Ideally, your Linux router is a small machine with at least two network interfaces. Linux Gizmos has a great roundup of single-board computers here: [Catalog of 98 open-spec, hacker friendly SBCs][5]. You could use an old laptop or desktop PC. You could use a compact computer, like the ZaReason Zini or the System76 Meerkat, though these are a little pricey at nearly $600\. But they are stout and reliable, and you're not wasting money on a Windows license. - -The Raspberry Pi 3 Model B is great for lower-demand routing. It has a single 10/100 Ethernet port, onboard 2.4GHz 802.11n wireless, and four USB ports, so you can plug in more USB network interfaces. USB 2.0 and the slower onboard network interfaces make the Pi a bit of a network bottleneck, but you can't beat the price ($35 without storage or power supply). It supports a couple dozen Linux flavors, so chances are you can have your favorite. The Debian-based Raspbian is my personal favorite. - -### Operating System - -You might as well stuff the smallest version of your favorite Linux on your chosen hardware thingy, because the specialized router operating systems such as OpenWRT, Tomato, DD-WRT, Smoothwall, Pfsense, and so on all have their own non-standard interfaces. In my admirable opinion this is an unnecessary complication that gets in the way rather than helping. Use the standard Linux tools and learn them once. - -The Debian net install image is about 300MB and supports multiple architectures, including ARM, i386, amd64, and armhf. Ubuntu's server net installation image is under 50MB, giving you even more control over what packages you install. Fedora, Mageia, and openSUSE all offer compact net install images. If you need inspiration browse [Distrowatch][6]. - -### What Routers Do - -Why do we even need network routers? A router connects different networks. Without routing every network space is isolated, all sad and alone with no one to talk to but the same boring old nodes. Suppose you have a 192.168.1.0/24 and a 192.168.2.0/24 network. Your two networks cannot talk to each other without a router connecting them. These are Class C private networks with 254 usable addresses each. Use ipcalc to get nice visual information about them: - -``` -$ ipcalc 192.168.1.0/24 -Address: 192.168.1.0 11000000.10101000.00000001\. 00000000 -Netmask: 255.255.255.0 = 24 11111111.11111111.11111111\. 00000000 -Wildcard: 0.0.0.255 00000000.00000000.00000000\. 11111111 -=> -Network: 192.168.1.0/24 11000000.10101000.00000001\. 00000000 -HostMin: 192.168.1.1 11000000.10101000.00000001\. 00000001 -HostMax: 192.168.1.254 11000000.10101000.00000001\. 11111110 -Broadcast: 192.168.1.255 11000000.10101000.00000001\. 11111111 -Hosts/Net: 254 Class C, Private Internet -``` - -I like that ipcalc's binary output makes a visual representation of how the netmask works. The first three octets are the network address, and the fourth octet is the host address, so when you are assigning host addresses you "mask" out the network portion and use the leftover. Your two networks have different network addresses, and that is why they cannot communicate without a router in between them. - -Each octet is 256 bytes, but that does not give you 256 host addresses because the first and last values, 0 and 255, are reserved. 0 is the network identifier, and 255 is the broadcast address, so that leaves 254 host addresses. ipcalc helpfully spells all of this out. - -This does not mean that you never have a host address that ends in 0 or 255\. Suppose you have a 16-bit prefix: - -``` -$ ipcalc 192.168.0.0/16 -Address: 192.168.0.0 11000000.10101000\. 00000000.00000000 -Netmask: 255.255.0.0 = 16 11111111.11111111\. 00000000.00000000 -Wildcard: 0.0.255.255 00000000.00000000\. 11111111.11111111 -=> -Network: 192.168.0.0/16 11000000.10101000\. 00000000.00000000 -HostMin: 192.168.0.1 11000000.10101000\. 00000000.00000001 -HostMax: 192.168.255.254 11000000.10101000\. 11111111.11111110 -Broadcast: 192.168.255.255 11000000.10101000\. 11111111.11111111 -Hosts/Net: 65534 Class C, Private Internet -``` - -ipcalc lists your first and last host addresses, 192.168.0.1 and 192.168.255.254\. You may have host addresses that end in 0 and 255, for example 192.168.1.0 and 192.168.0.255, because those fall in between the HostMin and HostMax. - -The same principles apply regardless of your address blocks, whether they are private or public, and don't be shy about using ipcalc to help you understand. - -### CIDR - -CIDR (Classless Inter-Domain Routing) was created to extend IPv4 by providing variable-length subnet masking. CIDR allows finer slicing-and-dicing of your network space. Let ipcalc demonstrate: - -``` -$ ipcalc 192.168.1.0/22 -Address: 192.168.1.0 11000000.10101000.000000 01.00000000 -Netmask: 255.255.252.0 = 22 11111111.11111111.111111 00.00000000 -Wildcard: 0.0.3.255 00000000.00000000.000000 11.11111111 -=> -Network: 192.168.0.0/22 11000000.10101000.000000 00.00000000 -HostMin: 192.168.0.1 11000000.10101000.000000 00.00000001 -HostMax: 192.168.3.254 11000000.10101000.000000 11.11111110 -Broadcast: 192.168.3.255 11000000.10101000.000000 11.11111111 -Hosts/Net: 1022 Class C, Private Internet -``` - -The netmask is not limited to whole octets, but rather crosses the boundary between the third and fourth octets, and the subnet portion ranges from 0 to 3, and not from 0 to 255\. The number of available hosts is not a multiple of 8 as it is when the netmask is defined by whole octets. - -Your homework is to review CIDR and how the IPv4 address space is allocated between public, private, and reserved blocks, as this is essential to understanding routing. Setting up routes is not complicated as long as you have a good knowledge of addressing. - -Start with [Understanding IP Addressing and CIDR Charts][7], [IPv4 Private Address Space and Filtering][8], and [IANA IPv4 Address Space Registry][9]. Then come back next week to learn how to create and manage routes. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginners-part-1 - -作者:[CARLA SCHRODER ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/licenses/category/creative-commons-attribution -[2]:https://commons.wikimedia.org/wiki/File:Traffic_warder.jpeg -[3]:https://www.linux.com/files/images/trafficwarderjpeg -[4]:https://www.linux.com/learn/intro-to-linux/2017/7/practical-networking-linux-admins-ipv6-routing -[5]:http://linuxgizmos.com/catalog-of-98-open-spec-hacker-friendly-sbcs/#catalog -[6]:http://distrowatch.org/ -[7]:https://www.ripe.net/about-us/press-centre/understanding-ip-addressing -[8]:https://www.arin.net/knowledge/address_filters.html -[9]:https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml From a31da24f3a2dbf78e9604a752e85a4c40e9375d8 Mon Sep 17 00:00:00 2001 From: jessie-pang <35220454+jessie-pang@users.noreply.github.com> Date: Mon, 9 Apr 2018 09:59:11 +0800 Subject: [PATCH 0371/1057] Update 20180317 How To Edit Multiple Files Using Vim Editor.md Update 20180317 How To Edit Multiple Files Using Vim Editor.md --- .../20180317 How To Edit Multiple Files Using Vim Editor.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md b/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md index 8e78bb8477..6cebe726d1 100644 --- a/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md +++ b/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md @@ -1,3 +1,5 @@ +Translating by jessie-pang + How To Edit Multiple Files Using Vim Editor ====== From a6f63acd940d47eda0561d64b133aada9b05506a Mon Sep 17 00:00:00 2001 From: jessie-pang <35220454+jessie-pang@users.noreply.github.com> Date: Mon, 9 Apr 2018 10:34:37 +0800 Subject: [PATCH 0372/1057] Update 20180402 Understanding Linux filesystems- ext4 and beyond.md Update 20180402 Understanding Linux filesystems- ext4 and beyond.md --- ...20180402 Understanding Linux filesystems- ext4 and beyond.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md index 9e1b37b043..2166be74bd 100644 --- a/sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/sources/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -1,3 +1,5 @@ +Translating by jessie-pang + Understanding Linux filesystems: ext4 and beyond ====== From b9938a6daf9a92dd6081a4673bf8f48b6b529528 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 11:48:48 +0800 Subject: [PATCH 0373/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Why=20I=20love?= =?UTF-8?q?=20ARM=20and=20PowerPC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180403 Why I love ARM and PowerPC.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 sources/tech/20180403 Why I love ARM and PowerPC.md diff --git a/sources/tech/20180403 Why I love ARM and PowerPC.md b/sources/tech/20180403 Why I love ARM and PowerPC.md new file mode 100644 index 0000000000..16dcd2e76c --- /dev/null +++ b/sources/tech/20180403 Why I love ARM and PowerPC.md @@ -0,0 +1,77 @@ +Why I love ARM and PowerPC +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) +Recently I've been asked why I mention [ARM][1] and [PowerPC][2] so often on my blogs and in my tweets. I have two answers: one is personal, the other technical. + +### The personal + +Once upon a time, I studied environmental protection. While working on my PhD, I was looking for a new computer. As an environmentally aware person, I wanted a high-performing computer that was also efficient. That is how I first became interested in the PowerPC and discovered [Pegasos][3], a PowerPC workstation created by [Genesi][4]. + +I had already used [RS/6000][5] (PowerPC), [SGI][6] (MIPS), [HP-UX][7] (PA-RISC), and [VMS][8] (Alpha) both as a server and a workstation, and on my PC I used Linux, not Windows, so using a different CPU architecture was not a barrier. [Pegasos][9], which was small and efficient enough for home use, was my first workstation. + +Soon I was working for Genesi, enabling [openSUSE][10], Ubuntu, and various other Linux distributions on Pegasos and providing quality assurance and community support. Pegasos was followed by [EFIKA][11], another PowerPC board. It felt strange at first to use an embedded system after using workstations. But as one of the first affordable developer boards, it was the start of a revolution. + +I was working on some large-scale server projects when I received another interesting piece of hardware from Genesi: a [Smarttop][12] and a [Smartbook][13] based on ARM. My then-favorite Linux distribution, openSUSE, also received a dozen of these machines. This gave a big boost to ARM-related openSUSE developments at a time when very few ARM machines were available. + +Although I have less time available these days, I try to stay up-to-date on ARM and PowerPC news. This helps me support syslog-ng users on non-x86 platforms. And when I have half an hour free, I hack one of my ARM machines. I did some benchmarks on the [Raspberry Pi 2][14] with [syslog-ng][15], and the [results were quite surprising][16]. Recently, I built a music player using a Raspberry Pi, a USB sound card, and the [Music Player Daemon][17], and I use it regularly. + +### The technical + +Diversity is good: It creates competition, and competition creates better products. While x86 is a solid generic workhorse, chips like ARM and PowerPC (and many others) are better suited in various situations. + +If you have an [Android][18] mobile device or an [Apple][19] iPhone or iPad, there's a good chance it is running on an ARM SoC (system on chip). Same with a network-attached storage server. The reason is quite simple: power efficiency. You don't want to constantly recharge batteries or pay more for electricity than you did for your router. + +ARM is also conquering the enterprise server world with its 64-bit ARMv8 chips. Many tasks require minimal computing capacity; on the other hand, power efficiency and fast I/O are key— think storage, static web content, email, and other storage- and network-intensive functions. A prime example is [Ceph][20], a distributed object storage and file system. [SoftIron][21], which uses CentOS as reference software on its ARMv8 developer hardware, is working on Ceph-based turnkey storage appliances. + +Most people know PowerPC as the former CPU of [Apple Mac][22] machines. While it is no longer used as a generic desktop CPU, it still functions in routers, telecommunications equipment. And [IBM][23] continued to produce chips for high-performance servers. A few years ago, with the introduction of POWER8, IBM opened up the architecture under the aegis of the [OpenPOWER Foundation][24]. POWER8 is an ideal platform for HPC, big data, and analytics, where memory bandwidth is key. POWER9 is right around the corner. + +These are all server applications, but there are plans for end-user devices. Raptor Engineering is working on a [POWER9 workstation][25], and there is also an initiative to [create a notebook][26] based on a Freescale/NXP QorIQ e6500 chip. Of course, these machines are not for everybody—you can't install your favorite Windows game or commercial application on them. But they are great for PowerPC developers and enthusiasts, or anyone wanting a fully open system, from hardware to firmware to applications. + +### The dream + +My dream is a completely x86-free environment—not because I don't like x86, but because I like diversity and always use the most suitable tool for the job. If you look at the [graph][27] on Raptor Engineering's page, you will see that, depending on your use case, ARM and POWER can replace most of x86. Right now I compile, package, and test syslog-ng in x86 virtual machines running on my laptop. Using a strong enough ARMv8 or PowerPC machine, either as a workstation or a server, I could avoid x86 for this kind of tasks. + +Right now I am waiting for the next generation of [Pinebook][28] to arrive, as I was told at [FOSDEM][29] in February that the next version is expected to offer much higher performance. Unlike Chromebooks, this ARM-powered laptop runs Linux by design, not as a hack. For a desktop, I am looking for ARMv8 workstation-class hardware. Some are already available—like the [ThunderX Desktop][30] from Avantek—but they do not yet feature the latest, fastest, and more importantly, most energy-efficient ARMv8 CPU generations. Until these arrive, I'll use my Pixel C laptop running Android. It's not as easy and flexible as Linux, but it has a powerful ARM SoC and a Linux kernel at its heart. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/why-i-love-arm-and-powerpc + +作者:[Peter Czanik][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/czanik +[1]:https://en.wikipedia.org/wiki/ARM_architecture +[2]:https://en.wikipedia.org/wiki/PowerPC +[3]:https://genesi.company/products/opendesktop +[4]:https://genesi.company/ +[5]:https://en.wikipedia.org/wiki/RS/6000 +[6]:https://en.wikipedia.org/wiki/Silicon_Graphics#Workstations +[7]:https://en.wikipedia.org/wiki/HP-UX +[8]:https://en.wikipedia.org/wiki/OpenVMS#Port_to_DEC_Alpha +[9]:https://en.wikipedia.org/wiki/Pegasos +[10]:https://www.opensuse.org/ +[11]:https://genesi.company/products/efika/5200b +[12]:https://genesi.company/products/efika +[13]:https://genesi.company/products/smartbook +[14]:https://www.raspberrypi.org/products/raspberry-pi-2-model-b/ +[15]:https://syslog-ng.com/open-source-log-management +[16]:https://syslog-ng.com/blog/syslog-ng-raspberry-pi-2/ +[17]:https://www.musicpd.org/ +[18]:https://www.android.com/ +[19]:http://www.apple.com/ +[20]:http://ceph.com/ +[21]:http://softiron.co.uk/ +[22]:https://en.wikipedia.org/wiki/Power_Macintosh +[23]:https://www.ibm.com/us-en/ +[24]:http://openpowerfoundation.org/ +[25]:https://www.raptorcs.com/TALOSII/ +[26]:http://www.powerpc-notebook.org/en/ +[27]:https://secure.raptorengineering.com/TALOS/power_advantages.php +[28]:https://www.pine64.org/?page_id=3707 +[29]:https://fosdem.org/2018/ +[30]:https://www.avantek.co.uk/store/avantek-32-core-cavium-thunderx-arm-desktop.html From 3ce03a598eabd4eaada690dc76c43d303f7e1ba0 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 11:51:33 +0800 Subject: [PATCH 0374/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=2012=20Git=20tips?= =?UTF-8?q?=20for=20Git's=2012th=20birthday?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...407 12 Git tips for Git-s 12th birthday.md | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 sources/tech/20180407 12 Git tips for Git-s 12th birthday.md diff --git a/sources/tech/20180407 12 Git tips for Git-s 12th birthday.md b/sources/tech/20180407 12 Git tips for Git-s 12th birthday.md new file mode 100644 index 0000000000..f0214a6b99 --- /dev/null +++ b/sources/tech/20180407 12 Git tips for Git-s 12th birthday.md @@ -0,0 +1,150 @@ +12 Git tips for Git's 12th birthday +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/party_anniversary_flag_birthday_celebrate.jpg?itok=KqfMENa7) +[Git][1], the distributed revision-control system that's become the default tool for source code control in the open source world, turns 12 on April 7. One of the more frustrating things about using Git is how much you need to know to use it effectively. This can also be one of the more awesome things about using Git, because there's nothing quite like discovering a new tip or trick that can streamline or improve your workflow. + +In honor of Git's 12th birthday, here are 12 tips and tricks to make your Git experience more useful and powerful, starting with some basics you might have overlooked and scaling up to some real power-user tricks! + +### 1\. Your ~/.gitconfig file + +The first time you tried to use the `git` command to commit a change to a repository, you might have been greeted with something like this: +``` +*** Please tell me who you are. + +Run + +  git config --global user.email "you@example.com" + +  git config --global user.name "Your Name" + +to set your account's default identity. + +``` + +What you might not have realized is that those commands are modifying the contents of `~/.gitconfig`, which is where Git stores global configuration options. There are a vast array of things you can do via your `~/.gitconfig` file, including defining aliases, turning particular command options on (or off!) on a permanent basis, and modifying aspects of how Git works (e.g., which diff algorithm `git diff` uses or what type of merge strategy is used by default). You can even conditionally include other config files based on the path to a repository! See `man git-config` for all the details. + +### 2\. Your repo's .gitconfig file + +In the previous tip, you may have wondered what that `--global` flag on the `git config` command was doing. It tells Git to update the "global" configuration, the one found in `~/.gitconfig`. Of course, having a global config also implies a local configuration, and sure enough, if you omit the `--global` flag, `git config` will instead update the repository-specific configuration, which is stored in `.git/config`. + +Options that are set in the `.git/config` file will override any setting in the `~/.gitconfig` file. So, for example, if you need to use a different email address for a particular repository, you can run `git config user.email "also_you@example.com"`. Then, any commits in that repository will use your other email address. This can be super useful if you work on open source projects from a work laptop and want them to show up with a personal email address while still using your work email for your main Git configuration. + +Pretty much anything you can set in `~/.gitconfig`, you can also set in `.git/config` to make it specific to the given repository. In any of the following tips, when I mention adding something to your `~/.gitconfig`, just remember you could also set that option for just one repository by adding it to `.git/config` instead. + +### 3\. Aliases + +Aliases are another thing you can put in your `~/.gitconfig`. These work just like aliases in the command shell—they set up a new command name that can invoke one or more other commands, often with a particular set of options or flags. They're super useful for longer, more complicated commands you use frequently. + +You can define aliases using the `git config` command—for example, running `git config --global --add alias.st status` will make running `git st` do the same thing as running `git status`—but I find when defining aliases, it's frequently easier to just edit the `~/.gitconfig` file directly. + +If you choose to go this route, you'll find that the `~/.gitconfig` file is an [INI file][2]. INI is basically a key-value file format with particular sections. When adding an alias, you'll be changing the `[alias]` section. For example, to define the same `git st` alias as above, add this to the file: +``` +[alias] + +st = status + +``` + +(If there's already an `[alias]` section, just add the second line to that existing section.) + +### 4\. Aliases to shell commands + +Aliases aren't limited to just running other Git subcommands—you can also define aliases that run other shell commands. This is a fantastic way to deal with a recurring, infrequent, and complicated task: Once you've figured out how to do it once, preserve the command under an alias. For example, I have a few repositories where I've forked an open source project and made some local modifications that don't need to be contributed back to the project. I want to keep up-to-date with ongoing development work in the project but also maintain my local changes. To accomplish this, I need to periodically merge the changes from the upstream repo into my fork—which I do by using an alias I call `upstream-merge`. It's defined like this: +``` +upstream-merge = !"git fetch origin -v && git fetch upstream -v && git merge upstream/master && git push" + +``` + +The `!` at the beginning of the alias definition tells Git to run the command via the shell. This example involves running a number of `git` commands, but aliases defined in this way can run any shell command. + +(Note that if you want to copy my `upstream-merge` alias, you'll need to make sure you have a Git remote named `upstream` pointed at the upstream repository you've forked from. You can add this by running `git remote add upstream `.) + +### 5\. Visualizing the commit graph + +If you work on a project with a lot of branching activity, sometimes it can be difficult to get a handle on all the work that's happening and how it's all related. Various GUI tools allow you to get a picture of different branches and commits in what's called the "commit graph." For example, here's a section of one of my repositories visualized with the [GitLab][3] commit graph viewer: + + +![GitLab commit graph viewer][5] + +John Anderson, CC BY + +If you're a dedicated command-line user or somebody who finds switching tools to be distracting, it's nice to get a similar view of the commit graph from the command line. That's where the `--graph` argument to the `git log` command comes in: + +![Repository visualized with --graph command][7] + +John Anderson, CC BY + +This is the same section of the same repo visualized with the following command: +``` +git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative + +``` + +The `--graph` option adds the graph to the left side of the log, `--abbrev-commit` shortens the commit [SHAs][8], `--date=relative` expresses the dates in relative terms, and the `--pretty` bit handles all the other custom formatting. I have this aliased to `git lg`, and it is one of my top 10 most frequently run commands. + +### 6\. A nicer force-push + +Sometimes, as hard as you try to avoid it, you'll find that you need to run `git push --force` to overwrite the history on a remote copy of your repository. You may have gotten some feedback that caused you to do an interactive rebase, or you may simply have messed up and want to hide the evidence. + +One of the hazards with force pushes happens when somebody else has made changes on top of the same branch in the remote copy of the repository. When you force-push your rewritten history, those commits will be lost. This is where `git push --force-with-lease` comes in—it will not allow you to force-push if the remote branch has been updated, which will ensure you don't throw away someone else's work. + +### 7\. git add -N + +Have you ever used `git commit -a` to stage and commit all your outstanding changes in a single move, only to discover after you've pushed your commit that `git commit -a` ignores newly added files? You can work around this by using the `git add -N` (think "notify") to tell Git about newly added files you'd like to be included in commits before you actually commit them for the first time. + +### 8\. git add -p + +A best practice when using Git is to make sure each commit consists of only a single logical change—whether that's a fix for a bug or a new feature. Sometimes when you're working, however, you'll end up with more than one commit's worth of change in your repository. How can you manage to divide things up so that each commit contains only the appropriate changes? `git add --patch` to the rescue! + +This flag will cause the `git add` command to look at all the changes in your working copy and, for each one, ask if you'd like to stage it to be committed, skip over it, or defer the decision (as well as a few other more powerful options you can see by selecting `?` after running the command). `git add -p` is a fantastic tool for producing well-structured commits. + +### 9\. git checkout -p + +Similar to `git add -p`, the `git checkout` command will take a `--patch` or `-p` option, which will cause it to present each "hunk" of change in your local working copy and allow you to discard it—basically reverting your local working copy to what was there before your change. + +This is fantastic when, for example, you've introduced a bunch of debug logging statements while chasing down a bug. After the bug is fixed, you can first use `git checkout -p` to remove all the new debug logging, then you `git add -p` to add the bug fix. Nothing is more satisfying than putting together a beautiful, well-structured commit! + +### 10\. Rebase with command execution + +Some projects have a rule that each commit in the repository must be in a working state—that is, at each commit, it should be possible to compile the code or the test suite should run without failure. This is not too difficult when you're working on a branch over time, but if you end up needing to rebase for whatever reason, it can be a little tedious to step through each rebased commit to make sure you haven't accidentally introduced a break. + +Fortunately, `git rebase` has you covered with the `-x` or `--exec` option. `git rebase -x ` will run that command after each commit is applied in the rebase. So, for example, if you have a project where `npm run tests` runs your test suite, `git rebase -x npm run tests` would run the test suite after each commit was applied during the rebase. This allows you to see if the test suite fails at any of the rebased commits so you can confirm that the test suite is still passing at each commit. + +### 11\. Time-based revision references + +Many Git subcommands take a revision argument to specify what part of the repository to work on. This can be the SHA1 of a particular commit, a branch name, or even a symbolic name like `HEAD` (which refers to the most recent commit on the currently checked out branch). In addition to these simple forms, you can also append a specific date or time to mean "this reference, at this time." + +This becomes very useful when you're dealing with a newly introduced bug and find yourself saying, "I know this worked yesterday! What changed?" Instead of staring at the output of `git log` trying to figure out what commit was changed when, you can simply run `git diff HEAD@{yesterday}`, and see all the changes that have happened since then. This also works with longer time periods (e.g., `git diff HEAD@{'2 months ago'}`) as well as exact dates (e.g., `git diff HEAD@{'2010-01-01 12:00:00'}`). + +You can also use these date-based revision arguments with any Git subcommand that takes a revision argument. Find full details about which format to use in the man page for `gitrevisions`. + +### 12\. The all-seeing reflog + +Have you ever rebased away a commit, then discovered there was something in that commit you wanted to keep? You may have thought that information was lost forever and would need to be recreated. But if you committed it in your local working copy, it was added to the reference log (reflog), and you should still be able to access it. + +Running `git reflog` will show you a list of all the activity for the current branch in your local working copy and also give you the SHA1 of each commit. Once you've found the commit you rebased away, you can run `git checkout ` to check out that commit, copy any information you need, and run `git checkout HEAD` to return to the most recent commit in the branch. + +### That's all folks! + +Hopefully at least one of these tips has taught you something new about Git, a 12-year-old project that's continuing to innovate and add new features. What's your favorite Git trick? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/12-git-tips-gits-12th-birthday + +作者:[John SJ Anderson][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/genehack +[1]:https://git-scm.com/ +[2]:https://en.wikipedia.org/wiki/INI_file +[3]:https://gitlab.com/ +[4]:/file/392941 +[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gui_graph.png?itok=3GovYfG1 (GitLab commit graph viewer) +[6]:/file/392936 +[7]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/console_graph.png?itok=XogY1P8M (Repository visualized with --graph command) +[8]:https://en.wikipedia.org/wiki/Secure_Hash_Algorithms From bfa0126267963d4956658d81823d3a65a4c23ecc Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 11:58:47 +0800 Subject: [PATCH 0375/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20The=20fc=20Comm?= =?UTF-8?q?and=20Tutorial=20With=20Examples=20For=20Beginners?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nd Tutorial With Examples For Beginners.md | 310 ++++++++++++++++++ 1 file changed, 310 insertions(+) create mode 100644 sources/tech/20180405 The fc Command Tutorial With Examples For Beginners.md diff --git a/sources/tech/20180405 The fc Command Tutorial With Examples For Beginners.md b/sources/tech/20180405 The fc Command Tutorial With Examples For Beginners.md new file mode 100644 index 0000000000..010178b2ec --- /dev/null +++ b/sources/tech/20180405 The fc Command Tutorial With Examples For Beginners.md @@ -0,0 +1,310 @@ +The fc Command Tutorial With Examples For Beginners +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/04/fc-command-720x340.png) +The **fc** command, short for **f** ix **c** ommands, is a shell built-in command used to list, edit and re-execute the most recently entered commands in to an interactive shell. You can edit the recently entered commands in your favorite editor and run them without having to retype the entire commands. This command can be helpful to correct the spelling mistakes in the previously entered commands and avoids the repetition of long and complicated commands. Since it is shell-builtin, it is available in most shells, including Bash, Zsh, Ksh etc. In this brief tutorial, we are going to learn to use fc command in Linux. + +### The fc Command Tutorial With Examples + +**List the recently executed commands** + +If you run “fc -l” command with no arguments, it will display the last **16** commands. +``` +$ fc -l +507 fish +508 fc -l +509 sudo netctl restart wlp9s0sktab +510 ls -l +511 pwd +512 uname -r +513 uname -a +514 touch ostechnix.txt +515 vi ostechnix.txt +516 echo "Welcome to OSTechNix" +517 sudo apcman -Syu +518 sudo pacman -Syu +519 more ostechnix.txt +520 wc -l ostechnix.txt +521 cat ostechnix.txt +522 clear + +``` + +To reverse the order of the commands, use **-r** flag. +``` +$ fc -l + +``` + +You can suppress the line numbers using “-n” parameter. +``` +$ fc -ln + nano ~/.profile + source ~/.profile + source ~/.profile + fc -ln + fc -l + sudo netctl restart wlp9s0sktab + ls -l + pwd + uname -r + uname -a + echo "Welcome to OSTechNix" + sudo apcman -Syu + cat ostechnix.txt + wc -l ostechnix.txt + more ostechnix.txt + clear + +``` + +Now you won’t see the line numbers. + +To list the result staring from a specific command, simply use the line number along with **-l** option. For instance, to display the commands starting from line number 520 up to the present, we do: +``` +$ fc -l 520 +520 ls -l +521 pwd +522 uname -r +523 uname -a +524 echo "Welcome to OSTechNix" +525 sudo apcman -Syu +526 cat ostechnix.txt +527 wc -l ostechnix.txt +528 more ostechnix.txt +529 clear +530 fc -ln +531 fc -l + +``` + +To list a commands within a specific range, for example 520 to 525, do: +``` +$ fc -l 520 525 +520 ls -l +521 pwd +522 uname -r +523 uname -a +524 echo "Welcome to OSTechNix" +525 sudo apcman -Syu + +``` + +Instead of using the line numbers, we can also use strings. For example, list the commands starting from “pwd” command up to the resent, just use the staring letter of that command (i.e **p** ) like below. +``` +$ fc -l p +521 pwd +522 uname -r +523 uname -a +524 echo "Welcome to OSTechNix" +525 sudo apcman -Syu +526 cat ostechnix.txt +527 wc -l ostechnix.txt +528 more ostechnix.txt +529 clear +530 fc -ln +531 fc -l +532 fc -l 520 +533 fc -l 520 525 +534 fc -l 520 +535 fc -l 522 +536 fc -l l + +``` + +To see everything between “pwd” to “more” command, you could use either: +``` +$ fc -l p m + +``` + +Or, use combination of first letter of the starting command command and line number of the ending command: +``` +$ fc -l p 528 + +``` + +Or, just line numbers of starting and ending commands: +``` +$ fc -l 521 528 + +``` + +All of these three commands will display the same result. + +**Edit and re-run the last command automatically** + +At times, you might misspelled a previous command. In such situations, you can easily edit the spelling mistakes of the command using your default editor and execute it without having to retype again. + +To edit the last command and re-run it again, do: +``` +$ fc + +``` + +This will open your last command in the default editor. + +![][2] + +As you see in the above screenshot, my last command was “fc -l”. You can make any changes in the command and re-run it automatically again once you save and quit the editor. This can be useful when you use long and complicated commands or arguments. Please be mindful that this also can be a **destructive**. For example, if the previous command was a deadly command like “rm -fr ”, it will automatically execute and you may lost your important data. So, be very careful before using command. + +**Change the default editor to edit commands** + +Another notable option of fc is **“e”** to choose a different editor to edit the commands. For example, we can use “nano” editor to edit the last command like below. +``` +$ fc -e nano + +``` + +This command will open the nano editor(instead of the default editor) to edit last command. + +![][3] + +You may find it time consuming to use **-e** option for each command. To make the new editor as your default, just set the environment variable **FCEDIT** to the name of the editor you want **fc** to use. + +For example, to set “nano” as the new default editor, edit your **~/.profile** or environment file: +``` +$ vi ~/.profile + +``` + +Add the following line: +``` +FCEDIT=nano + +``` + +You can also use the full path of the editor like below. +``` +FCEDIT=/usr/local/bin/emacs + +``` + +Type **:wq** to save and close the file. To update the changes, run: +``` +$ source ~/.profile + +``` + +Now, you can just type to “fc” to edit the last command using “nano” editor. + +**Re-run the last command without editing it** + +We already knew if we run “fc” without any arguments, it loads the editor with the most recent command. At times, you may not want to edit, but simply execute the last command. To do so, use hyphen (-) symbol at the end as shown below. +``` +$ echo "Welcome to OSTechNix" +Welcome to OSTechNix + +$ fc -e - +echo "Welcome to OSTechNix" +Welcome to OSTechNix + +``` + +As you see, fc didn’t edit the last command (i.e echo “Welcome to OSTechNix”) even if I used **-e** option. + +Please note that some of the options are shell-specific. They may not work in other shells. For example the following options can be used in **zsh** shell. It won’t work in Bash or Ksh shells. + +**Display when the commands were executed** + +To view when the commands were run, use **-d** like below. +``` +fc -ld +1 18:41 exit +2 18:41 clear +3 18:42 fc -l +4 18:42 sudo netctl restart wlp9s0sktab +5 18:42 ls -l +6 18:42 pwd +7 18:42 uname -r +8 18:43 uname -a +9 18:43 cat ostechnix.txt +10 18:43 echo "Welcome to OSTechNix" +11 18:43 more ostechnix.txt +12 18:43 wc -l ostechnix.txt +13 18:43 cat ostechnix.txt +14 18:43 clear +15 18:43 fc -l + +``` + +Now you see the execution time of most recently executed commands. + +We can also display the full timestamp of each command using **-f** option. +``` + fc -lf + 1 4/5/2018 18:41 exit + 2 4/5/2018 18:41 clear + 3 4/5/2018 18:42 fc -l + 4 4/5/2018 18:42 sudo netctl restart wlp9s0sktab + 5 4/5/2018 18:42 ls -l + 6 4/5/2018 18:42 pwd + 7 4/5/2018 18:42 uname -r + 8 4/5/2018 18:43 uname -a + 9 4/5/2018 18:43 cat ostechnix.txt + 10 4/5/2018 18:43 echo "Welcome to OSTechNix" + 11 4/5/2018 18:43 more ostechnix.txt + 12 4/5/2018 18:43 wc -l ostechnix.txt + 13 4/5/2018 18:43 cat ostechnix.txt + 14 4/5/2018 18:43 clear + 15 4/5/2018 18:43 fc -l + 16 4/5/2018 18:43 fc -ld + +``` + +Of course, the European folks can use european date format using **-E** option. +``` + fc -lE + 2 5.4.2018 18:41 clear + 3 5.4.2018 18:42 fc -l + 4 5.4.2018 18:42 sudo netctl restart wlp9s0sktab + 5 5.4.2018 18:42 ls -l + 6 5.4.2018 18:42 pwd + 7 5.4.2018 18:42 uname -r + 8 5.4.2018 18:43 uname -a + 9 5.4.2018 18:43 cat ostechnix.txt + 10 5.4.2018 18:43 echo "Welcome to OSTechNix" + 11 5.4.2018 18:43 more ostechnix.txt + 12 5.4.2018 18:43 wc -l ostechnix.txt + 13 5.4.2018 18:43 cat ostechnix.txt + 14 5.4.2018 18:43 clear + 15 5.4.2018 18:43 fc -l + 16 5.4.2018 18:43 fc -ld + 17 5.4.2018 18:49 fc -lf + +``` + +### TL;DR + + * When running without any arguments, fc will load the most recent command in the default text editor. + * When running with a numeric argument, fc loads the editor with the command with that specified number. + * When running with a string argument, fc loads the most recent command starting with that specified string. + * When running with two arguments to fc , the arguments specify the beginning and end of a range of commands. + + + +For more details, refer man pages. +``` +$ man fc + +``` + +And, that’s all for today. Hope you find this article useful. More good stuffs to come. Stay tuned! + +Cheers! + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/the-fc-command-tutorial-with-examples-for-beginners/ + +作者:[SK][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://www.ostechnix.com/author/sk/ +[2]:http://www.ostechnix.com/wp-content/uploads/2018/04/fc-command-1.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/04/fc-command-2.png From c74678e62b7dfc71c04d92c24b341549888a420c Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 12:01:04 +0800 Subject: [PATCH 0376/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20MX=20Linux:=20A?= =?UTF-8?q?=20Mid-Weight=20Distro=20Focused=20on=20Simplicity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Mid-Weight Distro Focused on Simplicity.md | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 sources/tech/20180406 MX Linux- A Mid-Weight Distro Focused on Simplicity.md diff --git a/sources/tech/20180406 MX Linux- A Mid-Weight Distro Focused on Simplicity.md b/sources/tech/20180406 MX Linux- A Mid-Weight Distro Focused on Simplicity.md new file mode 100644 index 0000000000..8cf35ea8bf --- /dev/null +++ b/sources/tech/20180406 MX Linux- A Mid-Weight Distro Focused on Simplicity.md @@ -0,0 +1,147 @@ +MX Linux: A Mid-Weight Distro Focused on Simplicity +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/mxlinux.png?itok=OLjmCxT9) +There are so many distributions of Linux. Some of those distributions go a very long way to differentiate themselves. In other cases, the differences are so minimal, you wonder why anyone would have bothered reinventing that particular wheel. It’s that latter concern that had me wondering why [antiX][1] and [MEPIS][2] communities would come together to create yet another distribution—especially given that the results would be an Xfce edition of antiX, built by the MEPIS community. + +Does building antiX with an Xfce desktop warrant its own distribution? After all, antiX claims to be a “fast, lightweight and easy to install systemd-free linux live CD distribution based on Debian Stable.” The antiX desktop of choice is [LXDE][3], which does certainly fit the bill for a lightweight desktop. So why retool antiX into another lightweight distribution, only this time with Xfce? Well, as anyone within the Linux community knows, variance adds flavor and a good lightweight distribution is a worthwhile endeavor (especially in preventing old hardware from making its way to the landfill). Of course, LXDE and Xfce aren’t quite in the same category. LXDE should be considered a true lightweight desktop, whereas Xfce should be considered more a mid-weight desktop. And that, my friends, is key to why MX Linux is an important iteration of antiX. A mid-weight distribution, built on Debian, that includes all the tools you need to get your work done. + +But there’s something really keen within MX Linux—something directly borrowed from antiX—and that is the installation tool. When I first set up a VirtualBox VM to install MX Linux, I assumed the installation would be the typical, incredibly easy Linux installation I’d grown accustomed to. Much to my surprise, that antiX installer MX Linux uses could be a real game changer, especially for those on the fence about giving Linux a try. + +So even before I began kicking the tires of MX Linux, I was impressed. Let’s take a look at what makes the installation of this distribution so special, and then finally have a go with the desktop. + +You can download MX Linux 17.1 from [here][4]. The minimum system requirements are: + + * A CD/DVD drive (and BIOS capable of booting from that drive), or a live USB (and BIOS capable of booting from USB) + + * A modern i486 Intel or AMD processor + + * 512 MB of RAM memory + + * 5 GB free hard drive space + + * A SoundBlaster, AC97 or HDA-compatible sound card + + * For use as a LiveUSB, 4 GB free + + + + +### Installation + +Out of the gate, the MX Linux installer makes installing Linux a breeze. Although it may not be the most modern-looking installation tool, there’s little to second-guess. The heart of the installation begins with choosing the disks and selecting the installation type (Figure 1). + + +![install][6] + +Figure 1: One of the first installer screens for MX Linux. + +[Used with permission][7] + +The next important screen (Figure 2) requires you to set a computer name, domain, and (if necessary) a workgroup for MS Networking. + +That ability to configure a workgroup is the first bit to really stand out. This is the first distribution I can remember that offers this option during installation. It also should clue you in that MX Linux offers the ability to share directories out of the box. It does, and it does so with aplomb. It’s not perfect, but it works without having to install any extra package (more on this in a bit). + +The last important installation screen (that requires user-interaction) is the creation of the user account and root password (Figure 3). + + +![user][9] + +Figure 3: Setting up your user account details and the root user password. + +[Used with permission][7] + +Once you’ve taken care of this final screen, the installation will complete and ask you to reboot. Upon rebooting, you’ll be greeted with the login screen. Login and enjoy the MX Linux experience. + +### Usage + +The Xfce desktop is quite an easy interface to get up to speed with. The default places the panel on the left edge of the screen (Figure 4). + + +![desktop ][11] + +Figure 4: The default MX Linux desktop. + +[Used with permission][7] + +If you want to move the panel to a more traditional location, right click a blank spot on the panel and click Panel > Panel Preferences. In the resulting window (Figure 5), click the Mode drop-down to select from between Deskbar, Vertical, or Horizontal. + + +![panel][13] + +Figure 5: Configuring the MX Linux Panel. + +[Used with permission][7] + +The difference between the Deskbar and Vertical options is that, in the Deskbar mode, the panel is aligned vertically, just like in the vertical mode, but the plugins are laid out horizontally. This means you can create much wider panels (for widescreen layouts). If you opt for a horizontal layout, it will default to the top—you will have to then uncheck the Lock panel check box, click Close, and then (using the drag handle on the left edge of the panel) drag it to the bottom. You can then go back into the Panel Settings window and re-lock the panel. + +Beyond that, using the Xfce desktop should be a no-brainer for nearly any experience level … it’s that easy. You’ll find software to cover productivity (LibreOffice, Orage Calendar, PDF-Shuffler), graphics (GIMP), communication (Firefox, Thunderbird, HexChat), multimedia (Clementine, guvcview, SMTube, VLC media player), and a number of tools specific to MX Linux (called MX Tools, that range from a live-USB drive creator, a network assistant, package installer, repo manager, live ISO snapshot creator, and more). + +![sharing][15] + +Figure 6: Sharing out a directory to your network. + +[Used with permission][7] + +### Samba + +Let’s talk about sharing folders to your network. As I mentioned, you won’t have to install any extra packages to get this to function. You simply open up the file manager, right-click anywhere, and select Share a folder on your network. You will be prompted for the administrative password (set during installation). Upon successful authentication, the Samba Server Configuration Tool will open (Figure 6). + +![sharing][17] + +Figure 7: Configuring the share on MX Linux. + +[Used with permission][7] + +Click the + button and configure your share. You will be asked to locate the directory, give the share a name/description, and then decide if the share is writeable and visible (Figure 7). + +When you click the Access tab, you have the choice between giving everyone access to the share or just specific users. Here’s where the problem arises. At this point, no users will be available for sharing. Why? They haven’t been added. In order to add them, there are two possibilities: From the command line or using the tool we already have open. Let’s take the obvious route. From the main window of the Samba Server Configuration Tool, click Preferences > Samba Users. In the resulting window, click Add user. + +A new window will appear (Figure 8), where you need to select the user from the drop-down, enter a Windows username, and type/retype a password for the user. + +![Samba][19] + +Figure 8: Adding a user to Samba. + +[Used with permission][7] + +Once you’ve clicked OK, the user will be added and the share will be accessible, to that user, across your network. Creating Samba shares really can be that easy. + +### The conclusion + +MX Linux makes transitioning from just about any desktop operating system simple. Although some might find the desktop interface to be a bit less-than-modern, the distribution’s primary focus isn’t on beauty, but simplicity. To that end, MX Linux succeeds in stellar fashion. This flavor of Linux can make anyone feel right at home on Linux. Spin up this mid-weight distribution and see if it can’t serve as your daily driver. + +Learn more about Linux through the free ["Introduction to Linux" ][20]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/4/mx-linux-mid-weight-distro-focused-simplicity + +作者:[JACK WALLEN][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://www.linux.com/users/jlwallen +[1]:https://antixlinux.com/ +[2]:https://en.wikipedia.org/wiki/MEPIS +[3]:https://lxde.org/ +[4]:https://mxlinux.org/download-links +[5]:/files/images/mxlinux1jpg +[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/mxlinux_1.jpg?itok=i9bNScjH (install) +[7]:/licenses/category/used-permission +[8]:/files/images/mxlinux3jpg +[9]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/mxlinux_3.jpg?itok=ppf2l_bm (user) +[10]:/files/images/mxlinux4jpg +[11]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/mxlinux_4.jpg?itok=mS1eBy9m (desktop) +[12]:/files/images/mxlinux5jpg +[13]:https://www.linux.com/sites/lcom/files/styles/floated_images/public/mxlinux_5.jpg?itok=wsN1hviN (panel) +[14]:/files/images/mxlinux6jpg +[15]:https://www.linux.com/sites/lcom/files/styles/floated_images/public/mxlinux_6.jpg?itok=vw8mIp9T (sharing) +[16]:/files/images/mxlinux7jpg +[17]:https://www.linux.com/sites/lcom/files/styles/floated_images/public/mxlinux_7.jpg?itok=tRIWdcEk (sharing) +[18]:/files/images/mxlinux8jpg +[19]:https://www.linux.com/sites/lcom/files/styles/floated_images/public/mxlinux_8.jpg?itok=ZS6lhZN2 (Samba) +[20]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 8ac2785cf6491250c86e9e7bfdb16440028aa596 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 12:02:35 +0800 Subject: [PATCH 0377/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Regi?= =?UTF-8?q?ster=20The=20Oracle=20Linux=20System=20With=20The=20Unbreakable?= =?UTF-8?q?=20Linux=20Network=20(ULN)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ith The Unbreakable Linux Network (ULN).md | 302 ++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 sources/tech/20180406 How To Register The Oracle Linux System With The Unbreakable Linux Network (ULN).md 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 new file mode 100644 index 0000000000..a6cb4b4154 --- /dev/null +++ b/sources/tech/20180406 How To Register The Oracle Linux System With The Unbreakable Linux Network (ULN).md @@ -0,0 +1,302 @@ +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. + +Even i don’t know the information about this and i recently came to know about this and wants to share this with others so, i’m going to write a article which will guide you to register the Oracle Linux system with the Unbreakable Linux Network (ULN). + +This allows the register systems to get software update and other patches ASAP. + +### What Is Unbreakable Linux Network + +ULN stands for Unbreakable Linux Network which is owned by Oracle. If you have a active subscription to Oracle OS Support, you can register your system with Unbreakable Linux Network (ULN). + +ULN offers software patches, updates, and fixes for Oracle Linux and Oracle VM, as well as information on yum, Ksplice, and support policies. You can also download useful packages that are not included in the original distribution. + +The ULN Alert Notification Tool periodically checks with ULN and alerts you when updates are available. + +If you want to use ULN repository with yum to manage your systems, make sure your system should registered with ULN and subscribe each system to one or more ULN channels. When you register a system with ULN, automatically it will choose latest version of channel based on the system architecture and OS. + +### How To Register As A ULN User + +To register as a ULN user, make sure you have a valid customer support identifier (CSI) for Oracle Linux support or Oracle VM support. + +Follow the below steps to register as a ULN user. + +Visit @ [linux.oracle.com][1] +![][3] + +If you already have an SSO account, click Sign On. +![][4] + +If you don’t have a account, click Create New Single Signon Account and follow the onscreen instructions to create one. +![][5] + +Verify your email address to complete your account setup. + +Log in using your SSO user name and password. On the Create New ULN User page, enter your CSI and click Create New User. +![][6] + +**Note :** + + * If no administrator is currently assigned to manage the CSI, you are prompted to click Confirm to become the CSI administrator. + * If your user name already exists on the system, you are prompted to proceed to ULN by clicking the link Unbreakable Linux Network. + + + +### How To Register The Oracle Linux 6/7 System With ULN + +Just run the below command and follow the instruction to register the system. +``` +# uln_register + +``` + +Make sure your system is having active internet connection. Also keep ready your Oracle Single Sign-On Login & password (SSO) details then hit `Next`. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + +ââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠Setting up software updates âââââââââââââââââââââââââââââââââââââââââââââââââââââ +â This assistant will guide you through connecting your system to Unbreakable Linux Network (ULN) to receive software updates, â +â including security updates, to keep your system supported and compliant. You will need the following at this time: â +â â +â * A network connection â +â * Your Oracle Single Sign-On Login & password â +â â +â â +â â +â â +â â +â â +â â +â â +â ââââââââââââââââââââââââââââââââââââ ââââââââ ââââââââââ â +â â Why Should I Connect to ULN? ... â â Next â â Cancel â â +â ââââââââââââââââââââââââââââââââââââ ââââââââ ââââââââââ â +â â +ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +Input your login information for Unbreakable Linux Network, then hit `Next`. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + +ââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠Setting up software updates âââââââââââââââââââââââââââââââââââââââââââââââââââââ +â â +â Please enter your login information for Unbreakable Linux Network (http://linux.oracle.com/): â +â â +â â +â Oracle Single Sign-On Login: [email protected] â +â Password: **********__________ â +â CSI: 12345678____________ â +â Tip: Forgot your login or password? Visit: http://www.oracle.com/corporate/contact/getaccthelp.html â +â â +â ââââââââ ââââââââ ââââââââââ â +â â Next â â Back â â Cancel â â +â ââââââââ ââââââââ ââââââââââ â +â â +â â +ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +Register a System Profile – Hardware information, then hit `Next`. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + +âââââââââââââââââââââââââââââââââââââââââââââ⤠Register a System Profile - Hardware ââââââââââââââââââââââââââââââââââââââââââââââ +â â +â A Profile Name is a descriptive name that you choose to identify this â +â System Profile on the Unbreakable Linux Network web pages. Optionally, â +â include a computer serial or identification number. â +â Profile name: 2g-oracle-sys___________________________ â +â â +â [*] Include the following information about hardware and network: â +â Press to deselect the option. â +â â +â Version: 6 CPU model: Intel(R) Xeon(R) CPU E5-5650 0 @ 2.00GHz â +â Hostname: 2g-oracle-sys â +â CPU speed: 1199 MHz IP Address: 192.168.1.101 Memory: â +â â +â Additional hardware information including PCI devices, disk sizes and mount points will be included in the profile. â +â â +â ââââââââ ââââââââ ââââââââââ â +â â Next â â Back â â Cancel â â +â ââââââââ ââââââââ ââââââââââ â +â â +â â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +Register a System Profile – Packages configuration, then hit `Next`. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + +âââââââââââââââââââââââââââââââââââââââââââââ⤠Register a System Profile - Packages âââââââââââââââââââââââââââââââââââââââââââââââ +â â +â RPM information is important to determine what updated software packages are relevant to this system. â +â â +â [*] Include RPM packages installed on this system in my System Profile â +â â +â You may deselect individual packages by unchecking them below. â +â [*] ConsoleKit-0.4.1-6.el6 â â +â [*] ConsoleKit-libs-0.4.1-6.el6 â â +â [*] ConsoleKit-x11-0.4.1-6.el6 â â +â [*] DeviceKit-power-014-3.el6 â â +â [*] GConf2-2.28.0-7.el6 â â +â [*] GConf2-2.28.0-7.el6 â â +â [*] GConf2-devel-2.28.0-7.el6 â â +â [*] GConf2-gtk-2.28.0-7.el6 â â +â [*] MAKEDEV-3.24-6.el6 â â +â [*] MySQL-python-1.2.3-0.3.c1.1.el6 â â +â [*] NessusAgent-7.0.3-es6 â â +â [*] ORBit2-2.14.17-6.el6_8 â â +â [*] ORBit2-2.14.17-6.el6_8 â â +â [*] ORBit2-devel-2.14.17-6.el6_8 â â +â [*] PackageKit-0.5.8-26.0.1.el6 â â +â [*] PackageKit-device-rebind-0.5.8-26.0.1.el6 â â +â [*] PackageKit-glib-0.5.8-26.0.1.el6 â â +â â +â ââââââââ ââââââââ ââââââââââ â +â â Next â â Back â â Cancel â â +â ââââââââ ââââââââ ââââââââââ â +â â +â â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +Press “Next” to send this System Profile to Unbreakable Linux Network. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + +âââââââââââââââââââââââââââââââââââ⤠Send Profile Information to Unbreakable Linux Network âââââââââââââââââââââââââââââââââââââ +â â +â We are finished collecting information for the System Profile. â +â â +â Press "Next" to send this System Profile to Unbreakable Linux Network. Click "Cancel" and no information will be sent. You â +â can run the registration program later by typing `uln_register` at the command line. â +â â +â ââââââââ ââââââââ ââââââââââ â +â â Next â â Back â â Cancel â â +â ââââââââ ââââââââ ââââââââââ â +â â +â â +ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +Sending Profile to Unbreakable Linux Network is under processing. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + + + +â⤠Sending Profile to Unbreakable Linux Network â +â â +â 75% â +â â +ââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +ULN registration has been done and review system subscription details. If everything is fine, then hit `ok`. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + +ââââââââââââââââââââââââââââââââââââââââââââââââââ⤠Review system subscription details ââââââââââââââââââââââââââââââââââââââââââââââââââ +â â +â â +â Note: yum-rhn-plugin has been enabled. â +â â +â Please review the subscription details below: â +â â +â Software channel subscriptions: â +â This system will receive updates from the following Unbreakable Linux Network software channels: â +â Oracle Linux 6 Latest (x86_64) â +â Unbreakable Enterprise Kernel Release 4 for Oracle Linux 6 (x86_64) â +â â +â Warning: If an installed product on this system is not listed above, you will not receive updates or support for that product. If â +â you would like to receive updates for that product, please visit http://linux.oracle.com/ and subscribe this system to the â +â appropriate software channels to get updates for that product. â +â â +â â +â â +â â +â â +â â +â â +â ââââââ â +â â OK â â +â ââââââ â +â â +â â +ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +Finally hit `Finish` to complete the registration. +``` +Copyright © 2006--2010 Red Hat, Inc. All rights reserved. + + +ââââââââââââââââââââââââââââââââââââââââââââââ⤠Finish setting up software updates âââââââââââââââââââââââââââââââââââââââââââââââ +â â +â You may now run 'yum update' from this system's command line to get the latest software updates from Unbreakable Linux Network. â +â You will need to run this periodically to get the latest updates. â +â â +â ââââââââââ â +â â Finish â â +â ââââââââââ â +â â +â â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +``` + +ULN registration has been done successfully, in order to get repository from ULN run the following command. +``` +# yum repolist +Loaded plugins: aliases, changelog, presto, refresh-packagekit, rhnplugin, security, tmprepo, ulninfo, verify, versionlock +This system is receiving updates from ULN. +ol6_x86_64_UEKR3_latest | 1.2 kB 00:00 +ol6_x86_64_UEKR3_latest/primary | 35 MB 00:14 +ol6_x86_64_UEKR3_latest 874/874 +repo id repo name status +ol6_x86_64_UEKR3_latest Unbreakable Enterprise Kernel Release 3 for Oracle Linux 6 (x86_64) - Latest 874 +ol6_x86_64_latest Oracle Linux 6 Latest (x86_64) 40,092 +repolist: 40,966 + +``` + +Also, you can check the same in ULN website. Go to the `System` tab to view the list of registered systems. +![][7] + +To view list of the enabled repositories. Go to the `System` tab then hit the corresponding system. Also, you can able to see the available updates for the system for errata. +![][8] + +To manage subscription channel. Go to the `System` tab, then hit appropriate `system name` and finally hit `Manage Subscriptions`. +![][9] + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-register-the-oracle-linux-system-with-the-unbreakable-linux-network-uln/ + +作者:[Vinoth Kumar][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://www.2daygeek.com/author/vinoth/ +[1]:https://linux.oracle.com/register +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:https://www.2daygeek.com/wp-content/uploads/2018/04/How-To-Register-The-Oracle-Linux-System-With-The-Unbreakable-Linux-Network-ULN-1.png +[4]:https://www.2daygeek.com/wp-content/uploads/2018/04/How-To-Register-The-Oracle-Linux-System-With-The-Unbreakable-Linux-Network-ULN-3.png +[5]:https://www.2daygeek.com/wp-content/uploads/2018/04/How-To-Register-The-Oracle-Linux-System-With-The-Unbreakable-Linux-Network-ULN-2.png +[6]:https://www.2daygeek.com/wp-content/uploads/2018/04/How-To-Register-The-Oracle-Linux-System-With-The-Unbreakable-Linux-Network-ULN-4.png +[7]:https://www.2daygeek.com/wp-content/uploads/2018/04/How-To-Register-The-Oracle-Linux-System-With-The-Unbreakable-Linux-Network-ULN-5a.png +[8]:https://www.2daygeek.com/wp-content/uploads/2018/04/How-To-Register-The-Oracle-Linux-System-With-The-Unbreakable-Linux-Network-ULN-6a.png +[9]:https://www.2daygeek.com/wp-content/uploads/2018/04/How-To-Register-The-Oracle-Linux-System-With-The-Unbreakable-Linux-Network-ULN-7a.png From 2fc5bde7cf9226a9c7faaaf793d9772a45ce368d Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 12:23:50 +0800 Subject: [PATCH 0378/1057] edition 2 --- ...when moving to blockchain is a bad idea.md | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md index b288532a84..0e87f33272 100644 --- a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -5,74 +5,72 @@ pinewall Translating ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/blocks_building.png?itok=eMOT-ire) 不错,区块链的概念异常的火热。 -众所周知,我一直关注区块链及相关技术的成熟度发展情况,思考其是否达到过高期望的峰值(peak hype);但从目前的情况来看,还没有这个迹象。我在文中所说的区块链技术是广义上的,包含了狭义上不属于区块链的分布式账本技术(DLTs)。我对私有链更感兴趣,其中私有链的定义可以参考我的文章[区块链是安全性方面的话题吗?][1]简而言之,我对加密货币之外的区块链业务应用兴极大^{1}。 +众所周知,我一直关注区块链及相关技术的成熟度发展情况,思考其是否达到过高期望的峰值(peak hype);但从目前的情况来看,还没有这个迹象。我在文中所说的区块链技术是广义上的,包含了狭义上不属于区块链的分布式账本技术(DLTs)。我对私有链更感兴趣,其中私有链的定义可以参考我的文章[区块链是安全性方面的话题吗?][1]简而言之,我对加密货币之外的区块链业务应用特别感兴趣[#1]。 -And, if the hype is to be believed—and some of it probably should be2—then there is an almost infinite set of applications for blockchain. That's probably correct, but it doesn't mean all of them are good applications for blockchain. Some, in fact, are likely to be very bad applications for blockchain. +我们对区块链的技术成熟度的判断应该有一部分可以得到证实[#2]。如果我们判断正确,未来将会出现海量的区块链应用。这很可能会变成现实,但并不是所有的应用都是优秀的区块链应用,其中一部分很可能是非常糟糕的。 -The hype associated with blockchain, however, means that businesses are rushing to embrace this new technology3 without really understanding what they're doing. The drivers towards this are arguably three-fold: +但区块链所处的技术成熟度意味着,大量业务将快速拥抱新技术[#3],但对于可能的前景却一知半解。促成这种情况的原因可以大致分为三种: - 1. You can, if you try, make almost any application with multiple users that stores data into a blockchain-enabled application. - 2. There are lots of conferences and "gurus" telling people that if they don't embrace blockchain now, they'll go out of business within six months4. - 3. It's not easy technology to understand fully, and lots of its proponents "on-the-ground" in organisations are techies. + 1. 对于涉及多用户数据存储的业务应用,在投入精力的情况下,几乎都可以改造为基于区块链的版本; + 2. 很多区块链相关的会议和“专家”呼吁尽快拥抱区块链,否则可能会在半年内被淘汰[#4]; + 3. 完全理解区块链技术是很难的,支持其在企业中落地的往往是工程师。 +对于最后一条,我必须补充几句,不然很容易被引起众怒[#5]。作为一名工程师,我显然无意贬低工程师.工程师的天性使然,我们对见到的新鲜事物(亮点)热情澎湃,但由于对业务本身神交[#6]不足,对于新技术给业务带来的影响理解可能并不深刻。在业务领导者看来,这些影响不一定是有利的。 +上面提到的三种促因可能导致一种风险,即在没有充分评估利弊的情况下,将业务改造为区块链应用。在另一文([区块链:每个人都应该参与进来吗?][2])中提到几个场景,用于判断一个业务什么情况下适合采用区块链技术。这些场景是有益的,但更进一步,我坚人们更加需要的是,给出业务完全不适用区块链的几种简单的场景判定。我总结了三种场景判定,如果对于其中任何一个问题你给出了肯定的回答,那么很大概率上你并不需要区块链。 -I want to unpack that last statement before I get a hail of trolls flaming me.5 I have nothing against techies—I'm one myself—but one of our characteristics tends to be enormous enthusiasm about new things ("shinies") that we understand, but whose impact on the business we don't always fully grok.6 That's not always a positive for business leaders. +### 场景判定1:业务是否需要集中式的管控或授权? -The danger, then, is that the confluence of those three drivers may lead to businesses moving to blockchain applications without fully understanding whether it's a good idea. I wrote in another post ([Blockchain: should we all play?][2]) about some tests to decide when a process is a good fit for blockchain and when it's not. They were useful, but the more I think about it, the more I'm convinced that we need some simple tests to tell us when we should definitely not move a process or an application to a blockchain. I present my three tests. If your answer to any of these questions is "yes," then you almost certainly don't need a blockchain. +如果你给出了肯定的回答,那么你并不需要区块链。 -### Test 1: Does it have a centralised controller or authority? +例如,假设你是一个蒲团销售商,具有唯一的订单系统,那么对于何时发货你有唯一的授权,显然你基本不需要使用区块链。假设你是一个内容提供商,所有提供的内容都会经过唯一的编辑和发布过程,显然你基本不需要使用区块链。 -If the answer is "yes," then you don't need a blockchain. +经验总结:只有当任务对应的执行流程及相应的认证流程是分布于众多主体时,区块链是有价值的。 -If, for instance, you're selling, I don't know, futons, and you have a single ordering system, then you have a single authority for deciding when to send out a futon. You almost certainly don't need to make this a blockchain. If you are a purveyor of content that has to pass through a single editorial and publishing process, you almost certainly don't need to make this a blockchain. +### 场景判定2:业务使用经典数据库是否工作良好? -The lesson is: Blockchains really don't make sense unless the tasks required in the process execution—and the trust associated with those tasks—is distributed among multiple entities. +如果你给出了肯定的回答,那么你并不需要区块链。 -### Test 2: Could it work fine with a standard database? +该场景似乎与上一个场景是强相关的,但并不总是如此。在一些应用中,处理流程是分布的,但信息存储是中心化的;在另外一些应用中,处理流程需要中心化的授权,但信息存储是分布的,即总有一个并不是分布式的。但如果业务使用经典数据库可以工作量良好的话,使用经典数据库是一个好主意。 -If the answer to this question is "yes," then you don't need a blockchain. +经典数控不仅性能良好,在设计与运营成本方面低比区块链或分布式账本,而且我们在这方面技术积累丰厚。区块链让所有人[#8]可以查看和持有数据,但间接成本和潜在成本都比较高昂。 -This and the previous question are somewhat intertwined but don't need to be. There are applications where you have distributed processes but need to store information centrally, or you have centralised authorities but distributed data, where one answer may be "yes" and the other is "no." But if your answer to this question is "yes," use a standard database. +### 场景判定3:业务采用新技术是否成本高昂或对合作伙伴有负面效果? -Databases are good at what they do, they are cheaper in terms of design and operations than running a blockchain or distributed ledger, and we know how to make them work. Blockchains are about letting everybody8 see and hold data, but the overheads can be high and the implications costly. +如果你给出了肯定的回答,那么你并不需要区块链。 -### Test 3: Is adoption going to be costly or annoying to some stakeholders? +我曾听过这种观点,即区块链会让所有人收益。但这显然是不可能的。假设你正在为某个流程设计一个应用,改变合作伙伴与你及应用的交互方式,那么你需要判断这个改变是否符合合作伙伴的兴趣。不论是否涉及区块链,可以很容易的设计并引入一个应用,虽然降低了你自己的业务阻力,但与此同时增加了合作伙伴的业务阻力。 -If the answer to this question is "yes," then you don't need a blockchain. +假设我为汽车行业生产发动机配件,那么使用区块链追溯和管理配件会让我受益匪浅。例如,我可以查看购买的滚珠轴承的生产商、生产时间和钢铁材料供应商等。换一个角度,假设我是滚珠轴承生产商,已经为40多个客户公司建立了处理流程。为一家客户引入新的流程会涉及工作方式、系统体系、储藏和安全性标准等方面的变更,这无法让我感兴趣,相反,这会导致复杂性和高开销。 -I've heard assertions that blockchains always benefit all users. This is patently false. If you are creating an application for a process and changing the way your stakeholders interact with you and it, you need to consider whether that change is in their best interests. It's very easy to create and introduce an application, blockchain or not, that reduces business friction for the owner of the process but increases it for other stakeholders. +### 总结 -If I make engine parts for the automotive industry, it may benefit me immensely to be able to track and manage the parts on a blockchain. I may be able to see at a glance who supplied what, when, and the quality of the steel used in the (for example) ball bearings I buy. On the other hand, if I'm a ball-bearing producer with an established process that works for the 40 other companies to whom I sell ball bearings, adopting a new process for one company—with associated changes to my method of work, systems, storage, and security requirements—is unlikely to be in my best interests. It's going to be both costly and annoying. +这几个场景判定用于提纲挈领,并不是一成不变的。其中数据库相关的那个场景判定更像是技术方面的,但也是紧密结合业务定位和功能的。希望这几个判定可以为区块链技术引进促因带来的过热进行降温。 -### In summary +[#1]\. 请不要误解我的意思,加密货币显然是一种有趣的区块链业务应用,只是不在本文的讨论范畴而已。 -Tests are guidelines; they're not fixed in stone. One of these tests looks like a technical test (the database one), but it's really as much about business roles and responsibilities as the other two. All of them, hopefully, can be used as a counterbalance to the three drivers of blockchain adoption I mentioned. +[#2]\. 知道具体是哪些部分是很有意义的,如果你知道,请告诉我好吗? -1\. Which, don't get me wrong, is definitely interesting and a business application—it's just not what I'm going to talk about in this post. +[#3]\. 坦率的说,它其实更像是一大堆技术的集合体。 -2\. The trick is knowing which bits. Let me know if you work out how, OK? +[#4]\. 这显然是假的,如果被淘汰的主体是这些会议和“专家”本身倒十分有可能。 -3\. It's actually quite a large set of technologies, to be honest. +[#5]\. 由于比方打得有些不恰当,估计还是会引起众怒。 -4\. Which is patently untrue, unless the word "they" refers to the conferences and gurus, in which case it's probably correct. +[#6]\. 我太喜欢这个grok单词了,我把它放在这里作为我的工程师标志[#7]。 -5\. Which may happen anyway due to my egregious mixing of metaphors. +[#7]\. 你可能已经想到了,我读过_Stranger in a Strange Land_一书,包括删减版和原版。 -6\. There's a word to love. I've put it in to exhibit my techie credentials.7 +[#8]\. 合理地。 -7\. And before you doubt them, yes, I've read the book, in both cut and uncut versions. - -8\. Within reason. - -This article originally appeared on [Alice, Eve, and Bob – a security blog][3] and is republished with permission. +原文最初发表于[爱丽丝, 夏娃和鲍勃 – 一个安全性主题博客][3],以获得转载许可。 -------------------------------------------------------------------------------- via: https://opensource.com/article/18/3/3-tests-not-moving-blockchain 作者:[Mike Bursell][a] -译者:[译者ID](https://github.com/译者ID) +译者:[pinewall](https://github.com/pinewall) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8ac2455cb651f7fc8be1349939d13d61f0b06b10 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 12:41:47 +0800 Subject: [PATCH 0379/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Emacs=20#5:=20D?= =?UTF-8?q?ocuments=20and=20Presentations=20with=20org-mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cuments and Presentations with org-mode.md | 177 ++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 sources/tech/20180404 Emacs -5- Documents and Presentations with org-mode.md diff --git a/sources/tech/20180404 Emacs -5- Documents and Presentations with org-mode.md b/sources/tech/20180404 Emacs -5- Documents and Presentations with org-mode.md new file mode 100644 index 0000000000..06c8dc8856 --- /dev/null +++ b/sources/tech/20180404 Emacs -5- Documents and Presentations with org-mode.md @@ -0,0 +1,177 @@ +Emacs #5: Documents and Presentations with org-mode +====== + +### 1 About org-mode exporting + +#### 1.1 Background + +org-mode isn't just an agenda-making program. It can also export to lots of formats: LaTeX, PDF, Beamer, iCalendar (agendas), HTML, Markdown, ODT, plain text, man pages, and more complicated formats such as a set of web pages. + +This isn't just some afterthought either; it's a core part of the system and integrates very well. + +One file can be source code, automatically-generated output, task list, documentation, and presentation, all at once. + +Some use org-mode as their preferred markup format, even for things like LaTeX documents. The org-mode manual has an extensive [section on exporting][13]. + +#### 1.2 Getting started + +From any org-mode document, just hit C-c C-e. From there will come up a menu, letting you choose various export formats and options. These are generally single-key options so it's easy to set and execute. For instance, to export a document to a PDF, use C-c C-e l p or for HTML export, C-c C-e h h. + +There are lots of settings available for all of these export options; see the manual. It is, in fact, quite possible to use LaTeX-format equations in both LaTeX and HTML modes, to insert arbitrary preambles and settings for different modes, etc. + +#### 1.3 Add-on packages + +ELPA containts many addition exporters for org-mode as well. Check there for details. + +### 2 Beamer slides with org-mode + +#### 2.1 About Beamer + +[Beamer][14] is a LaTeX environment for making presentations. Its features include: + +* Automated generating of structural elements in the presentation (see, for example, [the Marburg theme][1]). This provides a visual reference for the audience of where they are in the presentation. + +* Strong help for structuring the presentation + +* Themes + +* Full LaTeX available + +#### 2.2 Benefits of Beamer in org-mode + +org-mode has a lot of benefits for working with Beamer. Among them: + +* org-mode's very easy and strong support for visualizing and changing the structure makes it very quick to reorganize your material. + +* Combined with org-babel, live source code (with syntax highlighting) and results can be embedded. + +* The syntax is often easier to work with. + +I have completely replaced my usage of LibreOffice/Powerpoint/GoogleDocs with org-mode and beamer. It is, in fact, rather frustrating when I have to use one of those tools, as they are nowhere near as strong as org-mode for visualizing a presentation structure. + +#### 2.3 Headline Levels + +org-mode's Beamer export will convert sections of your document (defined by headings) into slides. The question, of course, is: which sections? This is governed by the H [export setting][15] (org-export-headline-levels). + +There are many ways to go, which suit people. I like to have my presentation like this: + +``` +#+OPTIONS: H:2 +#+BEAMER_HEADER: \AtBeginSection{\frame{\sectionpage}} +``` + +This gives a standalone section slide for each major topic, to highlight major transitions, and then takes the level 2 (two asterisks) headings to set the slide. Many Beamer themes expect a third level of indirection, so you would set H:3 for them. + +#### 2.4 Themes and settings + +You can configure many Beamer and LaTeX settings in your document by inserting lines at the top of your org file. This document, for instance, defines: + +``` +#+TITLE: Documents and presentations with org-mode +#+AUTHOR: John Goerzen +#+BEAMER_HEADER: \institute{The Changelog} +#+PROPERTY: comments yes +#+PROPERTY: header-args :exports both :eval never-export +#+OPTIONS: H:2 +#+BEAMER_THEME: CambridgeUS +#+BEAMER_COLOR_THEME: default +``` + +#### 2.5 Advanced settings + +I like to change some colors, bullet formatting, and the like. I round out my document with: + +``` +# We can't just +BEAMER_INNER_THEME: default because that picks the theme default. +# Override per https://tex.stackexchange.com/questions/11168/change-bullet-style-formatting-in-beamer +#+BEAMER_INNER_THEME: default +#+LaTeX_CLASS_OPTIONS: [aspectratio=169] +#+BEAMER_HEADER: \definecolor{links}{HTML}{0000A0} +#+BEAMER_HEADER: \hypersetup{colorlinks=,linkcolor=,urlcolor=links} +#+BEAMER_HEADER: \setbeamertemplate{itemize items}[default] +#+BEAMER_HEADER: \setbeamertemplate{enumerate items}[default] +#+BEAMER_HEADER: \setbeamertemplate{items}[default] +#+BEAMER_HEADER: \setbeamercolor*{local structure}{fg=darkred} +#+BEAMER_HEADER: \setbeamercolor{section in toc}{fg=darkred} +#+BEAMER_HEADER: \setlength{\parskip}{\smallskipamount} +``` + +Here, aspectratio=169 sets a 16:9 aspect ratio, and the remaining are standard LaTeX/Beamer configuration bits. + +#### 2.6 Shrink (to fit) + +Sometimes you've got some really large code examples and you might prefer to just shrink the slide to fit. + +Just type C-c C-x p, set the BEAMER_opt property to shrink=15\. + +(Or a larger value of shrink). The previous slide uses this here. + +#### 2.7 Result + +Here's the end result: + + [![screenshot1](https://farm1.staticflickr.com/889/26366340577_fbde8ff266_o.png)][16] + +### 3 Interactive Slides + +#### 3.1 Interactive Emacs Slideshows + +With the [org-tree-slide package][17], you can display your slideshow from right within Emacs. Just run M-x org-tree-slide-mode. Then, use C-> and C-< to move between slides. + +You might find C-c C-x C-v (which is org-toggle-inline-images) helpful to cause the system to display embedded images. + +#### 3.2 HTML Slideshows + +There are a lot of ways to export org-mode presentations to HTML, with various levels of JavaScript integration. See the [non-beamer presentations section][18] of the org-mode wiki for details. + +### 4 Miscellaneous + +#### 4.1 Additional resources to accompany this post + +* [orgmode.org beamer tutorial][2] + +* [LaTeX wiki][3] + +* [Generating section title slides][4] + +* [Shrinking content to fit on slide][5] + +* A great resource: refcard-org-beamer See its [Github repo][6] Make sure to check out both the PDF and the .org file + +* A nice [Theme matrix][7] + +#### 4.2 Up next in my Emacs series… + +mu4e for email! + + +-------------------------------------------------------------------------------- + +via: http://changelog.complete.org/archives/9900-emacs-5-documents-and-presentations-with-org-mode + +作者:[John Goerzen][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]:http://changelog.complete.org/archives/author/jgoerzen +[1]:https://hartwork.org/beamer-theme-matrix/all/beamer-albatross-Marburg-1.png +[2]:https://orgmode.org/worg/exporters/beamer/tutorial.html +[3]:https://en.wikibooks.org/wiki/LaTeX/Presentations +[4]:https://tex.stackexchange.com/questions/117658/automatically-generate-section-title-slides-in-beamer/117661 +[5]:https://tex.stackexchange.com/questions/78514/content-doesnt-fit-in-one-slide +[6]:https://github.com/fniessen/refcard-org-beamer +[7]:https://hartwork.org/beamer-theme-matrix/ +[8]:https://changelog.complete.org/archives/tag/emacs2018 +[9]:https://github.com/jgoerzen/public-snippets/blob/master/emacs/emacs-org-beamer/emacs-org-beamer.org +[10]:http://changelog.complete.org/archives/9900-emacs-5-documents-and-presentations-with-org-mode +[11]:https://github.com/jgoerzen/public-snippets/raw/master/emacs/emacs-org-beamer/emacs-org-beamer.pdf +[12]:https://github.com/jgoerzen/public-snippets/raw/master/emacs/emacs-org-beamer/emacs-org-beamer-document.pdf +[13]:https://orgmode.org/manual/Exporting.html#Exporting +[14]:https://en.wikipedia.org/wiki/Beamer_(LaTeX) +[15]:https://orgmode.org/manual/Export-settings.html#Export-settings +[16]:https://www.flickr.com/photos/jgoerzen/26366340577/in/dateposted/ +[17]:https://orgmode.org/worg/org-tutorials/non-beamer-presentations.html#org-tree-slide +[18]:https://orgmode.org/worg/org-tutorials/non-beamer-presentations.html From 9b369fba470e16a6a77e28f07c58161cf2db5579 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 12:41:55 +0800 Subject: [PATCH 0380/1057] edition 3 --- ...when moving to blockchain is a bad idea.md | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md index 0e87f33272..13a69686e9 100644 --- a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -1,11 +1,12 @@ -pinewall Translating -区块链技术不适用的若干场景 +区块链不适用的若干场景 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/blocks_building.png?itok=eMOT-ire) -不错,区块链的概念异常的火热。 -众所周知,我一直关注区块链及相关技术的成熟度发展情况,思考其是否达到过高期望的峰值(peak hype);但从目前的情况来看,还没有这个迹象。我在文中所说的区块链技术是广义上的,包含了狭义上不属于区块链的分布式账本技术(DLTs)。我对私有链更感兴趣,其中私有链的定义可以参考我的文章[区块链是安全性方面的话题吗?][1]简而言之,我对加密货币之外的区块链业务应用特别感兴趣[#1]。 + +不错,区块链这个概念异常的火热。 + +众所周知,我一直关注区块链及相关技术的成熟度发展情况,思考其是否达到过高期望的峰值(peak hype);但从目前的情况来看,还没有这个迹象。我在文中提到的区块链技术是广义上的,包含了狭义上不属于区块链的分布式账本技术(DLTs)。我对私有链更感兴趣,其中私有链的定义可以参考我的文章[区块链是安全性方面的话题吗?][1]。简而言之,我对加密货币之外的区块链业务应用特别感兴趣[1](#footnote1)。 我们对区块链的技术成熟度的判断应该有一部分可以得到证实[#2]。如果我们判断正确,未来将会出现海量的区块链应用。这很可能会变成现实,但并不是所有的应用都是优秀的区块链应用,其中一部分很可能是非常糟糕的。 @@ -15,31 +16,31 @@ pinewall Translating 2. 很多区块链相关的会议和“专家”呼吁尽快拥抱区块链,否则可能会在半年内被淘汰[#4]; 3. 完全理解区块链技术是很难的,支持其在企业中落地的往往是工程师。 -对于最后一条,我必须补充几句,不然很容易被引起众怒[#5]。作为一名工程师,我显然无意贬低工程师.工程师的天性使然,我们对见到的新鲜事物(亮点)热情澎湃,但由于对业务本身神交[#6]不足,对于新技术给业务带来的影响理解可能并不深刻。在业务领导者看来,这些影响不一定是有利的。 +对于最后一条,我必须补充几句,不然很容易被引起众怒[#5]。作为一名工程师,我显然无意贬低工程师。但工程师的天性使然,我们对见到的新鲜事物(亮点)热情澎湃,却对业务本身神交[#6]不足,故对于新技术给业务带来的影响理解可能并不深刻。在业务领导者看来,这些影响不一定是有利的。 -上面提到的三种促因可能导致一种风险,即在没有充分评估利弊的情况下,将业务改造为区块链应用。在另一文([区块链:每个人都应该参与进来吗?][2])中提到几个场景,用于判断一个业务什么情况下适合采用区块链技术。这些场景是有益的,但更进一步,我坚人们更加需要的是,给出业务完全不适用区块链的几种简单的场景判定。我总结了三种场景判定,如果对于其中任何一个问题你给出了肯定的回答,那么很大概率上你并不需要区块链。 +上面提到的三种促因可能导致一种风险,即在没有充分评估利弊的情况下,将业务改造为区块链应用。在另一文([区块链:每个人都应该参与进来吗?][2])中提到几个场景,用于判断一个业务什么情况下适合采用区块链技术。这些场景是有益的,但更进一步,我坚信人们更加需要的是,业务完全不适用区块链的几种简单的场景判定。我总结了三种场景判定,如果对于其中任何一个问题你给出了肯定的回答,那么很大概率上区块链不适合你。 ### 场景判定1:业务是否需要集中式的管控或授权? -如果你给出了肯定的回答,那么你并不需要区块链。 +如果你给出了肯定的回答,那么区块链不适合你。 -例如,假设你是一个蒲团销售商,具有唯一的订单系统,那么对于何时发货你有唯一的授权,显然你基本不需要使用区块链。假设你是一个内容提供商,所有提供的内容都会经过唯一的编辑和发布过程,显然你基本不需要使用区块链。 +例如,假设你是一个蒲团销售商,具有唯一的订单系统,那么对于何时发货你有唯一的授权,显然区块链不适合你。假设你是一个内容提供商,所有提供的内容都会经过唯一的编辑和发布过程,显然区块链不适合你。 经验总结:只有当任务对应的执行流程及相应的认证流程是分布于众多主体时,区块链是有价值的。 ### 场景判定2:业务使用经典数据库是否工作良好? -如果你给出了肯定的回答,那么你并不需要区块链。 +如果你给出了肯定的回答,那么区块链不适合你。 该场景似乎与上一个场景是强相关的,但并不总是如此。在一些应用中,处理流程是分布的,但信息存储是中心化的;在另外一些应用中,处理流程需要中心化的授权,但信息存储是分布的,即总有一个并不是分布式的。但如果业务使用经典数据库可以工作量良好的话,使用经典数据库是一个好主意。 -经典数控不仅性能良好,在设计与运营成本方面低比区块链或分布式账本,而且我们在这方面技术积累丰厚。区块链让所有人[#8]可以查看和持有数据,但间接成本和潜在成本都比较高昂。 +经典数据库不仅性能良好,在设计与运营成本方面低比区块链或分布式账本,而且我们在这方面技术积累丰厚。区块链让所有人[#8]可以查看和持有数据,但间接成本和潜在成本都比较高昂。 ### 场景判定3:业务采用新技术是否成本高昂或对合作伙伴有负面效果? -如果你给出了肯定的回答,那么你并不需要区块链。 +如果你给出了肯定的回答,那么区块链不适合你。 -我曾听过这种观点,即区块链会让所有人收益。但这显然是不可能的。假设你正在为某个流程设计一个应用,改变合作伙伴与你及应用的交互方式,那么你需要判断这个改变是否符合合作伙伴的兴趣。不论是否涉及区块链,可以很容易的设计并引入一个应用,虽然降低了你自己的业务阻力,但与此同时增加了合作伙伴的业务阻力。 +我曾听过这种观点,即区块链会让所有人获益。但这显然是不可能的。假设你正在为某个流程设计一个应用,改变合作伙伴与你及应用的交互方式,那么你需要判断这个改变是否符合合作伙伴的兴趣。不论是否涉及区块链,可以很容易的设计并引入一个应用,虽然降低了你自己的业务阻力,但与此同时增加了合作伙伴的业务阻力。 假设我为汽车行业生产发动机配件,那么使用区块链追溯和管理配件会让我受益匪浅。例如,我可以查看购买的滚珠轴承的生产商、生产时间和钢铁材料供应商等。换一个角度,假设我是滚珠轴承生产商,已经为40多个客户公司建立了处理流程。为一家客户引入新的流程会涉及工作方式、系统体系、储藏和安全性标准等方面的变更,这无法让我感兴趣,相反,这会导致复杂性和高开销。 @@ -47,7 +48,7 @@ pinewall Translating 这几个场景判定用于提纲挈领,并不是一成不变的。其中数据库相关的那个场景判定更像是技术方面的,但也是紧密结合业务定位和功能的。希望这几个判定可以为区块链技术引进促因带来的过热进行降温。 -[#1]\. 请不要误解我的意思,加密货币显然是一种有趣的区块链业务应用,只是不在本文的讨论范畴而已。 +1\. 请不要误解我的意思,加密货币显然是一种有趣的区块链业务应用,只是不在本文的讨论范畴而已。 [#2]\. 知道具体是哪些部分是很有意义的,如果你知道,请告诉我好吗? @@ -57,11 +58,11 @@ pinewall Translating [#5]\. 由于比方打得有些不恰当,估计还是会引起众怒。 -[#6]\. 我太喜欢这个grok单词了,我把它放在这里作为我的工程师标志[#7]。 +[#6]\. 我太喜欢grok这个单词了,我把它放在这里作为我的工程师标志[#7]。 [#7]\. 你可能已经想到了,我读过_Stranger in a Strange Land_一书,包括删减版和原版。 -[#8]\. 合理地。 +[#8]\. 在合理的情况下。 原文最初发表于[爱丽丝, 夏娃和鲍勃 – 一个安全性主题博客][3],以获得转载许可。 From db918eb45375f757157baa655b125f5f24ba1c80 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 12:46:16 +0800 Subject: [PATCH 0381/1057] edition 4 --- ...when moving to blockchain is a bad idea.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md index 13a69686e9..0bd1f651a5 100644 --- a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -8,15 +8,15 @@ 众所周知,我一直关注区块链及相关技术的成熟度发展情况,思考其是否达到过高期望的峰值(peak hype);但从目前的情况来看,还没有这个迹象。我在文中提到的区块链技术是广义上的,包含了狭义上不属于区块链的分布式账本技术(DLTs)。我对私有链更感兴趣,其中私有链的定义可以参考我的文章[区块链是安全性方面的话题吗?][1]。简而言之,我对加密货币之外的区块链业务应用特别感兴趣[1](#footnote1)。 -我们对区块链的技术成熟度的判断应该有一部分可以得到证实[#2]。如果我们判断正确,未来将会出现海量的区块链应用。这很可能会变成现实,但并不是所有的应用都是优秀的区块链应用,其中一部分很可能是非常糟糕的。 +我们对区块链的技术成熟度的判断应该有一部分可以得到证实[2](#footnote2)。如果我们判断正确,未来将会出现海量的区块链应用。这很可能会变成现实,但并不是所有的应用都是优秀的区块链应用,其中一部分很可能是非常糟糕的。 -但区块链所处的技术成熟度意味着,大量业务将快速拥抱新技术[#3],但对于可能的前景却一知半解。促成这种情况的原因可以大致分为三种: +但区块链所处的技术成熟度意味着,大量业务将快速拥抱新技术[3](#footnote3),但对于可能的前景却一知半解。促成这种情况的原因可以大致分为三种: 1. 对于涉及多用户数据存储的业务应用,在投入精力的情况下,几乎都可以改造为基于区块链的版本; - 2. 很多区块链相关的会议和“专家”呼吁尽快拥抱区块链,否则可能会在半年内被淘汰[#4]; + 2. 很多区块链相关的会议和“专家”呼吁尽快拥抱区块链,否则可能会在半年内被淘汰[4](#footnote4); 3. 完全理解区块链技术是很难的,支持其在企业中落地的往往是工程师。 -对于最后一条,我必须补充几句,不然很容易被引起众怒[#5]。作为一名工程师,我显然无意贬低工程师。但工程师的天性使然,我们对见到的新鲜事物(亮点)热情澎湃,却对业务本身神交[#6]不足,故对于新技术给业务带来的影响理解可能并不深刻。在业务领导者看来,这些影响不一定是有利的。 +对于最后一条,我必须补充几句,不然很容易被引起众怒[5](#footnote5)。作为一名工程师,我显然无意贬低工程师。但工程师的天性使然,我们对见到的新鲜事物(亮点)热情澎湃,却对业务本身神交[6](#footnote6)不足,故对于新技术给业务带来的影响理解可能并不深刻。在业务领导者看来,这些影响不一定是有利的。 上面提到的三种促因可能导致一种风险,即在没有充分评估利弊的情况下,将业务改造为区块链应用。在另一文([区块链:每个人都应该参与进来吗?][2])中提到几个场景,用于判断一个业务什么情况下适合采用区块链技术。这些场景是有益的,但更进一步,我坚信人们更加需要的是,业务完全不适用区块链的几种简单的场景判定。我总结了三种场景判定,如果对于其中任何一个问题你给出了肯定的回答,那么很大概率上区块链不适合你。 @@ -34,7 +34,7 @@ 该场景似乎与上一个场景是强相关的,但并不总是如此。在一些应用中,处理流程是分布的,但信息存储是中心化的;在另外一些应用中,处理流程需要中心化的授权,但信息存储是分布的,即总有一个并不是分布式的。但如果业务使用经典数据库可以工作量良好的话,使用经典数据库是一个好主意。 -经典数据库不仅性能良好,在设计与运营成本方面低比区块链或分布式账本,而且我们在这方面技术积累丰厚。区块链让所有人[#8]可以查看和持有数据,但间接成本和潜在成本都比较高昂。 +经典数据库不仅性能良好,在设计与运营成本方面低比区块链或分布式账本,而且我们在这方面技术积累丰厚。区块链让所有人[8](#footnote8)可以查看和持有数据,但间接成本和潜在成本都比较高昂。 ### 场景判定3:业务采用新技术是否成本高昂或对合作伙伴有负面效果? @@ -50,19 +50,19 @@ 1\. 请不要误解我的意思,加密货币显然是一种有趣的区块链业务应用,只是不在本文的讨论范畴而已。 -[#2]\. 知道具体是哪些部分是很有意义的,如果你知道,请告诉我好吗? +2\. 知道具体是哪些部分是很有意义的,如果你知道,请告诉我好吗? -[#3]\. 坦率的说,它其实更像是一大堆技术的集合体。 +3\. 坦率的说,它其实更像是一大堆技术的集合体。 -[#4]\. 这显然是假的,如果被淘汰的主体是这些会议和“专家”本身倒十分有可能。 +4\. 这显然是假的,如果被淘汰的主体是这些会议和“专家”本身倒十分有可能。 -[#5]\. 由于比方打得有些不恰当,估计还是会引起众怒。 +5\. 由于比方打得有些不恰当,估计还是会引起众怒。 -[#6]\. 我太喜欢grok这个单词了,我把它放在这里作为我的工程师标志[#7]。 +6\. 我太喜欢grok这个单词了,我把它放在这里作为我的工程师标志[7](#footnote7)。 -[#7]\. 你可能已经想到了,我读过_Stranger in a Strange Land_一书,包括删减版和原版。 +7\. 你可能已经想到了,我读过_Stranger in a Strange Land_一书,包括删减版和原版。 -[#8]\. 在合理的情况下。 +8\. 在合理的情况下。 原文最初发表于[爱丽丝, 夏娃和鲍勃 – 一个安全性主题博客][3],以获得转载许可。 From 6122824335eeba7f0e052647a1a8dfa6e7ca934f Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 12:47:56 +0800 Subject: [PATCH 0382/1057] edition 5 --- ...323 How to tell when moving to blockchain is a bad idea.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md index 0bd1f651a5..d254dd92d0 100644 --- a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -64,11 +64,11 @@ 8\. 在合理的情况下。 -原文最初发表于[爱丽丝, 夏娃和鲍勃 – 一个安全性主题博客][3],以获得转载许可。 +原文最初发表于[爱丽丝, 夏娃和鲍勃 – 一个安全性主题博客][3],已获得转载许可。 -------------------------------------------------------------------------------- -via: https://opensource.com/article/18/3/3-tests-not-moving-blockchain +原文链接: https://opensource.com/article/18/3/3-tests-not-moving-blockchain 作者:[Mike Bursell][a] 译者:[pinewall](https://github.com/pinewall) From 477c75dc722c39887585bbbcf38d4152ef0b1859 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 14:23:35 +0800 Subject: [PATCH 0383/1057] edition 6 --- ...80323 How to tell when moving to blockchain is a bad idea.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md index d254dd92d0..eba84296e5 100644 --- a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -54,7 +54,7 @@ 3\. 坦率的说,它其实更像是一大堆技术的集合体。 -4\. 这显然是假的,如果被淘汰的主体是这些会议和“专家”本身倒十分有可能。 +4\. 这显然是不太可能的,如果被淘汰的主体是这些会议和“专家”本身倒十分有可能。 5\. 由于比方打得有些不恰当,估计还是会引起众怒。 From 3765a534742932d7c56dec4fa8f61af92fa3f559 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 14:25:28 +0800 Subject: [PATCH 0384/1057] edition 7 --- ...80323 How to tell when moving to blockchain is a bad idea.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md index eba84296e5..944af54995 100644 --- a/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md +++ b/translated/talk/20180323 How to tell when moving to blockchain is a bad idea.md @@ -60,7 +60,7 @@ 6\. 我太喜欢grok这个单词了,我把它放在这里作为我的工程师标志[7](#footnote7)。 -7\. 你可能已经想到了,我读过_Stranger in a Strange Land_一书,包括删减版和原版。 +7\. 你可能已经想到了,我读过*Stranger in a Strange Land*一书,包括删减版和原版。 8\. 在合理的情况下。 From 908deed3b0f812ccf697f146666cbc509c28b058 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 9 Apr 2018 14:54:16 +0800 Subject: [PATCH 0385/1057] add tag for translation --- .../tech/20180329 Protect Your Websites with Let-s Encrypt.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md b/sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md index e38875f292..d82ba5fc99 100644 --- a/sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md +++ b/sources/tech/20180329 Protect Your Websites with Let-s Encrypt.md @@ -1,3 +1,5 @@ +pinewall translating + Protect Your Websites with Let's Encrypt ====== From d4ec74d769b6642547e196168a93881c84048040 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 15:32:40 +0800 Subject: [PATCH 0386/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Is=20the=20term?= =?UTF-8?q?=20DevSecOps=20necessary=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0180404 Is the term DevSecOps necessary.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sources/talk/20180404 Is the term DevSecOps necessary.md diff --git a/sources/talk/20180404 Is the term DevSecOps necessary.md b/sources/talk/20180404 Is the term DevSecOps necessary.md new file mode 100644 index 0000000000..96b544e7c4 --- /dev/null +++ b/sources/talk/20180404 Is the term DevSecOps necessary.md @@ -0,0 +1,51 @@ +Is the term DevSecOps necessary? +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2) +First came the term "DevOps." + +It has many different aspects. For some, [DevOps][1] is mostly about a culture valuing collaboration, openness, and transparency. Others focus more on key practices and principles such as automating everything, constantly iterating, and instrumenting heavily. And while DevOps isn’t about specific tools, certain platforms and tooling make it a more practical proposition. Think containers and associated open source cloud-native technologies like [Kubernetes][2] and CI/CD pipeline tools like [Jenkins][3]—as well as native Linux capabilities. + +However, one of the earliest articulated concepts around DevOps was the breaking down of the “wall of confusion” specifically between developers and operations teams. This was rooted in the idea that developers didn’t think much about operational concerns and operators didn’t think much about application development. Add the fact that developers want to move quickly and operators care more about (and tend to be measured on) stability than speed, and it’s easy to see why it was difficult to get the two groups on the same page. Hence, DevOps came to symbolize developers and operators working more closely together, or even merging roles to some degree. + +Of course, calls for improved communications and better-integrated workflows were never just about dev and ops. Business owners should be part of conversations as well. And there are the actual users of the software. Indeed, you can write up an almost arbitrarily long list of stakeholders concerned with the functionality, cost, reliability, and other aspects of software and its associated infrastructure. Which raises the question that many have asked: “What’s so special about security that we need a DevSecOps term?” + +I’m glad you asked. + +The first is simply that it serves as a useful reminder. If developers and operations were historically two of the most common silos in IT organizations, security was (and often still is) another. Security people are often thought of as conservative gatekeepers for whom “no” often seems the safest response to new software releases and technologies. Security’s job is to protect the company, even if that means putting the brakes on a speedy development process. + +Many aspects of traditional security, and even its vocabulary, can also seem arcane to non-specialists. This has also contributed to the notion that security is something apart from mainstream IT. I often share the following anecdote: A year or two ago I was leading a security discussion at a [DevOpsDays][4] event in London in which we were talking about traditional security roles. One of the participants raised his hand and admitted that he was one of those security gatekeepers. He went on to say that this was the first time in his career that he had ever been to a conference that wasn’t a traditional security conference like RSA. (He also noted that he was going to broaden both his and his team’s horizons more.) + +So DevSecOps perhaps shouldn’t be a needed term. But explicitly calling it out seems like a good practice at a time when software security threats are escalating. + +The second reason is that the widespread introduction of cloud-native technologies, particularly those built around containers, are closely tied to DevOps practices. These new technologies are both leading to and enabling greater scale and more dynamic infrastructures. Static security policies and checklists no longer suffice. Security must become a continuous activity. And it must be considered at every stage of your application and infrastructure lifecycle. + +**Here are a few examples:** + +You need to secure the pipeline and applications. You need to use trusted sources for content so that you know who has signed off on container images and that they’re up-to-date with the most recent patches. Your continuous integration system must integrate automated security testing. You’ll sometimes hear people talking about “shifting security left,” which means earlier in the process so that problems can be dealt with sooner. But it’s actually better to think about embedding security throughout the entire pipeline at each step of the testing, integration, deployment, and ongoing management process. + +You need to secure the underlying infrastructure. This means securing the host Linux kernel from container escapes and securing containers from each other. It means using a container orchestration platform with integrated security features. It means defending the network by using network namespaces to isolate applications from other applications within a cluster and isolate environments (such as dev, test, and production) from each other. + +And it means taking advantage of the broader security ecosystem such as container content scanners and vulnerability management tools. + +In short, it’s DevSecOps because modern application development and container platforms require a new type of Dev and a new type of Ops. But they also require a new type of Sec. Thus, DevSecOps. + +**[See our related story,[Security and the SRE: How chaos engineering can play a key role][5].]** + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/devsecops + +作者:[Gordon Haff][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/ghaff +[1]:https://opensource.com/resources/devops +[2]:https://kubernetes.io/ +[3]:https://jenkins.io/ +[4]:https://www.devopsdays.org/ +[5]:https://opensource.com/article/18/3/through-looking-glass-security-sre From f04b115e026676a31f04ff214c303d5bbc1ea36f Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 15:34:36 +0800 Subject: [PATCH 0387/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20find?= =?UTF-8?q?=20files=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180405 How to find files in Linux.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/tech/20180405 How to find files in Linux.md diff --git a/sources/tech/20180405 How to find files in Linux.md b/sources/tech/20180405 How to find files in Linux.md new file mode 100644 index 0000000000..52291cff3e --- /dev/null +++ b/sources/tech/20180405 How to find files in Linux.md @@ -0,0 +1,74 @@ +How to find files 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) +If you're a Windows user or a non-power-user of OSX, you probably use a GUI to find files. You may also find the interface limited, frustrating, or both, and have learned to excel at organizing things and remembering the exact order of your files. You can do that in Linux, too—but you don't have to. + +One of the best things about Linux is that it offers a variety of ways to do things. You can open any file manager and `ctrl`+`f`, you can use the program you are in to open files manually, or you can simply start typing letters and it'll filter the current directory listing. + +![Screenshot of how to find files in Linux with Ctrl+F][2] + +Screenshot of how to find files in Linux with Ctrl+F + +But what if you don't know where your file is and don't want to search the entire disk? Linux is well-tooled for this and a variety of other use-cases. + +### Finding program locations by command name + +The Linux file system can seem daunting if you're used to putting things wherever you like. For me, one of the hardest things to get used to was finding where programs are supposed to live. + +For example, `which bash` will usually return `/bin/bash`, but if you download a program and it doesn't appear in your menus, the `which` command can be a great tool. + +A similar utility is the `locate` command, which I find useful for finding configuration files. I don't like typing in program names because simple ones like `locate php` often offer many results that need to be filtered further. + +For more information about `locate` and `which`, see the `man` pages: + + * `man which` + * `man locate` + + + +### Find + +The `find` utility offers much more advanced functionality. Below is an example from a script I've installed on a number of servers that I administer to ensure that a specific pattern of file (also known as a glob) exists for only five days and all files older than that are deleted. (Since its last modification, a decimal is used to account for up to 240 minutes difference.) +``` +find ./backup/core-files*.tar.gz -mtime +4.9 -exec rm {} \; + +``` + +The `find` utility has many advanced use-cases, but most common is executing commands on results without chaining and filtering files by type, creation, and modification date. + +Another interesting use of `find` is to find all files with executable permissions. This can help ensure that nobody is installing bitcoin miners or botnets on your expensive servers. +``` +find / -perm /+x + +``` + +For more information on `find`, see the `man` page using `man find.` + +### Grep + +Want to find a file by its contents? Linux has it covered. You can use many Linux utilities to efficiently search for files that match a pattern, but `grep` is one that I use often. + +Suppose you have an application that's delivering error messages with a code reference and stack trace. You find these in your logs. Grepping is not always the go-to, but I always `grep -R` if the issue is with a supplied value. + +An increasing number of IDEs are implementing find functions, but if you're accessing a remote system or for whatever reason don't have a GUI, or if you want to iterate in-place, then use: `grep -R {searchterm}` or on systems supporting `egrep` alias; just add `-e` flag to command `egrep -r {regex-pattern}`. + +I used this technique when patching the `dhcpcd5` in [Raspbian][3] last year so I could continue to operate a network access point on newer Debian releases from the [Raspberry Pi Foundation][4]. + +What tips help you search for files more efficiently on Linux? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/how-find-files-linux + +作者:[Lewis Cowles][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/lewiscowles1986 +[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/find-files-in-linux-ctrlf.png?itok=1gf9kIut (Screenshot of how to find files in Linux with Ctrl+F) +[3]:https://www.raspbian.org/ +[4]:https://www.raspberrypi.org/ From 1b5c674ca45c6d4304966d5606c963230ed8fa39 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 15:36:16 +0800 Subject: [PATCH 0388/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Rethinking=20"o?= =?UTF-8?q?wnership"=20across=20the=20organization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ing -ownership- across the organization.md | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 sources/talk/20180405 Rethinking -ownership- across the organization.md diff --git a/sources/talk/20180405 Rethinking -ownership- across the organization.md b/sources/talk/20180405 Rethinking -ownership- across the organization.md new file mode 100644 index 0000000000..d41a3a86dc --- /dev/null +++ b/sources/talk/20180405 Rethinking -ownership- across the organization.md @@ -0,0 +1,125 @@ +Rethinking "ownership" across the organization +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chain.png?itok=sgAjswFf) +Differences in organizational design don't necessarily make some organizations better than others—just better suited to different purposes. Any style of organization must account for its models of ownership (the way tasks get delegated, assumed, executed) and responsibility (the way accountability for those tasks gets distributed and enforced). Conventional organizations and open organizations treat these issues differently, however, and those difference can be jarring for anyone hopping transitioning from one organizational model to another. But transitions are ripe for stumbling over—oops, I mean, learning from. + +Let's do that. + +### Ownership explained + +In most organizations (and according to typical project management standards), work on projects proceeds in five phases: + + * Initiation: Assess project feasibility, identify deliverables and stakeholders, assess benefits + * Planning (Design): Craft project requirements, scope, and schedule; develop communication and quality plans + * Executing: Manage task execution, implement plans, maintain stakeholder relationships + * Monitoring/Controlling: Manage project performance, risk, and quality of deliverables + * Closing: Sign-off on completion requirements, release resources + + + +The list above is not exhaustive, but I'd like to add one phase that is often overlooked: the "Adoption" phase, frequently needed for strategic projects where a change to the culture or organization is required for "closing" or completion. + + * Adoption: Socializing the work of the project; providing communication, training, or integration into processes and standard workflows. + + + +Examining project phases is one way contrast the expression of ownership and responsibility in organizations. + +### Two models, contrasted + +In my experience, "ownership" in a traditional software organization works like this. + +A manager or senior technical associate initiates a project with senior stakeholders and, with the authority to champion and guide the project, they bestow the project on an associate at some point during the planning and execution stages. Frequently, but not always, the groundwork or fundamental design of the work has already been defined and approved—sometimes even partially solved. Employees are expected to see the project through execution and monitoring to completion. + +Employees cut their teeth on a "starter project," where they prove their abilities to a management chain (for example, I recall several such starter projects that were already defined by a manager and architect, and I was assigned to help implement them). Employees doing a good job on a project for which they're responsible get rewarded with additional opportunities, like a coveted assignment, a new project, or increased responsibility. + +An associate acting as "owner" of work is responsible and accountable for that work (if someone, somewhere, doesn't do their job, then the responsible employee either does the necessary work herself or alerts a manager to the problem.) A sense of ownership begins to feel stable over time: Employees generally work on the same projects, and in the same areas for an extended period. For some employees, it means the development of deep expertise. That's because the social network has tighter integration between people and the work they do, so moving around and changing roles and projects is rather difficult. + +This process works differently in an open organization. + +Associates continually define the parameters of responsibility and ownership in an open organization—typically in light of their interests and passions. Associates have more agency to perform all the stages of the project themselves, rather than have pre-defined projects assigned to them. This places additional emphasis on leadership skills in an open organization, because the process is less about one group of people making decisions for others, and more about how an associate manages responsibilities and ownership (whether or not they roughly follow the project phases while being inclusive, adaptable, and community-focused, for example). + +Being responsible for all project phases can make ownership feel more risky for associates in an open organization. Proposing a new project, designing it, and leading its implementation takes initiative and courage—especially when none of this is pre-defined by leadership. It's important to get continuous buy-in, which comes with questions, criticisms, and resistance not only from leaders but also from peers. By default, in open organizations this makes associates leaders; they do much the same work that higher-level leaders do in conventional organizations. And incidentally, this is why Jim Whitehurst, in The Open Organization, cautions us about the full power of "transparency" and the trickiness of getting people's real opinions and thoughts whether we like them or not. The risk is not as high in a traditional organization, because in those organizations leaders manage some of it by shielding associates from heady discussions that arise. + +The reward in an Open Organization is more opportunity—offers of new roles, promotions, raises, etc., much like in a conventional organization. Yet in the case of open organizations, associates have developed reputations of excellence based on their own initiatives, rather than on pre-sanctioned opportunities from leadership. + +### Thinking about adoption + +Any discussion of ownership and responsibility involves addressing the issue of buy-in, because owning a project means we are accountable to our sponsors and users—our stakeholders. We need our stakeholders to buy-into our idea and direction, or we need users to adopt an innovation we've created with our stakeholders. Achieving buy-in for ideas and work is important in each type of organization, and it's difficult in both traditional and open systems—but for different reasons. + +Open organizations better allow highly motivated associates, who are ambitious and skilled, to drive their careers. But support for their ideas is required across the organization, rather than from leadership alone. + +Penetrating a traditional organization's closely knit social ties can be difficult, and it takes time. In such "command-and-control" environments, one would think that employees are simply "forced" to do whatever leaders want them to do. In some cases that's true (e.g., a travel reimbursement system). However, with more innovative programs, this may not be the case; the adoption of a program, tool, or process can be difficult to achieve by fiat, just like in an open organization. And yet these organizations tend to reduce redundancies of work and effort, because "ownership" here involves leaders exerting responsibility over clearly defined "domains" (and because those domains don't change frequently, knowing "who's who"—who's in charge, who to contact with a request or inquiry or idea—can be easier). + +Open organizations better allow highly motivated associates, who are ambitious and skilled, to drive their careers. But support for their ideas is required across the organization, rather than from leadership alone. Points of contact and sources of immediate support can be less obvious, and this means achieving ownership of a project or acquiring new responsibility takes more time. And even then someone's idea may never get adopted. A project's owner can change—and the idea of "ownership" itself is more flexible. Ideas that don't get adopted can even be abandoned, leaving a great idea unimplemented or incomplete. Because any associate can "own" an idea in an open organization, these organizations tend to exhibit more redundancy. (Some people immediately think this means "wasted effort," but I think it can augment the implementation and adoption of innovative solutions. By comparing these organizations, we can also see why Jim Whitehurst calls this kind of culture "chaotic" in The Open Organization). + +### Two models of ownership + +In my experience, I've seen very clear differences between conventional and open organizations when it comes to the issues of ownership and responsibility. + +In an traditional organization: + + * I couldn't "own" things as easily + * I felt frustrated, wanting to take initiative and always needing permission + * I could more easily see who was responsible because stakeholder responsibility was more clearly sanctioned and defined + * I could more easily "find" people, because the organizational network was more fixed and stable + * I more clearly saw what needed to happen (because leadership was more involved in telling me). + + + +Over time, I've learned the following about ownership and responsibility in an open organization: + + * People can feel good about what they are doing because the structure rewards behavior that's more self-driven + * Responsibility is less clear, especially in situations where there's no leader + * In cases where open organizations have "shared responsibility," there is the possibility that no one in the group identified with being responsible; often there is lack of role clarity ("who should own this?") + * More people participate + * Someone's leadership skills must be stronger because everyone is "on their own"; you are the leader. + + + +### Making it work + +On the subject of ownership, each type of organization can learn from the other. The important thing to remember here: Don't make changes to one open or conventional value without considering all the values in both organizations. + +Sound confusing? Maybe these tips will help. + +If you're a more conventional organization trying to act more openly: + + * Allow associates to take ownership out of passion or interest that align with the strategic goals of the organization. This enactment of meritocracy can help them build a reputation for excellence and execution. + * But don't be afraid sprinkle in a bit of "high-level perspective" in the spirit of transparency; that is, an associate should clearly communicate plans to their leadership, so the initiative doesn't create irrelevant or unneeded projects. + * Involving an entire community (as when, for example, the associate gathers feedback from multiple stakeholders and user groups) aids buy-in and creates beneficial feedback from the diversity of perspectives, and this helps direct the work. + * Exploring the work with the community [doesn't mean having to come to consensus with thousands of people][1]. Use the [Open Decision Framework][2] to set limits and be transparent about what those limits are so that feedback and participation is organized ad boundaries are understood. + + + +If you're already an open organization, then you should remember: + + * Although associates initiate projects from "the bottom up," leadership needs to be involved to provide guidance, input to the vision, and circulate centralized knowledge about ownership and responsibility creating a synchronicity of engagement that is transparent to the community. + * Ownership creates responsibility, and the definition and degree of these should be something both associates and leaders agree upon, increasing the transparency of expectations and accountability during the project. Don't make this a matter of oversight or babysitting, but rather [a collaboration where both parties give and take][3]—associates initiate, leaders guide; associates own, leaders support. + + + +Leadership education and mentorship, as it pertains to a particular organization, needs to be available to proactive associates, especially since there is often a huge difference between supporting individual contributors and guiding and coordinating a multiplicity of contributions. + +["Owning your own career"][4] can be difficult when "ownership" isn't a concept an organization completely understands. + +[Subscribe to our weekly newsletter][5] to learn more about open organizations. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/18/4/rethinking-ownership-across-organization + +作者:[Heidi Hess von Ludewig][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/heidi-hess-von-ludewig +[1]:https://opensource.com/open-organization/17/8/achieving-alignment-in-openorg +[2]:https://opensource.com/open-organization/resources/open-decision-framework +[3]:https://opensource.com/open-organization/17/11/what-is-collaboration +[4]:https://opensource.com/open-organization/17/12/drive-open-career-forward +[5]:https://opensource.com/open-organization/resources/newsletter From 52fb0efe4b97ff32ece6d03314461ba54ee2a33c Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 9 Apr 2018 15:38:23 +0800 Subject: [PATCH 0389/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Getting=20start?= =?UTF-8?q?ed=20with=20Vagrant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180405 Getting started with Vagrant.md | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 sources/tech/20180405 Getting started with Vagrant.md diff --git a/sources/tech/20180405 Getting started with Vagrant.md b/sources/tech/20180405 Getting started with Vagrant.md new file mode 100644 index 0000000000..2a0442fe52 --- /dev/null +++ b/sources/tech/20180405 Getting started with Vagrant.md @@ -0,0 +1,164 @@ +Getting started with Vagrant +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_scale_performance.jpg?itok=R7jyMeQf) +If you're like me, you probably have a "sandbox" somewhere, a place where you hack on whatever projects you're working on. Over time, the sandbox will get crufty and cluttered with bits and pieces of ideas, toolchain elements, code modules you aren't using, and other stuff you don't need. When you finish something, this can complicate your deployment, because you may be unsure of the actual dependencies of your project—you've had some tool in your sandbox for so long that you forget it must be installed. You need a clean environment, with all your dependencies in one place, to make things easier later. + +Or maybe you're in DevOps, and the developers you serve hand you code with muddy dependencies, and it makes testing that much harder. You need a way to have a clean box to pull in the code and run it through its paces. You want these environments to be disposable and repeatable. + +Enter [Vagrant][1]. Created by HashiCorp under the [MIT License][2], Vagrant acts as a wrapper and frontend for VirtualBox, Microsoft Hyper-V, or Docker containers, and it is extensible with plugins for [a great many other providers][3]. You can configure Vagrant to provide repeatably clean environments with needed infrastructure already installed. The configuration script is portable, so if your repository and Vagrant configuration script are on cloud-based storage, you can spin up and work on multiple machines with just a few limitations. Let's take a look. + +### Installation + +For this installation, I'm working on my Linux Mint desktop, version 18.3 Cinnamon 64-bit. Installation is very similar on most other Debian-derived systems, and there are similar installers for RPM-based systems on most distributions. Vagrant's [installation page][4] provides downloads for Debian, Windows, CentOS, MacOS, and Arch Linux, but I found it in my package manager, so I'll install that. + +The easiest install uses VirtualBox for the virtualization provider, so I'll need to install that, as well. +``` +sudo apt-get install virtualbox vagrant + +``` + +The installer will pick up the dependencies—mostly Ruby stuff—and install them. + +### Setting up a project + +Before setting up your project, you'll need to know a bit about the environment where you want to run it. You can find a whole bunch of preconfigured boxes for many virtualization providers at the [Vagrant Boxes repository][5]. Many will be pre-configured with some core infrastructure you might need, like PHP, MySQL, and Apache, but for this test, I'm going to install a bare Debian 8 64-bit "Jessie" box and manually install a few things, just so you can see how. +``` +mkdir ~/myproject + +cd ~/myproject + +vagrant init debian/contrib-jessie64 + +vagrant up + +``` + +The last command will fetch or update the VirtualBox image from the library, as needed, then pull the starter, and you'll have a running box on your system! The next time you start the box, it won't take as long, unless the image has been updated in the repository. + +To access the box, just enter `vagrant ssh`. You'll be dropped into a fully functional SSH session on the virtual machine. You'll be user `vagrant`, but you're a member of the `sudo` group, so you can change to root and do whatever you want from here. + +You'll see a directory named `/vagrant` on the box. Be careful with this directory, as it'll be synced with the `~/myproject` folder on the host machine. Touch a file in `/vagrant` on the virtual machine, and it's immediately copied out to the host, and vice versa. Be aware that some boxes do not have the VirtualBox guest additions installed, so the copy works only one-way and only at boot time! There are some command-line tools for manual syncing, which might be a really useful feature in a testing environment. I tend to stick to boxes that have the additions in place, so this directory syncing just works without me having to think about it. + +The benefits of this scheme become quickly apparent: If you have a code-editing toolchain on the host and don't want it on the virtual machine for any reason, that's not a problem—edit on the host, and the VM sees the change at once. Make a quick change on the VM, and it's synced to the "official" copy on the host, as well. + +Let's shut the box down so we can provision some things we'll need on this box: `vagrant halt`. + +### Installing additional software on the VM, consistently + +For this example, I'm going to work on a project using [Apache][6], [PostgreSQL][7], and the [Dancer][8] web framework for Perl. I'll modify the Vagrant configuration script so that the things I need are already installed. Just to make things easy to keep it updated later, I'll create a script at the top of `~/myproject/Vagrantfile`: +``` +$provision_script = < - ``` -### 7.2 - CSS +#### 7.2 - CSS 添加一个新文件 `/public/styles.css`,使用一些自定义的 UI 样式。 @@ -1098,10 +1057,9 @@ body { font-family: 'EB Garamond', serif; } justify-content: space-around; background: white; } - ``` -### 7.3 - 尝试输出 +#### 7.3 - 尝试输出 在你的浏览器中打开 `localhost:8080`,你将看到一个简单的带结果分页功能的搜索界面。在顶部的搜索框中尝试输入不同的关键字来查看它们的搜索情况。 @@ -1113,7 +1071,7 @@ body { font-family: 'EB Garamond', serif; } ### 8 - 分页预览 -如果点击每个搜索结果,然后查看到来自书中的内容,那将是非常棒的体验。 +如果能点击每个搜索结果,然后查看到来自书中的内容,那将是非常棒的体验。 ### 8.0 - 添加 Elasticsearch 查询 @@ -1137,12 +1095,11 @@ getParagraphs (bookTitle, startLocation, endLocation) { return client.search({ index, type, body }) } - ``` 这个新函数将返回给定的书的开始位置和结束位置之间的一个排序后的段落数组。 -### 8.1 - 添加 API 端点 +#### 8.1 - 添加 API 端点 现在,我们将这个函数链接到 API 端点。 @@ -1170,10 +1127,9 @@ router.get('/paragraphs', ctx.body = await search.getParagraphs(bookTitle, start, end) } ) - ``` -### 8.2 - 添加 UI 功能 +#### 8.2 - 添加 UI 功能 现在,我们的新端点已经就绪,我们为应用程序添加一些从书中查询和显示全部页面的前端功能。 @@ -1217,10 +1173,9 @@ router.get('/paragraphs', document.body.style.overflow = 'auto' this.selectedParagraph = null } - ``` -这五个函数了提供了通过页码从书中下载和分页(每次十个段落)的逻辑。 +这五个函数提供了通过页码从书中下载和分页(每次十个段落)的逻辑。 现在,我们需要添加一个 UI 去显示书的页面。在 `/public/index.html` 的 `` 注释下面添加如下的内容。 @@ -1258,7 +1213,6 @@ router.get('/paragraphs', - ``` 再次重启应用程序服务器(`docker-compose up -d --build`),然后打开 `localhost:8080`。当你再次点击搜索结果时,你将能看到关键字附近的段落。如果你感兴趣,你现在甚至可以看这本书的剩余部分。 @@ -1269,42 +1223,38 @@ router.get('/paragraphs', 你可以去比较你的本地结果与托管在这里的完整示例 —— [https://search.patricktriest.com/][37] -### 9 - ELASTICSEARCH 的缺点 +### 9 - Elasticsearch 的缺点 -### 9.0 - 耗费资源 +#### 9.0 - 耗费资源 -Elasticsearch 是计算密集型的。[官方建议][38] 运行 ES 的机器最好有 64 GB 的内存,强烈反对在低于 8 GB 内存的机器上运行它。Elasticsearch 是一个 _内存中_ 数据库,这样使它的查询速度非常快,但这也非常占用系统内存。在生产系统中使用时,[他们强烈建议在一个集群中运行多个 Elasticsearch 节点][39],以实现高可用、自动分区、和一个节点失败时的数据冗余。 +Elasticsearch 是计算密集型的。[官方建议][38] 运行 ES 的机器最好有 64 GB 的内存,强烈反对在低于 8 GB 内存的机器上运行它。Elasticsearch 是一个 _内存中_ 数据库,这样使它的查询速度非常快,但这也非常占用系统内存。在生产系统中使用时,[他们强烈建议在一个集群中运行多个 Elasticsearch 节点][39],以实现高可用、自动分区和一个节点失败时的数据冗余。 我们的这个教程中的应用程序运行在一个 $15/月 的 GCP 计算实例中( [search.patricktriest.com][40]),它只有 1.7 GB 的内存,它勉强能运行这个 Elasticsearch 节点;有时候在进行初始的数据加载过程中,整个机器就 ”假死机“ 了。在我的经验中,Elasticsearch 比传统的那些数据库,比如,PostgreSQL 和 MongoDB 耗费的资源要多很多,这样会使托管主机的成本增加很多。 ### 9.1 - 与数据库的同步 -在大多数应用程序,将数据全部保存在 Elasticsearch 并不是个好的选择。最好是使用 ES 作为应用程序的主要事务数据库,但是一般不推荐这样做,因为在 Elasticsearch 中缺少 ACID,如果在处理数据的时候发生伸缩行为,它将丢失写操作。在许多案例中,ES 服务器更多是一个特定的角色,比如做应用程序中的一个文本搜索功能。这种特定的用途,要求它从主数据库中复制数据到 Elasticsearch 实例中。 +对于大多数应用程序,将数据全部保存在 Elasticsearch 并不是个好的选择。可以使用 ES 作为应用程序的主要事务数据库,但是一般不推荐这样做,因为在 Elasticsearch 中缺少 ACID,如果大量读取数据的时候,它能导致写操作丢失。在许多案例中,ES 服务器更多是一个特定的角色,比如做应用程序中的一个文本搜索功能。这种特定的用途,要求它从主数据库中复制数据到 Elasticsearch 实例中。 -比如,假设我们将用户信息保存在一个 PostgreSQL 表中,但是用 Elasticsearch 去驱动我们的用户搜索功能。如果一个用户,比如,"Albert",决定将他的名字改成 "Al",我们将需要把这个变化同时反映到我们主要的 PostgreSQL 数据库和辅助的 Elasticsearch 集群中。 +比如,假设我们将用户信息保存在一个 PostgreSQL 表中,但是用 Elasticsearch 去提供我们的用户搜索功能。如果一个用户,比如,“Albert”,决定将他的名字改成 “Al”,我们将需要把这个变化同时反映到我们主要的 PostgreSQL 数据库和辅助的 Elasticsearch 集群中。 正确地集成它们可能比较棘手,最好的答案将取决于你现有的应用程序栈。这有多种开源方案可选,从 [用一个进程去关注 MongoDB 操作日志][41] 并自动同步检测到的变化到 ES,到使用一个 [PostgresSQL 插件][42] 去创建一个定制的、基于 PSQL 的索引来与 Elasticsearch 进行自动沟通。 -如果没有有效的预构建选项可用,你可能需要在你的服务器代码中增加一些钩子,这样可以基于数据库的变化来手动更新 Elasticsearch 索引。最后一招,我认为是一个最后的选择,因为,使用定制的业务逻辑去保持 ES 的同步可能很复杂,这将会给应用程序引入很多的 bugs。 +如果没有有效的预构建选项可用,你可能需要在你的服务器代码中增加一些钩子,这样可以基于数据库的变化来手动更新 Elasticsearch 索引。最后一招,我认为是一个最后的选择,因为,使用定制的业务逻辑去保持 ES 的同步可能很复杂,这将会给应用程序引入很多的 bug。 让 Elasticsearch 与一个主数据库同步,将使它的架构更加复杂,其复杂性已经超越了 ES 的相关缺点,但是当在你的应用程序中考虑添加一个专用的搜索引擎的利弊得失时,这个问题是值的好好考虑的。 ### 总结 -在很多现在流行的应用程序中,全文搜索是一个非常重要的功能 —— 而且是很难实现的一个功能。对于在你的应用程序中添加一个快速而又可定制的文本搜索,Elasticsearch 是一个非常好的选择,但是,在这里也有一个替代者。[Apache Solr][43] 是一个类似的开源搜索平台,它是基于 Apache Lucene 构建的,它与 Elasticsearch 的核心库是相同的。[Algolia][44] 是一个搜索即服务的 Web 平台,它已经很快流行了起来,并且它对新手非常友好,很易于上手(但是作为折衷,它的可定制性较小,并且使用成本较高)。 +在很多现在流行的应用程序中,全文搜索是一个非常重要的功能 —— 而且是很难实现的一个功能。对于在你的应用程序中添加一个快速而又可定制的文本搜索,Elasticsearch 是一个非常好的选择,但是,在这里也有一个替代者。[Apache Solr][43] 是一个类似的开源搜索平台,它是基于 Apache Lucene 构建的,与 Elasticsearch 的核心库是相同的。[Algolia][44] 是一个搜索即服务的 Web 平台,它已经很快流行了起来,并且它对新手非常友好,很易于上手(但是作为折衷,它的可定制性较小,并且使用成本较高)。 -“搜索” 特性并不是 Elasticsearch 唯一功能。ES 也是日志存储和分析的常用工具,在一个 ELK(Elasticsearch、Logstash、Kibana)栈配置中通常会使用它。灵活的全文搜索功能使得 Elasticsearch 在数据量非常大的科学任务中用处很大 —— 比如,在一个数据集中正确的/标准化的条目拼写,或者为了类似的词组搜索一个文本数据集。 +“搜索” 特性并不是 Elasticsearch 唯一功能。ES 也是日志存储和分析的常用工具,在一个 ELK(Elasticsearch、Logstash、Kibana)架构配置中通常会使用它。灵活的全文搜索功能使得 Elasticsearch 在数据量非常大的科学任务中用处很大 —— 比如,在一个数据集中正确的/标准化的条目拼写,或者为了类似的词组搜索一个文本数据集。 对于你自己的项目,这里有一些创意。 * 添加更多你喜欢的书到教程的应用程序中,然后创建你自己的私人图书馆搜索引擎。 - * 利用来自 [Google Scholar][2] 的论文索引,创建一个学术抄袭检测引擎。 - * 通过将字典中的每个词索引到 Elasticsearch,创建一个拼写检查应用程序。 - * 通过将 [Common Crawl Corpus][3] 加载到 Elasticsearch 中,构建你自己的与谷歌竞争的因特网搜索引擎(注意,它可能会超过 50 亿个页面,这是一个成本极高的数据集)。 - * 在 journalism 上使用 Elasticsearch:在最近的大规模泄露的文档中搜索特定的名字和关键词,比如, [Panama Papers][4] 和 [Paradise Papers][5]。 本教程中应用程序的源代码是 100% 公开的,你可以在 GitHub 仓库上找到它们 —— [https://github.com/triestpa/guttenberg-search][45] @@ -1324,7 +1274,7 @@ via: https://blog.patricktriest.com/text-search-docker-elasticsearch/ 作者:[Patrick Triest][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 7ea87f7b1877ce41ace45d0496922696f6e00333 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 29 Apr 2018 23:01:47 +0800 Subject: [PATCH 0707/1057] PUB:20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md @qhwdw --- ...LDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md (100%) diff --git a/translated/tech/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md b/published/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md similarity index 100% rename from translated/tech/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md rename to published/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md From 74b51c6832b5b34c7ab5d7cb890b33683fcd6301 Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Mon, 30 Apr 2018 12:57:31 +0800 Subject: [PATCH 0708/1057] translated by kennethXia --- ...ts You Safely Create Bootable USB Drive.md | 176 ------------------ ...ts You Safely Create Bootable USB Drive.md | 170 +++++++++++++++++ 2 files changed, 170 insertions(+), 176 deletions(-) delete mode 100644 sources/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md create mode 100644 translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md diff --git a/sources/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md b/sources/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md deleted file mode 100644 index 46f90e5f11..0000000000 --- a/sources/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md +++ /dev/null @@ -1,176 +0,0 @@ -Translating by kennethXia - -Bootiso Lets You Safely Create Bootable USB Drive -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/04/USB-drive-720x340.png) -Howdy newbies! Some of you may often use **dd command** to do various things, like creating a USB drive or cloning disk partitions. Please be mindful that dd command is one of the dangerous and destructive command. If you’re Linux beginner, mostly avoid using dd command to do stuffs. If you don’t know what you are doing, you may wipe your hard drive in minutes. The dd command literally just takes bytes from **if** and writes them to **of**. It doesn’t care what it’s overwriting, it doesn’t care if there’s a partition table in the way, or a boot sector, or a home folder, or anything important. It will simply do what it is told to do. Instead, use some user-friendly apps like [**Etcher**][1]. So you will know which device you’re going to format before actually start creating bootable USB devices. - -Today, I stumbled upon yet another utility named **“Bootiso”** , which is also used to safely create bootable USB drive. It is actually a BASH script, and is brilliant! It has some extra features that helps us to safely create bootable USB devices. If you want to be sure you’re targeting a USB device (and not internal drive), or if you want autodetection of a USB device, you can use bootiso. Here is the significant advantages of using this script: - - * If there is only one USB drive, Bootiso will automatically select it. - * If there are more than one USB drives present, it lets you to choose one of them from the list. - * Just in case you mistakenly choose one of Internal hard drive, it will exit without doing anything. - * It checks the selected ISO has the correct mime-type. If it has wrong mime-type, it will exit. - * It asserts that the selected item is not a partition and exit if it doesn’t. - * It will prompt the user confirmation before erasing and partitioning the USB drive. - * Lists available USB drives. - * Installs syslinux bootloader (optional). - * Free and Open Source. - - - -### Safely Create Bootable USB Drive Using Bootiso - -Installing Bootiso is very easy. Download the latest version using command: -``` -$ curl -L https://rawgit.com/jsamr/bootiso/latest/bootiso -O - -``` - -Move the downloaded file to your **$PATH** , for example /usr/local/bin/. -``` -$ sudo cp bootiso /usr/local/bin/ - -``` - -Finally, make it executable: -``` -$ sudo chmod +x /usr/local/bin/bootiso - -``` - -Done! Now, it is time to create bootable USB drives. First, let us see how many USB drives are present using command: -``` -$ bootiso -l - -``` - -Sample output: -``` -Listing USB drives available in your system: -NAME HOTPLUG SIZE STATE TYPE -sdb 1 7.5G running disk - -``` - -As you can see, I have only one USB drive. Let us go ahead and create the USB bootable from an ISO file using command: -``` -$ bootiso bionic-desktop-amd64.iso - -``` - -This command will prompt you to enter the sudo password. Type the password and hit ENTER key to install the missing dependencies (if there are any) and then create USB bootable device. - -Sample output: -``` -[...] -Listing USB drives available in your system: -NAME HOTPLUG SIZE STATE TYPE -sdb 1 7.5G running disk -Autoselecting `sdb' (only USB device candidate) -The selected device `/dev/sdb' is connected through USB. -Created ISO mount point at `/tmp/iso.c5m' -`bootiso' is about to wipe out the content of device `/dev/sdb'. -Are you sure you want to proceed? (y/n)>y -Erasing contents of /dev/sdb... -Creating FAT32 partition on `/dev/sdb1'... -Created USB device mount point at `/tmp/usb.QgV' -Copying files from ISO to USB device with `rsync' -Synchronizing writes on device `/dev/sdb' -`bootiso' took 303 seconds to write ISO to USB device with `rsync' method. -ISO succesfully unmounted. -USB device succesfully unmounted. -USB device succesfully ejected. -You can safely remove it ! - -``` - -If the your ISO file has the wrong mime-type, you will see the following error message: -``` -Provided file `bionic-desktop-amd64.iso' doesn't seem to be an iso file (wrong mime type: `application/octet-stream'). -Exiting bootiso... - -``` - -You can, however, skip the mime-type check using **–no-mime-check** option like below. -``` -$ bootiso --no-mime-check bionic-desktop-amd64.iso - -``` - -Like I already mentioned, Bootiso will automatically choose the USB drive if there is only one USB drive present in your system. So, we don’t need to mention the usb disk path. If you have more than one devices connected, you can explicitly specify the USB device using **-d** flag like below. -``` -$ bootiso -d /dev/sdb bionic-desktop-amd64.iso - -``` - -Replace “/dev/sdb” with your own path. - -If you don’t specify **-d** flag when using more than one USB devices, Bootiso will prompt you to select from available USB drives. - -Bootiso will ask the user confirmation before erasing and partitioning the USB devices. To auto-confirm this, use **-y** or **–assume-yes** flag. -``` -$ bootiso -y bionic-desktop-amd64.iso - -``` - -You can also enable autoselecting USB devices in conjunction with **-y** option as shown below. -``` -$ bootiso -y -a bionic-desktop-amd64.iso - -``` - -Or, -``` -$ bootiso --assume-yes --autoselect bionic-desktop-amd64.iso - -``` - -Please remember it will work only if you have only one connected USB drive. - -By default, Bootiso will create a **FAT 32** partition and then mount and copy the ISO contents using **“rsync”** program to your USB drive. You can also use “dd” instead of “rsync” if you want. -``` -$ bootiso --dd -d /dev/sdb bionic-desktop-amd64.iso - -``` - -If you want to increase the odds your USB will be bootable, use **“-b”** or **“–bootloader”** like below. -``` -$ bootiso -b bionic-desktop-amd64.iso - -``` - -The above command will install a bootloader with **syslinux** (safe mode). Please note that it doesn’t work if you use “–dd” option. - -After creating the bootable device, Bootiso will automatically eject the USB drive. If you don’t want it to automatically eject it, use **-J** or **–no-eject** flag. -``` -$ bootiso -J bionic-desktop-amd64.iso - -``` - -Now, the USb device will remain connected. You can unmount it at anytime using “umount” command. - -To display help section, run: -``` -$ bootiso -h - -``` - -And, that’s all for now. Hope this script helps. More good stuffs to come. Stay tuned! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/bootiso-lets-you-safely-create-bootable-usb-drive/ - -作者:[SK][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://www.ostechnix.com/author/sk/ -[1]:https://www.ostechnix.com/etcher-beauitiful-app-create-bootable-sd-cards-usb-drives/ diff --git a/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md b/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md new file mode 100644 index 0000000000..b0d6f088f5 --- /dev/null +++ b/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md @@ -0,0 +1,170 @@ +Bootiso 让你安全地创建 USB 启动设备 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/04/USB-drive-720x340.png) +你好,新兵!你们有些人经常使用 **dd 命令**做各种各样的事,比如创建 USB 启动盘或者克隆硬盘分区。不过请牢记,dd 是一个危险且有毁灭性的命令。如果你是个 Linux 的新手,最好避免使用 dd 命令。如果你不知道你在做什么,你可能会在几分钟里把硬盘擦掉。从原理上说,dd 只是从 **“if”** 读取然后写到 **“of”** 上。它才不管往哪里写呢。它根本不关心那里是否有分区表、引导区、家目录或是其他重要的东西。你叫它做什么它就做什么。可以使用像 [**Etcher**][1] 这样的用户友好的应用来代替它。这样你就可以在创建 USB 引导设备之前知道你将要格式化的是哪块盘。 + +今天,我发现了另一个可以安全创建 USB 引导设备的工具 **Bootiso** 。它实际上是一个 BASH 脚本,但真的很智能!它有很多额外的功能来帮我们安全创建 USB 引导盘。如果你想确定你的目标是 USB 设备(而不是内部驱动器),或者如果你想检测 USB 设备,你可以使用 Bootiso。下面是使用此脚本的显著优点: + + * 如果只有一个 USB 驱动器,Bootiso 会自动选择它。 + * 如果有一个以上的 USB 驱动器存在,它可以让你从列表中选择其中一个。 + * 万一你错误地选择一个内部硬盘驱动器,它将退出而不做任何事情。 + * 它检查选定的 ISO 是否具有正确的 MIME 类型。如果 MIME 类型不正确,它将退出。 + * 它判定所选的项目不是分区,如果判定失败则退出。 + * 它将在擦除和分区 USB 驱动器之前提示用户确认。 + * 列出可用的 USB 驱动器。 + * 安装 syslinux 引导系统 (可选)。 + * 自由且开源。 + +### 使用 Bootiso 安全地创建 USB 驱动器 + +安装 Bootiso 非常简单。用这个命令下载最新版本: +``` +$ curl -L https://rawgit.com/jsamr/bootiso/latest/bootiso -O + +``` + +把下载的文件加到 **$PATH** 目录中,比如 /usr/local/bin/. +``` +$ sudo cp bootiso /usr/local/bin/ + +``` + +最后,添加运行权限: +``` +$ sudo chmod +x /usr/local/bin/bootiso + +``` + +搞定!现在就可以创建 USB 引导设备了。首先,让我们用命令看看现在有哪些 USB 驱动器: +``` +$ bootiso -l + +``` + +输出: +``` +Listing USB drives available in your system: +NAME HOTPLUG SIZE STATE TYPE +sdb 1 7.5G running disk + +``` + +如你所见,我只有一个 USB 驱动器。让我们继续通过命令用 ISO 文件创建 USB 启动盘: +``` +$ bootiso bionic-desktop-amd64.iso + +``` + +这个命令会提示你输入 SUDO 密码。输入密码并回车来安装缺失的组件(如果有的话),然后创建 USB 启动盘。 + +输出: +``` +[...] +Listing USB drives available in your system: +NAME HOTPLUG SIZE STATE TYPE +sdb 1 7.5G running disk +Autoselecting `sdb' (only USB device candidate) +The selected device `/dev/sdb' is connected through USB. +Created ISO mount point at `/tmp/iso.c5m' +`bootiso' is about to wipe out the content of device `/dev/sdb'. +Are you sure you want to proceed? (y/n)>y +Erasing contents of /dev/sdb... +Creating FAT32 partition on `/dev/sdb1'... +Created USB device mount point at `/tmp/usb.QgV' +Copying files from ISO to USB device with `rsync' +Synchronizing writes on device `/dev/sdb' +`bootiso' took 303 seconds to write ISO to USB device with `rsync' method. +ISO succesfully unmounted. +USB device succesfully unmounted. +USB device succesfully ejected. +You can safely remove it ! + +``` + +如果你的 ISO 文件 mine 类型不对,你会得到下列错误信息: +``` +Provided file `bionic-desktop-amd64.iso' doesn't seem to be an iso file (wrong mime type: `application/octet-stream'). +Exiting bootiso... + +``` + +当然,你也能像下面那样使用 **–no-mime-check** 选项来跳过 mime 类型检查。 +``` +$ bootiso --no-mime-check bionic-desktop-amd64.iso + +``` + +就像我前面提到的,如果系统里只有1个 USB 设备 Bootiso 将自动选中它。所以我们不需要告诉它 USB 设备路径。如果你连接了多个设备,你可以像下面这样使用 **-d** 来指明 USB 设备。 +``` +$ bootiso -d /dev/sdb bionic-desktop-amd64.iso + +``` + +用你自己的设备路径来换掉 “/dev/sdb”. + +在多个设备情况下,如果你没有使用 **-d** 来指明要使用的设备,Bootiso 会提示你选择可用的 USB 设备。 + +Bootiso 在擦除和改写 USB 盘分区前会要求用户确认。使用 **-y** 或 **–assume-yes** 选项可以跳过这一步。 +``` +$ bootiso -y bionic-desktop-amd64.iso + +``` + +您也可以把自动选择 USB 设备与 **-y** 选项连用,如下所示。 +``` +$ bootiso -y -a bionic-desktop-amd64.iso + +``` + +或者, +``` +$ bootiso?--assume-yes?--autoselect bionic-desktop-amd64.iso + +``` + +请记住,当你只连接一个 USB 驱动器时,它才会起作用。 + +Bootiso 会默认创建一个 **FAT 32** 分区,挂载后用 **“rsync”** 程序把 ISO 的内容拷贝到 USB 盘里。 如果你愿意也可以使用 “dd” 代替 “rsync” 。 +``` +$ bootiso --dd -d /dev/sdb bionic-desktop-amd64.iso + +``` + +如果你想增加 USB 引导的成功概率,请使用 **“-b”** 或 **“–bootloader”** 选项。 +``` +$ bootiso -b bionic-desktop-amd64.iso + +``` + +上面这条命令会安装 **syslinux** 引导程序(安全模式)。注意,“–dd” 选项不可用. + +在创建引导设备后,Bootiso 会自动弹出 USB 设备。如果不想自动弹出,请使用 **-J** 或 **–no-eject** 选项。 +``` +$ bootiso -J bionic-desktop-amd64.iso + +``` + +现在,USB 设备依然连接中。你可以使用 “umount” 命令随时卸载它。 + +需要完整帮助信息,请输入: +``` +$ bootiso -h + +好,今天就到这里。希望这个脚本对你有帮助。好货不断,不要走开哦! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/bootiso-lets-you-safely-create-bootable-usb-drive/ + +作者:[SK][a] +译者:[kennethXia](https://github.com/kennethXia) +校对:[校对者ID](https://github.com/校对者ID) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/etcher-beauitiful-app-create-bootable-sd-cards-usb-drives/ From 23bf508bb735c8bdd6f9c8f73ea36ddfc666fe7c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 30 Apr 2018 20:08:15 +0800 Subject: [PATCH 0709/1057] PRF:20171102 Testing IPv6 Networking in KVM- Part 1.md @qhwdw --- ... Testing IPv6 Networking in KVM- Part 1.md | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/translated/tech/20171102 Testing IPv6 Networking in KVM- Part 1.md b/translated/tech/20171102 Testing IPv6 Networking in KVM- Part 1.md index 45a696511f..ca05272493 100644 --- a/translated/tech/20171102 Testing IPv6 Networking in KVM- Part 1.md +++ b/translated/tech/20171102 Testing IPv6 Networking in KVM- Part 1.md @@ -1,53 +1,55 @@ 在 KVM 中测试 IPv6 网络(第 1 部分) ====== +> 在这个两篇的系列当中,我们将学习关于 IPv6 私有地址的知识,以及如何在 KVM 中配置测试网络。 + ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ipv6-networking.png?itok=swQPV8Ey) 要理解 IPv6 地址是如何工作的,没有比亲自动手去实践更好的方法了,在 KVM 中配置一个小的测试实验室非常容易 —— 也很有趣。这个系列的文章共有两个部分,我们将学习关于 IPv6 私有地址的知识,以及如何在 KVM 中配置测试网络。 ### QEMU/KVM/虚拟机管理器 -我们先来了解什么是 KVM。在这里,我将使用 KVM 来表示 QEMU、KVM、以及虚拟机管理器的一个组合,虚拟机管理器在 Linux 发行版中一般内置了。简单解释就是,QEMU 模拟硬件,而 KVM 是一个内核模块,它在你的 CPU 上创建一个 “访客领地”,并去管理它们对内存和 CPU 的访问。虚拟机管理器是一个涵盖虚拟化和管理程序的图形工具。 +我们先来了解什么是 KVM。在这里,我将使用 KVM 来表示 QEMU、KVM、以及虚拟机管理器的一个组合,虚拟机管理器在 Linux 发行版中一般都内置了。简单解释就是,QEMU 模拟硬件,而 KVM 是一个内核模块,它在你的 CPU 上创建一个 “访客领地”,并去管理它们对内存和 CPU 的访问。虚拟机管理器是一个涵盖虚拟化和管理程序的图形工具。 -但是你不能被图形界面下 “点击” 操作的方式 "缠住" ,因为,它们也有命令行工具可以使用 —— 比如 virsh 和 virt-install。 +但是你不能被图形界面下 “点击” 操作的方式 “缠住” ,因为,它们也有命令行工具可以使用 —— 比如 `virsh` 和 `virt-install`。 如果你在使用 KVM 方面没有什么经验,你可以从 [在 KVM 中创建虚拟机:第 1 部分][1] 和 [在 KVM 中创建虚拟机:第 2 部分 - 网络][2] 开始学起。 ### IPv6 唯一本地地址 -在 KVM 中配置 IPv6 网络与配置 IPv4 网络很类似。它们的主要不同在于这些怪异的长地址。[上一次][3],我们讨论了 IPv6 地址的不同类型。其中有一个 IPv6 单播地址类,fc00::/7(详细情况请查阅 [RFC 4193][4]),它类似于 IPv4 中的私有地址 —— 10.0.0.0/8、172.16.0.0/12、和 192.168.0.0/16。 +在 KVM 中配置 IPv6 网络与配置 IPv4 网络很类似。它们的主要不同在于这些怪异的长地址。[上一次][3],我们讨论了 IPv6 地址的不同类型。其中有一个 IPv6 单播地址类,`fc00::/7`(详细情况请查阅 [RFC 4193][4]),它类似于 IPv4 中的私有地址 —— `10.0.0.0/8`、`172.16.0.0/12`、和 `192.168.0.0/16`。 下图解释了这个唯一本地地址空间的结构。前 48 位定义了前缀和全局 ID,随后的 16 位是子网,剩余的 64 位是接口 ID: -``` -| 7 bits |1| 40 bits | 16 bits | 64 bits | -+--------|-+------------|-----------|----------------------------+ -| Prefix |L| Global ID | Subnet ID | Interface ID | -+--------|-+------------|-----------|----------------------------+ +``` +| 7 bits |1| 40 bits | 16 bits | 64 bits | ++--------+-+------------+-----------+----------------------------+ +| Prefix |L| Global ID | Subnet ID | Interface ID | ++--------+-+------------+-----------+----------------------------+ ``` 下面是另外一种表示方法,它可能更有助于你理解这些地址是如何管理的: -``` -| Prefix | Global ID | Subnet ID | Interface ID | -+--------|--------------|-------------|----------------------+ -| fd | 00:0000:0000 | 0000 | 0000:0000:0000:0000 | -+--------|--------------|-------------|----------------------+ +``` +| Prefix | Global ID | Subnet ID | Interface ID | ++--------+--------------+-------------+----------------------+ +| fd | 00:0000:0000 | 0000 | 0000:0000:0000:0000 | ++--------+--------------+-------------+----------------------+ ``` -fc00::/7 共分成两个 /8 地址块,fc00::/8 和 fd00::/8。fc00::/8 是为以后使用保留的。因此,唯一本地地址通常都是以 fd 开头的,而剩余部分是由你使用的。L 位,也就是第八位,它总是设置为 1,这样它可以表示为 fd00::/8。设置为 0 时,它就表示为 fc00::/8。你可以使用 `subnetcalc` 来看到这些东西: +`fc00::/7` 共分成两个 `/8` 地址块,`fc00::/8` 和 `fd00::/8`。`fc00::/8` 是为以后使用保留的。因此,唯一本地地址通常都是以 `fd` 开头的,而剩余部分是由你使用的。`L` 位,也就是第八位,它总是设置为 `1`,这样它可以表示为 `fd00::/8`。设置为 `0` 时,它就表示为 `fc00::/8`。你可以使用 `subnetcalc` 来看到这些东西: + ``` $ subnetcalc fd00::/8 -n -Address = fd00:: - fd00 = 11111101 00000000 +Address = fd00:: + fd00 = 11111101 00000000 $ subnetcalc fc00::/8 -n -Address = fc00:: - fc00 = 11111100 00000000 - +Address = fc00:: + fc00 = 11111100 00000000 ``` -RFC 4193 要求地址必须随机产生。你可以用你选择的任何方法来造出个地址,只要它们以 `fd` 打头就可以,因为 IPv6 范围非常大,它不会因为地址耗尽而无法使用。当然,最佳实践还是按 RFCs 的要求来做。地址不能按顺序分配或者使用众所周知的数字。RFC 4193 包含一个构建伪随机地址生成器的算法,或者你可以在线找到任何生成器产生的数字。 +RFC 4193 要求地址必须随机产生。你可以用你选择的任何方法来造出个地址,只要它们以 `fd` 打头就可以,因为 IPv6 范围非常大,它不会因为地址耗尽而无法使用。当然,最佳实践还是按 RFC 的要求来做。地址不能按顺序分配或者使用众所周知的数字。RFC 4193 包含一个构建伪随机地址生成器的算法,或者你可以找到各种在线生成器。 唯一本地地址不像全局单播地址(它由你的因特网服务提供商分配)那样进行中心化管理,即使如此,发生地址冲突的可能性也是非常低的。当你需要去合并一些本地网络或者想去在不相关的私有网络之间路由时,这是一个非常好的优势。 @@ -61,7 +63,7 @@ RFC4193 建议,不要混用全局单播地址的 AAAA 和 PTR 记录,因为 下周我们将讲解如何在 KVM 中配置这些 IPv6 的地址,并现场测试它们。 -通过来自 Linux 基金会和 edX 的免费在线课程 ["Linux 入门" ][6] 学习更多的 Linux 知识。 +通过来自 Linux 基金会和 edX 的免费在线课程 [“Linux 入门”][6] 学习更多的 Linux 知识。 -------------------------------------------------------------------------------- @@ -69,7 +71,7 @@ via: https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking- 作者:[Carla Schroder][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 1c43fedcdd752d64aa6a35f68fb92d38696b09f6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 30 Apr 2018 20:09:43 +0800 Subject: [PATCH 0710/1057] PUB:20171102 Testing IPv6 Networking in KVM- Part 1.md @qhwdw https://linux.cn/article-9594-1.html --- .../20171102 Testing IPv6 Networking in KVM- Part 1.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171102 Testing IPv6 Networking in KVM- Part 1.md (100%) diff --git a/translated/tech/20171102 Testing IPv6 Networking in KVM- Part 1.md b/published/20171102 Testing IPv6 Networking in KVM- Part 1.md similarity index 100% rename from translated/tech/20171102 Testing IPv6 Networking in KVM- Part 1.md rename to published/20171102 Testing IPv6 Networking in KVM- Part 1.md From 85379d8436aabe4a90f3ba571a6f614c03f2c707 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 30 Apr 2018 20:21:36 +0800 Subject: [PATCH 0711/1057] PRF:20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md @geekpi --- ... To Mobile Devices By Scanning QR Codes.md | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/translated/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md b/translated/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md index bb869bb39e..6d12ac858f 100644 --- a/translated/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md +++ b/translated/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md @@ -2,89 +2,90 @@ ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-720x340.png) -将文件从计算机传输到智能手机并不是什么大问题。你可以使用 USB 线将手机挂载到系统上,然后从文件管理器传输文件。此外,某些第三方应用程序(例如 [**KDE Connect**][1] 和 [**AirDroid**] [2])可帮助你轻松管理和传输系统中的文件至 Android 设备。今天,我偶然发现了一个名为 **“Qr-filetransfer”** 的超酷工具。它允许你通过扫描二维码通过 WiFi 将文件从计算机传输到移动设备而无须离开终端。是的,你没有看错! qr-filetransfer 是一个使用 Go 语言编写的免费的开源命令行工具。在这个简短的教程中,我们将学习如何使用 qr-transfer 将文件从 Linux 传输到任何移动设备。 + +将文件从计算机传输到智能手机并不是什么大问题。你可以使用 USB 线将手机挂载到系统上,然后从文件管理器传输文件。此外,某些第三方应用程序(例如 [KDE Connect][1] 和 [AirDroid] [2])可帮助你轻松管理和传输系统中的文件至 Android 设备。今天,我偶然发现了一个名为 “Qr-filetransfer” 的超酷工具。它允许你通过扫描二维码通过 WiFi 将文件从计算机传输到移动设备而无须离开终端。是的,你没有看错! Qr-filetransfer 是一个使用 Go 语言编写的自由开源命令行工具。在这个简短的教程中,我们将学习如何使用 Qr-filetransfer 将文件从 Linux 传输到任何移动设备。 ### 安装 Qr-filetransfer 首先,在你的系统上安装 Go 语言。 在 Arch Linux 及其衍生版上: + ``` $ sudo pacman -S go - ``` 在基于 RPM 的系统(如 RHEL、CentOS、Fedora)上运行: + ``` $ sudo yum install golang - ``` 或者: + ``` $ sudo dnf install golang - ``` 在基于 DEB 的系统上,例如 Debian、Ubuntu、Linux Mint,你可以使用命令安装它: + ``` $ sudo apt-get install golang - ``` 在 SUSE/openSUSE 上: + ``` $ sudo zypper install golang - ``` -安装 Go 语言后,运行以下命令下载 qr-filetransfer 应用。 +安装 Go 语言后,运行以下命令下载 Qr-filetransfer 应用。 + ``` $ go get github.com/claudiodangelis/qr-filetransfer - ``` -上述命令将在当前工作目录下的一个名为 **“go”** 的目录中下载 qr-filetrnasfer GitHub 仓库的内容。 +上述命令将在当前工作目录下的一个名为 `go` 的目录中下载 Qr-filetransfer GitHub 仓库的内容。 + +将 Qr-filetransfer 的二进制文件复制到 PATH 中,例如 `/usr/local/bin/`。 -将 qt-filetransfer 的二进制文件复制到 PATH 中,例如 /usr/local/bin/。 ``` $ sudo cp go/bin/qr-filetransfer /usr/local/bin/ - ``` 最后,如下使其可执行: + ``` $ sudo chmod +x /usr/local/bin/qr-filetransfer - ``` ### 通过扫描二维码将文件从计算机传输到移动设备 确保你的智能手机已连接到与计算机相同的 WiFi 网络。 -然后,使用要传输的文件的完整路径启动 qt-filetransfer。 +然后,使用要传输的文件的完整路径启动 `qt-filetransfer`。 比如,我要传输一个 mp3 文件。 + ``` $ qr-filetransfer Chill\ Study\ Beats.mp3 - ``` -首次启动时,qr-filetransfer 会要求你选择使用的网络接口,如下所示。 +首次启动时,`qr-filetransfer` 会要求你选择使用的网络接口,如下所示。 + ``` Choose the network interface to use (type the number): [0] enp5s0 [1] wlp9s0 - ``` -我打算使用 **wlp9s0** 接口传输文件,因此我输入 “1”。qr-filetransfer 会记住这个选择,除非你通过 **-force** 参数或删除程序存储在当前用户的家目录中的 **.qr-filetransfer.json** 文件,否则永远不会再提示你。 +我打算使用 wlp9s0 接口传输文件,因此我输入 “1”。`qr-filetransfer` 会记住这个选择,除非你通过 `-force` 参数或删除程序存储在当前用户的家目录中的 `.qr-filetransfer.json` 文件,否则永远不会再提示你。 然后,你将看到二维码,如下图所示。 ![][4] -打开二维码应用(如果它尚未安装,请从 Play 商店安装任何一个二维码读取程序)并扫描终端中显示的二维码。 +打开二维码应用(如果尚未安装,请从 Play 商店安装任何一个二维码读取程序)并扫描终端中显示的二维码。 读取二维码后,系统会询问你是要复制链接还是打开链接。你可以复制链接并手动将其粘贴到移动网络浏览器上,或者选择“打开链接”以在移动浏览器中自动打开它。 @@ -94,34 +95,32 @@ Choose the network interface to use (type the number): ![][6] -如果文件太大,请压缩文件,然后传输它 +如果文件太大,请压缩文件,然后传输它: + ``` $ qr-filetransfer -zip /path/to/file.txt - ``` 要传输整个目录,请运行: + ``` $ qr-filetransfer /path/to/directory - ``` 请注意,目录在传输之前会被压缩。 -qr-filetransfer 只能将系统中的内容传输到移动设备,反之不能。这个项目非常新,所以会有 bug。如果你遇到了任何 bug,请在本指南最后给出的 GitHub 页面上报告。 +`qr-filetransfer` 只能将系统中的内容传输到移动设备,反之不能。这个项目非常新,所以会有 bug。如果你遇到了任何 bug,请在本指南最后给出的 GitHub 页面上报告。 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/transfer-files-from-computer-to-mobile-devices-by-scanning-qr-codes/ 作者:[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 8ebdf84c070521c51f032383bb77de5ddf336e0b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 30 Apr 2018 20:22:02 +0800 Subject: [PATCH 0712/1057] PUB:20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md @geekpi --- ... Files From Computer To Mobile Devices By Scanning QR Codes.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md (100%) diff --git a/translated/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md b/published/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md similarity index 100% rename from translated/tech/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md rename to published/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md From 00b0b86934ef95f5bb610ac5c17cc29abd326cbf Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 30 Apr 2018 22:19:41 +0800 Subject: [PATCH 0713/1057] Update 20180126 How To Manage NodeJS Packages Using Npm.md --- .../tech/20180126 How To Manage NodeJS Packages Using Npm.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md b/sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md index ac27816a7b..e21522944b 100644 --- a/sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md +++ b/sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + How To Manage NodeJS Packages Using Npm ====== From ba29496f23be05956f6cf518d9c7aaea07f7b26d Mon Sep 17 00:00:00 2001 From: kennethXia <37970750+kennethXia@users.noreply.github.com> Date: Tue, 1 May 2018 07:37:37 +0800 Subject: [PATCH 0714/1057] translating by kennethXia --- sources/tech/20180412 Getting started with Jenkins Pipelines.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180412 Getting started with Jenkins Pipelines.md b/sources/tech/20180412 Getting started with Jenkins Pipelines.md index 1cda5ee0c2..8fa216396c 100644 --- a/sources/tech/20180412 Getting started with Jenkins Pipelines.md +++ b/sources/tech/20180412 Getting started with Jenkins Pipelines.md @@ -1,3 +1,5 @@ +translating by kennethXia + Getting started with Jenkins Pipelines ====== From 4d2f00d54a73329ad29fb05fd3f3b6acdcbbe4c5 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Tue, 1 May 2018 09:19:43 +0800 Subject: [PATCH 0715/1057] Update 20180201 IT automation- How to make the case.md --- sources/talk/20180201 IT automation- How to make the case.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 4b70fbff49..19f096051e 100644 --- a/sources/talk/20180201 IT automation- How to make the case.md +++ b/sources/talk/20180201 IT automation- How to make the case.md @@ -1,4 +1,4 @@ -IT automation: How to make the case +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. From ccc847416b03f9ae27e8cc3a001c3867f14f05e7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 1 May 2018 22:56:13 +0800 Subject: [PATCH 0716/1057] =?UTF-8?q?=E5=BD=92=E6=A1=A3201804?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20090211 Page Cache the Affair Between Memory and Files.md | 0 ...10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md | 0 .../20150703 Let-s Build A Simple Interpreter. Part 2..md | 0 .../20150812 Let-s Build A Simple Interpreter. Part 3..md | 0 .../20170101 How to resolve mount.nfs- Stale file handle error.md | 0 ...d Folders From Accidental Deletion Or Modification In Linux.md | 0 ...8 Ansible Tutorial- Intorduction to simple Ansible commands.md | 0 ...arning wars- Facebook-backed PyTorch vs Google-s TensorFlow.md | 0 .../20170927 Best Linux Distros for the Enterprise.md | 0 .../20170927 Linux directory structure- -lib explained.md | 0 published/{ => 201804}/20170928 Process Monitoring.md | 0 .../20171002 Linux Gunzip Command Explained with Examples.md | 0 .../20171010 How to test internet speed in Linux terminal.md | 0 .../20171014 Proxy Models in Container Environments.md | 0 published/{ => 201804}/20171016 5 SSH alias examples in Linux.md | 0 ...8 Install a Centralized Log Server with Rsyslog in Debian 9.md | 0 .../{ => 201804}/20171027 Scary Linux commands for Halloween.md | 0 .../20171102 Testing IPv6 Networking in KVM- Part 1.md | 0 ...109 How to record statistics about a Linux machine-s uptime.md | 0 .../20171113 My Adventure Migrating Back To Windows.md | 0 .../{ => 201804}/20171113 The big break in computer languages.md | 0 .../20171123 Why microservices are a security issue.md | 0 .../20171205 7 rules for avoiding documentation pitfalls.md | 0 .../20171205 What DevOps teams really need from a CIO.md | 0 .../20171207 How to use KVM cloud images on Ubuntu Linux.md | 0 .../20171212 Oh My Fish- Make Your Shell Beautiful.md | 0 .../20171219 How to generate webpages using CGI scripts.md | 0 .../20171219 How to set GNOME to display a custom slideshow.md | 0 .../20171228 Testing Ansible Playbooks With Vagrant.md | 0 ...80102 The Uniq Command Tutorial With Examples For Beginners.md | 0 published/{ => 201804}/20180104 How does gdb call functions.md | 0 ...0109 Linux size Command Tutorial for Beginners (6 Examples).md | 0 .../20180110 8 simple ways to promote team communication.md | 0 ...0 Why isn-t open source hot among computer science students.md | 0 ...111 AI and machine learning bias has dangerous implications.md | 0 .../{ => 201804}/20180116 Monitor your Kubernetes Cluster.md | 0 .../20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md | 0 .../20180118 Securing the Linux filesystem with Tripwire.md | 0 published/{ => 201804}/20180122 How to Create a Docker Image.md | 0 .../{ => 201804}/20180123 Migrating to Linux- The Command Line.md | 0 ...LDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md | 0 .../{ => 201804}/20180127 Your instant Kubernetes cluster.md | 0 ... to add network bridge with nmcli (NetworkManager) on Linux.md | 0 .../20180129 A look inside Facebooks open source program.md | 0 published/{ => 201804}/20180129 How to Use DockerHub.md | 0 ...AWFFull web server log analysis application on ubuntu 17.10.md | 0 ...180130 Linux ln Command Tutorial for Beginners (5 Examples).md | 0 ...k Look at the Arch Based Indie Linux Distribution- MagpieOS.md | 0 ...0180206 How to start an open source program in your company.md | 0 published/{ => 201804}/20180206 Manage printers and printing.md | 0 .../{ => 201804}/20180206 Programming in Color with ncurses.md | 0 .../20180207 Python Global Keyword (With Examples).md | 0 ... Hollywood movie hacker with these three command line tools.md | 0 ...20180213 How to clone, modify, add, and delete files in Git.md | 0 published/{ => 201804}/20180214 11 awesome vi tips and tricks.md | 0 ... Code Integrity with PGP - Part 1- Basic Concepts and Tools.md | 0 .../20180215 Check Linux Distribution Name and Version.md | 0 published/{ => 201804}/20180215 What is a Linux -oops.md | 0 .../20180220 How to Get Started Using WSL in Windows 10.md | 0 published/{ => 201804}/20180221 Getting started with SQL.md | 0 ...ode Integrity with PGP - Part 2- Generating Your Master Key.md | 0 .../20180221 cTop - A CLI Tool For Container Monitoring.md | 0 .../20180222 How to configure an Apache web server.md | 0 .../{ => 201804}/20180226 5 keys to building open hardware.md | 0 .../{ => 201804}/20180226 How to Use WSL Like a Linux Pro.md | 0 published/{ => 201804}/20180301 How to add fonts to Fedora.md | 0 ...20180302 10 Quick Tips About sudo command for Linux systems.md | 0 ...pen Source Desktop YouTube Player For Privacy-minded People.md | 0 .../20180308 Dive into BPF a list of reading material.md | 0 .../{ => 201804}/20180312 Continuous integration in Fedora.md | 0 .../{ => 201804}/20180313 Running DOS on the Raspberry Pi.md | 0 ...80313 The Type Command Tutorial With Examples For Beginners.md | 0 published/{ => 201804}/20180314 Playing with water.md | 0 ...20180318 How To Manage Disk Partitions Using Parted Command.md | 0 ...1 The Command line Personal Assistant For Your Linux System.md | 0 ...ow To Find If A CPU Supports Virtualization Technology (VT).md | 0 ...0180323 How to tell when moving to blockchain is a bad idea.md | 0 ... Files From Computer To Mobile Devices By Scanning QR Codes.md | 0 .../{ => 201804}/20180326 Working with calendars on Linux.md | 0 .../20180328 Do continuous deployment with Github and Python.md | 0 ...0328 How To Create-Extend Swap Partition In Linux Using LVM.md | 0 .../20180329 Protect Your Websites with Let-s Encrypt.md | 0 published/{ => 201804}/20180402 Advanced SSH Cheat Sheet.md | 0 published/{ => 201804}/20180405 How to find files in Linux.md | 0 ...0180405 The fc Command Tutorial With Examples For Beginners.md | 0 .../{ => 201804}/20180407 12 Git tips for Git-s 12th birthday.md | 0 .../20180411 Awesome GNOME extensions for developers.md | 0 .../20180412 3 password managers for the Linux command line.md | 0 88 files changed, 0 insertions(+), 0 deletions(-) rename published/{ => 201804}/20090211 Page Cache the Affair Between Memory and Files.md (100%) rename published/{ => 201804}/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md (100%) rename published/{ => 201804}/20150703 Let-s Build A Simple Interpreter. Part 2..md (100%) rename published/{ => 201804}/20150812 Let-s Build A Simple Interpreter. Part 3..md (100%) rename published/{ => 201804}/20170101 How to resolve mount.nfs- Stale file handle error.md (100%) rename published/{ => 201804}/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md (100%) rename published/{ => 201804}/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md (100%) rename published/{ => 201804}/20170915 Deep learning wars- Facebook-backed PyTorch vs Google-s TensorFlow.md (100%) rename published/{ => 201804}/20170927 Best Linux Distros for the Enterprise.md (100%) rename published/{ => 201804}/20170927 Linux directory structure- -lib explained.md (100%) rename published/{ => 201804}/20170928 Process Monitoring.md (100%) rename published/{ => 201804}/20171002 Linux Gunzip Command Explained with Examples.md (100%) rename published/{ => 201804}/20171010 How to test internet speed in Linux terminal.md (100%) rename published/{ => 201804}/20171014 Proxy Models in Container Environments.md (100%) rename published/{ => 201804}/20171016 5 SSH alias examples in Linux.md (100%) rename published/{ => 201804}/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md (100%) rename published/{ => 201804}/20171027 Scary Linux commands for Halloween.md (100%) rename published/{ => 201804}/20171102 Testing IPv6 Networking in KVM- Part 1.md (100%) rename published/{ => 201804}/20171109 How to record statistics about a Linux machine-s uptime.md (100%) rename published/{ => 201804}/20171113 My Adventure Migrating Back To Windows.md (100%) rename published/{ => 201804}/20171113 The big break in computer languages.md (100%) rename published/{ => 201804}/20171123 Why microservices are a security issue.md (100%) rename published/{ => 201804}/20171205 7 rules for avoiding documentation pitfalls.md (100%) rename published/{ => 201804}/20171205 What DevOps teams really need from a CIO.md (100%) rename published/{ => 201804}/20171207 How to use KVM cloud images on Ubuntu Linux.md (100%) rename published/{ => 201804}/20171212 Oh My Fish- Make Your Shell Beautiful.md (100%) rename published/{ => 201804}/20171219 How to generate webpages using CGI scripts.md (100%) rename published/{ => 201804}/20171219 How to set GNOME to display a custom slideshow.md (100%) rename published/{ => 201804}/20171228 Testing Ansible Playbooks With Vagrant.md (100%) rename published/{ => 201804}/20180102 The Uniq Command Tutorial With Examples For Beginners.md (100%) rename published/{ => 201804}/20180104 How does gdb call functions.md (100%) rename published/{ => 201804}/20180109 Linux size Command Tutorial for Beginners (6 Examples).md (100%) rename published/{ => 201804}/20180110 8 simple ways to promote team communication.md (100%) rename published/{ => 201804}/20180110 Why isn-t open source hot among computer science students.md (100%) rename published/{ => 201804}/20180111 AI and machine learning bias has dangerous implications.md (100%) rename published/{ => 201804}/20180116 Monitor your Kubernetes Cluster.md (100%) rename published/{ => 201804}/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md (100%) rename published/{ => 201804}/20180118 Securing the Linux filesystem with Tripwire.md (100%) rename published/{ => 201804}/20180122 How to Create a Docker Image.md (100%) rename published/{ => 201804}/20180123 Migrating to Linux- The Command Line.md (100%) rename published/{ => 201804}/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md (100%) rename published/{ => 201804}/20180127 Your instant Kubernetes cluster.md (100%) rename published/{ => 201804}/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md (100%) rename published/{ => 201804}/20180129 A look inside Facebooks open source program.md (100%) rename published/{ => 201804}/20180129 How to Use DockerHub.md (100%) rename published/{ => 201804}/20180130 Install AWFFull web server log analysis application on ubuntu 17.10.md (100%) rename published/{ => 201804}/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md (100%) rename published/{ => 201804}/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md (100%) rename published/{ => 201804}/20180206 How to start an open source program in your company.md (100%) rename published/{ => 201804}/20180206 Manage printers and printing.md (100%) rename published/{ => 201804}/20180206 Programming in Color with ncurses.md (100%) rename published/{ => 201804}/20180207 Python Global Keyword (With Examples).md (100%) rename published/{ => 201804}/20180208 Become a Hollywood movie hacker with these three command line tools.md (100%) rename published/{ => 201804}/20180213 How to clone, modify, add, and delete files in Git.md (100%) rename published/{ => 201804}/20180214 11 awesome vi tips and tricks.md (100%) rename published/{ => 201804}/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md (100%) rename published/{ => 201804}/20180215 Check Linux Distribution Name and Version.md (100%) rename published/{ => 201804}/20180215 What is a Linux -oops.md (100%) rename published/{ => 201804}/20180220 How to Get Started Using WSL in Windows 10.md (100%) rename published/{ => 201804}/20180221 Getting started with SQL.md (100%) rename published/{ => 201804}/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md (100%) rename published/{ => 201804}/20180221 cTop - A CLI Tool For Container Monitoring.md (100%) rename published/{ => 201804}/20180222 How to configure an Apache web server.md (100%) rename published/{ => 201804}/20180226 5 keys to building open hardware.md (100%) rename published/{ => 201804}/20180226 How to Use WSL Like a Linux Pro.md (100%) rename published/{ => 201804}/20180301 How to add fonts to Fedora.md (100%) rename published/{ => 201804}/20180302 10 Quick Tips About sudo command for Linux systems.md (100%) rename published/{ => 201804}/20180307 An Open Source Desktop YouTube Player For Privacy-minded People.md (100%) rename published/{ => 201804}/20180308 Dive into BPF a list of reading material.md (100%) rename published/{ => 201804}/20180312 Continuous integration in Fedora.md (100%) rename published/{ => 201804}/20180313 Running DOS on the Raspberry Pi.md (100%) rename published/{ => 201804}/20180313 The Type Command Tutorial With Examples For Beginners.md (100%) rename published/{ => 201804}/20180314 Playing with water.md (100%) rename published/{ => 201804}/20180318 How To Manage Disk Partitions Using Parted Command.md (100%) rename published/{ => 201804}/20180321 The Command line Personal Assistant For Your Linux System.md (100%) rename published/{ => 201804}/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md (100%) rename published/{ => 201804}/20180323 How to tell when moving to blockchain is a bad idea.md (100%) rename published/{ => 201804}/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md (100%) rename published/{ => 201804}/20180326 Working with calendars on Linux.md (100%) rename published/{ => 201804}/20180328 Do continuous deployment with Github and Python.md (100%) rename published/{ => 201804}/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md (100%) rename published/{ => 201804}/20180329 Protect Your Websites with Let-s Encrypt.md (100%) rename published/{ => 201804}/20180402 Advanced SSH Cheat Sheet.md (100%) rename published/{ => 201804}/20180405 How to find files in Linux.md (100%) rename published/{ => 201804}/20180405 The fc Command Tutorial With Examples For Beginners.md (100%) rename published/{ => 201804}/20180407 12 Git tips for Git-s 12th birthday.md (100%) rename published/{ => 201804}/20180411 Awesome GNOME extensions for developers.md (100%) rename published/{ => 201804}/20180412 3 password managers for the Linux command line.md (100%) diff --git a/published/20090211 Page Cache the Affair Between Memory and Files.md b/published/201804/20090211 Page Cache the Affair Between Memory and Files.md similarity index 100% rename from published/20090211 Page Cache the Affair Between Memory and Files.md rename to published/201804/20090211 Page Cache the Affair Between Memory and Files.md diff --git a/published/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/published/201804/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md similarity index 100% rename from published/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md rename to published/201804/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md diff --git a/published/20150703 Let-s Build A Simple Interpreter. Part 2..md b/published/201804/20150703 Let-s Build A Simple Interpreter. Part 2..md similarity index 100% rename from published/20150703 Let-s Build A Simple Interpreter. Part 2..md rename to published/201804/20150703 Let-s Build A Simple Interpreter. Part 2..md diff --git a/published/20150812 Let-s Build A Simple Interpreter. Part 3..md b/published/201804/20150812 Let-s Build A Simple Interpreter. Part 3..md similarity index 100% rename from published/20150812 Let-s Build A Simple Interpreter. Part 3..md rename to published/201804/20150812 Let-s Build A Simple Interpreter. Part 3..md diff --git a/published/20170101 How to resolve mount.nfs- Stale file handle error.md b/published/201804/20170101 How to resolve mount.nfs- Stale file handle error.md similarity index 100% rename from published/20170101 How to resolve mount.nfs- Stale file handle error.md rename to published/201804/20170101 How to resolve mount.nfs- Stale file handle error.md diff --git a/published/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md b/published/201804/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md similarity index 100% rename from published/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md rename to published/201804/20170201 Prevent Files And Folders From Accidental Deletion Or Modification In Linux.md diff --git a/published/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md b/published/201804/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md similarity index 100% rename from published/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md rename to published/201804/20170508 Ansible Tutorial- Intorduction to simple Ansible commands.md diff --git a/published/20170915 Deep learning wars- Facebook-backed PyTorch vs Google-s TensorFlow.md b/published/201804/20170915 Deep learning wars- Facebook-backed PyTorch vs Google-s TensorFlow.md similarity index 100% rename from published/20170915 Deep learning wars- Facebook-backed PyTorch vs Google-s TensorFlow.md rename to published/201804/20170915 Deep learning wars- Facebook-backed PyTorch vs Google-s TensorFlow.md diff --git a/published/20170927 Best Linux Distros for the Enterprise.md b/published/201804/20170927 Best Linux Distros for the Enterprise.md similarity index 100% rename from published/20170927 Best Linux Distros for the Enterprise.md rename to published/201804/20170927 Best Linux Distros for the Enterprise.md diff --git a/published/20170927 Linux directory structure- -lib explained.md b/published/201804/20170927 Linux directory structure- -lib explained.md similarity index 100% rename from published/20170927 Linux directory structure- -lib explained.md rename to published/201804/20170927 Linux directory structure- -lib explained.md diff --git a/published/20170928 Process Monitoring.md b/published/201804/20170928 Process Monitoring.md similarity index 100% rename from published/20170928 Process Monitoring.md rename to published/201804/20170928 Process Monitoring.md diff --git a/published/20171002 Linux Gunzip Command Explained with Examples.md b/published/201804/20171002 Linux Gunzip Command Explained with Examples.md similarity index 100% rename from published/20171002 Linux Gunzip Command Explained with Examples.md rename to published/201804/20171002 Linux Gunzip Command Explained with Examples.md diff --git a/published/20171010 How to test internet speed in Linux terminal.md b/published/201804/20171010 How to test internet speed in Linux terminal.md similarity index 100% rename from published/20171010 How to test internet speed in Linux terminal.md rename to published/201804/20171010 How to test internet speed in Linux terminal.md diff --git a/published/20171014 Proxy Models in Container Environments.md b/published/201804/20171014 Proxy Models in Container Environments.md similarity index 100% rename from published/20171014 Proxy Models in Container Environments.md rename to published/201804/20171014 Proxy Models in Container Environments.md diff --git a/published/20171016 5 SSH alias examples in Linux.md b/published/201804/20171016 5 SSH alias examples in Linux.md similarity index 100% rename from published/20171016 5 SSH alias examples in Linux.md rename to published/201804/20171016 5 SSH alias examples in Linux.md diff --git a/published/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md b/published/201804/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md similarity index 100% rename from published/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md rename to published/201804/20171018 Install a Centralized Log Server with Rsyslog in Debian 9.md diff --git a/published/20171027 Scary Linux commands for Halloween.md b/published/201804/20171027 Scary Linux commands for Halloween.md similarity index 100% rename from published/20171027 Scary Linux commands for Halloween.md rename to published/201804/20171027 Scary Linux commands for Halloween.md diff --git a/published/20171102 Testing IPv6 Networking in KVM- Part 1.md b/published/201804/20171102 Testing IPv6 Networking in KVM- Part 1.md similarity index 100% rename from published/20171102 Testing IPv6 Networking in KVM- Part 1.md rename to published/201804/20171102 Testing IPv6 Networking in KVM- Part 1.md diff --git a/published/20171109 How to record statistics about a Linux machine-s uptime.md b/published/201804/20171109 How to record statistics about a Linux machine-s uptime.md similarity index 100% rename from published/20171109 How to record statistics about a Linux machine-s uptime.md rename to published/201804/20171109 How to record statistics about a Linux machine-s uptime.md diff --git a/published/20171113 My Adventure Migrating Back To Windows.md b/published/201804/20171113 My Adventure Migrating Back To Windows.md similarity index 100% rename from published/20171113 My Adventure Migrating Back To Windows.md rename to published/201804/20171113 My Adventure Migrating Back To Windows.md diff --git a/published/20171113 The big break in computer languages.md b/published/201804/20171113 The big break in computer languages.md similarity index 100% rename from published/20171113 The big break in computer languages.md rename to published/201804/20171113 The big break in computer languages.md diff --git a/published/20171123 Why microservices are a security issue.md b/published/201804/20171123 Why microservices are a security issue.md similarity index 100% rename from published/20171123 Why microservices are a security issue.md rename to published/201804/20171123 Why microservices are a security issue.md diff --git a/published/20171205 7 rules for avoiding documentation pitfalls.md b/published/201804/20171205 7 rules for avoiding documentation pitfalls.md similarity index 100% rename from published/20171205 7 rules for avoiding documentation pitfalls.md rename to published/201804/20171205 7 rules for avoiding documentation pitfalls.md diff --git a/published/20171205 What DevOps teams really need from a CIO.md b/published/201804/20171205 What DevOps teams really need from a CIO.md similarity index 100% rename from published/20171205 What DevOps teams really need from a CIO.md rename to published/201804/20171205 What DevOps teams really need from a CIO.md diff --git a/published/20171207 How to use KVM cloud images on Ubuntu Linux.md b/published/201804/20171207 How to use KVM cloud images on Ubuntu Linux.md similarity index 100% rename from published/20171207 How to use KVM cloud images on Ubuntu Linux.md rename to published/201804/20171207 How to use KVM cloud images on Ubuntu Linux.md diff --git a/published/20171212 Oh My Fish- Make Your Shell Beautiful.md b/published/201804/20171212 Oh My Fish- Make Your Shell Beautiful.md similarity index 100% rename from published/20171212 Oh My Fish- Make Your Shell Beautiful.md rename to published/201804/20171212 Oh My Fish- Make Your Shell Beautiful.md diff --git a/published/20171219 How to generate webpages using CGI scripts.md b/published/201804/20171219 How to generate webpages using CGI scripts.md similarity index 100% rename from published/20171219 How to generate webpages using CGI scripts.md rename to published/201804/20171219 How to generate webpages using CGI scripts.md diff --git a/published/20171219 How to set GNOME to display a custom slideshow.md b/published/201804/20171219 How to set GNOME to display a custom slideshow.md similarity index 100% rename from published/20171219 How to set GNOME to display a custom slideshow.md rename to published/201804/20171219 How to set GNOME to display a custom slideshow.md diff --git a/published/20171228 Testing Ansible Playbooks With Vagrant.md b/published/201804/20171228 Testing Ansible Playbooks With Vagrant.md similarity index 100% rename from published/20171228 Testing Ansible Playbooks With Vagrant.md rename to published/201804/20171228 Testing Ansible Playbooks With Vagrant.md diff --git a/published/20180102 The Uniq Command Tutorial With Examples For Beginners.md b/published/201804/20180102 The Uniq Command Tutorial With Examples For Beginners.md similarity index 100% rename from published/20180102 The Uniq Command Tutorial With Examples For Beginners.md rename to published/201804/20180102 The Uniq Command Tutorial With Examples For Beginners.md diff --git a/published/20180104 How does gdb call functions.md b/published/201804/20180104 How does gdb call functions.md similarity index 100% rename from published/20180104 How does gdb call functions.md rename to published/201804/20180104 How does gdb call functions.md diff --git a/published/20180109 Linux size Command Tutorial for Beginners (6 Examples).md b/published/201804/20180109 Linux size Command Tutorial for Beginners (6 Examples).md similarity index 100% rename from published/20180109 Linux size Command Tutorial for Beginners (6 Examples).md rename to published/201804/20180109 Linux size Command Tutorial for Beginners (6 Examples).md diff --git a/published/20180110 8 simple ways to promote team communication.md b/published/201804/20180110 8 simple ways to promote team communication.md similarity index 100% rename from published/20180110 8 simple ways to promote team communication.md rename to published/201804/20180110 8 simple ways to promote team communication.md diff --git a/published/20180110 Why isn-t open source hot among computer science students.md b/published/201804/20180110 Why isn-t open source hot among computer science students.md similarity index 100% rename from published/20180110 Why isn-t open source hot among computer science students.md rename to published/201804/20180110 Why isn-t open source hot among computer science students.md diff --git a/published/20180111 AI and machine learning bias has dangerous implications.md b/published/201804/20180111 AI and machine learning bias has dangerous implications.md similarity index 100% rename from published/20180111 AI and machine learning bias has dangerous implications.md rename to published/201804/20180111 AI and machine learning bias has dangerous implications.md diff --git a/published/20180116 Monitor your Kubernetes Cluster.md b/published/201804/20180116 Monitor your Kubernetes Cluster.md similarity index 100% rename from published/20180116 Monitor your Kubernetes Cluster.md rename to published/201804/20180116 Monitor your Kubernetes Cluster.md diff --git a/published/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md b/published/201804/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md similarity index 100% rename from published/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md rename to published/201804/20180118 Configuring MSMTP On Ubuntu 16.04 (Again).md diff --git a/published/20180118 Securing the Linux filesystem with Tripwire.md b/published/201804/20180118 Securing the Linux filesystem with Tripwire.md similarity index 100% rename from published/20180118 Securing the Linux filesystem with Tripwire.md rename to published/201804/20180118 Securing the Linux filesystem with Tripwire.md diff --git a/published/20180122 How to Create a Docker Image.md b/published/201804/20180122 How to Create a Docker Image.md similarity index 100% rename from published/20180122 How to Create a Docker Image.md rename to published/201804/20180122 How to Create a Docker Image.md diff --git a/published/20180123 Migrating to Linux- The Command Line.md b/published/201804/20180123 Migrating to Linux- The Command Line.md similarity index 100% rename from published/20180123 Migrating to Linux- The Command Line.md rename to published/201804/20180123 Migrating to Linux- The Command Line.md diff --git a/published/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md b/published/201804/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md similarity index 100% rename from published/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md rename to published/201804/20180125 BUILDING A FULL-TEXT SEARCH APP USING DOCKER AND ELASTICSEARCH.md diff --git a/published/20180127 Your instant Kubernetes cluster.md b/published/201804/20180127 Your instant Kubernetes cluster.md similarity index 100% rename from published/20180127 Your instant Kubernetes cluster.md rename to published/201804/20180127 Your instant Kubernetes cluster.md diff --git a/published/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md b/published/201804/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md similarity index 100% rename from published/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md rename to published/201804/20180128 How to add network bridge with nmcli (NetworkManager) on Linux.md diff --git a/published/20180129 A look inside Facebooks open source program.md b/published/201804/20180129 A look inside Facebooks open source program.md similarity index 100% rename from published/20180129 A look inside Facebooks open source program.md rename to published/201804/20180129 A look inside Facebooks open source program.md diff --git a/published/20180129 How to Use DockerHub.md b/published/201804/20180129 How to Use DockerHub.md similarity index 100% rename from published/20180129 How to Use DockerHub.md rename to published/201804/20180129 How to Use DockerHub.md diff --git a/published/20180130 Install AWFFull web server log analysis application on ubuntu 17.10.md b/published/201804/20180130 Install AWFFull web server log analysis application on ubuntu 17.10.md similarity index 100% rename from published/20180130 Install AWFFull web server log analysis application on ubuntu 17.10.md rename to published/201804/20180130 Install AWFFull web server log analysis application on ubuntu 17.10.md diff --git a/published/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md b/published/201804/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md similarity index 100% rename from published/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md rename to published/201804/20180130 Linux ln Command Tutorial for Beginners (5 Examples).md diff --git a/published/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md b/published/201804/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md similarity index 100% rename from published/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md rename to published/201804/20180130 Quick Look at the Arch Based Indie Linux Distribution- MagpieOS.md diff --git a/published/20180206 How to start an open source program in your company.md b/published/201804/20180206 How to start an open source program in your company.md similarity index 100% rename from published/20180206 How to start an open source program in your company.md rename to published/201804/20180206 How to start an open source program in your company.md diff --git a/published/20180206 Manage printers and printing.md b/published/201804/20180206 Manage printers and printing.md similarity index 100% rename from published/20180206 Manage printers and printing.md rename to published/201804/20180206 Manage printers and printing.md diff --git a/published/20180206 Programming in Color with ncurses.md b/published/201804/20180206 Programming in Color with ncurses.md similarity index 100% rename from published/20180206 Programming in Color with ncurses.md rename to published/201804/20180206 Programming in Color with ncurses.md diff --git a/published/20180207 Python Global Keyword (With Examples).md b/published/201804/20180207 Python Global Keyword (With Examples).md similarity index 100% rename from published/20180207 Python Global Keyword (With Examples).md rename to published/201804/20180207 Python Global Keyword (With Examples).md diff --git a/published/20180208 Become a Hollywood movie hacker with these three command line tools.md b/published/201804/20180208 Become a Hollywood movie hacker with these three command line tools.md similarity index 100% rename from published/20180208 Become a Hollywood movie hacker with these three command line tools.md rename to published/201804/20180208 Become a Hollywood movie hacker with these three command line tools.md diff --git a/published/20180213 How to clone, modify, add, and delete files in Git.md b/published/201804/20180213 How to clone, modify, add, and delete files in Git.md similarity index 100% rename from published/20180213 How to clone, modify, add, and delete files in Git.md rename to published/201804/20180213 How to clone, modify, add, and delete files in Git.md diff --git a/published/20180214 11 awesome vi tips and tricks.md b/published/201804/20180214 11 awesome vi tips and tricks.md similarity index 100% rename from published/20180214 11 awesome vi tips and tricks.md rename to published/201804/20180214 11 awesome vi tips and tricks.md diff --git a/published/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md b/published/201804/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md similarity index 100% rename from published/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md rename to published/201804/20180214 Protecting Code Integrity with PGP - Part 1- Basic Concepts and Tools.md diff --git a/published/20180215 Check Linux Distribution Name and Version.md b/published/201804/20180215 Check Linux Distribution Name and Version.md similarity index 100% rename from published/20180215 Check Linux Distribution Name and Version.md rename to published/201804/20180215 Check Linux Distribution Name and Version.md diff --git a/published/20180215 What is a Linux -oops.md b/published/201804/20180215 What is a Linux -oops.md similarity index 100% rename from published/20180215 What is a Linux -oops.md rename to published/201804/20180215 What is a Linux -oops.md diff --git a/published/20180220 How to Get Started Using WSL in Windows 10.md b/published/201804/20180220 How to Get Started Using WSL in Windows 10.md similarity index 100% rename from published/20180220 How to Get Started Using WSL in Windows 10.md rename to published/201804/20180220 How to Get Started Using WSL in Windows 10.md diff --git a/published/20180221 Getting started with SQL.md b/published/201804/20180221 Getting started with SQL.md similarity index 100% rename from published/20180221 Getting started with SQL.md rename to published/201804/20180221 Getting started with SQL.md diff --git a/published/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md b/published/201804/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md similarity index 100% rename from published/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md rename to published/201804/20180221 Protecting Code Integrity with PGP - Part 2- Generating Your Master Key.md diff --git a/published/20180221 cTop - A CLI Tool For Container Monitoring.md b/published/201804/20180221 cTop - A CLI Tool For Container Monitoring.md similarity index 100% rename from published/20180221 cTop - A CLI Tool For Container Monitoring.md rename to published/201804/20180221 cTop - A CLI Tool For Container Monitoring.md diff --git a/published/20180222 How to configure an Apache web server.md b/published/201804/20180222 How to configure an Apache web server.md similarity index 100% rename from published/20180222 How to configure an Apache web server.md rename to published/201804/20180222 How to configure an Apache web server.md diff --git a/published/20180226 5 keys to building open hardware.md b/published/201804/20180226 5 keys to building open hardware.md similarity index 100% rename from published/20180226 5 keys to building open hardware.md rename to published/201804/20180226 5 keys to building open hardware.md diff --git a/published/20180226 How to Use WSL Like a Linux Pro.md b/published/201804/20180226 How to Use WSL Like a Linux Pro.md similarity index 100% rename from published/20180226 How to Use WSL Like a Linux Pro.md rename to published/201804/20180226 How to Use WSL Like a Linux Pro.md diff --git a/published/20180301 How to add fonts to Fedora.md b/published/201804/20180301 How to add fonts to Fedora.md similarity index 100% rename from published/20180301 How to add fonts to Fedora.md rename to published/201804/20180301 How to add fonts to Fedora.md diff --git a/published/20180302 10 Quick Tips About sudo command for Linux systems.md b/published/201804/20180302 10 Quick Tips About sudo command for Linux systems.md similarity index 100% rename from published/20180302 10 Quick Tips About sudo command for Linux systems.md rename to published/201804/20180302 10 Quick Tips About sudo command for Linux systems.md diff --git a/published/20180307 An Open Source Desktop YouTube Player For Privacy-minded People.md b/published/201804/20180307 An Open Source Desktop YouTube Player For Privacy-minded People.md similarity index 100% rename from published/20180307 An Open Source Desktop YouTube Player For Privacy-minded People.md rename to published/201804/20180307 An Open Source Desktop YouTube Player For Privacy-minded People.md diff --git a/published/20180308 Dive into BPF a list of reading material.md b/published/201804/20180308 Dive into BPF a list of reading material.md similarity index 100% rename from published/20180308 Dive into BPF a list of reading material.md rename to published/201804/20180308 Dive into BPF a list of reading material.md diff --git a/published/20180312 Continuous integration in Fedora.md b/published/201804/20180312 Continuous integration in Fedora.md similarity index 100% rename from published/20180312 Continuous integration in Fedora.md rename to published/201804/20180312 Continuous integration in Fedora.md diff --git a/published/20180313 Running DOS on the Raspberry Pi.md b/published/201804/20180313 Running DOS on the Raspberry Pi.md similarity index 100% rename from published/20180313 Running DOS on the Raspberry Pi.md rename to published/201804/20180313 Running DOS on the Raspberry Pi.md diff --git a/published/20180313 The Type Command Tutorial With Examples For Beginners.md b/published/201804/20180313 The Type Command Tutorial With Examples For Beginners.md similarity index 100% rename from published/20180313 The Type Command Tutorial With Examples For Beginners.md rename to published/201804/20180313 The Type Command Tutorial With Examples For Beginners.md diff --git a/published/20180314 Playing with water.md b/published/201804/20180314 Playing with water.md similarity index 100% rename from published/20180314 Playing with water.md rename to published/201804/20180314 Playing with water.md diff --git a/published/20180318 How To Manage Disk Partitions Using Parted Command.md b/published/201804/20180318 How To Manage Disk Partitions Using Parted Command.md similarity index 100% rename from published/20180318 How To Manage Disk Partitions Using Parted Command.md rename to published/201804/20180318 How To Manage Disk Partitions Using Parted Command.md diff --git a/published/20180321 The Command line Personal Assistant For Your Linux System.md b/published/201804/20180321 The Command line Personal Assistant For Your Linux System.md similarity index 100% rename from published/20180321 The Command line Personal Assistant For Your Linux System.md rename to published/201804/20180321 The Command line Personal Assistant For Your Linux System.md diff --git a/published/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md b/published/201804/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md similarity index 100% rename from published/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md rename to published/201804/20180322 How To Find If A CPU Supports Virtualization Technology (VT).md diff --git a/published/20180323 How to tell when moving to blockchain is a bad idea.md b/published/201804/20180323 How to tell when moving to blockchain is a bad idea.md similarity index 100% rename from published/20180323 How to tell when moving to blockchain is a bad idea.md rename to published/201804/20180323 How to tell when moving to blockchain is a bad idea.md diff --git a/published/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md b/published/201804/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md similarity index 100% rename from published/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md rename to published/201804/20180323 Transfer Files From Computer To Mobile Devices By Scanning QR Codes.md diff --git a/published/20180326 Working with calendars on Linux.md b/published/201804/20180326 Working with calendars on Linux.md similarity index 100% rename from published/20180326 Working with calendars on Linux.md rename to published/201804/20180326 Working with calendars on Linux.md diff --git a/published/20180328 Do continuous deployment with Github and Python.md b/published/201804/20180328 Do continuous deployment with Github and Python.md similarity index 100% rename from published/20180328 Do continuous deployment with Github and Python.md rename to published/201804/20180328 Do continuous deployment with Github and Python.md diff --git a/published/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md b/published/201804/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md similarity index 100% rename from published/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md rename to published/201804/20180328 How To Create-Extend Swap Partition In Linux Using LVM.md diff --git a/published/20180329 Protect Your Websites with Let-s Encrypt.md b/published/201804/20180329 Protect Your Websites with Let-s Encrypt.md similarity index 100% rename from published/20180329 Protect Your Websites with Let-s Encrypt.md rename to published/201804/20180329 Protect Your Websites with Let-s Encrypt.md diff --git a/published/20180402 Advanced SSH Cheat Sheet.md b/published/201804/20180402 Advanced SSH Cheat Sheet.md similarity index 100% rename from published/20180402 Advanced SSH Cheat Sheet.md rename to published/201804/20180402 Advanced SSH Cheat Sheet.md diff --git a/published/20180405 How to find files in Linux.md b/published/201804/20180405 How to find files in Linux.md similarity index 100% rename from published/20180405 How to find files in Linux.md rename to published/201804/20180405 How to find files in Linux.md diff --git a/published/20180405 The fc Command Tutorial With Examples For Beginners.md b/published/201804/20180405 The fc Command Tutorial With Examples For Beginners.md similarity index 100% rename from published/20180405 The fc Command Tutorial With Examples For Beginners.md rename to published/201804/20180405 The fc Command Tutorial With Examples For Beginners.md diff --git a/published/20180407 12 Git tips for Git-s 12th birthday.md b/published/201804/20180407 12 Git tips for Git-s 12th birthday.md similarity index 100% rename from published/20180407 12 Git tips for Git-s 12th birthday.md rename to published/201804/20180407 12 Git tips for Git-s 12th birthday.md diff --git a/published/20180411 Awesome GNOME extensions for developers.md b/published/201804/20180411 Awesome GNOME extensions for developers.md similarity index 100% rename from published/20180411 Awesome GNOME extensions for developers.md rename to published/201804/20180411 Awesome GNOME extensions for developers.md diff --git a/published/20180412 3 password managers for the Linux command line.md b/published/201804/20180412 3 password managers for the Linux command line.md similarity index 100% rename from published/20180412 3 password managers for the Linux command line.md rename to published/201804/20180412 3 password managers for the Linux command line.md From 0162c4e8eb2008dfe918274a284758d81f6c4b5b Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 1 May 2018 23:11:33 +0800 Subject: [PATCH 0717/1057] Delete 20180126 How To Manage NodeJS Packages Using Npm.md --- ...How To Manage NodeJS Packages Using Npm.md | 375 ------------------ 1 file changed, 375 deletions(-) delete mode 100644 sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md diff --git a/sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md b/sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md deleted file mode 100644 index e21522944b..0000000000 --- a/sources/tech/20180126 How To Manage NodeJS Packages Using Npm.md +++ /dev/null @@ -1,375 +0,0 @@ -Translating by MjSeven - - -How To Manage NodeJS Packages Using Npm -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/01/npm-720x340.png) - -A while ago, we have published a guide to [**manage Python packages using PIP**][1]. Today, we are going to discuss how to manage NodeJS packages using Npm. NPM is the largest software registry that contains over 600,000 packages. Everyday, developers across the world shares and downloads packages through npm. In this guide, I will explain the the basics of working with npm, such as installing packages(locally and globally), installing certain version of a package, updating, removing and managing NodeJS packages and so on. - -### Manage NodeJS Packages Using Npm - -##### Installing NPM - -Since npm is written in NodeJS, we need to install NodeJS in order to use npm. To install NodeJS on different Linux distributions, refer the following link. - -Once installed, ensure that NodeJS and NPM have been properly installed. There are couple ways to do this. - -To check where node has been installed: -``` -$ which node -/home/sk/.nvm/versions/node/v9.4.0/bin/node -``` - -Check its version: -``` -$ node -v -v9.4.0 -``` - -Log in to Node REPL session: -``` -$ node -> .help -.break Sometimes you get stuck, this gets you out -.clear Alias for .break -.editor Enter editor mode -.exit Exit the repl -.help Print this help message -.load Load JS from a file into the REPL session -.save Save all evaluated commands in this REPL session to a file -> .exit -``` - -Check where npm installed: -``` -$ which npm -/home/sk/.nvm/versions/node/v9.4.0/bin/npm -``` - -And the version: -``` -$ npm -v -5.6.0 -``` - -Great! Node and NPM have been installed and are working! As you may have noticed, I have installed NodeJS and NPM in my $HOME directory to avoid permission issues while installing modules globally. This is the recommended method by NodeJS team. - -Well, let us go ahead to see managing NodeJS modules (or packages) using npm. - -##### Installing NodeJS modules - -NodeJS modules can either be installed locally or globally(system wide). Now I am going to show how to install a package locally. - -**Install packages locally** - -To manage packages locally, we normally use **package.json** file. - -First, let us create our project directory. -``` -$ mkdir demo -``` -``` -$ cd demo -``` - -Create a package.json file inside your project's directory. To do so, run: -``` -$ npm init -``` - -Enter the details of your package such as name, version, author, github page etc., or just hit ENTER key to accept the default values and type **YES** to confirm. -``` -This utility will walk you through creating a package.json file. -It only covers the most common items, and tries to guess sensible defaults. - -See `npm help json` for definitive documentation on these fields -and exactly what they do. - -Use `npm install ` afterwards to install a package and -save it as a dependency in the package.json file. - -Press ^C at any time to quit. -package name: (demo) -version: (1.0.0) -description: demo nodejs app -entry point: (index.js) -test command: -git repository: -keywords: -author: -license: (ISC) -About to write to /home/sk/demo/package.json: - -{ - "name": "demo", - "version": "1.0.0", - "description": "demo nodejs app", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC" -} - -Is this ok? (yes) yes -``` - -The above command initializes your project and create package.json file. - -You can also do this non-interactively using command: -``` -npm init --y -``` - -This will create a package.json file quickly with default values without the user interaction. - -Now let us install package named [**commander**][2]. -``` -$ npm install commander -``` - -Sample output: -``` -npm notice created a lockfile as package-lock.json. You should commit this file. -npm WARN demo@1.0.0 No repository field. - -+ commander@2.13.0 -added 1 package in 2.519s -``` - -This will create a directory named **" node_modules"** (if it doesn't exist already) in the project's root directory and download the packages in it. - -Let us check the package.json file. -``` -$ cat package.json -{ - "name": "demo", - "version": "1.0.0", - "description": "demo nodejs app", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - **"dependencies": {** -**"commander": "^2.13.0"** - } -} -``` - -You will see the dependencies have been added. The caret ( **^** ) at the front of the version number indicates that when installing, npm will pull the highest version of the package it can find. -``` -$ ls node_modules/ -commander -``` - -The advantage of package.json file is if you had the package.json file in your project's directory, you can just type "npm install", then npm will look into the dependencies that listed in the file and download all of them. You can even share it with other developers or push into your GitHub repository, so when they type "npm install", they will get all the same packages that you have. - -You may also noticed another json file named **package-lock.json**. This file ensures that the dependencies remain the same on all systems the project is installed on. - -To use the installed package in your program, create a file **index.js** (or any name of you choice) in the project's directory with the actual code, and then run it using command: -``` -$ node index.js -``` - -**Install packages globally** - -If you want to use a package as a command line tool, then it is better to install it globally. This way, it works no matter which directory is your current directory. -``` -$ npm install async -g -+ async@2.6.0 -added 2 packages in 4.695s -``` - -Or, -``` -$ npm install async --global -``` - -To install a specific version of a package, we do: -``` -$ npm install async@2.6.0 --global -``` - -##### Updating NodeJS modules - -To update the local packages, go the the project's directory where the package.json is located and run: -``` -$ npm update -``` - -Then, run the following command to ensure all packages were updated. -``` -$ npm outdated -``` - -If there is no update, then it returns nothing. - -To find out which global packages need to be updated, run: -``` -$ npm outdated -g --depth=0 -``` - -If there is no output, then all packages are updated. - -To update the a single global package, run: -``` -$ npm update -g -``` - -To update all global packages, run: -``` -$ npm update -g -``` - -##### Listing NodeJS modules - -To list the local packages, go the project's directory and run: -``` -$ npm list -demo@1.0.0 /home/sk/demo -└── commander@2.13.0 -``` - -As you see, I have installed "commander" package in local mode. - -To list global packages, run this command from any location: -``` -$ npm list -g -``` - -Sample output: -``` -/home/sk/.nvm/versions/node/v9.4.0/lib -├─┬ async@2.6.0 -│ └── lodash@4.17.4 -└─┬ npm@5.6.0 - ├── abbrev@1.1.1 - ├── ansi-regex@3.0.0 - ├── ansicolors@0.3.2 - ├── ansistyles@0.1.3 - ├── aproba@1.2.0 - ├── archy@1.0.0 -[...] -``` - -This command will list all modules and their dependencies. - -To list only the top level modules, use -depth=0 option: -``` -$ npm list -g --depth=0 -/home/sk/.nvm/versions/node/v9.4.0/lib -├── async@2.6.0 -└── npm@5.6.0 -``` - -##### Searching NodeJS modules - -To search for a module, use "npm search" command: -``` -npm search -``` - -Example: -``` -$ npm search request -``` - -This command will display all modules that contains the search string "request". - -##### Removing NodeJS modules - -To remove a local package, go to the project's directory and run following command to remove the package from your **node_modules** directory: -``` -$ npm uninstall -``` - -To remove it from the dependencies in **package.json** file, use the **save** flag like below: -``` -$ npm uninstall --save - -``` - -To remove the globally installed packages, run: -``` -$ npm uninstall -g -``` - -##### Cleaning NPM cache - -By default, NPM keeps the copy of a installed package in the cache folder named npm in your $HOME directory when installing it. So, you can install it next time without having to download again. - -To view the cached modules: -``` -$ ls ~/.npm -``` - -The cache folder gets flooded with all old packages over time. It is better to clean the cache from time to time. - -As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, run: -``` -$ npm cache verify -``` - -To clear the entire cache, run: -``` -$ npm cache clean --force -``` - -##### Viewing NPM configuration - -To view the npm configuration, type: -``` -$ npm config list -``` - -Or, -``` -$ npm config ls -``` - -Sample output: -``` -; cli configs -metrics-registry = "https://registry.npmjs.org/" -scope = "" -user-agent = "npm/5.6.0 node/v9.4.0 linux x64" - -; node bin location = /home/sk/.nvm/versions/node/v9.4.0/bin/node -; cwd = /home/sk -; HOME = /home/sk -; "npm config ls -l" to show all defaults. -``` - -To display the current global location: -``` -$ npm config get prefix -/home/sk/.nvm/versions/node/v9.4.0 -``` - -And, that's all for now. What we have just covered here is just the basics. NPM is a vast topic. For more details, head over to the the [**NPM Getting Started**][3] guide. - -Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/manage-nodejs-packages-using-npm/ - -作者:[SK][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/author/sk/ -[1]:https://www.ostechnix.com/manage-python-packages-using-pip/ -[2]:https://www.npmjs.com/package/commander -[3]:https://docs.npmjs.com/getting-started/ From 38717e4d49bb37a11e854f0234884a565192f9a4 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 1 May 2018 23:14:53 +0800 Subject: [PATCH 0718/1057] Create 20180126 How To Manage NodeJS Packages Using Npm.md --- ...How To Manage NodeJS Packages Using Npm.md | 368 ++++++++++++++++++ 1 file changed, 368 insertions(+) create mode 100644 translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md diff --git a/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md b/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md new file mode 100644 index 0000000000..e443576852 --- /dev/null +++ b/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md @@ -0,0 +1,368 @@ +如何使用 Npm 管理 NodeJS 包 +===== + +![](https://www.ostechnix.com/wp-content/uploads/2018/01/npm-720x340.png) + +前一段时间,我们发布了一个[**使用 PIP 管理 Python 包**][3]的指南。今天,我们将讨论如何使用 Npm 管理 NodeJS 包。NPM 是最大的软件注册中心,包含 600,000 多个包。每天,世界各地的开发人员通过 npm 共享和下载软件包。在本指南中,我将解释使用 npm 基础知识,例如安装包(本地和全局)、安装特定版本的包、更新、删除和管理 NodeJS 包等等。 + +### 使用 Npm 管理 NodeJS 包 + +##### 安装 NPM + +用于 npm 是用 NodeJS 编写的,我们需要安装 NodeJS 才能使用 npm。要在不同的 Linux 发行版上安装 NodeJS,请参考下面的链接。 + +检查 node 安装的位置: +``` +$ which node +/home/sk/.nvm/versions/node/v9.4.0/bin/node +``` + +检查它的版本: +``` +$ node -v +v9.4.0 +``` + +进入 Node 交互式解释器: +``` +$ node +> .help +.break Sometimes you get stuck, this gets you out +.clear Alias for .break +.editor Enter editor mode +.exit Exit the repl +.help Print this help message +.load Load JS from a file into the REPL session +.save Save all evaluated commands in this REPL session to a file +> .exit +``` + +检查 npm 安装的位置: +``` +$ which npm +/home/sk/.nvm/versions/node/v9.4.0/bin/npm +``` + +还有版本: +``` +$ npm -v +5.6.0 +``` + +棒极了!Node 和 NPM 已安装并能工作!正如你可能已经注意到,我已经在我的 $HOME 目录中安装了 NodeJS 和 NPM,这样是为了避免在全局模块时出现权限问题。这是 NodeJS 团队推荐的方法。 + +那么,让我们继续看看如何使用 npm 管理 NodeJS 模块(或包)。 + +##### 安装 NodeJS 模块 + +NodeJS 模块可以安装在本地或全局(系统范围)。现在我将演示如何在本地安装包。 + +**在本地安装包** + +为了在本地管理包,我们通常使用 **package.json** 文件来管理。 + +首先,让我们创建我们的项目目录。 +``` +$ mkdir demo +``` +``` +$ cd demo +``` + +在项目目录中创建一个 package.json 文件。为此,运行: +``` +$ npm init +``` + +输入你的包的详细信息,例如名称,版本,作者,github 页面等等,或者按下 ENTER 键接受默认值并键入 **YES** 确认。 +``` +This utility will walk you through creating a package.json file. +It only covers the most common items, and tries to guess sensible defaults. + +See `npm help json` for definitive documentation on these fields +and exactly what they do. + +Use `npm install ` afterwards to install a package and +save it as a dependency in the package.json file. + +Press ^C at any time to quit. +package name: (demo) +version: (1.0.0) +description: demo nodejs app +entry point: (index.js) +test command: +git repository: +keywords: +author: +license: (ISC) +About to write to /home/sk/demo/package.json: + +{ + "name": "demo", + "version": "1.0.0", + "description": "demo nodejs app", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} + +Is this ok? (yes) yes +``` + +上面的命令初始化你的项目并创建了 package.json 文件。 + +你也可以使用命令以非交互式方式执行此操作: +``` +npm init --y +``` + +现在让我们安装名为 [**commander**][2] 的包。 +``` +$ npm install commander +``` + +示例输出: +``` +npm notice created a lockfile as package-lock.json. You should commit this file. +npm WARN demo@1.0.0 No repository field. + ++ commander@2.13.0 +added 1 package in 2.519s +``` + +这将在项目的根目录中创建一个名为 **" node_modules"** 的目录(如果它不存在的话),并在其中下载包。 + +让我们检查 pachage.json 文件。 +``` +$ cat package.json +{ + "name": "demo", + "version": "1.0.0", + "description": "demo nodejs app", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + **"dependencies": {** +**"commander": "^2.13.0"** + } +} +``` + +你会看到添加了依赖文件,版本号前面的插入符号 ( **^** ) 表示在安装时,npm 将取出它可以找到的最高版本的包。 +``` +$ ls node_modules/ +commander +``` + +package.json 文件的优点是,如果你的项目目录中有 package.json 文件,只需键入 "npm install",那么 npm 将查看文件中列出的依赖关系并下载它们。你甚至可以与其他开发人员共享它或将其推送到你的 GitHub 仓库。因此,当他们键入 “npm install” 时,他们将获得你拥有的所有相同的包。 + +你也可能会注意到另一个名为 **package-lock.json** 的文件,该文件确保在项目安装的所有系统上都保持相同的依赖关系。 + +要在你的程序中使用已安装的包,使用实际代码在项目目录中创建一个 **index.js**(或者其他任何名称)文件,然后使用以下命令运行它: +``` +$ node index.js +``` + +**在全局安装包** + +如果你想使用一个包作为命令行工具,那么最好在全局安装它。这样,无论你的当前目录是哪个目录,它都能正常工作。 +``` +$ npm install async -g ++ async@2.6.0 +added 2 packages in 4.695s +``` + +或者 +``` +$ npm install async --global +``` + +要安装特定版本的包,我们可以: +``` +$ npm install async@2.6.0 --global +``` + +##### 更新 NodeJS 模块 + +要更新本地包,转到 package.json 所在的项目目录并运行: +``` +$ npm update +``` + +然后,运行以下命令确保所有包都更新了。 +``` +$ npm outdated +``` + +如果没有需要更新的,那么它返回空。 + +要找出哪一个全局包需要更新,运行: +``` +$ npm outdated -g --depth=0 +``` + +如果没有输出,意味着所有包都已更新。 + +更新单个全局包,运行: +``` +$ npm update -g +``` + +更新所有的全局包,运行: +``` +$ npm update -g +``` + +##### 列出 NodeJS 模块 + +列出本地包,转到项目目录并运行: +``` +$ npm list +demo@1.0.0 /home/sk/demo +└── commander@2.13.0 +``` + +如你所见,我在本地安装了 "commander" 这个包。 + +要列出全局包,从任何位置都可以运行以下命令: +``` +$ npm list -g +``` + +示例输出: +``` +/home/sk/.nvm/versions/node/v9.4.0/lib +├─┬ async@2.6.0 +│ └── lodash@4.17.4 +└─┬ npm@5.6.0 + ├── abbrev@1.1.1 + ├── ansi-regex@3.0.0 + ├── ansicolors@0.3.2 + ├── ansistyles@0.1.3 + ├── aproba@1.2.0 + ├── archy@1.0.0 +[...] +``` + +该命令将列出所有模块及其依赖关系。 + +要仅仅列出顶级模块,使用 -depth=0 选项: +``` +$ npm list -g --depth=0 +/home/sk/.nvm/versions/node/v9.4.0/lib +├── async@2.6.0 +└── npm@5.6.0 +``` + +##### 寻找 NodeJS 模块 + +要搜索一个模块,使用 "npm search" 命令: +``` +npm search +``` + +例如: +``` +$ npm search request +``` + +该命令将显示包含搜索字符串 "request" 的所有模块。 + +##### 移除 NodeJS 模块 + +要删除本地包,转到项目目录并运行以下命令,这会从 **node_modules** 目录中删除包: +``` +$ npm uninstall +``` + +要从 **package.json** 文件中的依赖关系中删除它,使用如下所示的 **save** 标志: +``` +$ npm uninstall --save + +``` + +要删除已安装的全局包,运行: +``` +$ npm uninstall -g +``` + +##### 清楚 NPM 缓存 + +默认情况下,NPM 在安装包时,会将其副本保存在 $HOME 目录中名为 npm 的缓存文件夹中。所以,你可以在下次安装时不必再次下载。 + +查看缓存模块: +``` +$ ls ~/.npm +``` + +随着时间的推移,缓存文件夹会充斥着大量旧的包。所以不时清理缓存会好一些。 + +从 npm@5 开始,npm 缓存可以从 corruption 问题中自行修复,并且保证从缓存中提取的数据有效。如果你想确保一切都一致,运行: +``` +$ npm cache verify +``` + +清楚整个缓存,运行: +``` +$ npm cache clean --force +``` + +##### 查看 NPM 配置 + +要查看 NPM 配置,键入: +``` +$ npm config list +``` + +或者 +``` +$ npm config ls +``` + +示例输出: +``` +; cli configs +metrics-registry = "https://registry.npmjs.org/" +scope = "" +user-agent = "npm/5.6.0 node/v9.4.0 linux x64" + +; node bin location = /home/sk/.nvm/versions/node/v9.4.0/bin/node +; cwd = /home/sk +; HOME = /home/sk +; "npm config ls -l" to show all defaults. +``` + +要显示当前的全局位置: +``` +$ npm config get prefix +/home/sk/.nvm/versions/node/v9.4.0 +``` + +好吧,这就是全部了。我们刚才介绍的只是基础知识,NPM 是一个广泛话题。有关更多详细信息,参阅 [**NPM Getting Started**][3] 指南。 + +希望这对你有帮助。更多好东西即将来临,敬请关注! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/manage-nodejs-packages-using-npm/ + +作者:[SK][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者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/manage-python-packages-using-pip/ +[2]:https://www.npmjs.com/package/commander +[3]:https://docs.npmjs.com/getting-started/ From 6da3dcf4818bfed6b734f8673cd2d6c6b00f527b Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 2 May 2018 08:46:40 +0800 Subject: [PATCH 0719/1057] translated --- ... How to reset a root password on Fedora.md | 93 ------------------- ... How to reset a root password on Fedora.md | 89 ++++++++++++++++++ 2 files changed, 89 insertions(+), 93 deletions(-) delete mode 100644 sources/tech/20180423 How to reset a root password on Fedora.md create mode 100644 translated/tech/20180423 How to reset a root password on Fedora.md diff --git a/sources/tech/20180423 How to reset a root password on Fedora.md b/sources/tech/20180423 How to reset a root password on Fedora.md deleted file mode 100644 index e3b0234b77..0000000000 --- a/sources/tech/20180423 How to reset a root password on Fedora.md +++ /dev/null @@ -1,93 +0,0 @@ -translating---geekpi - -How to reset a root password on Fedora -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/04/resetrootpassword-816x345.jpg) -A system administrator can easily reset a password for a user that has forgotten their password. But what happens if the system administrator forgets the root password? This guide will show you how to reset a lost or forgotten root password. Note that to reset the root password, you need to have physical access to the machine in order to reboot and to access GRUB settings. Additionally, if the system is encrypted, you will also need to know the LUKS passphrase. - -### Edit the GRUB settings - -First you need to interrupt the boot process. So you’ll need to turn on the system or restart, if it’s already powered on. The first step is tricky because the grub menu tends to flash by very quickly on the screen. - -Press **E** on your keyboard when you see the GRUB menu: - -![][1] - -After pressing ‘e’ the following screen is shown: - -![][2] - -Use your arrow keys to move the the **linux16** line. - -![][3] - -Using your **del** key or **backspace** key, remove **rhgb quiet** and replace with the following. -``` -rd.break enforcing=0 - -``` - -![][4] - -After editing the lines, Press **Ctrl-x** to start the system. If the system is encrypted, you will be prompted for the LUKS passphase here. - -**Note:** Setting enforcing=0, avoids performing a complete system SELinux relabeling. Once the system is rebooted, restore the correct SELinux context for the /etc/shadow file. (this is explained a little further in this process) - -### Mounting the filesystem - -The system will now be in emergency mode. Remount the hard drive with read-write access: -``` -# mount –o remount,rw /sysroot - -``` - -### **Password Change - -** - -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 **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://fedoramagazine.org/reset-root-password-fedora/ - -作者:[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://fedoramagazine.org/author/rcurtiswarfield/ -[1]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub.png -[2]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub2.png -[3]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub3.png -[4]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub4.png diff --git a/translated/tech/20180423 How to reset a root password on Fedora.md b/translated/tech/20180423 How to reset a root password on Fedora.md new file mode 100644 index 0000000000..8d42ef9de0 --- /dev/null +++ b/translated/tech/20180423 How to reset a root password on Fedora.md @@ -0,0 +1,89 @@ +如何重置 Fedora 上的 root 密码 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/04/resetrootpassword-816x345.jpg) +系统管理员可以轻松地为忘记密码的用户重置密码。但是如果系统管理员忘记 root 密码会发生什么?本指南将告诉你如何重置遗失或忘记的 root 密码。请注意,要重置 root 密码,你需要能够接触到本机以重新启动并访问 GRUB 设置。此外,如果系统已加密,你还需要知道 LUKS 密码。 + +### 编辑 GRUB 设置 + +首先你需要中断启动过程。所以你需要打开系统,如果已经打开就重新启动。第一步很棘手,因为 grub 菜单往往会在屏幕上快速闪过。 + +当你看到 GRUB 菜单时,请按键盘上的 **E** 键: + +![][1] + +按下 ‘e’ 后显示以下屏幕: + +![][2] + +使用箭头键移动到 **linux16** 这行。 + +![][3] + +使用您的**删除**键或**后退**键,删除 **rhgb quiet** 并替换为以下内容。 +``` +rd.break enforcing=0 + +``` + +![][4] + +编辑好后,按下 **Ctrl-x** 启动系统。如果系统已加密,则系统会提示你输入 LUKS 密码。 + +**注意:** 设置 enforcing=0,避免执行完整的系统 SELinux 重新标记。系统重启后,为 /etc/shadow 恢复正确的 SELinux 上下文。(这个会进一步解释) + +### 挂载文件系统 + +系统现在将处于紧急模式。以读写权限重新挂载硬盘: +``` +# mount –o remount,rw /sysroot + +``` + +### 更改密码 + +运行 chroot 访问系统。 +``` +# chroot /sysroot + +``` + +你现在可以更改 root 密码。 +``` +# passwd + +``` + +出现提示时输入新的 root 密码两次。如果成功,你应该看到一条 **all authentication tokens updated successfully** 消息。 + +输入 **exit** 两次重新启动系统。 + +以 root 身份登录并将 SELinux 标签恢复到 /etc/shadow 中。 +``` +# restorecon -v /etc/shadow + +``` + +将 SELinux 变回 enforce 模式。 +``` +# setenforce 1 + +``` + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/reset-root-password-fedora/ + +作者:[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://fedoramagazine.org/author/rcurtiswarfield/ +[1]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub.png +[2]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub2.png +[3]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub3.png +[4]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub4.png From b502222c3fde7ed30aacf81cff44845572b4b86b Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 2 May 2018 08:49:17 +0800 Subject: [PATCH 0720/1057] translated --- sources/tech/20180427 How to use FIND in Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180427 How to use FIND in Linux.md b/sources/tech/20180427 How to use FIND in Linux.md index 829514dd3c..42da1784de 100644 --- a/sources/tech/20180427 How to use FIND in Linux.md +++ b/sources/tech/20180427 How to use FIND in Linux.md @@ -1,3 +1,5 @@ +translating---geekpi + How to use FIND in Linux ====== From c1b2e86d595ea39705835732c286144348b2c818 Mon Sep 17 00:00:00 2001 From: jessie-pang <35220454+jessie-pang@users.noreply.github.com> Date: Wed, 2 May 2018 09:40:31 +0800 Subject: [PATCH 0721/1057] Delete 20180317 How To Edit Multiple Files Using Vim Editor.md --- ...To Edit Multiple Files Using Vim Editor.md | 349 ------------------ 1 file changed, 349 deletions(-) delete mode 100644 sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md diff --git a/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md b/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md deleted file mode 100644 index 6cebe726d1..0000000000 --- a/sources/tech/20180317 How To Edit Multiple Files Using Vim Editor.md +++ /dev/null @@ -1,349 +0,0 @@ -Translating by jessie-pang - -How To Edit Multiple Files Using Vim Editor -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/03/Edit-Multiple-Files-Using-Vim-Editor-720x340.png) -Sometimes, you will find yourself in a situation where you want to make changes in multiple files or you might want to copy the contents of one file to another. If you’re on GUI mode, you could simply open the files in any graphical text editor, like gedit, and use CTRL+C and CTRL+V to copy/paste the contents. In CLI mode, you can’t use such editors. No worries! Where there is vim editor, there is a way! In this tutorial, we are going to learn to edit multiple files at the same time using Vim editor. Trust me, this is very interesting read. - -### Installing Vim - -Vim editor is available in the official repositories of most Linux distributions. So you can install it using the default package manager. For example, on Arch Linux and its variants you can install it using command: -``` -$ sudo pacman -S vim - -``` - -On Debian, Ubuntu: -``` -$ sudo apt-get install vim - -``` - -On RHEL, CentOS: -``` -$ sudo yum install vim - -``` - -On Fedora: -``` -$ sudo dnf install vim - -``` - -On openSUSE: -``` -$ sudo zypper install vim - -``` - -### Edit multiple files at a time using Vim editor in Linux - -Let us now get down to the business. We can do this in two methods. - -#### Method 1 - -I have two files namely **file1.txt** and **file2.txt** , with a bunch of random words. Let us have a look at them. -``` -$ cat file1.txt -ostechnix -open source -technology -linux -unix - -$ cat file2.txt -line1 -line2 -line3 -line4 -line5 - -``` - -Now, let us edit these two files at a time. To do so, run: -``` -$ vim file1.txt file2.txt - -``` - -Vim will display the contents of the files in an order. The first file’s contents will be shown first and then second file and so on. - -![][2] - -**Switch between files** - -To move to the next file, type: -``` -:n - -``` - -![][3] - -To go back to previous file, type: -``` -:N - -``` - -Vim won’t allow you to move to the next file if there are any unsaved changes. To save the changes in the current file, type: -``` -ZZ - -``` - -Please note that it is double capital letters ZZ (SHIFT+zz). - -To abandon the changes and move to the previous file, type: -``` -:N! - -``` - -To view the files which are being currently edited, type: -``` -:buffers - -``` - -![][4] - -You will see the list of loaded files at the bottom. - -![][5] - -To switch to the next file, type **:buffer** followed by the buffer number. For example, to switch to the first file, type: -``` -:buffer 1 - -``` - -![][6] - -**Opening additional files for editing** - -We are currently editing two files namely file1.txt, file2.txt. I want to open another file named **file3.txt** for editing. -What will you do? It’s easy! Just type **:e** followed by the file name like below. -``` -:e file3.txt - -``` - -![][7] - -Now you can edit file3.txt. - -To view how many files are being edited currently, type: -``` -:buffers - -``` - -![][8] - -Please note that you can not switch between opened files with **:e** using either **:n** or **:N**. To switch to another file, type **:buffer** followed by the file buffer number. - -**Copying contents of one file into another** - -You know how to open and edit multiple files at the same time. Sometimes, you might want to copy the contents of one file into another. It is possible too. Switch to a file of your choice. For example, let us say you want to copy the contents of file1.txt into file2.txt. - -To do so, first switch to file1.txt: -``` -:buffer 1 - -``` - -Place the move cursor in-front of a line that wants to copy and type **yy** to yank(copy) the line. Then. move to file2.txt: -``` -:buffer 2 - -``` - -Place the mouse cursor where you want to paste the copied lines from file1.txt and type **p**. For example, you want to paste the copied line between line2 and line3. To do so, put the mouse cursor before line and type **p**. - -Sample output: -``` -line1 -line2 -ostechnix -line3 -line4 -line5 - -``` - -![][9] - -To save the changes made in the current file, type: -``` -ZZ - -``` - -Again, please note that this is double capital ZZ (SHIFT+z). - -To save the changes in all files and exit vim editor. type: -``` -:wq - -``` - -Similarly, you can copy any line from any file to other files. - -**Copying entire file contents into another** - -We know how to copy a single line. What about the entire file contents? That’s also possible. Let us say, you want to copy the entire contents of file1.txt into file2.txt. - -To do so, open the file2.txt first: -``` -$ vim file2.txt - -``` - -If the files are already loaded, you can switch to file2.txt by typing: -``` -:buffer 2 - -``` - -Move the cursor to the place where you wanted to copy the contents of file1.txt. I want to copy the contents of file1.txt after line5 in file2.txt, so I moved the cursor to line 5. Then, type the following command and hit ENTER key: -``` -:r file1.txt - -``` - -![][10] - -Here, **r** means **read**. - -Now you will see the contents of file1.txt is pasted after line5 in file2.txt. -``` -line1 -line2 -line3 -line4 -line5 -ostechnix -open source -technology -linux -unix - -``` - -![][11] - -To save the changes in the current file, type: -``` -ZZ - -``` - -To save all changes in all loaded files and exit vim editor, type: -``` -:wq - -``` - -#### Method 2 - -The another method to open multiple files at once is by using either **-o** or **-O** flags. - -To open multiple files in horizontal windows, run: -``` -$ vim -o file1.txt file2.txt - -``` - -![][12] - -To switch between windows, press **CTRL-w w** (i.e Press **CTRL+w** and again press **w** ). Or, you the following shortcuts to move between windows. - - * **CTRL-w k** – top window - * **CTRL-w j** – bottom window - - - -To open multiple files in vertical windows, run: -``` -$ vim -O file1.txt file2.txt file3.txt - -``` - -![][13] - -To switch between windows, press **CTRL-w w** (i.e Press **CTRL+w** and again press **w** ). Or, use the following shortcuts to move between windows. - - * **CTRL-w l** – left window - * **CTRL-w h** – right window - - - -Everything else is same as described in method 1. - -For example, to list currently loaded files, run: -``` -:buffers - -``` - -To switch between files: -``` -:buffer 1 - -``` - -To open an additional file, type: -``` -:e file3.txt - -``` - -To copy entire contents of a file into another: -``` -:r file1.txt - -``` - -The only difference in method 2 is once you saved the changes in the current file using **ZZ** , the file will automatically close itself. Also, you need to close the files one by one by typing **:wq**. But, had you followed the method 1, when typing **:wq** all changes will be saved in all files and all files will be closed at once. - -For more details, refer man pages. -``` -$ man vim - -``` - -**Suggested read:** - -You know now how to edit multiples files using vim editor in Linux. As you can see, editing multiple files is not that difficult. Vim editor has more powerful features. We will write more about Vim editor in the days to come. - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-edit-multiple-files-using-vim-editor/ - -作者:[SK][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/author/sk/ -[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-1-1.png -[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-2.png -[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-5.png -[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-6.png -[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-7.png -[7]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-8.png -[8]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-10-1.png -[9]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-11.png -[10]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-12.png -[11]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-13.png -[12]:http://www.ostechnix.com/wp-content/uploads/2018/03/Edit-multiple-files-16.png -[13]:http://www.ostechnix.com/wp-content/uploads/2018/03/Edit-multiple-files-17.png From fcce42cd874a9b822c37278238573a28650b8463 Mon Sep 17 00:00:00 2001 From: jessie-pang <35220454+jessie-pang@users.noreply.github.com> Date: Wed, 2 May 2018 09:41:10 +0800 Subject: [PATCH 0722/1057] 20180317 How To Edit Multiple Files Using Vim Editor.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 --- ...To Edit Multiple Files Using Vim Editor.md | 351 ++++++++++++++++++ 1 file changed, 351 insertions(+) create mode 100644 translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md 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 new file mode 100644 index 0000000000..acb042fcbb --- /dev/null +++ b/translated/tech/20180317 How To Edit Multiple Files Using Vim Editor.md @@ -0,0 +1,351 @@ +如何使用 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 编辑器同时编辑多个文件。相信我,很有意思哒。 + +### 安装 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 编辑器同时编辑多个文件 + +现在让我们谈谈正事,我们可以用两种方法做到这一点。 + +#### 方法一 + +有两个文件,即 **file1.txt** 和 **file2.txt**,带有一堆随机单词: +``` +$ cat file1.txt +ostechnix +open source +technology +linux +unix + +$ cat file2.txt +line1 +line2 +line3 +line4 +line5 + +``` + +现在,让我们同时编辑这两个文件。请运行: +``` +$ vim file1.txt file2.txt + +``` + +Vim 将按顺序显示文件的内容。首先显示第一个文件的内容,然后显示第二个文件,依此类推。 + +![][2] + +**在文件中切换** + +要移至下一个文件,请键入: +``` +:n + +``` + +![][3] + +要返回到前一个文件,请键入: +``` +:N + +``` + +如果有任何未保存的更改,Vim 将不允许您移动到下一个文件。要保存当前文件中的更改,请键入: +``` +ZZ + +``` + +请注意,是两个大写字母 ZZ(SHIFT + zz)。 + +要放弃更改并移至上一个文件,请键入: +``` +:N! + +``` + +要查看当前正在编辑的文件,请键入: +``` +:buffers + +``` + +![][4] + +您将在底部看到加载文件的列表。 + +![][5] + +要切换到下一个文件,请输入 **:buffer**,后跟缓冲区编号。例如,要切换到第一个文件,请键入: +``` +:buffer 1 + +``` + +![][6] + +**打开其他文件进行编辑** + +目前我们正在编辑两个文件,即 file1.txt 和 file2.txt。我想打开另一个名为 **file3.txt** 的文件进行编辑。 + +您会怎么做?这很容易。只需键入 **:e**,然后输入如下所示的文件名即可: +``` +:e file3.txt + +``` + +![][7] + +现在你可以编辑 file3.txt 了。 + +要查看当前正在编辑的文件数量,请键入: +``` +:buffers + +``` + +![][8] + +请注意,对于使用 **:e** 打开的文件,您无法使用 **:n** 或 **:N** 进行切换。要切换到另一个文件,请输入 **:buffer**,然后输入文件缓冲区编号。 + +**将一个文件的内容复制到另一个文件中** + +您已经知道了如何同时打开和编辑多个文件。有时,您可能想要将一个文件的内容复制到另一个文件中。这也是可以做到的。切换到您选择的文件,例如,假设您想将 file1.txt 的内容复制到 file2.txt 中: + +首先,请切换到 file1.txt: +``` +:buffer 1 + +``` + +将光标移动至在想要复制的行的前面,并键入**yy** 以抽出(复制)该行。然后,移至 file2.txt: +``` +:buffer 2 + +``` + +将光标移至要从 file1.txt 粘贴复制行的位置,然后键入 **p**。例如,您想要将复制的行粘贴到 line2 和 line3 之间,请将鼠标光标置于行前并键入 **p**。 + +输出示例: +``` +line1 +line2 +ostechnix +line3 +line4 +line5 + +``` + +![][9] + +要保存当前文件中所做的更改,请键入: +``` +ZZ + +``` + +再次提醒,是两个大写字母 ZZ(SHIFT + z)。 + +保存所有文件的更改并退出 vim 编辑器,键入: +``` +:wq + +``` + +同样,您可以将任何文件的任何行复制到其他文件中。 + +**将整个文件内容复制到另一个文件中** + +我们知道如何复制一行,那么整个文件的内容呢?也是可以的。比如说,您要将 file1.txt 的全部内容复制到 file2.txt 中。 + +先打开 file2.txt: +``` +$ vim file2.txt + +``` + +如果文件已经加载,您可以通过输入以下命令切换到 file2.txt: +``` +:buffer 2 + +``` + +将光标移动到您想要粘贴 file1.txt 内容的位置。我想在 file2.txt 的第 5 行之后粘贴 file1.txt 的内容,所以我将光标移动到第 5 行。然后,键入以下命令并按回车键: +``` +:r file1.txt + +``` + +![][10] + +这里,**r** 代表 **read**。 + +现在您会看到 file1.txt 的内容被粘贴在 file2.txt 的第 5 行之后。 +``` +line1 +line2 +line3 +line4 +line5 +ostechnix +open source +technology +linux +unix + +``` + +![][11] + +要保存当前文件中的更改,请键入: +``` +ZZ + +``` + +要保存所有文件的所有更改并退出 vim 编辑器,请输入: +``` +:wq + +``` + +#### 方法二 + +另一种同时打开多个文件的方法是使用 **-o** 或 **-O** 标志。 + +要在水平窗口中打开多个文件,请运行: +``` +$ vim -o file1.txt file2.txt + +``` + +![][12] + +要在窗口之间切换,请按 **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** – 右面的窗口 + + + +其他的一切都与方法一的描述相同。 + +例如,要列出当前加载的文件,请运行: +``` +:buffers + +``` + +在文件之间切换: +``` +:buffer 1 + +``` + +打开其他文件,请键入: +``` +:e file3.txt + +``` + +将文件的全部内容复制到另一个文件中: +``` +:r file1.txt + +``` + +方法二的唯一区别是,只要您使用 **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) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-1-1.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-2.png +[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-5.png +[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-6.png +[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-7.png +[7]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-8.png +[8]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-10-1.png +[9]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-11.png +[10]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-12.png +[11]:http://www.ostechnix.com/wp-content/uploads/2018/03/edit-multiple-files-13.png +[12]:http://www.ostechnix.com/wp-content/uploads/2018/03/Edit-multiple-files-16.png +[13]:http://www.ostechnix.com/wp-content/uploads/2018/03/Edit-multiple-files-17.png \ No newline at end of file From 6daa7f012f1f8883ed972c12009a33b32c34584c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 12:27:15 +0800 Subject: [PATCH 0723/1057] PRF:20180308 How to set up a print server on a Raspberry Pi.md @qhwdw --- ...set up a print server on a Raspberry Pi.md | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180308 How to set up a print server on a Raspberry Pi.md b/translated/tech/20180308 How to set up a print server on a Raspberry Pi.md index 0b53281d7f..65b9fd5a5a 100644 --- a/translated/tech/20180308 How to set up a print server on a Raspberry Pi.md +++ b/translated/tech/20180308 How to set up a print server on a Raspberry Pi.md @@ -1,60 +1,58 @@ 如何将树莓派配置为打印服务器 ====== +> 用树莓派和 CUPS 打印服务器将你的打印机变成网络打印机。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life-raspberrypi_0.png?itok=Kczz87J2) -我喜欢在家做一些小项目,因此,今年我选择使用一个 [树莓派 3 Model B][1],这是一个像我这样的业余爱好者非常适合的东西。使用树莓派 3 Model B 的无线功能,我可以不使用线缆将树莓派连接到我的家庭网络中。这样可以很容易地将树莓派用到各种它所需要的地方。 +我喜欢在家做一些小项目,因此,今年我买了一个 [树莓派 3 Model B][1],这是一个非常适合像我这样的业余爱好者的东西。使用树莓派 3 Model B 的内置无线功能,我可以不使用线缆就将树莓派连接到我的家庭网络中。这样可以很容易地将树莓派用到各种所需要的地方。 -在家里,我和我的妻子都使用笔记本电脑,但是我们只有一台打印机:一台使用的并不频繁的 HP 彩色激光打印机。因为我们的打印机并不内置无线网卡,因此,它不能直接连接到无线网络中,一般情况下,使用我的笔记本电脑时,我并不连接打印机,因为,我做的大多数工作并不需要打印。虽然这种安排在大多数时间都没有问题,但是,有时候,我的妻子想在不 “麻烦” 我的情况下,自己去打印一些东西。 - -### 基本设置 +在家里,我和我的妻子都使用笔记本电脑,但是我们只有一台打印机:一台使用的并不频繁的 HP 彩色激光打印机。因为我们的打印机并不内置无线网卡,因此,它不能直接连接到无线网络中,我们一般把打印机连接到我的笔记本电脑上,因为通常是我在打印。虽然这种安排在大多数时间都没有问题,但是,有时候,我的妻子想在不 “麻烦” 我的情况下,自己去打印一些东西。 我觉得我们需要一个将打印机连接到无线网络的解决方案,以便于我们都能够随时随地打印。我本想买一个无线打印服务器将我的 USB 打印机连接到家里的无线网络上。后来,我决定使用我的树莓派,将它设置为打印服务器,这样就可以让家里的每个人都可以随时来打印。 -设置树莓派是非常简单的事。我下载了 [Raspbian][2] 镜像,并将它写入到我的 microSD 卡中。然后,使用它引导连接了一个 HDMI 显示器、一个 USB 键盘和一个 USB 鼠标的树莓派。之后,我们开始对它进行设置! +### 基本设置 + +设置树莓派是非常简单的事。我下载了 [Raspbian][2] 镜像,并将它写入到我的 microSD 卡中。然后,使用它来引导一个连接了 HDMI 显示器、 USB 键盘和 USB 鼠标的树莓派。之后,我们开始对它进行设置! 这个树莓派系统自动引导到一个图形桌面,然后我做了一些基本设置:设置键盘语言、连接无线网络、设置普通用户帐户(`pi`)的密码、设置管理员用户(`root`)的密码。 -我并不打算将树莓派运行在桌面环境下。我一般是通过我的普通的 Linux 计算机远程来使用它。因此,我使用树莓派的图形化管理工具,去设置将树莓派引导到控制台模式,而且不以 `pi` 用户自动登入。 +我并不打算将树莓派运行在桌面环境下。我一般是通过我的普通的 Linux 计算机远程来使用它。因此,我使用树莓派的图形化管理工具,去设置将树莓派引导到控制台模式,但不以 `pi` 用户自动登入。 重新启动树莓派之后,我需要做一些其它的系统方面的小调整,以便于我在家用网络中使用树莓派做为 “服务器”。我设置它的 DHCP 客户端为使用静态 IP 地址;默认情况下,DHCP 客户端可能任选一个可用的网络地址,这样我会不知道应该用哪个地址连接到树莓派。我的家用网络使用一个私有的 A 类地址,因此,我的路由器的 IP 地址是 `10.0.0.1`,并且我的全部可用地 IP 地址是 `10.0.0.x`。在我的案例中,低位的 IP 地址是安全的,因此,我通过在 `/etc/dhcpcd.conf` 中添加如下的行,设置它的无线网络使用 `10.0.0.11` 这个静态地址。 + ``` interface wlan0 - static ip_address=10.0.0.11/24 - static routers=10.0.0.1 - static domain_name_servers=8.8.8.8 8.8.4.4 - ``` 在我再次重启之前,我需要去确认安全 shell 守护程序(SSHD)已经正常运行(你可以在 “偏好” 中设置哪些服务在引导时启动它)。这样我就可以使用 SSH 从普通的 Linux 系统上基于网络连接到树莓派中。 ### 打印设置 -现在,我的树莓派已经在网络上正常工作了,我通过 SSH 从我的 Linux 电脑上远程连接它,接着做剩余的设置。在继续设置之前,确保你的打印机已经连接到树莓派上。 +现在,我的树莓派已经连到网络上了,我通过 SSH 从我的 Linux 电脑上远程连接它,接着做剩余的设置。在继续设置之前,确保你的打印机已经连接到树莓派上。 + +设置打印机很容易。现代的打印服务器被称为 CUPS,意即“通用 Unix 打印系统”。任何最新的 Unix 系统都可以通过 CUPS 打印服务器来打印。为了在树莓派上设置 CUPS 打印服务器。你需要通过几个命令去安装 CUPS 软件,并使用新的配置来重启打印服务器,这样就可以允许其它系统来打印了。 -设置打印机很容易。现在的打印服务器都称为 CUPS,它是标准的通用 Unix 打印系统。任何最新的 Unix 系统都可以通过 CUPS 打印服务器来打印。为了在树莓派上设置 CUPS 打印服务器。你需要通过几个命令去安装 CUPS 软件,并使用新的配置来重启打印服务器,这样就可以允许其它系统来打印了。 ``` $ sudo apt-get install cups - $ sudo cupsctl --remote-any - $ sudo /etc/init.d/cups restart - ``` -在 CUPS 中设置打印机也是非常简单的,你可以通过一个 Web 界面来完成。CUPS 监听端口是 631,因此你可以在浏览器中收藏这个地址: +在 CUPS 中设置打印机也是非常简单的,你可以通过一个 Web 界面来完成。CUPS 监听端口是 631,因此你用常用的浏览器来访问这个地址: + ``` https://10.0.0.11:631/ - ``` -你的 Web 浏览器可能会弹出警告,因为它不认可这个 Web 浏览器的 https 证书;选择 ”接受它“,然后以管理员用户登入系统,你将看到如下的标准的 CUPS 面板: +你的 Web 浏览器可能会弹出警告,因为它不认可这个 Web 浏览器的 https 证书;选择 “接受它”,然后以管理员用户登入系统,你将看到如下的标准的 CUPS 面板: + ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/cups-1-home.png?itok=t9OFJgSX) -这时候,导航到管理标签,选择 “Add Printer"。 +这时候,导航到管理标签,选择 “Add Printer”。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/cups-2-administration.png?itok=MlEINoYC) @@ -64,9 +62,9 @@ https://10.0.0.11:631/ ### 客户端设置 -从 Linux 中设置一台网络打印机非常简单。我的桌面环境是 GNOME,你可以从 GNOME 的设置应用程序中添加网络打印机。只需要导航到设备和打印机,然后解锁这个面板。点击 “Add" 按钮去添加打印机。 +从 Linux 中设置一台网络打印机非常简单。我的桌面环境是 GNOME,你可以从 GNOME 的“设置”应用程序中添加网络打印机。只需要导航到“设备和打印机”,然后解锁这个面板。点击 “添加” 按钮去添加打印机。 -在我的系统中,GNOME 设置为 ”自动发现网络打印机并添加它“。如果你的系统不是这样,你需要通过树莓派的 IP 地址,手动去添加打印机。 +在我的系统中,GNOME 的“设置”应用程序会自动发现网络打印机并添加它。如果你的系统不是这样,你需要通过树莓派的 IP 地址,手动去添加打印机。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gnome-settings-printers.png?itok=NOQLTaLs) @@ -78,7 +76,7 @@ via: https://opensource.com/article/18/3/print-server-raspberry-pi 作者:[Jim Hall][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 f07b16b3fa22f43803266da5da17755f8444245d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 12:27:41 +0800 Subject: [PATCH 0724/1057] PUB:20180308 How to set up a print server on a Raspberry Pi.md @qhwdw https://linux.cn/article-9596-1.html --- .../20180308 How to set up a print server on a Raspberry Pi.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180308 How to set up a print server on a Raspberry Pi.md (100%) diff --git a/translated/tech/20180308 How to set up a print server on a Raspberry Pi.md b/published/20180308 How to set up a print server on a Raspberry Pi.md similarity index 100% rename from translated/tech/20180308 How to set up a print server on a Raspberry Pi.md rename to published/20180308 How to set up a print server on a Raspberry Pi.md From eec7d59cb48f4cd725d3c48a36f1a72ab35e09b5 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 12:38:07 +0800 Subject: [PATCH 0725/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Configuring=20l?= =?UTF-8?q?ocal=20storage=20in=20Linux=20with=20Stratis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180425 Configuring local storage in Linux with Stratis.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180425 Configuring local storage in Linux with Stratis.md b/sources/tech/20180425 Configuring local storage in Linux with Stratis.md index fc9471c88f..f76b7f6fca 100644 --- a/sources/tech/20180425 Configuring local storage in Linux with Stratis.md +++ b/sources/tech/20180425 Configuring local storage in Linux with Stratis.md @@ -2,6 +2,7 @@ Configuring local storage in Linux with Stratis ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-storage.png?itok=95-zvHYl) + Configuring local storage is something desktop Linux users do very infrequently—maybe only once, during installation. Linux storage tech moves slowly, and many storage tools used 20 years ago are still used regularly today. But some things have improved since then. Why aren't people taking advantage of these new capabilities? This article is about Stratis, a new project that aims to bring storage advances to all Linux users, from the simple laptop single SSD to a hundred-disk array. Linux has the capabilities, but its lack of an easy-to-use solution has hindered widespread adoption. Stratis's goal is to make Linux's advanced storage features accessible. From 6e8f4721fc939d3bf75d81fdd503238fb24481cf Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 12:39:17 +0800 Subject: [PATCH 0726/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What=20Stratis?= =?UTF-8?q?=20learned=20from=20ZFS,=20Btrfs,=20and=20Linux=20Volume=20Mana?= =?UTF-8?q?ger=20|=20Opensource.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...from ZFS, Btrfs, and Linux Volume Manager - Opensource.com.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sources/tech/20180426 What Stratis learned from ZFS, Btrfs, and Linux Volume Manager - Opensource.com.md b/sources/tech/20180426 What Stratis learned from ZFS, Btrfs, and Linux Volume Manager - Opensource.com.md index a32792e532..bf658cab42 100644 --- a/sources/tech/20180426 What Stratis learned from ZFS, Btrfs, and Linux Volume Manager - Opensource.com.md +++ b/sources/tech/20180426 What Stratis learned from ZFS, Btrfs, and Linux Volume Manager - Opensource.com.md @@ -1,6 +1,5 @@ What Stratis learned from ZFS, Btrfs, and Linux Volume Manager | Opensource.com ====== - ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cloud-windows-building-containers.png?itok=0XvZLZ8k) As discussed in [Part 1][1] of this series, Stratis is a volume-managing filesystem (VMF) with functionality similar to [ZFS][2] and [Btrfs][3]. In designing Stratis, we studied the choices that developers of existing solutions made. From b82f481a832ff3e772200b07bcf410199cc49ccf Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 12:40:54 +0800 Subject: [PATCH 0727/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20PCGen:=20An=20e?= =?UTF-8?q?asy=20way=20to=20generate=20RPG=20characters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... An easy way to generate RPG characters.md | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 sources/tech/20180430 PCGen- An easy way to generate RPG characters.md diff --git a/sources/tech/20180430 PCGen- An easy way to generate RPG characters.md b/sources/tech/20180430 PCGen- An easy way to generate RPG characters.md new file mode 100644 index 0000000000..bd1fd6516d --- /dev/null +++ b/sources/tech/20180430 PCGen- An easy way to generate RPG characters.md @@ -0,0 +1,136 @@ +PCGen: An easy way to generate RPG characters +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_gaming.png?itok=poe7HXJ7) +Do you remember the first time you built a role-playing game (RPG) character? It was exciting and full of possibility, and your imagination ran wild. If you're an avid gamer, it was probably a major milestone for you. + +But do you also remember struggling to decipher an empty character sheet and what you were supposed to write down in each box? Remember poring over the core rulebook, cross-referencing one table with a class write-up, the spellbook with your chosen school of magic, and skills to your race? + +Whether you thought it was fun or perplexing—or both, if you play RPGs, the process of building and tracking a character is probably as natural to you now as using a computer. + +That's an appropriate analogy, because, as we all know, character sheets have been computerized. It's a sensible match; computers are great for tracking information that changes frequently. They certainly handle it a lot better than scratches on paper worn thin by repeated erasing and scribbling and more erasing. + +Sure, you could build custom spreadsheets in [Libre Office][1], but then again you could also try [PCGen][2], a Java-based application that makes character creation and maintenance sublimely simple without taking the fun out of either. While it doesn't have a mobile version, there is a [PCGen viewer][3] for Android so you can access your build whenever you need to. + +### Downloading and installing + +PCGen is a Java application, so it runs on anything that has Java installed. This isn't quite the same thing as Java in your web browser; PCGen is a downloadable application that runs locally on your computer. You likely already have Java installed; if not, download and install it from your distribution's repository. If you're not sure whether you have it installed, you can [download PCGen][4] first, try to run it, and install Java if it fails to run. + +Since PCGen is a Java application, you don't have to install it after you download it (because you've already got the Java runtime installed). The application should just run if you double-click the `pcgen.jar` file, but if your computer hasn't been told what to do with a Java app yet, you may need to tell it explicitly to run in Java. You usually do this by right-clicking and specifying what application to open the file in. The application you want, of course, is Java or, if you're asked to input the application launch command manually, `java -jar`. + +Linux and BSD users can customize this experience: + + 1. Download PCGen to a directory, such as `/opt` or `~/bin`. + 2. Unzip the archive with `unzip pcgen-x.yy.zz-full.zip`. + 3. Download a suitable icon (e.g., `wget https://openclipart.org/image/300px/svg_to_png/285672/d20-blank.png -O pcgen/d20.png`. + 4. Create a file called `pcgen.desktop` in your `~/.local/share/applications` directory. Open it in a text editor and type the following, adjusting as appropriate: + + +``` +[Desktop Entry] Version=1.0 Type=Application Name=PCGen Exec="/home/your-username/bin/pcgen/pcgen.sh" Encoding=UTF-8 Icon=/home/your-username/bin/pcgen/d20.png + +``` + +Now you can launch PCGen from your system's application menu as you would any other applications. + +### Player agency + +Many hours of my childhood were spent poring over my friends' D&D Player Handbooks, rolling up characters that I'd never play (thanks to the infamous "satanic panic," I wasn't allowed to play the game). What I learned from this is creating a character for an RPG is a kind of mini-game itself. There are rules to follow, important choices to make, and ultimately a needed narrative to make it all come together. + +A new player might think it's a good idea to allow an application to do a build for them, but most experienced players probably agree that the best way to learn is by doing. And besides, letting something build your character would rob you of the mini-game that is character building. If an application is nothing more than a pre-gen factory, one of the most important parts of being a player is removed from the game, and nobody wants that. + +On the other hand, nobody wants the character building process to discourage new players. + +PCGen manages to strike a perfect balance between guiding you through a character build and staying out of your way as you tinker. Primarily it does this by using an unobtrusive alert system that keeps you updated about any required tasks left in your character build. It's helpful without grabbing the steering wheel out of your hands to take over completely. + + +![PCGen to-do list][6] + +No annoying Clippy, but plenty of helpful hints + +### Getting started + +PCGen essentially has two modes: the character build and the character sheet. When you launch it, PCGen first asks you to choose the game system you're building for. + +![System selection][8] + +Selecting your game system + +Included systems are OGL (Open Game License) systems, including D&D 5e (3 and 3.5 editions), Pathfinder, and Fantasy Craft. Better still, PCGen comes preloaded with all manner of add-on material, so not only can you design characters from advanced and third-party modules, the dungeon master (DM) can even create stats for monsters and villains. + +Once you've double-clicked the system you're using, you're presented with a helpful screen letting you either load an existing build you have saved or start building a new one. Each new character gets its own tab in PCGen, so if you want to build a whole party or if a DM wants to track a whole hoard of monsters, it's easy to load up a cast of characters and have them at the ready. + +Starting from the top left, your character build starts with the basics: choosing a name, gender, and alignment. PCGen includes a random-name generator with lots of knobs and switches to adjust for etymology (real and fantasy), race, and gender. + +### Rolling for abilities + +When it's time to roll for ability scores, PCGen has lots of options. It defaults to manual entry. You roll physical dice and enter the numbers. + +Alternately, you can let PCGen roll for you, and you can set the rolling style. You can have PCGen roll 4d6 and drop the lowest, roll 3d6, or roll 2d6 and add 6. + +You can also choose to use a point-purchasing mode with a budget of anything between 15 and 25. This method might appeal to players coming from video games, many of which use this method to allocate attributes. + +### Classes and levels + +Once you pick a class and add your first level, your attributes are locked in and you get a budget for all remaining class- and level-dependent aspects of your character. What exactly those are, of course, depends on what system you're playing, but PCGen keeps you updated on any remaining required tasks as you go. + +There are a lot of tabs in PCGen, and it can sometimes seem just as overwhelming as staring at a physical 300-page Player's Handbook, but as long as you follow the tips, PCGen can keep you on the straight and narrow. + +### Character sheets + +As if building your character wasn't enough fun, the most satisfying step is yet to come: seeing all your choices laid out in a proper character-sheet format. + +The final tab of PCGen is the Character Sheet tab, and it formats your character's attributes into a layout of your choice. The default is a standard, generic layout. It's easily printable and easy to understand. + +There are several variations and addendums available, too. For spellcasters, there's a spellbook sheet that lists available spells, and there are several alternate layouts, some optimized for screen and others for print. + +If you're using PCGen as you play, you can add temporary effects to your character sheet to let PCGen adjust your attributes accordingly. + +If you export your character and import it into the PCGen Importer on your Android phone or tablet, you can use your digital character sheet to track spells and current health and make temporary adjustments to armour class and other attribute modifiers. + +![Exported character sheet on Android][10] + +Exported character sheet on Android + +### PCGen's advantages + +The market is full of digital character-sheet trackers, but PCGen stands out for several reasons. First, it's cross-platform. That may or may not mean much to you, because we tend to standardize our workflow to devices that play nice with one another. In my gaming groups, though, we have Linux users and Windows users, and we have people who want to work off a mobile device and others who prefer a proper computer. Choosing an application that everyone can use and become comfortable with makes the process of updating stats more efficient. + +Second, because PCGen is open source, all your character data remains in an open and parsable format. As an XML fan, I find it invaluable to get my character data as an XML dump, and it's doubly useful to me as a DM as I prepare for an upcoming adventure and need custom monster stat blocks to insert in my notes. + +On a related note, knowing that PCGen will always be available regardless of a player's financial circumstance is also nice. When I changed jobs a year ago, I was lucky to go from one job to the next without interruption in income. In one of my gaming groups, however, two members have been made redundant recently and a third is a university student without much disposable income. The fact that we don't have to worry about monthly membership fees or whether we can all afford to invest in software that is, at the end of the day, a minor convenience over pen and paper gives us confidence in our choice of using digital tools. + +PCGen's open source license also lends itself to rapid development and expansion and ensured maintenance. The reason there's a mobile edition is that the code and data are open. Who knows what's next? + +While PCGen's default datasets revolve, naturally, around OGL content (because the OGL is open and allows content to be freely redistributed), since the application is also open, you can add whatever data you want. It's not necessarily trivial, but games like Open Legend, Dungeon Delvers, and other openly licensed games are ripe for porting to PCGen. + +### Pen and paper + +The pen-and-paper tradition remains important. PCGen strikes a healthy balance between the desire to make stats accounting more convenient by leveraging the latest technology while maintaining the joy of manually updating characters. + +Whether you're an old-school gamer who banishes digital devices from your table or a progressive gamer who embraces technology, it's fair to say most of us have encountered a few times when a game has come to a halt because of a phone or tablet. The fact is, everyone has a mobile device now (even me, even if it's only because my job pays for it), so they will make their way onto your game table. I have found that encouraging game-relevant information to be on screens has helped focus players on the game; I'd rather my players stare at their character sheets and game reference documents than surf social media sites on their devices. + +PCGen, in my experience, is the most true-to-form digital character sheet available. It allows for user control, it offers useful guidance as needed, and it's as close to pen-and-paper convenience as possible. Take a look at it, open gamers! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/pcgen-rpg-character-generator + +作者:[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]:http://libreoffice.org +[2]:http://pcgen.org +[3]:https://play.google.com/store/apps/details?id=com.dysfunctional.apps.pcgencharactersheet +[4]:http://pcgen.org/download/ +[5]:/file/394491 +[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pcgen_tip.jpg?itok=GXOz_OJ_ (PCGen to-do list) +[7]:/file/394486 +[8]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pcgen_sys.jpg?itok=Zn0_9hkQ (System selection) +[9]:/file/394481 +[10]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pcgen_screen.jpg?itok=4V6AZPud (Exported character sheet on Android) From facde3bb19975119d38c4bc41f0a8f90fc88cb98 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 12:43:50 +0800 Subject: [PATCH 0728/1057] PRF:20180401 9 Useful touch command examples in Linux.md @MjSeven --- ... Useful touch command examples in Linux.md | 168 +++++++++--------- 1 file changed, 82 insertions(+), 86 deletions(-) diff --git a/translated/tech/20180401 9 Useful touch command examples in Linux.md b/translated/tech/20180401 9 Useful touch command examples in Linux.md index 34aab2d024..d6feddf595 100644 --- a/translated/tech/20180401 9 Useful touch command examples in Linux.md +++ b/translated/tech/20180401 9 Useful touch command examples in Linux.md @@ -1,77 +1,74 @@ 在 Linux 下 9 个有用的 touch 命令示例 ===== -touch 命令用于创建空文件,并且更改 Unix 和 Linux 系统上现有文件时间戳。这里更改时间戳意味着更新文件和目录的访问以及修改时间。 +`touch` 命令用于创建空文件,也可以更改 Unix 和 Linux 系统上现有文件时间戳。这里所说的更改时间戳意味着更新文件和目录的访问以及修改时间。 -[![touch-command-examples-linux][1]![touch-command-examples-linux][2]][2] +![touch-command-examples-linux][2] -让我们来看看 touch 命令的语法和选项: +让我们来看看 `touch` 命令的语法和选项: -**语法**: # touch {选项} {文件} +**语法**: -touch 命令中使用的选项: +``` +# touch {选项} {文件} +``` -![touch-command-options][1] +`touch` 命令中使用的选项: ![touch-command-options][3] -在这篇文章中,我们将介绍 Linux 中 9 个有用的 touch 命令示例。 +在这篇文章中,我们将介绍 Linux 中 9 个有用的 `touch` 命令示例。 -### 示例:1 使用 touch 创建一个空文件 +### 示例:1 使用 touch 创建一个空文件 + +要在 Linux 系统上使用 `touch` 命令创建空文件,键入 `touch`,然后输入文件名。如下所示: -要在 Linux 系统上使用 touch 命令创建空文件,键入 touch,然后输入文件名。如下所示: ``` [root@linuxtechi ~]# touch devops.txt [root@linuxtechi ~]# ls -l devops.txt -rw-r--r--. 1 root root 0 Mar 29 22:39 devops.txt -[root@linuxtechi ~]# - ``` -### 示例:2 使用 touch 创建批量空文件 +### 示例:2 使用 touch 创建批量空文件 + +可能会出现一些情况,我们必须为某些测试创建大量空文件,这可以使用 `touch` 命令轻松实现: -可能会出现一些情况,我们必须为某些测试创建大量空文件,这可以使用 touch 命令轻松实现: ``` [root@linuxtechi ~]# touch sysadm-{1..20}.txt - ``` -在上面的例子中,我们创建了 20 个名为 sysadm-1.txt 到 sysadm-20.txt 的空文件,你可以根据需要更改名称和数字。 +在上面的例子中,我们创建了 20 个名为 `sysadm-1.txt` 到 `sysadm-20.txt` 的空文件,你可以根据需要更改名称和数字。 -### 示例:3 改变/更新文件和目录的访问时间 +### 示例:3 改变/更新文件和目录的访问时间 + +假设我们想要改变名为 `devops.txt` 文件的访问时间,在 `touch` 命令中使用 `-a` 选项,然后输入文件名。如下所示: -假设我们想要改变名为 **devops.txt** 文件的访问时间,在 touch 命令中使用 **-a** 选项,然后输入文件名。如下所示: ``` [root@linuxtechi ~]# touch -a devops.txt -[root@linuxtechi ~]# - ``` 现在使用 `stat` 命令验证文件的访问时间是否已更新: ``` [root@linuxtechi ~]# stat devops.txt -  File: ‘devops.txt’ -  Size: 0               Blocks: 0          IO Block: 4096   regular empty file -Device: fd00h/64768d    Inode: 67324178    Links: 1 -Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) + File: 'devops.txt' + Size: 0 Blocks: 0 IO Block: 4096 regular empty file +Device: fd00h/64768d Inode: 67324178 Links: 1 +Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:admin_home_t:s0 Access: 2018-03-29 23:03:10.902000000 -0400 Modify: 2018-03-29 22:39:29.365000000 -0400 Change: 2018-03-29 23:03:10.902000000 -0400 - Birth: - -[root@linuxtechi ~]# - + Birth: - ``` -**改变目录的访问时间** +**改变目录的访问时间:** + +假设我们在 `/mnt` 目录下有一个 `nfsshare` 文件夹,让我们用下面的命令改变这个文件夹的访问时间: -假设我们在 /mnt 目录下有一个 ‘nfsshare’ 文件夹,让我们用下面的命令改变这个文件夹的访问时间: ``` [root@linuxtechi ~]# touch -m /mnt/nfsshare/ -[root@linuxtechi ~]# - [root@linuxtechi ~]# stat /mnt/nfsshare/ -  File: ‘/mnt/nfsshare/’ +  File: '/mnt/nfsshare/'   Size: 6               Blocks: 0          IO Block: 4096   directory Device: fd00h/64768d    Inode: 2258        Links: 2 Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root) @@ -80,37 +77,34 @@ Access: 2018-03-29 23:34:38.095000000 -0400 Modify: 2018-03-03 10:42:45.194000000 -0500 Change: 2018-03-29 23:34:38.095000000 -0400  Birth: - -[root@linuxtechi ~]# - ``` -### 示例:4 更改访问时间而不用创建新文件 +### 示例:4 更改访问时间而不用创建新文件 + +在某些情况下,如果文件存在,我们希望更改文件的访问时间,并避免创建文件。在 touch 命令中使用 `-c` 选项即可,如果文件存在,那么我们可以改变文件的访问时间,如果不存在,我们也可不会创建它。 -在某些情况下,如果文件存在,我们希望更改文件的访问时间,并避免创建文件。在 touch 命令中使用 **-c** 选项即可,如果文件存在,那么我们可以改变文件的访问时间,如果不存在,我们也可不会创建它。 ``` [root@linuxtechi ~]# touch -c sysadm-20.txt [root@linuxtechi ~]# touch -c winadm-20.txt [root@linuxtechi ~]# ls -l winadm-20.txt ls: cannot access winadm-20.txt: No such file or directory -[root@linuxtechi ~]# - ``` -### 示例:5 更改文件和目录的修改时间 +### 示例:5 更改文件和目录的修改时间 -在 touch 命令中使用 **-m** 选项,我们可以更改文件和目录的修改时间。 +在 `touch` 命令中使用 `-m` 选项,我们可以更改文件和目录的修改时间。 + +让我们更改名为 `devops.txt` 文件的更改时间: -让我们更改名为 “devops.txt” 文件的更改时间: ``` [root@linuxtechi ~]# touch -m devops.txt -[root@linuxtechi ~]# - ``` -现在使用 stat 命令来验证修改时间是否改变: +现在使用 `stat` 命令来验证修改时间是否改变: + ``` [root@linuxtechi ~]# stat devops.txt -  File: ‘devops.txt’ +  File: 'devops.txt'   Size: 0               Blocks: 0          IO Block: 4096   regular empty file Device: fd00h/64768d    Inode: 67324178    Links: 1 Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) @@ -119,21 +113,19 @@ Access: 2018-03-29 23:03:10.902000000 -0400 Modify: 2018-03-29 23:59:49.106000000 -0400 Change: 2018-03-29 23:59:49.106000000 -0400  Birth: - -[root@linuxtechi ~]# - ``` 同样的,我们可以改变一个目录的修改时间: + ``` [root@linuxtechi ~]# touch -m /mnt/nfsshare/ -[root@linuxtechi ~]# - ``` -使用 stat 交叉验证访问和修改时间: +使用 `stat` 交叉验证访问和修改时间: + ``` [root@linuxtechi ~]# stat devops.txt -  File: ‘devops.txt’ +  File: 'devops.txt'   Size: 0               Blocks: 0          IO Block: 4096   regular empty file Device: fd00h/64768d    Inode: 67324178    Links: 1 Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) @@ -142,47 +134,47 @@ Access: 2018-03-30 00:06:20.145000000 -0400 Modify: 2018-03-30 00:06:20.145000000 -0400 Change: 2018-03-30 00:06:20.145000000 -0400  Birth: - -[root@linuxtechi ~]# - ``` -### 示例:7 将访问和修改时间设置为特定的日期和时间 +### 示例:7 将访问和修改时间设置为特定的日期和时间 -每当我们使用 touch 命令更改文件和目录的访问和修改时间时,它将当前时间设置为该文件或目录的访问和修改时间。 +每当我们使用 `touch` 命令更改文件和目录的访问和修改时间时,它将当前时间设置为该文件或目录的访问和修改时间。 -假设我们想要将特定的日期和时间设置为文件的访问和修改时间,这可以使用 touch 命令中的 ‘-c’ 和 ‘-t’ 选项来实现。 +假设我们想要将特定的日期和时间设置为文件的访问和修改时间,这可以使用 `touch` 命令中的 `-c` 和 `-t` 选项来实现。 -日期和时间可以使用以下格式指定:{CCYY}MMDDhhmm.ss +日期和时间可以使用以下格式指定: + +``` +{CCYY}MMDDhhmm.ss +``` 其中: - * CC – 年份的前两位数字 - * YY – 年份的后两位数字 - * MM – 月份 (01-12) - * DD – 天 (01-31) - * hh – 小时 (00-23) - * mm – 分钟 (00-59) + * `CC` – 年份的前两位数字 + * `YY` – 年份的后两位数字 + * `MM` – 月份 (01-12) + * `DD` – 天 (01-31) + * `hh` – 小时 (00-23) + * `mm` – 分钟 (00-59) + +让我们将 `devops.txt` 文件的访问和修改时间设置为未来的一个时间(2025 年 10 月 19 日 18 时 20 分)。 -让我们将 devops.txt file 文件的访问和修改时间设置为未来的一个时间( 2025 年, 10 月, 19 日, 18 时 20 分)。 ``` [root@linuxtechi ~]# touch -c -t 202510191820 devops.txt - ``` -使用 stat 命令查看更新访问和修改时间: - -![stat-command-output-linux][1] +使用 `stat` 命令查看更新访问和修改时间: ![stat-command-output-linux][4] -根据日期字符串设置访问和修改时间,在 touch 命令中使用 ‘-d’ 选项,然后指定日期字符串,后面跟文件名。如下所示: +根据日期字符串设置访问和修改时间,在 `touch` 命令中使用 `-d` 选项,然后指定日期字符串,后面跟文件名。如下所示: + ``` [root@linuxtechi ~]# touch -c -d "2010-02-07 20:15:12.000000000 +0530" sysadm-29.txt -[root@linuxtechi ~]# - ``` -使用 stat 命令验证文件的状态: +使用 `stat` 命令验证文件的状态: + ``` [root@linuxtechi ~]# stat sysadm-20.txt   File: ‘sysadm-20.txt’ @@ -194,39 +186,43 @@ Access: 2010-02-07 20:15:12.000000000 +0530 Modify: 2010-02-07 20:15:12.000000000 +0530 Change: 2018-03-30 10:23:31.584000000 +0530  Birth: - -[root@linuxtechi ~]# - ``` -**注意:**在上述命令中,如果我们不指定 ‘-c’,那么 touch 命令将创建一个新文件以防系统中存在该文件,并将时间戳设置为命令中给出的。 +**注意:**在上述命令中,如果我们不指定 `-c`,如果系统中不存在该文件那么 `touch` 命令将创建一个新文件,并将时间戳设置为命令中给出的。 -### 示例:8 使用参考文件设置时间戳(-r) +### 示例:8 使用参考文件设置时间戳(-r) -在 touch 命令中,我们可以使用参考文件来设置文件或目录的时间戳。假设我想在 “devops.txt” 文件上设置与文件 “sysadm-20.txt” 文件相同的时间戳,touch 命令中使用 ‘-r’ 选项可以轻松实现。 +在 `touch` 命令中,我们可以使用参考文件来设置文件或目录的时间戳。假设我想在 `devops.txt` 文件上设置与文件 `sysadm-20.txt` 文件相同的时间戳,`touch` 命令中使用 `-r` 选项可以轻松实现。 + +**语法:** + +``` +# touch -r {参考文件} 真正文件 +``` -**语法:**# touch -r {参考文件} 真正文件 ``` [root@linuxtechi ~]# touch -r sysadm-20.txt devops.txt -[root@linuxtechi ~]# - ``` -### 示例:9 在符号链接文件上更改访问和修改时间 +### 示例:9 在符号链接文件上更改访问和修改时间 -默认情况下,每当我们尝试使用 touch 命令更改符号链接文件的时间戳时,它只会更改原始文件的时间戳。如果你想更改符号链接文件的时间戳,则可以使用 touch 命令中的 ‘-h’ 选项来实现。 +默认情况下,每当我们尝试使用 `touch` 命令更改符号链接文件的时间戳时,它只会更改原始文件的时间戳。如果你想更改符号链接文件的时间戳,则可以使用 `touch` 命令中的 `-h` 选项来实现。 + +**语法:** + +``` +# touch -h {符号链接文件} +``` -**语法:** # touch -h {符号链接文件} ``` [root@linuxtechi opt]# ls -l /root/linuxgeeks.txt lrwxrwxrwx. 1 root root 15 Mar 30 10:56 /root/linuxgeeks.txt -> linuxadmins.txt [root@linuxtechi ~]# touch -t 203010191820 -h linuxgeeks.txt [root@linuxtechi ~]# ls -l linuxgeeks.txt lrwxrwxrwx. 1 root root 15 Oct 19  2030 linuxgeeks.txt -> linuxadmins.txt -[root@linuxtechi ~]# - ``` -这就是本教程的全部了。我希望这些例子能帮助你理解 touch 命令。请分享你的宝贵意见和评论。 +这就是本教程的全部了。我希望这些例子能帮助你理解 `touch` 命令。请分享你的宝贵意见和评论。 -------------------------------------------------------------------------------- @@ -234,7 +230,7 @@ via: https://www.linuxtechi.com/9-useful-touch-command-examples-linux/ 作者:[Pradeep Kumar][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 df38343f888280609ca1c968337417f766e726d8 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 12:44:12 +0800 Subject: [PATCH 0729/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Reset=20a=20los?= =?UTF-8?q?t=20root=20password=20in=20under=205=20minutes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...a lost root password in under 5 minutes.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..06e18a2d6d --- /dev/null +++ b/sources/tech/20180430 Reset a lost root password in under 5 minutes.md @@ -0,0 +1,80 @@ +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 From 2da76b34c9e8fe533e05767f8002fbb62b77cebd Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 12:44:32 +0800 Subject: [PATCH 0730/1057] PUB:20180401 9 Useful touch command examples in Linux.md @MjSeven https://linux.cn/article-9597-1.html --- .../20180401 9 Useful touch command examples in Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180401 9 Useful touch command examples in Linux.md (100%) diff --git a/translated/tech/20180401 9 Useful touch command examples in Linux.md b/published/20180401 9 Useful touch command examples in Linux.md similarity index 100% rename from translated/tech/20180401 9 Useful touch command examples in Linux.md rename to published/20180401 9 Useful touch command examples in Linux.md From 221d82bcc95c37621fdc94cb0028770c45574452 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 12:48:32 +0800 Subject: [PATCH 0731/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20practical?= =?UTF-8?q?=20Python=20tools:=20magic=20methods,=20iterators=20and=20gener?= =?UTF-8?q?ators,=20and=20method=20magic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rators and generators, and method magic.md | 633 ++++++++++++++++++ 1 file changed, 633 insertions(+) create mode 100644 sources/tech/20180430 3 practical Python tools- magic methods, iterators and generators, and method magic.md diff --git a/sources/tech/20180430 3 practical Python tools- magic methods, iterators and generators, and method magic.md b/sources/tech/20180430 3 practical Python tools- magic methods, iterators and generators, and method magic.md new file mode 100644 index 0000000000..2cb0e5a948 --- /dev/null +++ b/sources/tech/20180430 3 practical Python tools- magic methods, iterators and generators, and method magic.md @@ -0,0 +1,633 @@ +3 practical Python tools: magic methods, iterators and generators, and method magic +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/serving-bowl-forks-dinner.png?itok=a3YqPwr5) +Python offers a unique set of tools and language features that help make your code more elegant, readable, and intuitive. By selecting the right tool for the right problem, your code will be easier to maintain. In this article, we'll examine three of those tools: magic methods, iterators and generators, and method magic. + +### Magic methods + + +Magic methods can be considered the plumbing of Python. They're the methods that are called "under the hood" for certain built-in methods, symbols, and operations. A common magic method you may be familiar with is, `__init__()`,which is called when we want to initialize a new instance of a class. + +You may have seen other common magic methods, like `__str__` and `__repr__`. There is a whole world of magic methods, and by implementing a few of them, we can greatly modify the behavior of an object or even make it behave like a built-in datatype, such as a number, list, or dictionary. + +Let's take this `Money` class for example: +``` +class Money: + + + +    currency_rates = { + +        '$': 1, + +        '€': 0.88, + +    } + + + +    def __init__(self, symbol, amount): + +        self.symbol = symbol + +        self.amount = amount + + + +    def __repr__(self): + +        return '%s%.2f' % (self.symbol, self.amount) + + + +    def convert(self, other): + +        """ Convert other amount to our currency """ + +        new_amount = ( + +            other.amount / self.currency_rates[other.symbol] + +            * self.currency_rates[self.symbol]) + + + +        return Money(self.symbol, new_amount) + +``` + +The class defines a currency rate for a given symbol and exchange rate, specifies an initializer (also known as a constructor), and implements `__repr__`, so when we print out the class, we see a nice representation such as `$2.00` for an instance `Money('$', 2.00)` with the currency symbol and amount. Most importantly, it defines a method that allows you to convert between different currencies with different exchange rates. + +Using a Python shell, let's say we've defined the costs for two food items in different currencies, like so: +``` +>>> soda_cost = Money('$', 5.25) + +>>> soda_cost + +    $5.25 + + + +>>> pizza_cost = Money('€', 7.99) + +>>> pizza_cost + +    €7.99 + +``` + +We could use magic methods to help instances of this class interact with each other. Let's say we wanted to be able to add two instances of this class together, even if they were in different currencies. To make that a reality, we could implement the `__add__` magic method on our `Money` class: +``` +class Money: + + + +    # ... previously defined methods ... + + + +    def __add__(self, other): + +        """ Add 2 Money instances using '+' """ + +        new_amount = self.amount + self.convert(other).amount + +        return Money(self.symbol, new_amount) + +``` + +Now we can use this class in a very intuitive way: +``` +>>> soda_cost = Money('$', 5.25) + + + +>>> pizza_cost = Money('€', 7.99) + + + +>>> soda_cost + pizza_cost + +    $14.33 + + + +>>> pizza_cost + soda_cost + +    €12.61 + +``` + +When we add two instances together, we get a result in the first defined currency. All the conversion is done seamlessly under the hood. If we wanted to, we could also implement `__sub__` for subtraction, `__mul__` for multiplication, and many more. Read about [emulating numeric types][1], or read this [guide to magic methods][2] for others. + +We learned that `__add__` maps to the built-in operator `+`. Other magic methods can map to symbols like `[]`. For example, to access an item by index or key (in the case of a dictionary), use the `__getitem__` method: +``` +>>> d = {'one': 1, 'two': 2} + + + +>>> d['two'] + +2 + +>>> d.__getitem__('two') + +2 + +``` + +Some magic methods even map to built-in functions, such as `__len__()`, which maps to `len()`. +``` +class Alphabet: + +    letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + + + +    def __len__(self): + +        return len(self.letters) + + + + + +>>> my_alphabet = Alphabet() + +>>> len(my_alphabet) + +    26 + +``` + +### Custom iterators + +Custom iterators are an incredibly powerful but unfortunately confusing topic to new and seasoned Pythonistas alike. + +Many built-in types, such as lists, sets, and dictionaries, already implement the protocol that allows them to be iterated over under the hood. This allows us to easily loop over them. +``` +>>> for food in ['Pizza', 'Fries']: + +         print(food + '. Yum!') + + + +Pizza. Yum! + +Fries. Yum! + +``` + +How can we iterate over our own custom classes? First, let's clear up some terminology. + + * To be iterable, a class needs to implement `__iter__()` + * The `__iter__()` method needs to return an iterator + * To be an iterator, a class needs to implement `__next__()` (or `next()` [in Python 2][3]), which must raise a `StopIteration` exception when there are no more items to iterate over. + + + +Whew! It sounds complicated, but once you remember these fundamental concepts, you'll be able to iterate in your sleep. + +When might we want to use a custom iterator? Let's imagine a scenario where we have a `Server` instance running different services such as `http` and `ssh` on different ports. Some of these services have an `active` state while others are `inactive`. +``` +class Server: + + + +    services = [ + +        {'active': False, 'protocol': 'ftp', 'port': 21}, + +        {'active': True, 'protocol': 'ssh', 'port': 22}, + +        {'active': True, 'protocol': 'http', 'port': 80}, + +    ] + +``` + +When we loop over our `Server` instance, we only want to loop over `active` services. Let's create a new class, an `IterableServer`: +``` +class IterableServer: + + + +    def __init__(self): + +        self.current_pos = 0 + + + +    def __next__(self): + +        pass  # TODO: Implement and remember to raise StopIteration + +``` + +First, we initialize our current position to `0`. Then, we define a `__next__()` method, which will return the next item. We'll also ensure that we raise `StopIteration` when there are no more items to return. So far so good! Now, let's implement this `__next__()` method. +``` +class IterableServer: + + + +    def __init__(self): + +        self.current_pos = 0.  # we initialize our current position to zero + + + +    def __iter__(self):  # we can return self here, because __next__ is implemented + +        return self + + + +    def __next__(self): + +        while self.current_pos < len(self.services): + +            service = self.services[self.current_pos] + +            self.current_pos += 1 + +            if service['active']: + +                return service['protocol'], service['port'] + +        raise StopIteration + + + +    next = __next__  # optional python2 compatibility + +``` + +We keep looping over the services in our list while our current position is less than the length of the services but only returning if the service is active. Once we run out of services to iterate over, we raise a `StopIteration` exception. + +Because we implement a `__next__()` method that raises `StopIteration` when it is exhausted, we can return `self` from `__iter__()` because the `IterableServer` class adheres to the `iterable` protocol. + +Now we can loop over an instance of `IterableServer`, which will allow us to look at each active service, like so: +``` +>>> for protocol, port in IterableServer(): + +        print('service %s is running on port %d' % (protocol, port)) + + + +service ssh is running on port 22 + +service http is running on port 21 + +``` + +That's pretty great, but we can do better! In an instance like this, where our iterator doesn't need to maintain a lot of state, we can simplify our code and use a [generator][4] instead. +``` +class Server: + + + +    services = [ + +        {'active': False, 'protocol': 'ftp', 'port': 21}, + +        {'active': True, 'protocol': 'ssh', 'port': 22}, + +        {'active': True, 'protocol': 'http', 'port': 21}, + +    ] + + + +    def __iter__(self): + +        for service in self.services: + +            if service['active']: + +                yield service['protocol'], service['port'] + +``` + +What exactly is the `yield` keyword? Yield is used when defining a generator function. It's sort of like a `return`. While a `return` exits the function after returning the value, `yield` suspends execution until the next time it's called. This allows your generator function to maintain state until it resumes. Check out [yield's documentation][5] to learn more. With a generator, we don't have to manually maintain state by remembering our position. A generator knows only two things: what it needs to do right now and what it needs to do to calculate the next item. Once we reach a point of execution where `yield` isn't called again, we know to stop iterating. + +This works because of some built-in Python magic. In the [Python documentation for `__iter__()`][6] we can see that if `__iter__()` is implemented as a generator, it will automatically return an iterator object that supplies the `__iter__()` and `__next__()` methods. Read this great article for a deeper dive of [iterators, iterables, and generators][7]. + +### Method magic + +Due to its unique aspects, Python provides some interesting method magic as part of the language. + +One example of this is aliasing functions. Since functions are just objects, we can assign them to multiple variables. For example: +``` +>>> def foo(): + +       return 'foo' + + + +>>> foo() + +'foo' + + + +>>> bar = foo + + + +>>> bar() + +'foo' + +``` + +We'll see later on how this can be useful. + +Python provides a handy built-in, [called `getattr()`][8], that takes the `object, name, default` parameters and returns the attribute `name` on `object`. This programmatically allows us to access instance variables and methods. For example: +``` +>>> class Dog: + +        sound = 'Bark' + +        def speak(self): + +            print(self.sound + '!', self.sound + '!') + + + +>>> fido = Dog() + + + +>>> fido.sound + +'Bark' + +>>> getattr(fido, 'sound') + +'Bark' + + + +>>> fido.speak + +> + +>>> getattr(fido, 'speak') + +> + + + + + +>>> fido.speak() + +Bark! Bark! + +>>> speak_method = getattr(fido, 'speak') + +>>> speak_method() + +Bark! Bark! + +``` + +Cool trick, but how could we practically use `getattr`? Let's look at an example that allows us to write a tiny command-line tool to dynamically process commands. +``` +class Operations: + +    def say_hi(self, name): + +        print('Hello,', name) + + + +    def say_bye(self, name): + +        print ('Goodbye,', name) + + + +    def default(self, arg): + +        print ('This operation is not supported.') + + + +if __name__ == '__main__': + +    operations = Operations() + + + +    # let's assume we do error handling + +    command, argument = input('> ').split() + +    func_to_call = getattr(operations, command, operations.default) + +    func_to_call(argument) + +``` + +The output of our script is: +``` +$ python getattr.py + + + +> say_hi Nina + +Hello, Nina + + + +> blah blah + +This operation is not supported. + +``` + +Next, we'll look at `partial`. For example, **`functool.partial(func, *args, **kwargs)`** allows you to return a new [partial object][9] that behaves like `func` called with `args` and `kwargs`. If more `args` are passed in, they're appended to `args`. If more `kwargs` are passed in, they extend and override `kwargs`. Let's see it in action with a brief example: +``` +>>> from functools import partial + +>>> basetwo = partial(int, base=2) + +>>> basetwo + + + + + +>>> basetwo('10010') + +18 + + + +# This is the same as + +>>> int('10010', base=2) + +``` + +Let's see how this method magic ties together in some sample code from a library I enjoy using [called][10]`agithub`, which is a (poorly named) REST API client with transparent syntax that allows you to rapidly prototype any REST API (not just GitHub) with minimal configuration. I find this project interesting because it's incredibly powerful yet only about 400 lines of Python. You can add support for any REST API in about 30 lines of configuration code. `agithub` knows everything it needs to about protocol (`REST`, `HTTP`, `TCP`), but it assumes nothing about the upstream API. Let's dive into the implementation. + +Here's a simplified version of how we'd define an endpoint URL for the GitHub API and any other relevant connection properties. View the [full code][11] instead. +``` +class GitHub(API): + + + +    def __init__(self, token=None, *args, **kwargs): + +        props = ConnectionProperties(api_url = kwargs.pop('api_url', 'api.github.com')) + +        self.setClient(Client(*args, **kwargs)) + +        self.setConnectionProperties(props) + +``` + +Then, once your [access token][12] is configured, you can start using the [GitHub API][13]. +``` +>>> gh = GitHub('token') + +>>> status, data = gh.user.repos.get(visibility='public', sort='created') + +>>> # ^ Maps to GET /user/repos + +>>> data + +... ['tweeter', 'snipey', '...'] + +``` + +Note that it's up to you to spell things correctly. There's no validation of the URL. If the URL doesn't exist or anything else goes wrong, the error thrown by the API will be returned. So, how does this all work? Let's figure it out. First, we'll check out a simplified example of the [`API` class][14]: +``` +class API: + + + +    # ... other methods ... + + + +    def __getattr__(self, key): + +        return IncompleteRequest(self.client).__getattr__(key) + +    __getitem__ = __getattr__ + +``` + +Each call on the `API` class ferries the call to the [`IncompleteRequest` class][15] for the specified `key`. +``` +class IncompleteRequest: + + + +    # ... other methods ... + + + +    def __getattr__(self, key): + +        if key in self.client.http_methods: + +            htmlMethod = getattr(self.client, key) + +            return partial(htmlMethod, url=self.url) + +        else: + +            self.url += '/' + str(key) + +            return self + +    __getitem__ = __getattr__ + + + + + +class Client: + +    http_methods = ('get')  # ... and post, put, patch, etc. + + + +    def get(self, url, headers={}, **params): + +        return self.request('GET', url, None, headers) + +``` + +If the last call is not an HTTP method (like 'get', 'post', etc.), it returns an `IncompleteRequest` with an appended path. Otherwise, it gets the right function for the specified HTTP method from the [`Client` class][16] and returns a `partial` . + +What happens if we give a non-existent path? +``` +>>> status, data = this.path.doesnt.exist.get() + +>>> status + +... 404 + +``` + +And because `__getitem__` is aliased to `__getattr__`: +``` +>>> owner, repo = 'nnja', 'tweeter' + +>>> status, data = gh.repos[owner][repo].pulls.get() + +>>> # ^ Maps to GET /repos/nnja/tweeter/pulls + +>>> data + +.... # {....} + +``` + +Now that's some serious method magic! + +### Learn more + +Python provides plenty of tools that allow you to make your code more elegant and easier to read and understand. The challenge is finding the right tool for the job, but I hope this article added some new ones to your toolbox. And, if you'd like to take this a step further, you can read about decorators, context managers, context generators, and `NamedTuple`s on my blog [nnja.io][17]. As you become a better Python developer, I encourage you to get out there and read some source code for well-architected projects. [Requests][18] and [Flask][19] are two great codebases to start with. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/elegant-solutions-everyday-python-problems + +作者:[Nina Zakharenko][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/nnja +[1]:https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types +[2]:https://rszalski.github.io/magicmethods/ +[3]:https://docs.python.org/2/library/stdtypes.html#iterator.next +[4]:https://docs.python.org/3/library/stdtypes.html#generator-types +[5]:https://docs.python.org/3/reference/expressions.html#yieldexpr +[6]:https://docs.python.org/3/reference/datamodel.html#object.__iter__ +[7]:http://nvie.com/posts/iterators-vs-generators/ +[8]:https://docs.python.org/3/library/functions.html#getattr +[9]:https://docs.python.org/3/library/functools.html#functools.partial +[10]:https://github.com/mozilla/agithub +[11]:https://github.com/mozilla/agithub/blob/master/agithub/GitHub.py +[12]:https://github.com/settings/tokens +[13]:https://developer.github.com/v3/repos/#list-your-repositories +[14]:https://github.com/mozilla/agithub/blob/dbf7014e2504333c58a39153aa11bbbdd080f6ac/agithub/base.py#L30-L58 +[15]:https://github.com/mozilla/agithub/blob/dbf7014e2504333c58a39153aa11bbbdd080f6ac/agithub/base.py#L60-L100 +[16]:https://github.com/mozilla/agithub/blob/dbf7014e2504333c58a39153aa11bbbdd080f6ac/agithub/base.py#L102-L231 +[17]:http://nnja.io +[18]:https://github.com/requests/requests +[19]:https://github.com/pallets/flask +[20]:https://us.pycon.org/2018/schedule/presentation/164/ +[21]:https://us.pycon.org/2018/ From f07b87e68f601015a530ebabd7ff1202b809d7c7 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 12:51:28 +0800 Subject: [PATCH 0732/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20Beginners?= =?UTF-8?q?=20Guide=20To=20Flatpak?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180428 A Beginners Guide To Flatpak.md | 311 ++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100644 sources/tech/20180428 A Beginners Guide To Flatpak.md diff --git a/sources/tech/20180428 A Beginners Guide To Flatpak.md b/sources/tech/20180428 A Beginners Guide To Flatpak.md new file mode 100644 index 0000000000..db1dfa8181 --- /dev/null +++ b/sources/tech/20180428 A Beginners Guide To Flatpak.md @@ -0,0 +1,311 @@ +A Beginners Guide To Flatpak +====== + +![](https://www.ostechnix.com/wp-content/uploads/2016/06/flatpak-720x340.jpg) + +A while, we have written about [**Ubuntu’s Snaps**][1]. Snaps are introduced by Canonical for Ubuntu operating system, and later it was adopted by other Linux distributions such as Arch, Gentoo, and Fedora etc. A snap is a single binary package bundled with all required libraries and dependencies, and you can install it on any Linux distribution, regardless of its version and architecture. Similar to Snaps, there is also another tool called **Flatpak**. As you may already know, packaging distributed applications for different Linux distributions are quite time consuming and difficult process. Each distributed application has different set of libraries and dependencies for various Linux distributions. But, Flatpak, the new framework for desktop applications that completely reduces this burden. Now, you can build a single Flatpak app and install it on various operating systems. How cool, isn’t it? + +Also, the users don’t have to worry about the libraries and dependencies, everything is bundled within the app itself. Most importantly, Flaptpak apps are sandboxed and isolated from the rest of the host operating system, and other applications. Another notable feature is we can install multiple versions of the same application at the same time in the same system. For example, you can install VLC player version 2.1, 2.2, and 2.3 on the same system. So, the developers can test different versions of same application at a time. + +In this tutorial, we will see how to install Flatpak in GNU/Linux. + +### Install Flatpak + +Flatpak is available for many popular Linux distributions such as Arch Linux, Debian, Fedora, Gentoo, Red Hat, Linux Mint, openSUSE, Solus, Mageia and Ubuntu distributions. + +To install Flatpak on Arch Linux, run: +``` +$ sudo pacman -S flatpak + +``` + +Flatpak is available in the default repositories of Debian Stretch and newer. To install it, run: +``` +$ sudo apt install flatpak + +``` + +On Fedora, Flatpak is installed by default. All you have to do is enable enable Flathub as described in the next section. + +Just in case, it is not installed for any reason, run: +``` +$ sudo dnf install flatpak + +``` + +On RHEL 7, run: +``` +$ sudo yum install flatpak + +``` + +On Linux Mint 18.3, flatpak is installed by default. So, no setup required. + +On openSUSE Tumbleweed, Flatpak can also be installed using Zypper: +``` +$ sudo zypper install flatpak + +``` + +On Ubuntu, add the following repository and install Flatpak as shown below. +``` +$ sudo add-apt-repository ppa:alexlarsson/flatpak + +$ sudo apt update + +$ sudo apt install flatpak + +``` + +The Flatpak plugin for the Software app makes it possible to install apps without needing the command line. To install this plugin, run: +``` +$ sudo apt install gnome-software-plugin-flatpak + +``` + +For other Linux distributions, refer the official installation [**link**][2]. + +### Getting Started With Flatpak + +There are many popular applications such as Gimp, Kdenlive, Steam, Spotify, Visual studio code etc., available as flatpaks. + +Let us now see the basic usage of flatpak command. + +First of all, we need to add remote repositories. + +#### Adding Remote Repositories** + +**Enable Flathub Repository:** + +**Flathub** is nothing but a central repository where all flatpak applications available to users. To enable it, just run: +``` +$ sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + +``` + +Flathub is enough to install most popular apps. Just in case you wanted to try some GNOME apps, add the GNOME repository. + +**Enable GNOME Repository:** + +The GNOME repository contains all GNOME core applications. GNOME flatpak repository itself is available as two versions, **stable** and **nightly**. + +To add GNOME stable repository, run the following commands: +``` +$ wget https://sdk.gnome.org/keys/gnome-sdk.gpg + +$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg --if-not-exists gnome-apps https://sdk.gnome.org/repo-apps/ + +``` + +Applications in this repository require the **3.20 version of the org.gnome.Platform runtime**. + +To install the stable runtimes, run: +``` +$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg gnome https://sdk.gnome.org/repo/ + +``` + +To add the GNOME nightly apps repository, run: +``` +$ wget https://sdk.gnome.org/nightly/keys/nightly.gpg + +$ sudo flatpak remote-add --gpg-import=nightly.gpg --if-not-exists gnome-nightly-apps https://sdk.gnome.org/nightly/repo-apps/ + +``` + +Applications in this repository require the **nightly version of the org.gnome.Platform runtime**. + +To install the nightly runtimes, run: +``` +$ sudo flatpak remote-add --gpg-import=nightly.gpg gnome-nightly https://sdk.gnome.org/nightly/repo/ + +``` + +#### Listing Remotes + +To list all configured remote repositories, run: +``` +$ flatpak remotes +Name Options +flathub system +gnome system +gnome-apps system +gnome-nightly system +gnome-nightly-apps system + +``` + +As you can see, the above command lists the remotes that you have added in your system. It also lists whether the remote has been added per-user or system-wide. + +#### Removing Remotes + +To remove a remote, for example flathub, simply do; +``` +$ sudo flatpak remote-delete flathub + +``` + +Here **flathub** is remote name. + +#### Installing Flatpak Applications + +In this section, we will see how to install flatpak apps. To install a flatpak application + +To install an application, simply do: +``` +$ sudo flatpak install flathub com.spotify.Client + +``` + +All the apps in the GNOME stable repository uses the version name of “stable”. + +To install any Stable GNOME applications, for example **Evince** , run: +``` +$ sudo flatpak install gnome-apps org.gnome.Evince stable + +``` + +All the apps in the GNOME nightly repository uses the version name of “master”. + +For example, to install gedit, run: +``` +$ sudo flatpak install gnome-nightly-apps org.gnome.gedit master + +``` + +If you don’t want to install apps system-wide, you also can install flatpak apps per-user like below. +``` +$ flatpak install --user + +``` + +All installed apps will be stored in **$HOME/.var/app/** location. +``` +$ ls $HOME/.var/app/ +com.spotify.Client + +``` + +#### Running Flatpak Applications + +You can launch the installed applications at any time from the application launcher. From command line, you can run it, for example Spotify, using command: +``` +$ flatpak run com.spotify.Client + +``` + +#### Listing Applications + +To view the installed applications and runtimes, run: +``` +$ flatpak list + +``` + +To view only the applications, not run times, use this command instead. +``` +$ flatpak list --app + +``` + +You can also view the list of available applications and runtimes from all remotes using command: +``` +$ flatpak remote-ls + +``` + +To list only applications not runtimes, run: +``` +$ flatpak remote-ls --app + +``` + +To list applications and runtimes from a specific repository, for example **gnome-apps** , run: +``` +$ flatpak remote-ls gnome-apps + +``` + +To list only the applications from a remote repository, run: +``` +$ flatpak remote-ls flathub --app + +``` + +#### Updating Applications + +To update all your flatpak applications, run: +``` +$ flatpak update + +``` + +To update a specific application, we do: +``` +$ flatpak update com.spotify.Client + +``` + +#### Getting Details Of Applications + +To display the details of a installed application, run: +``` +$ flatpak info io.github.mmstick.FontFinder + +``` + +Sample output: +``` +Ref: app/io.github.mmstick.FontFinder/x86_64/stable +ID: io.github.mmstick.FontFinder +Arch: x86_64 +Branch: stable +Origin: flathub +Date: 2018-04-11 15:10:31 +0000 +Subject: Workaround appstream issues (391ef7f5) +Commit: 07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4 +Parent: dbff9150fce9fdfbc53d27e82965010805f16491ec7aa1aa76bf24ec1882d683 +Location: /var/lib/flatpak/app/io.github.mmstick.FontFinder/x86_64/stable/07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4 +Installed size: 2.5 MB +Runtime: org.gnome.Platform/x86_64/3.28 + +``` + +#### Removing Applications + +To remove a flatpak application, run: +``` +$ sudo flatpak uninstall com.spotify.Client + +``` + +For details, refer flatpak help section. +``` +$ flatpak --help + +``` + +And, that’s all for now. Hope you had basic idea about Flatpak. + +If you find this guide useful, please share it on your social, professional networks and support OSTechNix. + +More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/flatpak-new-framework-desktop-applications-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]:http://www.ostechnix.com/introduction-ubuntus-snap-packages/ +[2]:https://flatpak.org/setup/ From 137ec530c627a5cad79993704330bd5b87f1c158 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 12:59:44 +0800 Subject: [PATCH 0733/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Testing=20IPv6?= =?UTF-8?q?=20Networking=20in=20KVM:=20Part=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Testing IPv6 Networking in KVM- Part 2.md | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..b9787effe0 --- /dev/null +++ b/sources/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md @@ -0,0 +1,119 @@ +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 From a9010018d0001286b4c148a0faf0519963d59239 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 13:12:05 +0800 Subject: [PATCH 0734/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Easily=20Search?= =?UTF-8?q?=20And=20Install=20Google=20Web=20Fonts=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...h And Install Google Web Fonts In Linux.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..cbed6ac244 --- /dev/null +++ b/sources/tech/20180430 Easily Search And Install Google Web Fonts In Linux.md @@ -0,0 +1,87 @@ +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 From d9b082aa44c4bcda9ad2f069c9a97ccc38eb240c Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 15:01:28 +0800 Subject: [PATCH 0735/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20Python=20te?= =?UTF-8?q?mplate=20libraries=20compared?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...27 3 Python template libraries compared.md | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 sources/tech/20180427 3 Python template libraries compared.md diff --git a/sources/tech/20180427 3 Python template libraries compared.md b/sources/tech/20180427 3 Python template libraries compared.md new file mode 100644 index 0000000000..18a434150b --- /dev/null +++ b/sources/tech/20180427 3 Python template libraries compared.md @@ -0,0 +1,135 @@ +3 Python template libraries compared +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/library-libraries-search.png?itok=xH8xSU_G) +In my day job, I spend a lot of time wrangling data from various sources into human-readable information. While a lot of the time this just takes the form of a spreadsheet or some type of chart or other data visualization, there are other times when it makes sense to present the data instead in a written format. + +But a pet peeve of mine is copying and pasting. If you’re moving data from its source to a standardized template, you shouldn’t be copying and pasting either. It’s error-prone, and honestly, it’s not a good use of your time. + +So for any piece of information I send out regularly which follows a common pattern, I tend to find some way to automate at least a chunk of it. Maybe that involves creating a few formulas in a spreadsheet, a quick shell script, or some other solution to autofill a template with information pulled from an outside source. + +But lately, I’ve been exploring Python templating to do much of the work of creating reports and graphs from other datasets. + +Python templating engines are hugely powerful. My use case of simplifying report creation only scratches the surface of what they can be put to work for. Many developers are making use of these tools to build full-fledged web applications and content management systems. But you don’t have to have a grand vision of a complicated web app to make use of Python templating tools. + +### Why templating? + +Each templating tool is a little different, and you should read the documentation to understand the exact usage. But let’s create a hypothetical example. Let’s say I’d like to create a short page listing all of the Python topics I've written about recently. Something like this: +``` +html> + +  head> + +    title>/title> + +  /head> + +  body> + +    p>/p> + +    ul> + +      li>/li> + +      li>/li> + +      li>/li> + +    /ul> + +  /body> + +/html>My Python articlesThese are some of the things I have written about Python:Python GUIsPython IDEsPython web scrapers + +``` + +Simple enough to maintain when it’s just these three items. But what happens when I want to add a fourth, or fifth, or sixty-seventh? Rather than hand-coding this page, could I generate it from a CSV or other data file containing a list of all of my pages? Could I easily create duplicates of this for every topic I've written on? Could I programmatically change the text or title or heading on each one of those pages? That's where a templating engine can come into play. + +There are many different options to choose from, and today I'll share with you three, in no particular order: [Mako][6], [Jinja2][7], and [Genshi][8]. + +### Mako + +[Mako][6] is a Python templating tool released under the MIT license that is designed for fast performance (not unlike Jinja2). Mako has been used by Reddit to power their web pages, as well as being the default templating language for web frameworks like Pyramid and Pylons. It's also fairly simple and straightforward to use; you can design templates with just a couple of lines of code. Supporting both Python 2.x and 3.x, it's a powerful and feature-rich tool with [good documentation][9], which I consider a must. Features include filters, inheritance, callable blocks, and a built-in caching system, which could be import for large or complex web projects. + +### Jinja2 + +Jinja2 is another speedy and full-featured option, available for both Python 2.x and 3.x under a BSD license. Jinja2 has a lot of overlap from a feature perspective with Mako, so for a newcomer, your choice between the two may come down to which formatting style you prefer. Jinja2 also compiles your templates to bytecode, and has features like HTML escaping, sandboxing, template inheritance, and the ability to sandbox portions of templates. Its users include Mozilla, SourceForge, NPR, Instagram, and others, and also features [strong documentation][10]. Unlike Mako, which uses Python inline for logic inside your templates, Jinja2 uses its own syntax. + +### Genshi + +[Genshi][8] is the third option I'll mention. It's really an XML tool which has a strong templating component, so if the data you are working with is already in XML format, or you need to work with formatting beyond a web page, Genshi might be a good solution for you. HTML is basically a type of XML (well, not precisely, but that's beyond the scope of this article and a bit pedantic), so formatting them is quite similar. Since a lot of the data I work with commonly is in one flavor of XML or another, I appreciated working with a tool I could use for multiple things. + +The release version currently only supports Python 2.x, although Python 3 support exists in trunk, I would caution you that it does not appear to be receiving active development. Genshi is made available under a BSD license. + +### Example + +So in our hypothetical example above, rather than update the HTML file every time I write about a new topic, I can update it programmatically. I can create a template, which might look like this: +``` +html> + +  head> + +    title>/title> + +  /head> + +  body> + +    p>/p> + +    ul> + +      %for topic in topics: + +      li>/li> + +      %endfor + +    /ul> + +  /body> + +/html>My Python articlesThese are some of the things I have written about Python:%for topic in topics:${topic}%endfor + +``` + +And then I can iterate across each topic with my templating library, in this case, Mako, like this: +``` +from mako.template import Template + + + +mytemplate = Template(filename='template.txt') + +print(mytemplate.render(topics=("Python GUIs","Python IDEs","Python web scrapers"))) + +``` + +Of course, in a real-world usage, rather than listing the contents manually in a variable, I would likely pull them from an outside data source, like a database or an API. + +These are not the only Python templating engines out there. If you’re starting down the path of creating a new project which will make heavy use of templates, you’ll want to consider more than just these three. Check out this much more comprehensive list on the [Python wiki][11] for more projects that are worth considering. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/resources/python/template-libraries + +作者:[Jason Baker][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/jason-baker +[1]:https://opensource.com/resources/python?intcmp=7016000000127cYAAQ +[2]:https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ +[3]:https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ +[4]:https://opensource.com/tags/python?intcmp=7016000000127cYAAQ +[5]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ +[6]:http://www.makotemplates.org/ +[7]:http://jinja.pocoo.org/ +[8]:https://genshi.edgewall.org/ +[9]:http://docs.makotemplates.org/en/latest/ +[10]:http://jinja.pocoo.org/docs/2.10/ +[11]:https://wiki.python.org/moin/Templating From b8b7a66b1a319ae1617279d715cb908bb0e41e3f Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 2 May 2018 15:04:30 +0800 Subject: [PATCH 0736/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Comp?= =?UTF-8?q?ile=20a=20Linux=20Kernel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180427 How to Compile a Linux Kernel.md | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..cc71b7fbae --- /dev/null +++ b/sources/tech/20180427 How to Compile a Linux Kernel.md @@ -0,0 +1,144 @@ +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 From 15754fbc9f4c239b85ff076d7b151b237fda5b09 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 21:36:37 +0800 Subject: [PATCH 0737/1057] PRF:20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md @geekpi --- ... Transferred Files Over SSH Using Rsync.md | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/translated/tech/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md b/translated/tech/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md index 3ae2d7761c..7f3f10a6e3 100644 --- a/translated/tech/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md +++ b/translated/tech/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md @@ -1,17 +1,17 @@ -如何使用 Rsync 通过 SSH 恢复部分传输的文件 +如何使用 rsync 通过 SSH 恢复部分传输的文件 ====== ![](https://www.ostechnix.com/wp-content/uploads/2016/02/Resume-Partially-Transferred-Files-Over-SSH-Using-Rsync.png) -由于诸如电源故障、网络故障或用户干预等各种原因,使用 SCP 命令通过 SSH 复制的大型文件可能会中断,取消或损坏。有一天,我将 Ubuntu 16.04 ISO 文件复制到我的远程系统。不幸的是断电了,网络连接立即丢失。结果么?复制过程终止!这只是一个简单的例子。Ubuntu ISO 并不是那么大,一旦电源恢复,我就可以重新启动复制过程。但在生产环境中,当你在传输大型文件时,你可能并不希望这样做。 +由于诸如电源故障、网络故障或用户干预等各种原因,使用 `scp` 命令通过 SSH 复制的大型文件可能会中断、取消或损坏。有一天,我将 Ubuntu 16.04 ISO 文件复制到我的远程系统。不幸的是断电了,网络连接立即断了。结果么?复制过程终止!这只是一个简单的例子。Ubuntu ISO 并不是那么大,一旦电源恢复,我就可以重新启动复制过程。但在生产环境中,当你在传输大型文件时,你可能并不希望这样做。 -而且,你不能总是使用 **scp** 命令恢复被中止的进度。因为,如果你这样做,它只会覆盖现有的文件。这时你会怎么做?别担心!这是 **Rsync** 派上用场的地方!Rsync 可以帮助你恢复中断的复制或下载过程。对于那些好奇的人,Rsync 是一个快速、多功能的文件复制程序,可用于复制和传输远程和本地系统中的文件或文件夹。 +而且,你不能继续使用 `scp` 命令恢复被中止的进度。因为,如果你这样做,它只会覆盖现有的文件。这时你会怎么做?别担心!这是 `rsync` 派上用场的地方!`rsync` 可以帮助你恢复中断的复制或下载过程。对于那些好奇的人,`rsync` 是一个快速、多功能的文件复制程序,可用于复制和传输远程和本地系统中的文件或文件夹。 -它提供了大量控制其行为的每个方面的选项,并允许非常灵活地指定要复制的一组文件。它以增量传输算法而闻名,它通过仅发送源文件和目标中现有文件之间的差异来减少通过网络发送的数据量。 Rsync 广泛用于备份和镜像,以及日常使用中改进的复制命令。 +它提供了大量控制其各种行为的选项,并允许非常灵活地指定要复制的一组文件。它以增量传输算法而闻名,它通过仅发送源文件和目标中现有文件之间的差异来减少通过网络发送的数据量。 `rsync` 广泛用于备份和镜像,以及日常使用中改进的复制命令。 -就像 SCP 一样,rsync 也会通过 SSH 复制文件。如果你想通过 SSH 下载或传输大文件和文件夹,我建议您使用 rsync。请注意,**应该在两边都安装 rsync**(远程和本地系统)来恢复部分传输的文件。 +就像 `scp` 一样,`rsync` 也会通过 SSH 复制文件。如果你想通过 SSH 下载或传输大文件和文件夹,我建议您使用 `rsync`。请注意,应该在两边(远程和本地系统)都安装 `rsync` 来恢复部分传输的文件。 -### 使用 Rsync 恢复部分传输的文件 +### 使用 rsync 恢复部分传输的文件 好吧,让我给你看一个例子。我将使用命令将 Ubuntu 16.04 ISO 从本地系统复制到远程系统: @@ -21,33 +21,32 @@ $ scp Soft_Backup/OS\ Images/Linux/ubuntu-16.04-desktop-amd64.iso sk@192.168.43. 这里, - * **sk**是我的远程系统的用户名 - * **192.168.43.2** 是远程机器的 IP 地址。 + * `sk`是我的远程系统的用户名 + * `192.168.43.2` 是远程机器的 IP 地址。 +现在,我按下 `CTRL+C` 结束它。 - -现在,我按下 **CTRL+c** 结束它。 - -**示例输出:** +示例输出: ``` sk@192.168.43.2's password: ubuntu-16.04-desktop-amd64.iso 26% 372MB 26.2MB/s 00:39 ETA^c ``` -[![][1]][2] +![][2] 正如你在上面的输出中看到的,当它达到 26% 时,我终止了复制过程。 如果我重新运行上面的命令,它只会覆盖现有的文件。换句话说,复制过程不会在我断开的地方恢复。 -为了恢复复制过程,我们可以使用 **rsync** 命令,如下所示。 +为了恢复复制过程,我们可以使用 `rsync` 命令,如下所示。 ``` $ rsync -P -rsh=ssh Soft_Backup/OS\ Images/Linux/ubuntu-16.04-desktop-amd64.iso sk@192.168.43.2:/home/sk/ ``` -**示例输出:** +示例输出: + ``` sk@192.168.1.103's password: sending incremental file list @@ -55,14 +54,15 @@ ubuntu-16.04-desktop-amd64.iso                    380.56M 26% 41.05MB/s 0:00:25 ``` -[![][1]][4] +![][4] + +看见了吗?现在,复制过程在我们之前断开的地方恢复了。你也可以像下面那样使用 `-partial` 而不是 `-P` 参数。 -看见了吗?现在,复制过程在我们之前断开的地方恢复了。你也可以像下面那样使用 “-partial” 而不是 “-P” 参数。 ``` $ rsync --partial -rsh=ssh Soft_Backup/OS\ Images/Linux/ubuntu-16.04-desktop-amd64.iso sk@192.168.43.2:/home/sk/ ``` -这里,参数 “-partial” 或 “-P” 告诉 rsync 命令保留部分下载的文件并恢复进度。 +这里,参数 `-partial` 或 `-P` 告诉 `rsync` 命令保留部分下载的文件并恢复进度。 或者,我们也可以使用以下命令通过 SSH 恢复部分传输的文件。 @@ -76,26 +76,24 @@ $ rsync -avP Soft_Backup/OS\ Images/Linux/ubuntu-16.04-desktop-amd64.iso sk@192. rsync -av --partial Soft_Backup/OS\ Images/Linux/ubuntu-16.04-desktop-amd64.iso sk@192.168.43.2:/home/sk/ ``` -就是这样了。你现在知道如何使用 rsync 命令恢复取消、中断和部分下载的文件。正如你所看到的,它也不是那么难。如果两个系统都安装了 rsync,我们可以轻松地通过上面描述的那样恢复复制进度。 +就是这样了。你现在知道如何使用 `rsync` 命令恢复取消、中断和部分下载的文件。正如你所看到的,它也不是那么难。如果两个系统都安装了 `rsync`,我们可以轻松地通过上面描述的那样恢复复制的进度。 -如果你觉得本教程有帮助,请在你的社交、专业网络上分享,并支持 OSTechNix。还有更多的好东西。敬请关注! +如果你觉得本教程有帮助,请在你的社交、专业网络上分享,并支持我们。还有更多的好东西。敬请关注! 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-resume-partially-downloaded-or-transferred-files-using-rsync/ 作者:[SK][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/) 荣誉推出 [a]:https://www.ostechnix.com/author/sk/ [1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]:http://www.ostechnix.com/wp-content/uploads/2016/02/scp.png () +[2]:http://www.ostechnix.com/wp-content/uploads/2016/02/scp.png [3]:/cdn-cgi/l/email-protection -[4]:http://www.ostechnix.com/wp-content/uploads/2016/02/rsync.png () +[4]:http://www.ostechnix.com/wp-content/uploads/2016/02/rsync.png From f238012f8d82a756af913bcefa1252480fef1a6c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 21:36:53 +0800 Subject: [PATCH 0738/1057] PUB:20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md @geekpi --- ... To Resume Partially Transferred Files Over SSH Using Rsync.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md (100%) diff --git a/translated/tech/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md b/published/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md similarity index 100% rename from translated/tech/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md rename to published/20180129 How To Resume Partially Transferred Files Over SSH Using Rsync.md From a4dec2d9ee0deafc3935c92554a0c07156f45562 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 21:53:37 +0800 Subject: [PATCH 0739/1057] PRF:20180122 A Simple Command-line Snippet Manager.md @MjSeven --- ...2 A Simple Command-line Snippet Manager.md | 117 +++++++++++------- 1 file changed, 72 insertions(+), 45 deletions(-) diff --git a/translated/tech/20180122 A Simple Command-line Snippet Manager.md b/translated/tech/20180122 A Simple Command-line Snippet Manager.md index f9e827024e..dd18a8cb10 100644 --- a/translated/tech/20180122 A Simple Command-line Snippet Manager.md +++ b/translated/tech/20180122 A Simple Command-line Snippet Manager.md @@ -1,12 +1,13 @@ -一个简单的命令行片段管理器 +Pet:一个简单的命令行片段管理器 ===== ![](https://www.ostechnix.com/wp-content/uploads/2018/01/pet-6-720x340.png) -我们不可能记住所有的命令,对吧?是的。除了经常使用的命令之外,我们几乎不可能记住一些很少使用的长命令。这就是为什么需要一些外部工具来帮助我们在需要时找到命令。在过去,我们已经审查了两个有用的工具,名为 "Bashpast" 和 "Keep"。使用 Bashpast,我们可以轻松地为 Linux 命令添加书签,以便更轻松地重复调用。而且,Keep 实用程序可以用来在终端中保留一些重要且冗长的命令,以便你可以按需使用它们。今天,我们将看到该系列中的另一个工具,以帮助你记住命令。现在向 "Pet" 打个招呼,这是一个用 Go 语言编写的简单的命令行代码管理器。 + +我们不可能记住所有的命令,对吧?是的。除了经常使用的命令之外,我们几乎不可能记住一些很少使用的长命令。这就是为什么需要一些外部工具来帮助我们在需要时找到命令。在过去,我们已经点评了两个有用的工具,名为 “Bashpast” 和 “Keep”。使用 Bashpast,我们可以轻松地为 Linux 命令添加书签,以便更轻松地重复调用。而 Keep 实用程序可以用来在终端中保留一些重要且冗长的命令,以便你可以随时使用它们。今天,我们将看到该系列中的另一个工具,以帮助你记住命令。现在让我们认识一下 “Pet”,这是一个用 Go 语言编写的简单的命令行代码管理器。 使用 Pet,你可以: - * 注册/添加你重要的,冗长和复杂的命令片段。 + * 注册/添加你重要的、冗长和复杂的命令片段。 * 以交互方式来搜索保存的命令片段。 * 直接运行代码片段而无须一遍又一遍地输入。 * 轻松编辑保存的代码片段。 @@ -14,68 +15,78 @@ * 在片段中使用变量 * 还有很多特性即将来临。 - -#### 安装 Pet 命令行接口代码管理器 +### 安装 Pet 命令行接口代码管理器 由于它是用 Go 语言编写的,所以确保你在系统中已经安装了 Go。 安装 Go 后,从 [**Pet 发布页面**][3] 获取最新的二进制文件。 + ``` wget https://github.com/knqyf263/pet/releases/download/v0.2.4/pet_0.2.4_linux_amd64.zip ``` 对于 32 位计算机: + ``` wget https://github.com/knqyf263/pet/releases/download/v0.2.4/pet_0.2.4_linux_386.zip ``` 解压下载的文件: + ``` unzip pet_0.2.4_linux_amd64.zip ``` 对于 32 位: + ``` unzip pet_0.2.4_linux_386.zip ``` -将 pet 二进制文件复制到 PATH(即 **/usr/local/bin** 之类的)。 +将 `pet` 二进制文件复制到 PATH(即 `/usr/local/bin` 之类的)。 + ``` sudo cp pet /usr/local/bin/ ``` 最后,让它可以执行: + ``` sudo chmod +x /usr/local/bin/pet ``` 如果你使用的是基于 Arch 的系统,那么你可以使用任何 AUR 帮助工具从 AUR 安装它。 -使用 [**Pacaur**][4]: +使用 [Pacaur][4]: + ``` pacaur -S pet-git ``` -使用 [**Packer**][5]: +使用 [Packer][5]: + ``` packer -S pet-git ``` -使用 [**Yaourt**][6]: +使用 [Yaourt][6]: + ``` yaourt -S pet-git ``` -使用 [**Yay** :][7] +使用 [Yay][7]: + ``` yay -S pet-git ``` -此外,你需要安装 **[fzf][8]** 或 [**peco**][9] 工具已启用交互式搜索。请参阅官方 GitHub 链接了解如何安装这些工具。 +此外,你需要安装 [fzf][8] 或 [peco][9] 工具以启用交互式搜索。请参阅官方 GitHub 链接了解如何安装这些工具。 -#### 用法 +### 用法 + +运行没有任何参数的 `pet` 来查看可用命令和常规选项的列表。 -运行没有任何参数的 'pet' 来查看可用命令和常规选项的列表。 ``` $ pet pet - Simple command-line snippet manager. @@ -103,21 +114,23 @@ Use "pet [command] --help" for more information about a command. ``` 要查看特定命令的帮助部分,运行: + ``` $ pet [command] --help ``` -**配置 Pet** - -它只适用于默认值。但是,你可以更改默认目录来保存片段,选择要使用的选择器 (fzf 或 peco),默认文本编辑器编辑片段,添加 GIST id 详细信息等。 +#### 配置 Pet +默认配置其实工作的挺好。但是,你可以更改保存片段的默认目录,选择要使用的选择器(fzf 或 peco),编辑片段的默认文本编辑器,添加 GIST id 详细信息等。 要配置 Pet,运行: + ``` $ pet configure ``` -该命令将在默认的文本编辑器中打开默认配置(例如我是 **vim**),根据你的要求更改或编辑特定值。 +该命令将在默认的文本编辑器中打开默认配置(例如我是 vim),根据你的要求更改或编辑特定值。 + ``` [General] snippetfile = "/home/sk/.config/pet/snippet.toml" @@ -133,24 +146,27 @@ $ pet configure ~ ``` -**创建片段** +#### 创建片段 为了创建一个新的片段,运行: + ``` $ pet new ``` -添加命令和描述,然后按下 ENTER 键保存它。 +添加命令和描述,然后按下回车键保存它。 + ``` Command> echo 'Hell1o, Welcome1 2to OSTechNix4' | tr -d '1-9' Description> Remove numbers from output. ``` -[![][10]][11] +![][11] -这是一个简单的命令,用于从 echo 命令输出中删除所有数字。你可以很轻松地记住它。但是,如果你很少使用它,几天后你可能会完全忘记它。当然,我们可以使用 "CTRL+r" 搜索历史记录,但 "Pet" 会更容易。另外,Pet 可以帮助你添加任意数量的条目。 +这是一个简单的命令,用于从 `echo` 命令输出中删除所有数字。你可以很轻松地记住它。但是,如果你很少使用它,几天后你可能会完全忘记它。当然,我们可以使用 `CTRL+R` 搜索历史记录,但 Pet 会更容易。另外,Pet 可以帮助你添加任意数量的条目。 + +另一个很酷的功能是我们可以轻松添加以前的命令。为此,在你的 `.bashrc` 或 `.zshrc` 文件中添加以下行。 -另一个很酷的功能是我们可以轻松添加以前的命令。为此,在你的 **.bashrc** 或 **.zshrc** 文件中添加以下行。 ``` function prev() { PREV=$(fc -lrn | head -n 1) @@ -159,46 +175,53 @@ function prev() { ``` 执行以下命令来使保存的更改生效。 + ``` source .bashrc ``` -或者 +或者: + ``` source .zshrc ``` 现在,运行任何命令,例如: + ``` $ cat Documents/ostechnix.txt | tr '|' '\n' | sort | tr '\n' '|' | sed "s/.$/\\n/g" ``` -要添加上述命令,你不必使用 "pet new" 命令。只需要: +要添加上述命令,你不必使用 `pet new` 命令。只需要: + ``` $ prev ``` -将说明添加到命令代码片段中,然后按下 ENTER 键保存。 +将说明添加到该命令代码片段中,然后按下回车键保存。 ![][12] -**片段列表** +#### 片段列表 要查看保存的片段,运行: + ``` $ pet list ``` ![][13] -**编辑片段** +#### 编辑片段 + +如果你想编辑代码片段的描述或命令,运行: -如果你想编辑描述或代码片段的命令,运行: ``` $ pet edit ``` 这将在你的默认文本编辑器中打开所有保存的代码片段,你可以根据需要编辑或更改片段。 + ``` [[snippets]] description = "Remove numbers from output." @@ -211,33 +234,35 @@ $ pet edit output = "" ``` -**在片段中使用标签** +#### 在片段中使用标签 + +要将标签用于判断,使用下面的 `-t` 标志。 -要将标签用于判断,使用下面的 **-t** 标志。 ``` $ pet new -t Command> echo 'Hell1o, Welcome1 2to OSTechNix4' | tr -d '1-9 Description> Remove numbers from output. Tag> tr command examples - ``` -**执行片段** +#### 执行片段 要执行一个保存的片段,运行: + ``` $ pet exec ``` -从列表中选择你要运行的代码段,然后按 ENTER 键来运行它: +从列表中选择你要运行的代码段,然后按回车键来运行它: ![][14] 记住你需要安装 fzf 或 peco 才能使用此功能。 -**寻找片段** +#### 寻找片段 如果你有很多要保存的片段,你可以使用字符串或关键词如 below.qjz 轻松搜索它们。 + ``` $ pet search ``` @@ -246,40 +271,43 @@ $ pet search ![][15] -**同步片段** +#### 同步片段 -首先,你需要获取访问令牌。转到此链接 并创建访问令牌(只需要 "gist" 范围)。 +首先,你需要获取访问令牌。转到此链接 并创建访问令牌(只需要 “gist” 范围)。 使用以下命令来配置 Pet: + ``` $ pet configure ``` -将标记设置到 **[Gist]** 字段中的 **access_token**。 +将令牌设置到 `[Gist]` 字段中的 `access_token`。 设置完成后,你可以像下面一样将片段上传到 Gist。 + ``` $ pet sync -u Gist ID: 2dfeeeg5f17e1170bf0c5612fb31a869 Upload success - ``` -你也可以在其他 PC 上下载片段。为此,编辑配置文件并在 **[Gist]** 中将 **Gist ID** 设置为 **gist_id**。 +你也可以在其他 PC 上下载片段。为此,编辑配置文件并在 `[Gist]` 中将 `gist_id` 设置为 GIST id。 + +之后,使用以下命令下载片段: -之后,下载片段使用以下命令: ``` $ pet sync Download success - ``` -获取更多细节,参阅 help 选项: +获取更多细节,参阅帮助选项: + ``` pet -h ``` -或者 +或者: + ``` pet [command] -h ``` @@ -289,14 +317,13 @@ pet [command] -h 干杯! - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/pet-simple-command-line-snippet-manager/ 作者:[SK][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 29715fe9962dd4cd8e7802297e684f2c138e93d0 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 21:54:02 +0800 Subject: [PATCH 0740/1057] PUB:20180122 A Simple Command-line Snippet Manager.md @MjSeven https://linux.cn/article-9600-1.html --- .../20180122 A Simple Command-line Snippet Manager.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180122 A Simple Command-line Snippet Manager.md (100%) diff --git a/translated/tech/20180122 A Simple Command-line Snippet Manager.md b/published/20180122 A Simple Command-line Snippet Manager.md similarity index 100% rename from translated/tech/20180122 A Simple Command-line Snippet Manager.md rename to published/20180122 A Simple Command-line Snippet Manager.md From cd662c55d38d62f40c98954b3579c26d78be5966 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 22:18:04 +0800 Subject: [PATCH 0741/1057] PRF:20180403 10 fundamental commands for new Linux users.md @MjSeven --- ...undamental commands for new Linux users.md | 109 ++++++++++-------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/translated/tech/20180403 10 fundamental commands for new Linux users.md b/translated/tech/20180403 10 fundamental commands for new Linux users.md index 671ef52d49..a423d7671e 100644 --- a/translated/tech/20180403 10 fundamental commands for new Linux users.md +++ b/translated/tech/20180403 10 fundamental commands for new Linux users.md @@ -1,7 +1,10 @@ -对于 Linux 新手来说 10 个基础的命令 +每个 Linux 新手都应该知道的 10 个命令 ===== +> 通过这 10 个基础命令开始掌握 Linux 命令行。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_terminals.png?itok=CfBqYBah) + 你可能认为你是 Linux 新手,但实际上并不是。全球互联网用户有 [3.74 亿][1],他们都以某种方式使用 Linux,因为 Linux 服务器占据了互联网的 90%。大多数现代路由器运行 Linux 或 Unix,[TOP500 超级计算机][2] 也依赖于 Linux。如果你拥有一台 Android 智能手机,那么你的操作系统就是由 Linux 内核构建的。 换句话说,Linux 无处不在。 @@ -10,118 +13,124 @@ 下面是你需要知道的基本的 Linux 命令。每一个都很简单,也很容易记住。换句话说,你不必成为比尔盖茨就能理解它们。 -### 1\. ls +### 1、 ls -你可能会想:“这是什么东西?”不,那不是一个印刷错误 - 我真的打算输入一个小写的 l。`ls`,或者 “list,” 是你需要知道的使用 Linux CLI 的第一个命令。这个 list 命令在 Linux 终端中运行,以显示在相应文件系统下归档的所有主要目录。例如,这个命令: +你可能会想:“这是(is)什么东西?”不,那不是一个印刷错误 —— 我真的打算输入一个小写的 l。`ls`,或者说 “list”, 是你需要知道的使用 Linux CLI 的第一个命令。这个 list 命令在 Linux 终端中运行,以显示在存放在相应文件系统下的所有主要目录。例如,这个命令: -`ls /applications` +``` +ls /applications +``` -显示存储在 applications 文件夹下的每个文件夹,你将使用它来查看文件、文件夹和目录。 +显示存储在 `applications` 文件夹下的每个文件夹,你将使用它来查看文件、文件夹和目录。 显示所有隐藏的文件都可以使用命令 `ls -a`。 -### 2\. cd +### 2、 cd -这个命令是你用来跳转(或“更改”)到一个目录的。它指导你如何从一个文件夹导航到另一个文件夹。假设你位于 Downloads 文件夹中,但你想到名为 Gym Playlist 的文件夹中,简单地输入 `cd Gym Playlist` 将不起作用,(译注:这应该是 Gym 目录下的 Playlist 文件夹)因为 shell 不会识别它,并会报告你正在查找的文件夹不存在。要跳转到那个文件夹,你需要包含一个反斜杠。改命令如下所示: +这个命令是你用来跳转(或“更改”)到一个目录的。它指导你如何从一个文件夹导航到另一个文件夹。假设你位于 `Downloads` 文件夹中,但你想到名为 `Gym Playlist` 的文件夹中,简单地输入 `cd Gym Playlist` 将不起作用,因为 shell 不会识别它,并会报告你正在查找的文件夹不存在(LCTT 译注:这是因为目录名中有空格)。要跳转到那个文件夹,你需要包含一个反斜杠。改命令如下所示: -`cd Gym\ Playlist` +``` +cd Gym\ Playlist +``` -要从当前文件夹返回到上一个文件夹,你可以输入 `cd ..` 后跟着文件夹名称(译注:返回上一层目录不应该是 cd .. ?)。把这两个点想象成一个后退按钮。 +要从当前文件夹返回到上一个文件夹,你可以在该文件夹输入 `cd ..`。把这两个点想象成一个后退按钮。 -### 3\. mv +### 3、 mv 该命令将文件从一个文件夹转移到另一个文件夹;`mv` 代表“移动”。你可以使用这个简单的命令,就像你把一个文件拖到 PC 上的一个文件夹一样。 -例如,如果我想创建一个名为 `testfile` 的文件来演示所有基本的 Linux 命令,并且我想将它移动到我的 Documents 文件夹中,我将输入这个命令: +例如,如果我想创建一个名为 `testfile` 的文件来演示所有基本的 Linux 命令,并且我想将它移动到我的 `Documents` 文件夹中,我将输入这个命令: -`mv /home/sam/testfile /home/sam/Documents/` +``` +mv /home/sam/testfile /home/sam/Documents/ +``` 命令的第一部分(`mv`)说我想移动一个文件,第二部分(`home/sam/testfile`)表示我想移动的文件,第三部分(`/home/sam/Documents/`)表示我希望传输文件的位置。 -### 4\. 快捷键 +### 4、 快捷键 好吧,这不止一个命令,但我忍不住把它们都包括进来。为什么?因为它们能节省时间并避免经历头痛。 -`CTRL+K` 从光标处剪切文本直至本行结束 - -`CTRL+Y` 粘贴文本 - -`CTRL+E` 将光标移到本行的末尾 - -`CTRL+A` 将光标移动到本行的开头 - -`ALT+F` 跳转到下一个空格处 - -`ALT+B` 回到之前的空格处 - -`ALT+Backspace` 删除前一个词 - -`CTRL+W` 将光标前一个词剪贴 - -`Shift+Insert` 将文本粘贴到终端中 - -`Ctrl+D` 注销 +- `CTRL+K` 从光标处剪切文本直至本行结束 +- `CTRL+Y` 粘贴文本 +- `CTRL+E` 将光标移到本行的末尾 +- `CTRL+A` 将光标移动到本行的开头 +- `ALT+F` 跳转到下一个空格处 +- `ALT+B` 回到前一个空格处 +- `ALT+Backspace` 删除前一个词 +- `CTRL+W` 剪切光标前一个词 +- `Shift+Insert` 将文本粘贴到终端中 +- `Ctrl+D` 注销 这些命令在许多方面都能派上用场。例如,假设你在命令行文本中拼错了一个单词: -`sudo apt-get intall programname` +``` +sudo apt-get intall programname +``` -你可能注意到 "insatll" 拼写错了,因此该命令无法工作。但是快捷键可以让你分容易回去修复它。如果我的光标在这一行的末尾,我可以按下两次 `ALT+B` 来将光标移动到下面用 `^` 符号标记的地方: +你可能注意到 `install` 拼写错了,因此该命令无法工作。但是快捷键可以让你很容易回去修复它。如果我的光标在这一行的末尾,我可以按下两次 `ALT+B` 来将光标移动到下面用 `^` 符号标记的地方: -`sudo apt-get^intall programname` +``` +sudo apt-get^intall programname +``` 现在,我们可以快速地添加字母 `s` 来修复 `install`,十分简单! -### 5\. mkdir +### 5、 mkdir 这是你用来在 Linux 环境下创建目录或文件夹的命令。例如,如果你像我一样喜欢 DIY,你可以输入 `mkdir DIY` 为你的 DIY 项目创建一个目录。 -### 6\. at +### 6、 at 如果你想在特定时间运行 Linux 命令,你可以将 `at` 添加到语句中。语法是 `at` 后面跟着你希望命令运行的日期和时间,然后命令提示符变为 `at>`,这样你就可以输入在上面指定的时间运行的命令。 例如: -`at 4:08 PM Sat` -`at> cowsay 'hello'` -`at> CTRL+D` +``` +at 4:08 PM Sat +at> cowsay 'hello' +at> CTRL+D +``` -这将会在周六下午 4:08 运行 cowsay 程序。 +这将会在周六下午 4:08 运行 `cowsay` 程序。 -### 7\. rmdir +### 7、 rmdir 这个命令允许你通过 Linux CLI 删除一个目录。例如: -`rmdir testdirectory` +``` +rmdir testdirectory +``` 请记住,这个命令不会删除里面有文件的目录。这只在删除空目录时才起作用。 -### 8\. rm +### 8、 rm 如果你想删除文件,`rm` 命令就是你想要的。它可以删除文件和目录。要删除一个文件,键入 `rm testfile`,或者删除一个目录和里面的文件,键入 `rm -r`。 -### 9\. touch +### 9、 touch -`touch` 命令,也就是所谓的 "make file 命令",允许你使用 Linux CLI 创建新的、空的文件。很像 `mkdir` 创建目录,`touch` 会创建文件。例如,`touch testfile` 将会创建一个名为 testfile 的空文件。 +`touch` 命令,也就是所谓的 “make file 的命令”,允许你使用 Linux CLI 创建新的、空的文件。很像 `mkdir` 创建目录,`touch` 会创建文件。例如,`touch testfile` 将会创建一个名为 testfile 的空文件。 -### 10\. locate +### 10、 locate 这个命令是你在 Linux 系统中用来查找文件的命令。就像在 Windows 中搜索一样,如果你忘了存储文件的位置或它的名字,这是非常有用的。 例如,如果你有一个关于区块链用例的文档,但是你忘了标题,你可以输入 `locate -blockchain` 或者通过用星号分隔单词来查找 "blockchain use cases",或者星号(`*`)。例如: -`locate -i*blockchain*use*cases*` +``` +locate -i*blockchain*use*cases* +``` 还有很多其他有用的 Linux CLI 命令,比如 `pkill` 命令,如果你开始关机但是你意识到你并不想这么做,那么这条命令很棒。但是这里描述的 10 个简单而有用的命令是你开始使用 Linux 命令行所需的基本知识。 - -------------------------------------------------------------------------------- via: https://opensource.com/article/18/4/10-commands-new-linux-users 作者:[Sam Bocetta][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 e1c0dc1df7f6960d13571cb8c3fd0cc6dbb15c4e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 2 May 2018 22:18:29 +0800 Subject: [PATCH 0742/1057] PUB:20180403 10 fundamental commands for new Linux users.md @MjSeven https://linux.cn/article-9601-1.html --- .../20180403 10 fundamental commands for new Linux users.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180403 10 fundamental commands for new Linux users.md (100%) diff --git a/translated/tech/20180403 10 fundamental commands for new Linux users.md b/published/20180403 10 fundamental commands for new Linux users.md similarity index 100% rename from translated/tech/20180403 10 fundamental commands for new Linux users.md rename to published/20180403 10 fundamental commands for new Linux users.md From d38958e23069c54163bcd1423eb8b0effa3f443c Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 3 May 2018 08:55:05 +0800 Subject: [PATCH 0743/1057] translated --- ...0420 A Perl module for better debugging.md | 82 ------------------- ...0420 A Perl module for better debugging.md | 80 ++++++++++++++++++ 2 files changed, 80 insertions(+), 82 deletions(-) delete mode 100644 sources/tech/20180420 A Perl module for better debugging.md create mode 100644 translated/tech/20180420 A Perl module for better debugging.md diff --git a/sources/tech/20180420 A Perl module for better debugging.md b/sources/tech/20180420 A Perl module for better debugging.md deleted file mode 100644 index ca9f8bd8fd..0000000000 --- a/sources/tech/20180420 A Perl module for better debugging.md +++ /dev/null @@ -1,82 +0,0 @@ -translating---geekpi - -A Perl module for better debugging -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/annoyingbugs.png?itok=ywFZ99Gs) -It's occasionally useful to have a block of Perl code that you use only for debugging or development tweaking. That's fine, but having blocks like this can be expensive to performance, particularly if the decision whether to execute it is made at runtime. - -[Curtis "Ovid" Poe][1] recently wrote a module that can help with this problem: [Keyword::DEVELOPMENT][2]. The module utilizes Keyword::Simple and the pluggable keyword architecture introduced in Perl 5.012 to create a new keyword: DEVELOPMENT. It uses the value of the PERL_KEYWORD_DEVELOPMENT environment variable to determine whether or not a block of code is to be executed. - -Using it couldn't be easier: -``` -use Keyword::DEVELOPMENT; - -        - -sub doing_my_big_loop { - -    my $self = shift; - -    DEVELOPMENT { - -        # insert expensive debugging code here! - -    } - -}Keyworddoing_my_big_loopDEVELOPMENT - -``` - -At compile time, the code inside the DEVELOPMENT block is optimized away and simply doesn't exist. - -Do you see the advantage here? Set up the PERL_KEYWORD_DEVELOPMENT environment variable to be true on your sandbox and false on your production environment, and valuable debugging tools can be committed to your code repo, always there when you need them. - -You could also use this module, in the absence of a more evolved configuration management system, to handle variations in settings between production and development or test environments: -``` -sub connect_to_my_database { - -        - -    my $dsn = "dbi:mysql:productiondb"; - -    my $user = "db_user"; - -    my $pass = "db_pass"; - -    - -    DEVELOPMENT { - -        # Override some of that config information - -        $dsn = "dbi:mysql:developmentdb"; - -    } - -    - -    my $db_handle = DBI->connect($dsn, $user, $pass); - -}connect_to_my_databaseDEVELOPMENTDBI - -``` - -Later enhancement to this snippet would have you reading in configuration information from somewhere else, perhaps from a YAML or INI file, but I hope you see the utility here. - -I looked at the source code for Keyword::DEVELOPMENT and spent about a half hour wondering, "Gosh, why didn't I think of that?" Once Keyword::Simple is installed, the module that Curtis has given us is surprisingly simple. It's an elegant solution to something I've needed in my own coding practice for a long time. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/perl-module-debugging-code - -作者:[Ruth Holloway][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/druthb -[1]:https://metacpan.org/author/OVID -[2]:https://metacpan.org/pod/release/OVID/Keyword-DEVELOPMENT-0.04/lib/Keyword/DEVELOPMENT.pm diff --git a/translated/tech/20180420 A Perl module for better debugging.md b/translated/tech/20180420 A Perl module for better debugging.md new file mode 100644 index 0000000000..c2f599f8f5 --- /dev/null +++ b/translated/tech/20180420 A Perl module for better debugging.md @@ -0,0 +1,80 @@ +一个更好的调试 Perl 模块 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/annoyingbugs.png?itok=ywFZ99Gs) +只有在调试或开发调整时才使用 Perl 代码块有时会很有用。这很好,但是这样的代码块可能会对性能产生很大的影响, 尤其是在运行时决定是否执行它。 + +[Curtis“Ovid”Poe][1] 编写了一个可以帮助解决这个问题的模块:[Keyword::DEVELOPMENT][2]。该模块利用 Keyword::Simple 和 Perl 5.012 中引入的可插入关键字架构来创建新的关键字:DEVELOPMENT。它使用 PERL_KEYWORD_DEVELOPMENT 环境变量的值来确定是否要执行一段代码。 + +使用它并不容易: +``` +use Keyword::DEVELOPMENT; + +        + +sub doing_my_big_loop { + +    my $self = shift; + +    DEVELOPMENT { + +        # insert expensive debugging code here! + +    } + +}Keyworddoing_my_big_loopDEVELOPMENT + +``` + +在编译时,DEVELOPMENT 块内的代码已经被优化掉了,根本就不存在。 + +你看到好处了么?在沙盒中将 PERL_KEYWORD_DEVELOPMENT 环境变量设置为 true,在生产环境设为 false,并且可以将有价值的调试工具提交到你的代码库中,在你需要的时候随时可用。 + +在缺乏高级配置管理的系统中,你也可以使用此模块来处理生产和开发或测试环境之间的设置差异: +``` +sub connect_to_my_database { + +        + +    my $dsn = "dbi:mysql:productiondb"; + +    my $user = "db_user"; + +    my $pass = "db_pass"; + +    + +    DEVELOPMENT { + +        # Override some of that config information + +        $dsn = "dbi:mysql:developmentdb"; + +    } + +    + +    my $db_handle = DBI->connect($dsn, $user, $pass); + +}connect_to_my_databaseDEVELOPMENTDBI + +``` + +稍后对此代码片段的增强使你能在其他地方,比如 YAML 或 INI 中读取配置信息,但我希望您能在此看到该工具。 + +我查看了关键字 Keyword::DEVELOPMENT 的源码,花了大约半小时研究,“天哪,我为什么没有想到这个?”安装 Keyword::Simple 后,Curtis 给我们的模块就非常简单了。这是我长期以来在自己的编码实践中需要的一个优雅解决方案。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/4/perl-module-debugging-code + +作者:[Ruth Holloway][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/druthb +[1]:https://metacpan.org/author/OVID +[2]:https://metacpan.org/pod/release/OVID/Keyword-DEVELOPMENT-0.04/lib/Keyword/DEVELOPMENT.pm From 69ad7fdea4ab1fd9dfc8cb42cb516d419cd78adf Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 3 May 2018 08:58:45 +0800 Subject: [PATCH 0744/1057] translating --- .../20180425 Enhance your Python with an interactive shell.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180425 Enhance your Python with an interactive shell.md b/sources/tech/20180425 Enhance your Python with an interactive shell.md index 19826d142b..4d1f6a9a9d 100644 --- a/sources/tech/20180425 Enhance your Python with an interactive shell.md +++ b/sources/tech/20180425 Enhance your Python with an interactive shell.md @@ -1,3 +1,5 @@ +translating---geekpi + Enhance your Python with an interactive shell ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/03/python-shells-816x345.jpg) From f500b3328b9b23bcac5bce994707139dea8814e1 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Thu, 3 May 2018 10:35:23 +0800 Subject: [PATCH 0745/1057] submit tech/20180417 How to do math on the Linux command line.md --- ...ow to do math on the Linux command line.md | 349 ------------------ ...ow to do math on the Linux command line.md | 344 +++++++++++++++++ 2 files changed, 344 insertions(+), 349 deletions(-) delete mode 100644 sources/tech/20180417 How to do math on the Linux command line.md create mode 100644 translated/tech/20180417 How to do math on the Linux command line.md diff --git a/sources/tech/20180417 How to do math on the Linux command line.md b/sources/tech/20180417 How to do math on the Linux command line.md deleted file mode 100644 index a6e37cf19e..0000000000 --- a/sources/tech/20180417 How to do math on the Linux command line.md +++ /dev/null @@ -1,349 +0,0 @@ -pinewall translating - -How to do math on the Linux command line -====== - -![](https://images.techhive.com/images/article/2014/12/math_blackboard-100534564-large.jpg) -Can you do math on the Linux command line? You sure can! In fact, there are quite a few commands that can make the process easy and some you might even find interesting. Let's look at some very useful commands and syntax for command line math. - -### expr - -First and probably the most obvious and commonly used command for performing mathematical calculations on the command line is the **expr** (expression) command. It can manage addition, subtraction, division, and multiplication. It can also be used to compare numbers. Here are some examples: - -#### Incrementing a variable -``` -$ count=0 -$ count=`expr $count + 1` -$ echo $count -1 - -``` - -#### Performing a simple calculations -``` -$ expr 11 + 123 -134 -$ expr 134 / 11 -12 -$ expr 134 - 11 -123 -$ expr 11 * 123 -expr: syntax error <== oops! -$ expr 11 \* 123 -1353 -$ expr 20 % 3 -2 - -``` - -Notice that you have to use a \ character in front of * to avoid the syntax error. The % operator is for modulo calculations. - -Here's a slightly more complex example: -``` -participants=11 -total=156 -share=`expr $total / $participants` -remaining=`expr $total - $participants \* $share` -echo $share -14 -echo $remaining -2 - -``` - -If we have 11 participants in some event and 156 prizes to distribute, each participant's fair share of the take is 14, leaving 2 in the pot. - -#### Making comparisons - -Now let's look at the logic for comparisons. These statements may look a little odd at first. They are not setting values, but only comparing the numbers. What **expr** is doing in the examples below is determining whether the statements are true. If the result is 1, the statement is true; otherwise, it's false. -``` -$ expr 11 = 11 -1 -$ expr 11 = 12 -0 - -``` - -Read them as "Does 11 equal 11?" and "Does 11 equal 12?" and you'll get used to how this works. Of course, no one would be asking if 11 equals 11 on the command line, but they might ask if $age equals 11. -``` -$ age=11 -$ expr $age = 11 -1 - -``` - -If you put the numbers in quotes, you'd actually be doing a string comparison rather than a numeric one. -``` -$ expr "11" = "11" -1 -$ expr "eleven" = "11" -0 - -``` - -In the following examples, we're asking whether 10 is greater than 5 and, then, whether it's greater than 99. -``` -$ expr 10 \> 5 -1 -$ expr 10 \> 99 -0 - -``` - -Of course, having true comparisons resulting in 1 and false resulting in 0 goes against what we generally expect on Linux systems. The example below shows that using **expr** in this kind of context doesn't work because **if** works with the opposite orientation (0=true). -``` -#!/bin/bash - -echo -n "Cost to us> " -read cost -echo -n "Price we're asking> " -read price - -if [ `expr $price \> $cost` ]; then - echo "We make money" -else - echo "Don't sell it" -fi - -``` - -Now, let's run this script: -``` -$ ./checkPrice -Cost to us> 11.50 -Price we're asking> 6 -We make money - -``` - -That sure isn't going to help with sales! With a small change, this would work as we'd expect: -``` -#!/bin/bash - -echo -n "Cost to us> " -read cost -echo -n "Price we're asking> " -read price - -if [ `expr $price \> $cost` == 1 ]; then - echo "We make money" -else - echo "Don't sell it" -fi - -``` - -### factor - -The **factor** command works just like you'd probably expect. You feed it a number, and it tells you what its factors are. -``` -$ factor 111 -111: 3 37 -$ factor 134 -134: 2 67 -$ factor 17894 -17894: 2 23 389 -$ factor 1987 -1987: 1987 - -``` - -NOTE: The factor command didn't get very far on factoring that last value because 1987 is a **prime number**. - -### jot - -The **jot** command allows you to create a list of numbers. Provide it with the number of values you want to see and the number that you want to start with. -``` -$ jot 8 10 -10 -11 -12 -13 -14 -15 -16 -17 - -``` - -You can also use **jot** like this. Here we're asking it to decrease the numbers by telling it we want to stop when we get to 2: -``` -$ jot 8 10 2 -10 -9 -8 -7 -5 -4 -3 -2 - -``` - -The **jot** command can be useful if you want to iterate through a series of numbers to create a list for some other purpose. -``` -$ for i in `jot 7 17`; do echo April $i; done -April 17 -April 18 -April 19 -April 20 -April 21 -April 22 -April 23 - -``` - -### bc - -The **bc** command is probably one of the best tools for doing calculations on the command line. Enter the calculation that you want performed, and pipe it to the command like this: -``` -$ echo "123.4+5/6-(7.89*1.234)" | bc -113.664 - -``` - -Notice that **bc** doesn't shy away from precision and that the string you need to enter is fairly straightforward. It can also make comparisons, handle Booleans, and calculate square roots, sines, cosines, tangents, etc. -``` -$ echo "sqrt(256)" | bc -16 -$ echo "s(90)" | bc -l -.89399666360055789051 - -``` - -In fact, **bc** can even calculate pi. You decide how many decimal points you want to see: -``` -$ echo "scale=5; 4*a(1)" | bc -l -3.14156 -$ echo "scale=10; 4*a(1)" | bc -l -3.1415926532 -$ echo "scale=20; 4*a(1)" | bc -l -3.14159265358979323844 -$ echo "scale=40; 4*a(1)" | bc -l -3.1415926535897932384626433832795028841968 - -``` - -And **bc** isn't just for receiving data through pipes and sending answers back. You can also start it interactively and enter the calculations you want it to perform. Setting the scale (as shown below) determines how many decimal places you'll see. -``` -$ bc -bc 1.06.95 -Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. -This is free software with ABSOLUTELY NO WARRANTY. -For details type `warranty'. -scale=2 -3/4 -.75 -2/3 -.66 -quit - -``` - -Using **bc** , you can also convert numbers between different bases. The **obase** setting determines the output base. -``` -$ bc -bc 1.06.95 -Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. -This is free software with ABSOLUTELY NO WARRANTY. -For details type `warranty'. -obase=16 -16 <=== entered -10 <=== response -256 <=== entered -100 <=== response -quit - -``` - -One of the easiest ways to convert between hex and decimal is to use **bc** like this: -``` -$ echo "ibase=16; F2" | bc -242 -$ echo "obase=16; 242" | bc -F2 - -``` - -In the first example above, we're converting from hex to decimal by setting the input base (ibase) to hex (base 16). In the second, we're doing the reverse by setting the outbut base (obase) to hex. - -### Easy bash math - -With sets of double-parentheses, we can do some easy math in bash. In the examples below, we create a variable and give it a value and then perform addition, decrement the result, and then square the remaining value. -``` -$ ((e=11)) -$ (( e = e + 7 )) -$ echo $e -18 - -$ ((e--)) -$ echo $e -17 - -$ ((e=e**2)) -$ echo $e -289 - -``` - -The arithmetic operators allow you to: -``` -+ - Add and subtract -++ -- Increment and decrement -* / % Multiply, divide, find remainder -^ Get exponent - -``` - -You can also use both logical and boolean operators: -``` -$ ((x=11)); ((y=7)) -$ if (( x > y )); then -> echo "x > y" -> fi -x > y - -$ ((x=11)); ((y=7)); ((z=3)) -$ if (( x > y )) >> (( y > z )); then -> echo "letters roll downhill" -> fi -letters roll downhill - -``` - -or if you prefer ... -``` -$ if [ x > y ] << [ y > z ]; then echo "letters roll downhill"; fi -letters roll downhill - -``` - -Now let's raise 2 to the 3rd power: -``` -$ echo "2 ^ 3" -2 ^ 3 -$ echo "2 ^ 3" | bc -8 - -``` - -### Wrap-up - -There are sure a lot of different ways to work with numbers and perform calculations on the command line on Linux systems. I hope you picked up a new trick or two by reading this post. - -Join the Network World communities on [Facebook][1] and [LinkedIn][2] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3268964/linux/how-to-do-math-on-the-linux-command-line.html - -作者:[Sandra Henry-Stocker][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://www.networkworld.com/author/Sandra-Henry_Stocker/ -[1]:https://www.facebook.com/NetworkWorld/ -[2]:https://www.linkedin.com/company/network-world 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 new file mode 100644 index 0000000000..eb4567454c --- /dev/null +++ b/translated/tech/20180417 How to do math on the Linux command line.md @@ -0,0 +1,344 @@ +Linux 命令行下的数学运算 +====== + +![](https://images.techhive.com/images/article/2014/12/math_blackboard-100534564-large.jpg) +可以在 Linux 命令行下做数学运算吗?当然可以!事实上,有不少命令可以轻松完成这些操作,其中一些甚至让你大吃一惊。让我们来学习这些有用的数学运算命令或命令语法吧。 + +### expr + +首先,对于在命令行使用命令进行数学运算,可能最容易想到、最常用的命令就是 **expr** (expression)。它可以完成四则运算,也可以用于比较大小。下面是几个例子: + +#### 变量递增 +``` +$ count=0 +$ count=`expr $count + 1` +$ echo $count +1 + +``` + +#### 完成简单运算 +``` +$ expr 11 + 123 +134 +$ expr 134 / 11 +12 +$ expr 134 - 11 +123 +$ expr 11 * 123 +expr: syntax error <== oops! +$ expr 11 \* 123 +1353 +$ expr 20 % 3 +2 + +``` +注意,你需要在 * 运算符之前增加 \ 符号,避免语法错误。% 运算符用于取余运算。 + +下面是一个稍微复杂的例子: +``` +participants=11 +total=156 +share=`expr $total / $participants` +remaining=`expr $total - $participants \* $share` +echo $share +14 +echo $remaining +2 + +``` + +假设某个活动中有 11 位参与者,需要颁发的奖项总数为 156,那么平均每个参与者获得 14 项奖项,额外剩余 2 个奖项。 + +#### 比较大小 + +下面让我们看一下比较大小的操作。从第一印象来看,语句看似有些怪异;这里并不是设置数值,而是进行数字大小比较。在本例中 **expr** 判断表达式是否为真:如果结果是 1,那么表达式为真;反之,表达式为假。 +``` +$ expr 11 = 11 +1 +$ expr 11 = 12 +0 + +``` +请读作"11 是否等于 11?"及"11 是否等于 12?",你很快就会习惯这种写法。当然,我们不会在命令行上执行上述比较,可能的比较是 $age 是否等于 11。 +``` +$ age=11 +$ expr $age = 11 +1 + +``` +如果将数字放到引号中间,那么你将进行字符串比较,而不是数值比较。 +``` +$ expr "11" = "11" +1 +$ expr "eleven" = "11" +0 + +``` + +在本例中,我们判断 10 是否大于 5,以及是否 大于 99。 +``` +$ expr 10 \> 5 +1 +$ expr 10 \> 99 +0 + +``` + +的确,返回 1 和 0 分别代表比较的结果为真和假,我们一般预期在 Linux 上得到这个结果。在下面的例子中,按照上述逻辑使用 **expr** 并不正确,因为 **if** 的工作原理刚好相反,即 0 代表真。 +``` +#!/bin/bash + +echo -n "Cost to us> " +read cost +echo -n "Price we're asking> " +read price + +if [ `expr $price \> $cost` ]; then + echo "We make money" +else + echo "Don't sell it" +fi + +``` + +下面,我们运行这个脚本: +``` +$ ./checkPrice +Cost to us> 11.50 +Price we're asking> 6 +We make money + +``` + +这显然与我们预期不符!我们稍微修改一下,以便使其按我们预期工作: +``` +#!/bin/bash + +echo -n "Cost to us> " +read cost +echo -n "Price we're asking> " +read price + +if [ `expr $price \> $cost` == 1 ]; then + echo "We make money" +else + echo "Don't sell it" +fi + +``` + +### factor + +**factor** 命令的功能基本与你预期相符。你给出一个数字,该命令会给出对应数字的因子。 +``` +$ factor 111 +111: 3 37 +$ factor 134 +134: 2 67 +$ factor 17894 +17894: 2 23 389 +$ factor 1987 +1987: 1987 + +``` + +注:factor 命令对于最后一个数字没有返回很多,这是因为 1987 是一个 **质数**。 + +### jot + +**jot** 命令可以创建一系列数字。给定数字总数及起始数字即可。 +``` +$ jot 8 10 +10 +11 +12 +13 +14 +15 +16 +17 + +``` + +你也可以用如下方式使用 **jot**,这里我们要求递减至数字 2。 +``` +$ jot 8 10 2 +10 +9 +8 +7 +5 +4 +3 +2 + +``` + +**jot** 可以帮你构造一系列数字组成的列表,该列表可以用于其它任务。 +``` +$ for i in `jot 7 17`; do echo April $i; done +April 17 +April 18 +April 19 +April 20 +April 21 +April 22 +April 23 + +``` + +### bc + +**bc** 基本上是命令行数学运算最佳工具之一。输入你想执行的运算,使用管道发送至该命令即可: +``` +$ echo "123.4+5/6-(7.89*1.234)" | bc +113.664 + +``` + +可见 **bc** 并没有忽略精度,而且输入的字符串也相当直截了当。它还可以进行大小比较、处理布尔值、计算平方根、正弦、余弦和正切等。 +``` +$ echo "sqrt(256)" | bc +16 +$ echo "s(90)" | bc -l +.89399666360055789051 + +``` + +事实上,**bc** 甚至可以计算 pi。你需要指定需要的精度。 +``` +$ echo "scale=5; 4*a(1)" | bc -l +3.14156 +$ echo "scale=10; 4*a(1)" | bc -l +3.1415926532 +$ echo "scale=20; 4*a(1)" | bc -l +3.14159265358979323844 +$ echo "scale=40; 4*a(1)" | bc -l +3.1415926535897932384626433832795028841968 + +``` + +除了通过管道接收数据并返回结果,**bc**还可以交互式运行,输入你想执行的运算即可。本例中提到的 scale 设置可以指定有效数字的个数。 +``` +$ bc +bc 1.06.95 +Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. +This is free software with ABSOLUTELY NO WARRANTY. +For details type `warranty'. +scale=2 +3/4 +.75 +2/3 +.66 +quit + +``` + +你还可以使用 **bc** 完成数字进制转换。**obase** 用于设置输出的数字进制。 +``` +$ bc +bc 1.06.95 +Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. +This is free software with ABSOLUTELY NO WARRANTY. +For details type `warranty'. +obase=16 +16 <=== entered +10 <=== response +256 <=== entered +100 <=== response +quit + +``` + +按如下方式使用 **bc** 也是完成十六进制与十进制转换的最简单方式之一: +``` +$ echo "ibase=16; F2" | bc +242 +$ echo "obase=16; 242" | bc +F2 + +``` + +在上面第一个例子中,我们将输入进制 (ibase) 设置为十六进制 (hex),完成十六进制到为十进制的转换。在第二个例子中,我们执行相反的操作,即将输出进制 (obase) 设置为十六进制。 + +### 简单的 bash 数学运算 + +通过使用双括号,我们可以在 bash 中完成简单的数学运算。在下面的例子中,我们创建一个变量,为变量赋值,然后依次执行加法、自减和平方。 +``` +$ ((e=11)) +$ (( e = e + 7 )) +$ echo $e +18 + +$ ((e--)) +$ echo $e +17 + +$ ((e=e**2)) +$ echo $e +289 + +``` + +允许使用的运算符包括: +``` ++ - 加法及减法 +++ -- 自增与自减 +* / % 乘法,除法及求余数 +^ 指数运算 + +``` + +你还可以使用逻辑运算符和布尔运算符: +``` +$ ((x=11)); ((y=7)) +$ if (( x > y )); then +> echo "x > y" +> fi +x > y + +$ ((x=11)); ((y=7)); ((z=3)) +$ 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 次幂: +``` +$ 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) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[1]:https://www.facebook.com/NetworkWorld/ +[2]:https://www.linkedin.com/company/network-world From 2de00fd94e9ee9ca00fef3134bec77377cbb4ebd Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Thu, 3 May 2018 10:46:23 +0800 Subject: [PATCH 0746/1057] add translation tag --- ...418 Getting started with Anaconda Python for data science.md | 2 ++ 1 file changed, 2 insertions(+) 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 43cd89f17c..fa55edc325 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 @@ -1,3 +1,5 @@ +pinewall translating + Getting started with Anaconda Python for data science ====== From 569b73eca26077f0fc8f6123add888e6208c8363 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Thu, 3 May 2018 10:53:43 +0800 Subject: [PATCH 0747/1057] add translation tag --- ...d application deployment with sample Face Recognition App.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180315 Kubernetes distributed application deployment with sample Face Recognition App.md b/sources/tech/20180315 Kubernetes distributed application deployment with sample Face Recognition App.md index 6971261590..83ef4b1835 100644 --- a/sources/tech/20180315 Kubernetes distributed application deployment with sample Face Recognition App.md +++ b/sources/tech/20180315 Kubernetes distributed application deployment with sample Face Recognition App.md @@ -1,3 +1,5 @@ +pinewall translating + Kubernetes distributed application deployment with sample Face Recognition App ============================================================ From 8cd6c038f748c4a3f9030fac70a03c3890fb82f5 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 3 May 2018 15:13:54 +0800 Subject: [PATCH 0748/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=209=20ways=20to?= =?UTF-8?q?=20improve=20collaboration=20between=20developers=20and=20desig?= =?UTF-8?q?ners?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ration between developers and designers.md | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sources/talk/20180502 9 ways to improve collaboration between developers and designers.md diff --git a/sources/talk/20180502 9 ways to improve collaboration between developers and designers.md b/sources/talk/20180502 9 ways to improve collaboration between developers and designers.md new file mode 100644 index 0000000000..293841714d --- /dev/null +++ b/sources/talk/20180502 9 ways to improve collaboration between developers and designers.md @@ -0,0 +1,66 @@ +9 ways to improve collaboration between developers and designers +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_consensuscollab1.png?itok=ULQdGjlV) + +This article was co-written with [Jason Porter][1]. + +Design is a crucial element in any software project. Sooner or later, the developers' reasons for writing all this code will be communicated to the designers, human beings who aren't as familiar with its inner workings as the development team. + +Stereotypes exist on both side of the divide; engineers often expect designers to be flaky and irrational, while designers often expect engineers to be inflexible and demanding. The truth is considerably more nuanced and, at the end of the day, the fates of designers and developers are forever intertwined. + +Here are nine things that can improve collaboration between the two. + +### 1\. First, knock down the wall. Seriously. + +There are loads of memes about the "wall of confusion" in just about every industry. No matter what else you do, the first step toward tearing down this wall is getting both sides to agree it needs to be gone. Once everyone agrees the existing processes aren't functioning optimally, you can pick and choose from the rest of these ideas to begin fixing the problems. + +### 2\. Learn to empathize. + +Before rolling up any sleeves to build better communication, take a break. This is a great junction point for team building. A time to recognize that we're all people, we all have strengths and weaknesses, and most importantly, we're all on the same team. Discussions around workflows and productivity can become feisty, so it's crucial to build a foundation of trust and cooperation before diving on in. + +### 3\. Recognize differences. + +Designers and developers attack the same problem from different angles. Given a similar problem, designers will seek the solution with the biggest impact while developers will seek the solution with the least amount of waste. These two viewpoints do not have to be mutually exclusive. There is plenty of room for negotiation and compromise, and somewhere in the middle is where the end user receives the best experience possible. + +### 4\. Embrace similarities. + +This is all about workflow. CI/CD, scrum, agile, etc., are all basically saying the same thing: Ideate, iterate, investigate, and repeat. Iteration and reiteration are common denominators for both kinds of work. So instead of running a design cycle followed by a development cycle, it makes much more sense to run them concurrently and in tandem. Syncing cycles allows teams to communicate, collaborate, and influence each other every step of the way. + +### 5\. Manage expectations. + +All conflict can be distilled down to one simple idea: incompatible expectations. Therefore, an easy way to prevent systemic breakdowns is to manage expectations by ensuring that teams are thinking before talking and talking before doing. Setting expectations often evolves organically through everyday conversation. Forcing them to happen by having meetings can be counterproductive. + +### 6\. Meet early and meet often. + +Meeting once at the beginning of work and once at the end simply isn't enough. This doesn't mean you need daily or even weekly meetings. Setting a cadence for meetings can also be counterproductive. Let them happen whenever they're necessary. Great things can happen with impromptu meetings—even at the watercooler! If your team is distributed or has even one remote employee, video conferencing, text chat, or phone calls are all excellent ways to meet. It's important that everyone on the team has multiple ways to communicate with each other. + +### 7\. Build your own lexicon. + +Designers and developers sometimes have different terms for similar ideas. One person's card is another person's tile is a third person's box. Ultimately, the fit and accuracy of a term aren't as important as everyone's agreement to use the same term consistently. + +### 8\. Make everyone a communication steward. + +Everyone in the group is responsible for maintaining effective communication, regardless of how or when it happens. Each person should strive to say what they mean and mean what they say. + +### 9\. Give a darn. + +It only takes one member of a team to sabotage progress. Go all in. If every individual doesn't care about the product or the goal, there will be problems with motivation to make changes or continue the process. + +This article is based on [Designers and developers: Finding common ground for effective collaboration][2], a talk the authors will be giving at [Red Hat Summit 2018][3], which will be held May 8-10 in San Francisco. [Register by May 7][3] to save US$ 500 off of registration. Use discount code **OPEN18** on the payment page to apply the discount. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/9-ways-improve-collaboration-developers-designers + +作者:[Jason Brock][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/jkbrock +[1]:https://opensource.com/users/lightguardjp +[2]:https://agenda.summit.redhat.com/SessionDetail.aspx?id=154267 +[3]:https://www.redhat.com/en/summit/2018 From 57010e6484827f7ec4be692265fb571db30ec6a2 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 3 May 2018 15:16:32 +0800 Subject: [PATCH 0749/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Use?= =?UTF-8?q?=20Vim=20Editor=20To=20Input=20Text=20Anywhere?= 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 insertions(+) create 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 new file mode 100644 index 0000000000..368d1b1dbc --- /dev/null +++ b/sources/tech/20180501 How To Use Vim Editor To Input Text Anywhere.md @@ -0,0 +1,100 @@ +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 5f5fc7fa8d24df558876a0ba65b795b3bacb7f4c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 3 May 2018 21:27:59 +0800 Subject: [PATCH 0750/1057] PRF:20180312 How To Quickly Monitor Multiple Hosts In Linux.md @MjSeven --- ...Quickly Monitor Multiple Hosts In Linux.md | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md b/translated/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md index 1f6f085feb..860f70553a 100644 --- a/translated/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md +++ b/translated/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md @@ -2,66 +2,67 @@ ===== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/rwho-1-720x340.png) -有很多监控工具可用来监控本地和远程 Linux 系统,一个很好的例子是 [**Cockpit**][1]。但是,这些工具的安装和使用比较复杂,至少对于新手管理员来说是这样。新手管理员可能需要花一些时间来弄清楚如何配置这些工具来监视系统。如果你想要以快速且粗略地在局域网中一次监控多台主机,你可能需要查看一下 **“rwho”** 工具。只要安装 rwho 实用程序,它将立即快速地监控本地和远程系统。你什么都不用配置!你所要做的就是在要监视的系统上安装 “rwho” 工具。 -请不要将 rwho 视为功能丰富且完整的监控工具。这只是一个简单的工具,它只监视远程系统的**正常运行时间**,**加载**和**登录用户**。使用 “rwho” 使用程序,我们可以发现谁在哪台计算机上登录,一个被监视的计算机的列表,有正常运行时间(自上次重新启动以来的时间),有多少用户登录了,以及在过去的 1、5、15 分钟的平均负载。不多不少!而且,它只监视同一子网中的系统。因此,它非常适合小型和家庭办公网络。 +有很多监控工具可用来监控本地和远程 Linux 系统,一个很好的例子是 [Cockpit][1]。但是,这些工具的安装和使用比较复杂,至少对于新手管理员来说是这样。新手管理员可能需要花一些时间来弄清楚如何配置这些工具来监视系统。如果你想要以快速且粗略地在局域网中一次监控多台主机,你可能需要了解一下 “rwho” 工具。只要安装了 rwho 实用程序,它将立即快速地监控本地和远程系统。你什么都不用配置!你所要做的就是在要监视的系统上安装 “rwho” 工具。 + +请不要将 rwho 视为功能丰富且完整的监控工具。这只是一个简单的工具,它只监视远程系统的“正常运行时间”(`uptime`),“负载”(`load`)和**登录的用户**。使用 “rwho” 使用程序,我们可以发现谁在哪台计算机上登录;一个被监视的计算机的列表,列出了正常运行时间(自上次重新启动以来的时间);有多少用户登录了;以及在过去的 1、5、15 分钟的平均负载。不多不少!而且,它只监视同一子网中的系统。因此,它非常适合小型和家庭办公网络。 ### 在 Linux 中监控多台主机 -让我来解释一下 rwho 是如何工作的。每个在网络上使用 rwho 的系统都将广播关于它自己的信息,其他计算机可以使用 rwhod-daemon 来访问这些信息。因此,网络上的每台计算机都必须安装 rwho。此外,为了分发或访问其他主机的信息,必须允许 rwho 端口(例如端口 513/UDP)通过防火墙/路由器。 +让我来解释一下 `rwho` 是如何工作的。每个在网络上使用 `rwho` 的系统都将广播关于它自己的信息,其他计算机可以使用 `rwhod` 守护进程来访问这些信息。因此,网络上的每台计算机都必须安装 `rwho`。此外,为了分发或访问其他主机的信息,必须允许 `rwho` 端口(例如端口 `513/UDP`)通过防火墙/路由器。 好的,让我们来安装它。 -我在 Ubuntu 16.04 LTS 服务器上进行了测试,rwho 在默认仓库中可用,所以,我们可以使用像下面这样的 APT 软件包管理器来安装它。 +我在 Ubuntu 16.04 LTS 服务器上进行了测试,`rwho` 在默认仓库中可用,所以,我们可以使用像下面这样的 APT 软件包管理器来安装它。 + ``` $ sudo apt-get install rwho - ``` -在基于 RPM 的系统如 CentOS, Fedora, RHEL上,使用以下命令来安装它: +在基于 RPM 的系统如 CentOS、 Fedora、 RHEL 上,使用以下命令来安装它: + ``` $ sudo yum install rwho - ``` -如果你在防火墙/路由器之后,确保你已经允许使用 rwhod 513 端口。另外,使用命令验证 rwhod-daemon 是否正在运行: +如果你在防火墙/路由器之后,确保你已经允许使用 rwhod 513 端口。另外,使用命令验证 `rwhod` 守护进程是否正在运行: $ sudo systemctl status rwhod -如果它尚未启动,运行以下命令启用并启动 rwhod 服务: +如果它尚未启动,运行以下命令启用并启动 `rwhod` 服务: + ``` $ sudo systemctl enable rwhod $ sudo systemctl start rwhod - ``` 现在是时候来监视系统了。运行以下命令以发现谁在哪台计算机上登录: + ``` $ rwho ostechni ostechnix:pts/5 Mar 12 17:41 root server:pts/0 Mar 12 17:42 - ``` -正如你所看到的,目前我的局域网中有两个系统。本地系统用户是 **ostechnix** (Ubuntu 16.04 LTS),远程系统的用户是 **root** (CentOS 7)。可能你已经猜到了,rwho 与 “who” 命令相似,但它会监视远程系统。 +正如你所看到的,目前我的局域网中有两个系统。本地系统用户是 `ostechnix` (Ubuntu 16.04 LTS),远程系统的用户是 `root` (CentOS 7)。可能你已经猜到了,`rwho` 与 `who` 命令相似,但它会监视远程系统。 而且,我们可以使用以下命令找到网络上所有正在运行的系统的正常运行时间: + ``` $ ruptime ostechnix up 2:17, 1 user, load 0.09, 0.03, 0.01 server up 1:54, 1 user, load 0.00, 0.01, 0.05 - ``` -这里,ruptime(类似于 “uptime” 命令)显示了我的 Ubuntu(本地) and CentOS(远程)系统的总运行时间。明白了吗?棒极了!以下是我的 Ubuntu 16.04 LTS 系统的示例屏幕截图: +这里,`ruptime`(类似于 `uptime` 命令)显示了我的 Ubuntu(本地) 和 CentOS(远程)系统的总运行时间。明白了吗?棒极了!以下是我的 Ubuntu 16.04 LTS 系统的示例屏幕截图: ![][3] 你可以在以下位置找到有关局域网中所有其他机器的信息: + ``` $ ls /var/spool/rwho/ whod.ostechnix whod.server - ``` 它很小,但却非常有用,可以发现谁在哪台计算机上登录,以及正常运行时间和系统负载详情。 @@ -71,23 +72,22 @@ whod.ostechnix whod.server 请注意,这种方法有一个严重的漏洞。由于有关每台计算机的信息都通过网络进行广播,因此该子网中的每个人都可能获得此信息。通常情况下可以,但另一方面,当有关网络的信息分发给非授权用户时,这可能是不必要的副作用。因此,强烈建议在受信任和受保护的局域网中使用它。 更多的信息,查找 man 手册页。 + ``` $ man rwho - ``` 好了,这就是全部了。更多好东西要来了,敬请期待! 干杯! - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/ 作者:[SK][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 d8ed9d63aa101e04fabcaf336c8114211b2fb5e7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 3 May 2018 21:28:22 +0800 Subject: [PATCH 0751/1057] PUB:20180312 How To Quickly Monitor Multiple Hosts In Linux.md @MjSeven https://linux.cn/article-9602-1.html --- .../20180312 How To Quickly Monitor Multiple Hosts In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180312 How To Quickly Monitor Multiple Hosts In Linux.md (100%) diff --git a/translated/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md b/published/20180312 How To Quickly Monitor Multiple Hosts In Linux.md similarity index 100% rename from translated/tech/20180312 How To Quickly Monitor Multiple Hosts In Linux.md rename to published/20180312 How To Quickly Monitor Multiple Hosts In Linux.md From b2937bde4b762cef825582708aad3241854e0ecb Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 4 May 2018 07:33:39 +0800 Subject: [PATCH 0752/1057] PRF:20180227 How to block local spoofed addresses using the Linux firewall.md @leemeans --- ...ofed addresses using the Linux firewall.md | 57 ++++++++----------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md b/translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md index 6c54c36164..be0e5f85ec 100644 --- a/translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md +++ b/translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md @@ -1,71 +1,60 @@ -如何使用Linux防火墙隔离局域网受欺骗地址 +如何使用 Linux 防火墙隔离本地欺骗地址 ====== +> 如何使用 iptables 防火墙保护你的网络免遭黑客攻击。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_UnspokenBlockers_1110_A.png?itok=x8A9mqVA) +即便是被入侵检测和隔离系统所保护的远程网络,黑客们也在寻找各种精巧的方法入侵。IDS/IPS 不能停止或者减少那些想要接管你的网络控制权的黑客攻击。不恰当的配置允许攻击者绕过所有部署的安全措施。 -即便是被入侵检测和隔离系统保护的远程网络,黑客们也在寻找精致的方法入侵。IDS/IPS是不能停止或者减少那些想要接管你的网络的黑客的攻击的。不恰当的配置允许攻击者绕过所有部署的安全措施。 +在这篇文章中,我将会解释安全工程师或者系统管理员该怎样避免这些攻击。 -在这篇文章中,我将会解释安全工程师或者系统管理员怎样可以避免这些攻击。 +几乎所有的 Linux 发行版都带着一个内建的防火墙来保护运行在 Linux 主机上的进程和应用程序。大多数防火墙都按照 IDS/IPS 解决方案设计,这样的设计的主要目的是检测和避免恶意包获取网络的进入权。 -几乎所有的Linux发行版都带着一个内建的防火墙来保护运行在Linux宿主机上的进程和应用程序。大多数都按照IDS/IPS解决方案设计,这样的设计的主要目的是检测和避免恶意包获取网络的进入权。 +Linux 防火墙通常有两种接口:iptables 和 ipchains 程序(LCTT 译注:在支持 systemd 的系统上,采用的是更新的接口 firewalld)。大多数人将这些接口称作 iptables 防火墙或者 ipchains 防火墙。这两个接口都被设计成包过滤器。iptables 是有状态防火墙,其基于先前的包做出决定。ipchains 不会基于先前的包做出决定,它被设计为无状态防火墙。 -Linux防火墙通常带有两个接口:iptable和ipchain程序。大多数人将这些接口称作iptables防火墙或者ipchains防火墙。这两个接口都被设计成包过滤器。iptables是有状态防火墙,基于先前的包做出决定。 +在这篇文章中,我们将会专注于内核 2.4 之后出现的 iptables 防火墙。 -在这篇文章中,我们将会专注于内核2.4之后出现的iptables防火墙。 +有了 iptables 防火墙,你可以创建策略或者有序的规则集,规则集可以告诉内核该如何对待特定的数据包。在内核中的是Netfilter 框架。Netfilter 既是框架也是 iptables 防火墙的项目名称。作为一个框架,Netfilter 允许 iptables 勾连被设计来操作数据包的功能。概括地说,iptables 依靠 Netfilter 框架构筑诸如过滤数据包数据的功能。 -有了iptables防火墙,你可以创建策略或者有序的规则集,规则集可以告诉内核如何对待特定的数据包。在内核中的是Netfilter框架。Netfilter既是框架也是iptables防火墙的工程名。作为一个框架,Netfilter允许iptables勾取被设计来操作数据包的函数。概括地说,iptables依靠Netfilter框架构筑诸如过滤数据包数据的功能。 +每个 iptables 规则都被应用到一个表中的链上。一个 iptables 链就是一个比较包中相似特征的规则集合。而表(例如 `nat` 或者 `mangle`)则描述不同的功能目录。例如, `mangle` 表用于修改包数据。因此,特定的修改包数据的规则被应用到这里;而过滤规则被应用到 `filter` 表,因为 `filter` 表过滤包数据。 -每个iptables规则都被应用到一个含表的链中。一个iptables链就是一个比较包中相似字符的规则的集合。而表(例如nat或者mangle)则描述不同的功能目录。例如,一个mangle表转化包数据。因此,特定的改变包数据的规则被应用到这里,而过滤规则被应用到filter表,因为filter表过滤包数据。 +iptables 规则有一个匹配集,以及一个诸如 `Drop` 或者 `Deny` 的目标,这可以告诉 iptables 对一个包做什么以符合规则。因此,没有目标和匹配集,iptables 就不能有效地处理包。如果一个包匹配了一条规则,目标会指向一个将要采取的特定措施。另一方面,为了让 iptables 处理,每个数据包必须匹配才能被处理。 -iptables规则有一系列匹配,伴随着一个诸如`Drop`或者`Deny`的目标,这可以告诉iptables对一个包做什么符合规则。因此,没有一个目标和一系列匹配,iptables就不能有效地处理包。如果一个包匹配一条规则,一个目标简单地指向一个将要采取的特定措施。另一方面,为了让iptables处理,匹配必须被每个包满足吗。 - - -现在我们已经知道iptables防火墙如何工作,开始着眼于如何使用iptables防火墙检测并拒绝或丢弃被欺骗的地址吧。 +现在我们已经知道 iptables 防火墙如何工作,让我们着眼于如何使用 iptables 防火墙检测并拒绝或丢弃欺骗地址吧。 ### 打开源地址验证 -作为一个安全工程师,在处理远程主机被欺骗地址的时候,我采取的第一步是在内核打开源地址验证。 +作为一个安全工程师,在处理远程的欺骗地址的时候,我采取的第一步是在内核打开源地址验证。 -源地址验证是一种内核层级的特性,这种特性丢弃那些伪装成来自你的网络的包。这种特性使用反向路径过滤器方法来检查收到的包的源地址是否可以通过包到达的接口可以到达。(译注:到达的包的源地址应该可以从它到达的网络接口反向到达,只需反转源地址和目的地址就可以达到这样的效果) +源地址验证是一种内核层级的特性,这种特性丢弃那些伪装成来自你的网络的包。这种特性使用反向路径过滤器方法来检查收到的包的源地址是否可以通过包到达的接口可以到达。(LCTT 译注:到达的包的源地址应该可以从它到达的网络接口反向到达,只需反转源地址和目的地址就可以达到这样的效果) 利用下面简单的脚本可以打开源地址验证而不用手工操作: + ``` #!/bin/sh - #作者: Michael K Aboagye - #程序目标: 打开反向路径过滤 - #日期: 7/02/18 - #在屏幕上显示 “enabling source address verification” - echo -n "Enabling source address verification…" - #将值0覆盖为1来打开源地址验证 - echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter - echo "completed" - ``` -先前的脚本在执行的时候只显示了`Enabling source address verification`这条信息而没有添加新行。默认的反向路径过滤的值是0,0表示没有源验证。因此,第二行简单地将默认值0覆盖为1。1表示内核将会通过确认反向路径来验证源(地址)。 +上面的脚本在执行的时候只显示了 `Enabling source address verification` 这条信息而不会换行。默认的反向路径过滤的值是 `0`,`0` 表示没有源验证。因此,第二行简单地将默认值 `0` 覆盖为 `1`。`1` 表示内核将会通过确认反向路径来验证源地址。 -最后,你可以使用下面的命令通过选择`DROP`或者`REJECT`目标中的一个来丢弃或者拒绝来自远端主机的被欺骗地址。但是,处于安全原因的考虑,我建议使用`DROP`目标。 +最后,你可以使用下面的命令通过选择 `DROP` 或者 `REJECT` 目标之一来丢弃或者拒绝来自远端主机的欺骗地址。但是,处于安全原因的考虑,我建议使用 `DROP` 目标。 -像下面这样,用你自己的IP地址代替“IP-address” 占位符。另外,你必须选择使用`REJECT`或者`DROP`中的一个,这两个目标不能同时使用。 -``` - iptables -A INPUT -i internal_interface -s IP_address -j REJECT / DROP - - - - iptables -A INPUT -i internal_interface -s 192.168.0.0/16 -j REJECT/ DROP +像下面这样,用你自己的 IP 地址代替 `IP-address` 占位符。另外,你必须选择使用 `REJECT` 或者 `DROP` 中的一个,这两个目标不能同时使用。 +``` +iptables -A INPUT -i internal_interface -s IP_address -j REJECT / DROP +iptables -A INPUT -i internal_interface -s 192.168.0.0/16 -j REJECT / DROP ``` -这篇文章只提供了如何使用iptables防火墙来避免远端欺骗攻击的基础(知识)。 +这篇文章只提供了如何使用 iptables 防火墙来避免远端欺骗攻击的基础知识。 -------------------------------------------------------------------------------- @@ -73,7 +62,7 @@ via: https://opensource.com/article/18/2/block-local-spoofed-addresses-using-lin 作者:[Michael Kwaku Aboagye][a] 译者:[leemeans](https://github.com/leemeans) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2a0213b2e4b892dc77b75b46284074fa32ab25aa Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 4 May 2018 07:34:12 +0800 Subject: [PATCH 0753/1057] PUB:20180227 How to block local spoofed addresses using the Linux firewall.md @leemeans https://linux.cn/article-9603-1.html --- ...w to block local spoofed addresses using the Linux firewall.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180227 How to block local spoofed addresses using the Linux firewall.md (100%) diff --git a/translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md b/published/20180227 How to block local spoofed addresses using the Linux firewall.md similarity index 100% rename from translated/tech/20180227 How to block local spoofed addresses using the Linux firewall.md rename to published/20180227 How to block local spoofed addresses using the Linux firewall.md From 9bb734767048a9923e728db5aeb80ab3afe97b9b Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 4 May 2018 08:55:34 +0800 Subject: [PATCH 0754/1057] translated --- ...w to start developing on Java in Fedora.md | 124 ------------------ ...w to start developing on Java in Fedora.md | 122 +++++++++++++++++ 2 files changed, 122 insertions(+), 124 deletions(-) delete mode 100644 sources/tech/20180420 How to start developing on Java in Fedora.md create mode 100644 translated/tech/20180420 How to start developing on Java in Fedora.md diff --git a/sources/tech/20180420 How to start developing on Java in Fedora.md b/sources/tech/20180420 How to start developing on Java in Fedora.md deleted file mode 100644 index cc192c915c..0000000000 --- a/sources/tech/20180420 How to start developing on Java in Fedora.md +++ /dev/null @@ -1,124 +0,0 @@ -translating----geekpi - -How to start developing on Java in Fedora -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/04/java-getting-started-816x345.jpg) -Java is one of the most popular programming languages in the world. It is widely-used to develop IOT appliances, Android apps, web, and enterprise applications. This article will provide a quick guide to install and configure your workstation using [OpenJDK][1]. - -### Installing the compiler and tools - -Installing the compiler, or Java Development Kit (JDK), is easy to do in Fedora. At the time of this article, versions 8 and 9 are available. Simply open a terminal and enter: -``` -sudo dnf install java-1.8.0-openjdk-devel - -``` - -This will install the JDK for version 8. For version 9, enter: -``` -sudo dnf install java-9-openjdk-devel - -``` - -For the developer who requires additional tools and libraries such as Ant and Maven, the **Java Development** group is available. To install the suite, enter: -``` -sudo dnf group install "Java Development" - -``` - -To verify the compiler is installed, run: -``` -javac -version - -``` - -The output shows the compiler version and looks like this: -``` -javac 1.8.0_162 - -``` - -### Compiling applications - -You can use any basic text editor such as nano, vim, or gedit to write applications. This example provides a simple “Hello Fedora” program. - -Open your favorite text editor and enter the following: -``` -public class HelloFedora { - - -      public static void main (String[] args) { -              System.out.println("Hello Fedora!"); -      } -} - -``` - -Save the file as HelloFedora.java. In the terminal change to the directory containing the file and do: -``` -javac HelloFedora.java - -``` - -The compiler will complain if it runs into any syntax errors. Otherwise it will simply display the shell prompt beneath. - -You should now have a file called HelloFedora, which is the compiled program. Run it with the following command: -``` -java HelloFedora - -``` - -And the output will display: -``` -Hello Fedora! - -``` - -### Installing an Integrated Development Environment (IDE) - -Some programs may be more complex and an IDE can make things flow smoothly. There are quite a few IDEs available for Java programmers including: - -+ Geany, a basic IDE that loads quickly, and provides built-in templates -+ Anjuta -+ GNOME Builder, which has been covered in the article Builder – a new IDE specifically for GNOME app developers - -However, one of the most popular open-source IDE’s, mainly written in Java, is [Eclipse][2]. Eclipse is available in the official repositories. To install it, run this command: -``` -sudo dnf install eclipse-jdt - -``` - -When the installation is complete, a shortcut for Eclipse appears in the desktop menu. - -For more information on how to use Eclipse, consult the [User Guide][3] available on their website. - -### Browser plugin - -If you’re developing web applets and need a plugin for your browser, [IcedTea-Web][4] is available. Like OpenJDK, it is open source and easy to install in Fedora. Run this command: -``` -sudo dnf install icedtea-web - -``` - -As of Firefox 52, the web plugin no longer works. For details visit the Mozilla support site at [https://support.mozilla.org/en-US/kb/npapi-plugins?as=u&utm_source=inproduct][5]. - -Congratulations, your Java development environment is ready to use. - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/start-developing-java-fedora/ - -作者:[Shaun Assam][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/sassam/ -[1]:http://openjdk.java.net/ -[2]:https://www.eclipse.org/ -[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 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 new file mode 100644 index 0000000000..b606a74a5d --- /dev/null +++ b/translated/tech/20180420 How to start developing on Java in Fedora.md @@ -0,0 +1,122 @@ +如何在 Fedora 上开始 Java 开发 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/04/java-getting-started-816x345.jpg) +Java 是世界上最流行的编程语言之一。它广泛用于开发物联网设备、Android 程序,Web 和企业应用。本文将提供使用 [OpenJDK][1] 安装和配置工作站的指南。 + +### 安装编译器和工具 + +在 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 + +``` + +### 编译程序 + +你可以使用任何基本的文本编辑器(如 nano、vim 或 gedit)编写程序。这个例子提供了一个简单的 “Hello Fedora” 程序。 + +打开你最喜欢的文本编辑器并输入以下内容: +``` +public class HelloFedora { + + +      public static void main (String[] args) { +              System.out.println("Hello Fedora!"); +      } +} + +``` + +将文件保存为 HelloFedora.java。在终端切换到包含该文件的目录并执行以下操作: +``` +javac HelloFedora.java + +``` + +如果编译器遇到任何语法错误,它会发出错误。否则,它只会在下面显示 shell 提示符。 + +你现在应该有一个名为 HelloFedora 的文件,它是编译好的程序。使用以下命令运行它: +``` +java HelloFedora + +``` + +输出将显示: +``` +Hello Fedora! + +``` + +### 安装集成开发环境(IDE) + +有些程序可能更复杂,IDE 可以帮助顺利进行。Java 程序员有很多可用的 IDE,其中包括: + ++ Geany,一个加载快速的基本 IDE,并提供内置模板 ++ Anjuta ++ GNOME Builder,已经在 Builder 的文章中介绍过 - 这是一个专门面向 GNOME 程序开发人员的新 IDE + +然而,主要用 Java 编写的最流行的开源 IDE 之一是 [Eclipse][2]。 Eclipse 在官方仓库中有。要安装它,请运行以下命令: +``` +sudo dnf install eclipse-jdt + +``` + +安装完成后,Eclipse 的快捷方式会出现在桌面菜单中。 + +有关如何使用 Eclipse 的更多信息,请参阅其网站上的[用户指南][3]。 + +### 浏览器插件 + +如果你正在开发 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]。 + +恭喜,你的 Java 开发环境已准备完毕。 + + +-------------------------------------------------------------------------------- + +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) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/sassam/ +[1]:http://openjdk.java.net/ +[2]:https://www.eclipse.org/ +[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 From 7927df72827e34e6b62edbfac34cbe804ef2d8e5 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 4 May 2018 08:59:27 +0800 Subject: [PATCH 0755/1057] translating --- .../20180430 Reset a lost root password in under 5 minutes.md | 2 ++ 1 file changed, 2 insertions(+) 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 index 06e18a2d6d..4521901e58 100644 --- 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 @@ -1,3 +1,5 @@ +translating---geekpi + Reset a lost root password in under 5 minutes ====== From cb16da8c12f125c1cc2035ea024a3854702c645b Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 4 May 2018 09:36:46 +0800 Subject: [PATCH 0756/1057] =?UTF-8?q?20180504-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...fficial Introduction to the Go Compiler.md | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 sources/tech/20180427 An Official Introduction to the Go Compiler.md diff --git a/sources/tech/20180427 An Official Introduction to the Go Compiler.md b/sources/tech/20180427 An Official Introduction to the Go Compiler.md new file mode 100644 index 0000000000..c8369c7c8c --- /dev/null +++ b/sources/tech/20180427 An Official Introduction to the Go Compiler.md @@ -0,0 +1,116 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +## Introduction to the Go compiler + +`cmd/compile` contains the main packages that form the Go compiler. The compiler +may be logically split in four phases, which we will briefly describe alongside +the list of packages that contain their code. + +You may sometimes hear the terms "front-end" and "back-end" when referring to +the compiler. Roughly speaking, these translate to the first two and last two +phases we are going to list here. A third term, "middle-end", often refers to +much of the work that happens in the second phase. + +Note that the `go/*` family of packages, such as `go/parser` and `go/types`, +have no relation to the compiler. Since the compiler was initially written in C, +the `go/*` packages were developed to enable writing tools working with Go code, +such as `gofmt` and `vet`. + +It should be clarified that the name "gc" stands for "Go compiler", and has +little to do with uppercase GC, which stands for garbage collection. + +### 1. Parsing + +* `cmd/compile/internal/syntax` (lexer, parser, syntax tree) + +In the first phase of compilation, source code is tokenized (lexical analysis), +parsed (syntactic analyses), and a syntax tree is constructed for each source +file. + +Each syntax tree is an exact representation of the respective source file, with +nodes corresponding to the various elements of the source such as expressions, +declarations, and statements. The syntax tree also includes position information +which is used for error reporting and the creation of debugging information. + +### 2. Type-checking and AST transformations + +* `cmd/compile/internal/gc` (create compiler AST, type checking, AST transformations) + +The gc package includes an AST definition carried over from when it was written +in C. All of its code is written in terms of it, so the first thing that the gc +package must do is convert the syntax package's syntax tree to the compiler's +AST representation. This extra step may be refactored away in the future. + +The AST is then type-checked. The first steps are name resolution and type +inference, which determine which object belongs to which identifier, and what +type each expression has. Type-checking includes certain extra checks, such as +"declared and not used" as well as determining whether or not a function +terminates. + +Certain transformations are also done on the AST. Some nodes are refined based +on type information, such as string additions being split from the arithmetic +addition node type. Some other examples are dead code elimination, function call +inlining, and escape analysis. + +### 3. Generic SSA + +* `cmd/compile/internal/gc` (converting to SSA) +* `cmd/compile/internal/ssa` (SSA passes and rules) + + +In this phase, the AST is converted into Static Single Assignment (SSA) form, a +lower-level intermediate representation with specific properties that make it +easier to implement optimizations and to eventually generate machine code from +it. + +During this conversion, function intrinsics are applied. These are special +functions that the compiler has been taught to replace with heavily optimized +code on a case-by-case basis. + +Certain nodes are also lowered into simpler components during the AST to SSA +conversion, so that the rest of the compiler can work with them. For instance, +the copy builtin is replaced by memory moves, and range loops are rewritten into +for loops. Some of these currently happen before the conversion to SSA due to +historical reasons, but the long-term plan is to move all of them here. + +Then, a series of machine-independent passes and rules are applied. These do not +concern any single computer architecture, and thus run on all `GOARCH` variants. + +Some examples of these generic passes include dead code elimination, removal of +unneeded nil checks, and removal of unused branches. The generic rewrite rules +mainly concern expressions, such as replacing some expressions with constant +values, and optimizing multiplications and float operations. + +### 4. Generating machine code + +* `cmd/compile/internal/ssa` (SSA lowering and arch-specific passes) +* `cmd/internal/obj` (machine code generation) + +The machine-dependent phase of the compiler begins with the "lower" pass, which +rewrites generic values into their machine-specific variants. For example, on +amd64 memory operands are possible, so many load-store operations may be combined. + +Note that the lower pass runs all machine-specific rewrite rules, and thus it +currently applies lots of optimizations too. + +Once the SSA has been "lowered" and is more specific to the target architecture, +the final code optimization passes are run. This includes yet another dead code +elimination pass, moving values closer to their uses, the removal of local +variables that are never read from, and register allocation. + +Other important pieces of work done as part of this step include stack frame +layout, which assigns stack offsets to local variables, and pointer liveness +analysis, which computes which on-stack pointers are live at each GC safe point. + +At the end of the SSA generation phase, Go functions have been transformed into +a series of obj.Prog instructions. These are passed to the assembler +(`cmd/internal/obj`), which turns them into machine code and writes out the +final object file. The object file will also contain reflect data, export data, +and debugging information. + +### Further reading + +To dig deeper into how the SSA package works, including its passes and rules, +head to `cmd/compile/internal/ssa/README.md`. From 91c919939bd2f5445bc1429823bdb8f84b2e809f Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 4 May 2018 09:38:00 +0800 Subject: [PATCH 0757/1057] =?UTF-8?q?20180504-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... An Official Introduction to the Go Compiler.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sources/tech/20180427 An Official Introduction to the Go Compiler.md b/sources/tech/20180427 An Official Introduction to the Go Compiler.md index c8369c7c8c..65c35fee64 100644 --- a/sources/tech/20180427 An Official Introduction to the Go Compiler.md +++ b/sources/tech/20180427 An Official Introduction to the Go Compiler.md @@ -114,3 +114,17 @@ and debugging information. To dig deeper into how the SSA package works, including its passes and rules, head to `cmd/compile/internal/ssa/README.md`. + + + +-------------------------------------------------------------------------------- + +via: https://github.com/golang/go/blob/master/src/cmd/compile/README.md + +作者:[mvdan ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://github.com/mvdan From 2a9b0a190292a758754616ad792ddfa22d227316 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 4 May 2018 09:40:32 +0800 Subject: [PATCH 0758/1057] =?UTF-8?q?20180504-2=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...426 Continuous Profiling of Go programs.md | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..ee91150b53 --- /dev/null +++ b/sources/tech/20180426 Continuous Profiling of Go programs.md @@ -0,0 +1,106 @@ +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 From 925433ef6c78a75aeddf4be00462ee079ac59312 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 4 May 2018 09:52:42 +0800 Subject: [PATCH 0759/1057] =?UTF-8?q?20180504-3=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cessing with Go using Kafka and MongoDB.md | 273 ++++++++++++++++++ 1 file changed, 273 insertions(+) create mode 100644 sources/tech/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md diff --git a/sources/tech/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md b/sources/tech/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md new file mode 100644 index 0000000000..ba57e40be3 --- /dev/null +++ b/sources/tech/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md @@ -0,0 +1,273 @@ +Asynchronous Processing with Go using Kafka and MongoDB +============================================================ + +In my previous blog post ["My First Go Microservice using MongoDB and Docker Multi-Stage Builds"][9], I created a Go microservice sample which exposes a REST http endpoint and saves the data received from an HTTP POST to a MongoDB database. + +In this example, I decoupled the saving of data to MongoDB and created another microservice to handle this. I also added Kafka to serve as the messaging layer so the microservices can work on its own concerns asynchronously. + +> In case you have time to watch, I recorded a walkthrough of this blog post in the [video below][1] :) + +Here is the high-level architecture of this simple asynchronous processing example wtih 2 microservices. + +![rest-kafka-mongo-microservice-draw-io](https://www.melvinvivas.com/content/images/2018/04/rest-kafka-mongo-microservice-draw-io.jpg) + +Microservice 1 - is a REST microservice which receives data from a /POST http call to it. After receiving the request, it retrieves the data from the http request and saves it to Kafka. After saving, it responds to the caller with the same data sent via /POST + +Microservice 2 - is a microservice which subscribes to a topic in Kafka where Microservice 1 saves the data. Once a message is consumed by the microservice, it then saves the data to MongoDB. + +Before you proceed, we need a few things to be able to run these microservices: + +1. [Download Kafka][2] - I used version kafka_2.11-1.1.0 + +2. Install [librdkafka][3] - Unfortunately, this library should be present in the target system + +3. Install the [Kafka Go Client by Confluent][4] + +4. Run MongoDB. You can check my [previous blog post][5] about this where I used a MongoDB docker image. + +Let's get rolling! + +Start Kafka first, you need Zookeeper running before you run the Kafka server. Here's how + +``` +$ cd //kafka_2.11-1.1.0 +$ bin/zookeeper-server-start.sh config/zookeeper.properties + +``` + +Then run Kafka - I am using port 9092 to connect to Kafka. If you need to change the port, just configure it in config/server.properties. If you are just a beginner like me, I suggest to just use default ports for now. + +``` +$ bin/kafka-server-start.sh config/server.properties + +``` + +After running Kafka, we need MongoDB. To make it simple, just use this docker-compose.yml. + +``` +version: '3' +services: + mongodb: + image: mongo + ports: + - "27017:27017" + volumes: + - "mongodata:/data/db" + networks: + - network1 + +volumes: + mongodata: + +networks: + network1: + +``` + +Run the MongoDB docker container using Docker Compose + +``` +docker-compose up + +``` + +Here is the relevant code of Microservice 1. I just modified my previous example to save to Kafka rather than MongoDB. + +[rest-to-kafka/rest-kafka-sample.go][10] + +``` +func jobsPostHandler(w http.ResponseWriter, r *http.Request) { + + //Retrieve body from http request + b, err := ioutil.ReadAll(r.Body) + defer r.Body.Close() + if err != nil { + panic(err) + } + + //Save data into Job struct + var _job Job + err = json.Unmarshal(b, &_job) + if err != nil { + http.Error(w, err.Error(), 500) + return + } + + saveJobToKafka(_job) + + //Convert job struct into json + jsonString, err := json.Marshal(_job) + if err != nil { + http.Error(w, err.Error(), 500) + return + } + + //Set content-type http header + w.Header().Set("content-type", "application/json") + + //Send back data as response + w.Write(jsonString) + +} + +func saveJobToKafka(job Job) { + + fmt.Println("save to kafka") + + jsonString, err := json.Marshal(job) + + jobString := string(jsonString) + fmt.Print(jobString) + + p, err := kafka.NewProducer(&kafka.ConfigMap{"bootstrap.servers": "localhost:9092"}) + if err != nil { + panic(err) + } + + // Produce messages to topic (asynchronously) + topic := "jobs-topic1" + for _, word := range []string{string(jobString)} { + p.Produce(&kafka.Message{ + TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny}, + Value: []byte(word), + }, nil) + } +} + +``` + +Here is the code of Microservice 2. What is important in this code is the consumption from Kafka, the saving part I already discussed in my previous blog post. Here are the important parts of the code which consumes the data from Kafka. + +[kafka-to-mongo/kafka-mongo-sample.go][11] + +``` + +func main() { + + //Create MongoDB session + session := initialiseMongo() + mongoStore.session = session + + receiveFromKafka() + +} + +func receiveFromKafka() { + + fmt.Println("Start receiving from Kafka") + c, err := kafka.NewConsumer(&kafka.ConfigMap{ + "bootstrap.servers": "localhost:9092", + "group.id": "group-id-1", + "auto.offset.reset": "earliest", + }) + + if err != nil { + panic(err) + } + + c.SubscribeTopics([]string{"jobs-topic1"}, nil) + + for { + msg, err := c.ReadMessage(-1) + + if err == nil { + fmt.Printf("Received from Kafka %s: %s\n", msg.TopicPartition, string(msg.Value)) + job := string(msg.Value) + saveJobToMongo(job) + } else { + fmt.Printf("Consumer error: %v (%v)\n", err, msg) + break + } + } + + c.Close() + +} + +func saveJobToMongo(jobString string) { + + fmt.Println("Save to MongoDB") + col := mongoStore.session.DB(database).C(collection) + + //Save data into Job struct + var _job Job + b := []byte(jobString) + err := json.Unmarshal(b, &_job) + if err != nil { + panic(err) + } + + //Insert job into MongoDB + errMongo := col.Insert(_job) + if errMongo != nil { + panic(errMongo) + } + + fmt.Printf("Saved to MongoDB : %s", jobString) + +} + +``` + +Let's get down to the demo, run Microservice 1\. Make sure Kafka is running. + +``` +$ go run rest-kafka-sample.go + +``` + +I used Postman to send data to Microservice 1 + +![Screenshot-2018-04-29-22.20.33](https://www.melvinvivas.com/content/images/2018/04/Screenshot-2018-04-29-22.20.33.png) + +Here is the log you will see in Microservice 1\. Once you see this, it means data has been received from Postman and saved to Kafka + +![Screenshot-2018-04-29-22.22.00](https://www.melvinvivas.com/content/images/2018/04/Screenshot-2018-04-29-22.22.00.png) + +Since we are not running Microservice 2 yet, the data saved by Microservice 1 will just be in Kafka. Let's consume it and save to MongoDB by running Microservice 2. + +``` +$ go run kafka-mongo-sample.go + +``` + +Now you'll see that Microservice 2 consumes the data and saves it to MongoDB + +![Screenshot-2018-04-29-22.24.15](https://www.melvinvivas.com/content/images/2018/04/Screenshot-2018-04-29-22.24.15.png) + +Check if data is saved in MongoDB. If it is there, we're good! + +![Screenshot-2018-04-29-22.26.39](https://www.melvinvivas.com/content/images/2018/04/Screenshot-2018-04-29-22.26.39.png) + +Complete source code can be found here +[https://github.com/donvito/learngo/tree/master/rest-kafka-mongo-microservice][12] + +Shameless plug! If you like this blog post, please follow me in Twitter [@donvito][6]. I tweet about Docker, Kubernetes, GoLang, Cloud, DevOps, Agile and Startups. Would love to connect in [GitHub][7] and [LinkedIn][8] + +[VIDEO](https://youtu.be/xa0Yia1jdu8) + +Enjoy! + +-------------------------------------------------------------------------------- + +via: https://www.melvinvivas.com/developing-microservices-using-kafka-and-mongodb/ + +作者:[Melvin Vivas ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.melvinvivas.com/author/melvin/ +[1]:https://www.melvinvivas.com/developing-microservices-using-kafka-and-mongodb/#video1 +[2]:https://kafka.apache.org/downloads +[3]:https://github.com/confluentinc/confluent-kafka-go +[4]:https://github.com/confluentinc/confluent-kafka-go +[5]:https://www.melvinvivas.com/my-first-go-microservice/ +[6]:https://twitter.com/donvito +[7]:https://github.com/donvito +[8]:https://www.linkedin.com/in/melvinvivas/ +[9]:https://www.melvinvivas.com/my-first-go-microservice/ +[10]:https://github.com/donvito/learngo/tree/master/rest-kafka-mongo-microservice/rest-to-kafka +[11]:https://github.com/donvito/learngo/tree/master/rest-kafka-mongo-microservice/kafka-to-mongo +[12]:https://github.com/donvito/learngo/tree/master/rest-kafka-mongo-microservice From a85a94d4be86b1ff8570da2127875f392abe4516 Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 4 May 2018 10:04:16 +0800 Subject: [PATCH 0760/1057] =?UTF-8?q?20180504-5=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Common Concurrent Programming Mistakes.md | 429 ++++++++++++++++++ 1 file changed, 429 insertions(+) create mode 100644 sources/tech/20180415 Some Common Concurrent Programming Mistakes.md diff --git a/sources/tech/20180415 Some Common Concurrent Programming Mistakes.md b/sources/tech/20180415 Some Common Concurrent Programming Mistakes.md new file mode 100644 index 0000000000..3bec5ee229 --- /dev/null +++ b/sources/tech/20180415 Some Common Concurrent Programming Mistakes.md @@ -0,0 +1,429 @@ +Some Common Concurrent Programming Mistakes +============================================================ + +Go is a language supporting built-in concurrent programming. By using the `go` keyword to create goroutines (light weight threads) and by [using][8] [channels][9] and [other concurrency][10] [synchronization techniques][11] provided in Go, concurrent programming becomes easy, flexible and enjoyable. + +One the other hand, Go doesn't prevent Go programmers from making some concurrent programming mistakes which are caused by either carelessnesses or lacking of experiences. The remaining of the current article will show some common mistakes in Go concurrent programming, to help Go programmers avoid making such mistakes. + +### No Synchronizations When Synchronizations Are Needed + +Code lines may be [not executed by the appearance orders][2]. + +There are two mistakes in the following program. + +* First, the read of `b` in the main goroutine and the write of `b` in the new goroutine might cause data races. + +* Second, the condition `b == true` can't ensure that `a != nil` in the main goroutine. Compilers and CPUs may make optimizations by [reordering instructions][1] in the new goroutine, so the assignment of `b`may happen before the assignment of `a` at run time, which makes that slice `a` is still `nil` when the elements of `a` are modified in the main goroutine. + +``` +package main + +import ( + "time" + "runtime" +) + +func main() { + var a []int // nil + var b bool // false + + // a new goroutine + go func () { + a = make([]int, 3) + b = true // write b + }() + + for !b { // read b + time.Sleep(time.Second) + runtime.Gosched() + } + a[0], a[1], a[2] = 0, 1, 2 // might panic +} + +``` + +The above program may run well on one computer, but may panic on another one. Or it may run well for  _N_ times, but may panic at the  _(N+1)_ th time. + +We should use channels or the synchronization techniques provided in the `sync` standard package to ensure the memory orders. For example, + +``` +package main + +func main() { + var a []int = nil + c := make(chan struct{}) + + // a new goroutine + go func () { + a = make([]int, 3) + c <- struct{}{} + }() + + <-c + a[0], a[1], a[2] = 0, 1, 2 +} + +``` + +### Use `time.Sleep` Calls To Do Synchronizations + +Let's view a simple example. + +``` +ppackage main + +import ( + "fmt" + "time" +) + +func main() { + var x = 123 + + go func() { + x = 789 // write x + }() + + time.Sleep(time.Second) + fmt.Println(x) // read x +} + +``` + +We expect the program to print `789`. If we run it, it really prints `789`, almost always. But is it a program with good syncrhonization? No! The reason is Go runtime doesn't guarantee the write of `x` happens before the read of `x` for sure. Under certain conditions, such as most CPU resources are cunsumed by other programs running on same OS, the write of `x` might happen after the read of `x`. This is why we should never use `time.Sleep` calls to do syncrhonizations in formal projects. + +Let's view another example. + +``` +package main + +import ( + "fmt" + "time" +) + +var x = 0 + +func main() { + var num = 123 + var p = &num + + c := make(chan int) + + go func() { + c <- *p + x + }() + + time.Sleep(time.Second) + num = 789 + fmt.Println(<-c) +} + +``` + +What do you expect the program will output? `123`, or `789`? In fact, the output is compiler dependent. For the standard Go compiler 1.10, it is very possible the program will output `123`. But in theory, it might output `789`, or another random number. + +Now, let's change `c <- *p + x` to `c <- *p` and run the program again. You will find the output becomes to `789` (for the he standard Go compiler 1.10). Again, the output is compiler dependent. + +Yes, there are data races in the above program. The expression `*p` might be evaluated before, after, or when the assignment `num = 789` is processed. The `time.Sleep` call can't guarantee the evaluation of `*p`happens before the assignment is processed. + +For this specified example, we should store the value to be sent in a temporary value before creating the new goroutine and send the temporary value instead in the new goroutine to remove the data races. + +``` +... + tmp := *p + x + go func() { + c <- tmp + }() +... + +``` + +### Leave Goroutines Hanging + +Hanging goroutines are the goroutines staying in blocking state for ever. There are many reasons leading goroutines into hanging. For example, + +* a goroutine tries to receive a value from a nil channel or from a channel which no more other goroutines will send values to. + +* a goroutine tries to send a value to nil channel or to a channel which no more other goroutines will receive values from. + +* a goroutine is dead locked by itself. + +* a group of goroutines are dead locked by each other. + +* a goroutine is blocked when executing a `select` code block without `default` branch, and all the channel operations following the `case` keywords in the `select` code block keep blocking for ever. + +Except sometimes we deliberately let the main goroutine in a program hanging to avoid the program exiting, most other hanging goroutine cases are unexpected. It is hard for Go runtime to judge whether or not a goroutine in blocking state is hanging or stays in blocking state temporarily. So Go runtime will never release the resources consumed by a hanging goroutine. + +In the [first-response-wins][12] channel use case, if the capacity of the channel which is used a future is not large enough, some slower response goroutines will hang when trying to send a result to the future channel. For example, if the following function is called, there will be 4 goroutines stay in blocking state for ever. + +``` +func request() int { + c := make(chan int) + for i := 0; i < 5; i++ { + i := i + go func() { + c <- i // 4 goroutines will hang here. + }() + } + return <-c +} + +``` + +To avoid the four goroutines hanging, the capacity of channel `c` must be at least `4`. + +In [the second way to implement the first-response-wins][13] channel use case, if the channel which is used as a future is an unbufferd channel, it is possible that the channel reveiver will never get a response and hang. For example, if the following function is called in a goroutine, the goroutine might hang. The reason is, if the five try-send operations all happen before the receive operation `<-c` is ready, then all the five try-send operations will fail to send values so that the caller goroutine will never receive a value. + +``` +func request() int { + c := make(chan int) + for i := 0; i < 5; i++ { + i := i + go func() { + select { + case c <- i: + default: + } + }() + } + return <-c +} + +``` + +Changing the channel `c` as a buffered channel will guarantee at least one of the five try-send operations succeed so that the caller goroutine will never hang in the above function. + +### Copy Values Of The Types In The `sync` Standard Package + +In practice, values of the types in the `sync` standard package shouldn't be copied. We should only copy pointers of such values. + +The following is bad concurrent programming example. In this example, when the `Counter.Value` method is called, a `Counter` receiver value will be copied. As a field of the receiver value, the respective `Mutex` field of the `Counter` receiver value will also be copied. The copy is not synchronized, so the copied `Mutex` value might be corrupt. Even if it is not corrupt, what it protects is the accessment of the copied `Counter` receiver value, which is meaningless generally. + +``` +import "sync" + +type Counter struct { + sync.Mutex + n int64 +} + +// This method is okay. +func (c *Counter) Increase(d int64) (r int64) { + c.Lock() + c.n += d + r = c.n + c.Unlock() + return +} + +// The method is bad. When it is called, a Counter +// receiver value will be copied. +func (c Counter) Value() (r int64) { + c.Lock() + r = c.n + c.Unlock() + return +} + +``` + +We should change the reveiver type of the `Value` method to the poiner type `*Counter` to avoid copying `Mutex` values. + +The `go vet` command provided in the official Go SDK will report potential bad value copies. + +### Call Methods Of `sync.WaitGroup` At Wrong Places + +Each `sync.WaitGroup` value maintains a counter internally, The initial value of the counter is zero. If the counter of a `WaitGroup` value is zero, a call to the `Wait` method of the `WaitGroup` value will not block, otherwise, the call blocks until the counter value becomes zero. + +To make the uses of `WaitGroup` value meaningful, when the counter of a `WaitGroup` value is zero, a call to the `Add` method of the `WaitGroup` value must happen before the corresponding call to the `Wait` method of the `WaitGroup` value. + +For example, in the following program, the `Add` method is called at an improper place, which makes that the final printed number is not always `100`. In fact, the final printed number of the program may be an arbitrary number in the range `[0, 100)`. The reason is none of the `Add` method calls are guaranteed to happen before the `Wait` method call. + +``` +package main + +import ( + "fmt" + "sync" + "sync/atomic" +) + +func main() { + var wg sync.WaitGroup + var x int32 = 0 + for i := 0; i < 100; i++ { + go func() { + wg.Add(1) + atomic.AddInt32(&x, 1) + wg.Done() + }() + } + + fmt.Println("To wait ...") + wg.Wait() + fmt.Println(atomic.LoadInt32(&x)) +} + +``` + +To make the program behave as expected, we should move the `Add` method calls out of the new goroutines created in the `for` loop, as the following code shown. + +``` +... + for i := 0; i < 100; i++ { + wg.Add(1) + go func() { + atomic.AddInt32(&x, 1) + wg.Done() + }() + } +... + +``` + +### Use Channels As Futures Improperly + +From the article [channel use cases][14], we know that some functions will return [channels as futures][15]. Assume `fa` and `fb` are two such functions, then the following call uses future arguments improperly. + +``` +doSomethingWithFutureArguments(<-fa(), <-fb()) + +``` + +In the above code line, the two channel receive operations are processed in sequentially, instead of concurrently. We should modify it as the following to process them concurrently. + +``` +ca, cb := fa(), fb() +doSomethingWithFutureArguments(<-c1, <-c2) + +``` + +### Close Channels Not From The Last Active Sender Goroutine + +A common mistake made by Go programmers is closing a channel when there are still some other goroutines will potentially send values to the channel later. When such a potential send (to the closed channel) really happens, a panic will occur. + +This mistake was ever made in some famous Go projects, such as [this bug][3] and [this bug][4] in the kubernetes project. + +Please read [this article][5] for explanations on how to safely and gracefully close channels. + +### Do 64-bit Atomic Operations On Values Which Are Not Guaranteed To Be 64-bit Aligned + +Up to now (Go 1.10), for the standard Go compiler, the address of the value involved in a 64-bit atomic operation is required to be 64-bit aligned. Failure to do so may make the current goroutine panic. For the standard Go compiler, such failure can only happen on 32-bit architectures. Please read [memory layouts][6] to get how to guarantee the addresses of 64-bit word 64-bit aligned on 32-bit OSes. + +### Not Pay Attention To Too Many Resources Are Consumed By Calls To The `time.After` Function + +The `After` function in the `time` standard package returns [a channel for delay notification][7]. The function is convenient, however each of its calls will create a new value of the `time.Timer` type. The new created `Timer` value will keep alive in the duration specified by the passed argument to the `After` function. If the function is called many times in the duration, there will be many `Timer` values alive and consuming much memory and computation. + +For example, if the following `longRunning` function is called and there are millions of messages coming in one minute, then there will be millions of `Timer` values alive in a certain period, even if most of these `Timer`values have already become useless. + +``` +import ( + "fmt" + "time" +) + +// The function will return if a message arrival interval +// is larger than one minute. +func longRunning(messages <-chan string) { + for { + select { + case <-time.After(time.Minute): + return + case msg := <-messages: + fmt.Println(msg) + } + } +} + +``` + +To avoid too many `Timer` values being created in the above code, we should use a single `Timer` value to do the same job. + +``` +func longRunning(messages <-chan string) { + timer := time.NewTimer(time.Minute) + defer timer.Stop() + + for { + select { + case <-timer.C: + return + case msg := <-messages: + fmt.Println(msg) + if !timer.Stop() { + <-timer.C + } + } + + // The above "if" block can also be put here. + + timer.Reset(time.Minute) + } +} + +``` + +### Use `time.Timer` Values Incorrectly + +An idiomatic use example of a `time.Timer` value has been shown in the last section. One detail which should be noted is that the `Reset` method should always be invoked on stopped or expired `time.Timer`values. + +At the end of the first `case` branch of the `select` block, the `time.Timer` value has expired, so we don't need to stop it. But we must stop the timer in the second branch. If the `if` code block in the second branch is missing, it is possible that a send (by the Go runtime) to the channel `timer.C` races with the `Reset`method call, and it is possible that the `longRunning` function returns earlier than expected, for the `Reset`method will only reset the internal timer to zero, it will not clear (drain) the value which has been sent to the `timer.C` channel. + +For example, the following program is very possible to exit in about one second, instead of ten seconds. and more importantly, the program is not data race free. + +``` +package main + +import ( + "fmt" + "time" +) + +func main() { + start := time.Now() + timer := time.NewTimer(time.Second/2) + select { + case <-timer.C: + default: + time.Sleep(time.Second) // go here + } + timer.Reset(time.Second * 10) + <-timer.C + fmt.Println(time.Since(start)) // 1.000188181s +} + +``` + +A `time.Timer` value can be leaved in non-stopping status when it is not used any more, but it is recommended to stop it in the end. + +It is bug prone and not recommended to use a `time.Timer` value concurrently in multiple goroutines. + +We should not rely on the return value of a `Reset` method call. The return result of the `Reset` method exists just for compatibility purpose. + +-------------------------------------------------------------------------------- + +via: https://go101.org/article/concurrent-common-mistakes.html + +作者:[go101.org ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:go101.org +[1]:https://go101.org/article/memory-model.html +[2]:https://go101.org/article/memory-model.html +[3]:https://github.com/kubernetes/kubernetes/pull/45291/files?diff=split +[4]:https://github.com/kubernetes/kubernetes/pull/39479/files?diff=split +[5]:https://go101.org/article/channel-closing.html +[6]:https://go101.org/article/memory-layout.html +[7]:https://go101.org/article/channel-use-cases.html#timer +[8]:https://go101.org/article/channel-use-cases.html +[9]:https://go101.org/article/channel.html +[10]:https://go101.org/article/concurrent-atomic-operation.html +[11]:https://go101.org/article/concurrent-synchronization-more.html +[12]:https://go101.org/article/channel-use-cases.html#first-response-wins +[13]:https://go101.org/article/channel-use-cases.html#first-response-wins-2 +[14]:https://go101.org/article/channel-use-cases.html +[15]:https://go101.org/article/channel-use-cases.html#future-promise From 17c836b003176ccf43ea584138bafcae8ba6fa39 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Fri, 4 May 2018 11:08:11 +0800 Subject: [PATCH 0761/1057] complete content and links --- .../tech/20180416 Running Jenkins builds in containers.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sources/tech/20180416 Running Jenkins builds in containers.md b/sources/tech/20180416 Running Jenkins builds in containers.md index 1b03413c3a..f820ddaf56 100644 --- a/sources/tech/20180416 Running Jenkins builds in containers.md +++ b/sources/tech/20180416 Running Jenkins builds in containers.md @@ -56,6 +56,9 @@ Note: This solution is not related to OpenShift's [Source-to-Image (S2I)][15] bu There are several good blogs and documentation about Jenkins builds on OpenShift. The following are good to start with: + * [OpenShift Jenkins][29] image documentation and [source][30] + * [CI/CD with OpenShift][31] webcast + * [External Jenkins Integration][32] playbook Take a look at them to understand the overall solution. In this article, we'll look at the different issues that come up while applying those practices. ### Build my application @@ -954,3 +957,7 @@ via: https://opensource.com/article/18/4/running-jenkins-builds-containers [26]:http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html [27]:http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#argLine [28]:https://itnext.io/running-jenkins-builds-in-containers-458e90ff2a7b +[29]:https://docs.openshift.com/container-platform/3.7/using_images/other_images/jenkins.html +[30]:https://github.com/openshift/jenkins +[31]:https://blog.openshift.com/cicd-with-openshift/ +[32]:http://v1.uncontained.io/playbooks/continuous_delivery/external-jenkins-integration.html From c9594735468aec2c681ec01fdf5f63634b14a7b2 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Fri, 4 May 2018 11:10:29 +0800 Subject: [PATCH 0762/1057] complete content and links --- sources/tech/20180416 Running Jenkins builds in containers.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180416 Running Jenkins builds in containers.md b/sources/tech/20180416 Running Jenkins builds in containers.md index f820ddaf56..5eb00ecc8e 100644 --- a/sources/tech/20180416 Running Jenkins builds in containers.md +++ b/sources/tech/20180416 Running Jenkins builds in containers.md @@ -59,6 +59,7 @@ There are several good blogs and documentation about Jenkins builds on OpenShift * [OpenShift Jenkins][29] image documentation and [source][30] * [CI/CD with OpenShift][31] webcast * [External Jenkins Integration][32] playbook + Take a look at them to understand the overall solution. In this article, we'll look at the different issues that come up while applying those practices. ### Build my application From 1d8a0cca50e7ac76490269e2e90db56c27934123 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Fri, 4 May 2018 12:26:14 +0800 Subject: [PATCH 0763/1057] submit tech/20180416 Running Jenkins builds in containers.md --- ...16 Running Jenkins builds in containers.md | 239 ++++++++---------- 1 file changed, 108 insertions(+), 131 deletions(-) rename {sources => translated}/tech/20180416 Running Jenkins builds in containers.md (50%) diff --git a/sources/tech/20180416 Running Jenkins builds in containers.md b/translated/tech/20180416 Running Jenkins builds in containers.md similarity index 50% rename from sources/tech/20180416 Running Jenkins builds in containers.md rename to translated/tech/20180416 Running Jenkins builds in containers.md index 5eb00ecc8e..f967436aa8 100644 --- a/sources/tech/20180416 Running Jenkins builds in containers.md +++ b/translated/tech/20180416 Running Jenkins builds in containers.md @@ -1,94 +1,76 @@ -pinewall translating - -Running Jenkins builds in containers +在容器中运行 Jenkins 构建 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_scale_performance.jpg?itok=R7jyMeQf) -Running applications in containers has become a well-accepted practice in the enterprise sector, as [Docker][1] with [Kubernetes][2] (K8s) now provides a scalable, manageable application platform. The container-based approach also suits the [microservices architecture][3] that's gained significant momentum in the past few years. +由于 [Docker][1] 和 [Kubernetes][2] (K8s) 目前提供了可扩展、可管理的应用平台,将应用运行在容器中的实践已经被企业广泛接受。近些年势头很猛的[微服务架构][3]也很适合用容器实现。 -One of the most important advantages of a container application platform is the ability to dynamically bring up isolated containers with resource limits. Let's check out how this can change the way we run our continuous integration/continuous development (CI/CD) tasks. +容器应用平台可以动态启动指定资源配额、互相隔离的容器,这是其最主要的优势之一。让我们看看这会对我们运行持续集成/持续部署 (continuous integration/continuous development, CI/CD) 任务的方式产生怎样的改变。 -Building and packaging an application requires an environment that can download the source code, access dependencies, and have the build tools installed. Running unit and component tests as part of the build may use local ports or require third-party applications (e.g., databases, message brokers, etc.) to be running. In the end, we usually have multiple, pre-configured build servers with each running a certain type of job. For tests, we maintain dedicated instances of third-party apps (or try to run them embedded) and avoid running jobs in parallel that could mess up each other's outcome. The pre-configuration for such a CI/CD environment can be a hassle, and the required number of servers for different jobs can significantly change over time as teams shift between versions and development platforms. +构建并打包应用需要一定的环境,要求能够下载源代码、使用相关依赖及已经安装构建工具。作为构建的一部分,运行单元及组件测试可能会用到本地端口或需要运行第三方应用 (例如数据库及消息中间件等)。另外,我们一般定制化多台构建服务器,每台执行一种指定类型的构建任务。为方便测试,我们维护一些实例专门用于运行第三方应用 (或者试图在构建服务器上启动这些第三方应用),避免并行运行构建任务防止结果互相干扰。为 CI/CD 环境定制化构建服务器是一项繁琐的工作,而且随着开发团队使用的开发平台或其版本变更,所需构建服务器的数量也会变更。 -Once we have access to a container platform (onsite or in the cloud), it makes sense to move the resource-intensive CI/CD task executions into dynamically created containers. In this scenario, build environments can be independently started and configured for each job execution. Tests during the build have free reign to use available resources in this isolated box, while we can also bring up a third-party application in a side container that exists only for this job's lifecycle. +一旦我们有了容器管理平台 (自建或在云端),将资源密集型的 CI/CD 任务在动态生成的容器中执行是比较合理的。在这种方案中,每个构建任务运行在独立启动并配置的构建环境中。构建过程中,构建任务的测试环节可以任意使用隔离环境中的可用资源;此外,我们也可以在辅助容器中启动一个第三方应用,只在构建任务生命周期中为测试提供服务。 -It sounds nice… Let's see how it works in real life. +听上去不错,让我们在现实环境中实践一下。 -Note: This article is based on a real-world solution for a project running on a [Red Hat OpenShift][4] v3.7 cluster. OpenShift is the enterprise-ready version of Kubernetes, so these practices work on a K8s cluster as well. To try, download the [Red Hat CDK][5] and run the `jenkins-ephemeral` or `jenkins-persistent` [templates][6] that create preconfigured Jenkins masters on OpenShift. +注:本文基于现实中已有的解决方案,即在 [Red Hat OpenShift][4] v3.7 集群上运行项目。OpenShift 是企业就绪版本的 Kubernetes,故这些实践也适用于 K8s 集群。如果愿意尝试,可以下载 [Red Hat CDK][5],运行 `jenkins-ephemeral` 或 `jenkins-persistent` [模板][6]在 OpenShift 上创建定制化好的 Jenkins 管理节点。 -### Solution overview +### 解决方案概述 -The solution to executing CI/CD tasks (builds, tests, etc.) in containers on OpenShift is based on [Jenkins distributed builds][7], which means: +在 OpenShift 容器中执行 CI/CD 任务 (构建和测试等) 的方案基于[分布式 Jenkins 构建][7],具体如下: + * 我们需要一个 Jenkins 主节点;可以运行在集群中,也可以是外部提供 + * 支持 Jenkins 特性和插件,故已有项目仍可使用 + * 可以用 Jenkins GUI 配置、运行任务或查看任务输出 + * 如果你愿意编码,也可以使用 [Jenkins Pipeline][8] - * We need a Jenkins master; it may run inside the cluster but also works with an external master - * Jenkins features/plugins are available as usual, so existing projects can be used - * The Jenkins GUI is available to configure, run, and browse job output - * if you prefer code, [Jenkins Pipeline][8] is also available - - - -From a technical point of view, the dynamic containers to run jobs are Jenkins agent nodes. When a build kicks off, first a new node starts and "reports for duty" to the Jenkins master via JNLP (port 5000). The build is queued until the agent node comes up and picks up the build. The build output is sent back to the master—just like with regular Jenkins agent servers—but the agent container is shut down once the build is done. +从技术角度来看,运行任务的动态容器是 Jenkins 代理节点。当构建启动时,首先是一个新节点启动,通过 Jenkins 主节点的 JNLP (5000 端口) 告知就绪状态。在代理节点启动并提取构建任务之前,构建任务处于排队状态。就像通常 Jenkins 代理服务器那样,构建输出会送达主节点;不同的是,构建完成后代理节点容器会自动关闭。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/1_running_jenkinsincontainers.png?itok=fR4ntnn8) -Different kinds of builds (e.g., Java, NodeJS, Python, etc.) need different agent nodes. This is nothing new—labels could previously be used to restrict which agent nodes should run a build. To define the config for these Jenkins agent containers started for each job, we will need to set the following: +不同类型的构建任务 (例如 Java, NodeJS, Python等) 对应不同的代理节点。这并不新奇,之前也是使用标签来限制哪些代理节点可以运行指定的构建任务。启动用于构建任务的 Jenkins 代理节点容器需要配置参数,具体如下: + * 用于启动容器的 Docker 镜像 + * 资源限制 + * 环境变量 + * 挂载卷 - * The Docker image to boot up - * Resource limits - * Environment variables - * Volumes mounted +这里用到的关键组件是 [Jenkins Kubernetes 插件][9]。该插件 (通过使用一个服务账号) 与 K8s 集群交互,可以启动和关闭代理节点。在插件的配置管理中,多种代理节点类型表现为多种Kubernetes pod 模板,它们通过项目标签对应。 +这些[代理节点镜像][10]以开箱即用的方式提供 (也有 [CentOS7][11] 系统的版本): + * [jenkins-slave-base-rhel7][12]:基础镜像,启动与 Jenkins 主节点连接的代理节点;其中 Java 堆大小根据容器内容设置 + * [jenkins-slave-maven-rhel7][13]:用于 Maven 和 Gradle 构建的镜像 (从基础镜像扩展) + * [jenkins-slave-nodejs-rhel7][14]:包含 NodeJS4 工具的镜像 (从基础镜像扩展) +注意:本解决方案与 OpenShift 中的 [Source-to-Image (S2I)][15] 构建不同,虽然后者也可以用于某些特定的 CI/CD 任务。 -The core component here is the [Jenkins Kubernetes plugin][9]. This plugin interacts with the K8s cluster (by using a ServiceAccount) and starts/stops the agent nodes. Multiple agent types can be defined as Kubernetes pod templates under the plugin's configuration (refer to them by label in projects). +### 入门学习资料 -These [agent images][10] are provided out of the box (also on [CentOS7][11]): +有很多不错的博客和文档介绍了如何在 OpenShift 上执行 Jenkins 构建。不妨从下面这些开始: + * [OpenShift Jenkins][29] 镜像文档及 [源代码][30] + * 网络直播[基于 OpenShift 的 CI/CD][31] + * [外部 Jenkins 集成][32] playbook - * [jenkins-slave-base-rhel7][12]: Base image starting the agent that connects to Jenkins master; the Java heap is set according to container memory - * [jenkins-slave-maven-rhel7][13]: Image for Maven and Gradle builds (extends base) - * [jenkins-slave-nodejs-rhel7][14]: Image with NodeJS4 tools (extends base) +阅读这些博客和文档有助于完整的理解本解决方案。在本文中,我们主要关注具体实践中遇到的各类问题。 +### 构建我的应用 +作为[示例项目][16],我们选取了包含如下构建步骤的 Java 项目: -Note: This solution is not related to OpenShift's [Source-to-Image (S2I)][15] build, which can also be used for certain CI/CD tasks. + * **代码源:** 从一个Git代码库中获取项目代码 + * **使用 Maven 编译:** 依赖可从内部仓库获取,(不妨使用 Apache Nexus) 从外部 Maven 仓库镜像 + * **发布 artifact:** 将编译好的 JAR 上传至内部仓库 -### Background learning material +在 CI/CD 过程中,我们需要与 Git 和 Nexus 交互,故 Jenkins 任务需要能够访问这些系统。这涉及参数配置和已存储凭证,可以在下列位置进行存放及管理: + * **在 Jenkins 中:** 我们可以在 Jenkins 中添加凭证,通过 Git 插件获取项目代码 (使用容器不会改变操作) + * **在 OpenShift 中:** 使用 ConfigMap 和 Secret 对象,以文件或环境变量的形式附加到 Jenkins 代理容器中 + * **在高度定制化的 Docker 容器中:** 镜像是定制化的,已包含完成特定类型构建的全部特性;从一个代理镜像进行扩展即可得到。 -There are several good blogs and documentation about Jenkins builds on OpenShift. The following are good to start with: +你可以按自己的喜好选择一种实现方式,甚至你最终可能混用多种实现方式。下面我们采用第二种实现方式,即首选在 OpenShift 中管理参数配置。使用 Kubernetes 插件配置来定制化 Maven 代理容器,包括设置环境变量和映射文件等。 - * [OpenShift Jenkins][29] image documentation and [source][30] - * [CI/CD with OpenShift][31] webcast - * [External Jenkins Integration][32] playbook +注意:对于 Kubernetes 插件 v1.0 版,由于 [bug][17],在 UI 界面增加环境变量并不生效。可以升级插件,或 (作为变通方案) 直接修改 `config.xml` 文件并重启 Jenkins。 -Take a look at them to understand the overall solution. In this article, we'll look at the different issues that come up while applying those practices. +### 从 Git 获取源代码 -### Build my application - -For our [example][16], let's assume a Java project with the following build steps: - - * **Source:** Pull project source from a Git repository - * **Build with Maven:** Dependencies come from an internal repository (let's use Apache Nexus) mirroring external Maven repos - * **Deploy artifact:** The built JAR is uploaded to the repository - - - -During the CI/CD process, we need to interact with Git and Nexus, so the Jenkins jobs have be able to access those systems. This requires configuration and stored credentials that can be managed at different places: - - * **In Jenkins:** We can add credentials to Jenkins that the Git plugin can use and add files to the project (using containers doesn't change anything). - * **In OpenShift:** Use ConfigMap and secret objects that are added to the Jenkins agent containers as files or environment variables. - * **In a fully customized Docker image:** These are pre-configured with everything to run a type of job; just extend one of the agent images. - - - -Which approach you use is a question of taste, and your final solution may be a mix. Below we'll look at the second option, where the configuration is managed primarily in OpenShift. Customize the Maven agent container via the Kubernetes plugin configuration by setting environment variables and mounting files. - -Note: Adding environment variables through the UI doesn't work with Kubernetes plugin v1.0 due to a [bug][17]. Either update the plugin or (as a workaround) edit `config.xml` directly and restart Jenkins. - -### Pull source from Git - -Pulling a public Git is trivial. For a private Git repo, authentication is required and the client also needs to trust the server for a secure connection. A Git pull can typically be done via two protocols: - - * HTTPS: Authentication is with username/password. The server's SSL certificate must be trusted by the job, which is only tricky if it's signed by a custom CA. +从公共 Git 仓库获取源代码很容易。但对于私有 Git 仓库,不仅需要认证操作,客户端还需要信任服务器以便建立安全连接。一般而言,通过两种协议获取源代码: + * HTTPS:验证通过用户名/密码完成。Git 服务器的 SSL 证书必须被代理节点信任,这仅在证书被自建 CA 签名时才需要特别关注。 ``` @@ -96,7 +78,7 @@ git clone https://git.mycompany.com:443/myapplication.git ``` - * SSH: Authentication is with a private key. The server is trusted when its public key's fingerprint is found in the `known_hosts` file. + * SSH:验证通过私钥完成。如果服务器的公钥指纹出现在 `known_hosts` 文件中,那么该服务器是被信任的。 ``` @@ -104,24 +86,23 @@ git clone ssh://git@git.mycompany.com:22/myapplication.git ``` -Downloading the source through HTTP with username/password is OK when it's done manually; for automated builds, SSH is better. +对于手动操作,使用用户名/密码通过 HTTP 方式下载源代码是可行的;但对于自动构建而言,SSH 是更佳的选择。 -#### Git with SSH +#### 通过 SSH 方式使用 Git -For a SSH download, we need to ensure that the SSH connection works between the agent container and the Git's SSH port. First, we need a private-public key pair. To generate one, run: +要通过 SSH 方式下载源代码,我们需要保证代理容器与 Git 的 SSH 端口之间可以建立 SSH 连接。首先,我们需要创建一个私钥-公钥对。使用如下命令生成: ``` ssh keygen -t rsa -b 2048 -f my-git-ssh -N '' ``` -It generates a private key in `my-git-ssh` (empty passphrase) and the matching public key in `my-git-ssh.pub`. Add the public key to the user on the Git server (preferably a ServiceAccount); web UIs usually support upload. To make the SSH connection work, we need two files on the agent container: +命令生成的私钥位于 `my-git-ssh` 文件中 (无密码口令),对应的公钥位于 `my-git-ssh.pub` 文件中。将公钥添加至 Git 服务器的对应用户下 (推荐使用服务账号);网页界面一般支持公钥上传。为建立 SSH 连接,我们还需要在代理容器上配置两个文件: - * The private key at `~/.ssh/id_rsa` - * The server's public key in `~/.ssh/known_hosts`. To get this, try `ssh git.mycompany.com` and accept the fingerprint; this will create a new line in the `known_hosts` file. Use that. + * 私钥文件位于 `~/.ssh/id_rsa` + * 服务器的公钥位于 `~/.ssh/known_hosts`。要实现这一点,运行 `ssh git.mycompany.com` 并接受服务器指纹,系统会在 `~/.ssh/known_hosts` 文件中增加一行。这样需求得到了满足。 - -Store the private key as `id_rsa` and server's public key as `known_hosts` in an OpenShift secret (or config map). +将 `id_rsa` 对应的私钥和 `known_hosts` 对应的公钥保存到一个 OpenShift secret (或 config map) 对象中。 ``` apiVersion: v1 @@ -147,7 +128,7 @@ stringData: ``` -Then configure this as a volume in the Kubernetes plugin for the Maven pod at mount point `/home/jenkins/.ssh/`. Each item in the secret will be a file matching the key name under the mount directory. We can use the UI (`Manage Jenkins / Configure / Cloud / Kubernetes`), or edit Jenkins config `/var/lib/jenkins/config.xml`: +在 Kubernetes 插件中将 secret 对象配置为卷,挂载到 `/home/jenkins/.ssh/`,供 Maven pod 使用。secret 中的每个对象对应挂载目录的一个文件,文件名与 key 名称相符。我们可以使用 UI (管理 Jenkins / 配置 / 云 / Kubernetes),也可以直接编辑 Jenkins 配置文件 `/var/lib/jenkins/config.xml`: ``` @@ -169,9 +150,9 @@ Then configure this as a volume in the Kubernetes plugin for the Maven pod at mo ``` -Pulling a Git source through SSH should work in the jobs running on this agent now. +此时,在代理节点上运行的任务应该可以通过 SSH 方式从 Git 代码库获取源代码。 -Note: It's also possible to customize the SSH connection in `~/.ssh/config`, for example, if we don't want to bother with `known_hosts` or the private key is mounted to a different location: +注:我们也可以在 `~/.ssh/config` 文件中自定义 SSH 连接。例如,如果你不想处理 `known_hosts` 或 私钥位于其它挂载目录中: ``` Host git.mycompany.com @@ -181,11 +162,11 @@ Host git.mycompany.com ``` -#### Git with HTTP +#### 通过 HTTP 方式使用 Git -If you prefer an HTTP download, add the username/password to a [Git-credential-store][18] file somewhere: +如果你选择使用 HTTP 方式下载,在指定的 [Git-credential-store][18] 文件中添加用户名/密码: - * E.g. `/home/jenkins/.config/git-secret/credentials` from an OpenShift secret, one site per line: + * 例如,在一个 OpenShift secret 对象中增加 `/home/jenkins/.config/git-secret/credentials` 文件对应,其中每个站点对应文件中的一行: ``` @@ -195,7 +176,7 @@ https://user:pass@github.com ``` - * Enable it in [git-config][19] expected at `/home/jenkins/.config/git/config`: + * 在 [git-config][19] 配置中启用该文件,其中配置文件默认路径为 `/home/jenkins/.config/git/config`: ``` @@ -204,11 +185,10 @@ https://user:pass@github.com   helper = store --file=/home/jenkins/.config/git-secret/credentials ``` +如果 Git 服务使用了自有 CA 签名的证书,为代理容器设置环境变量 `GIT_SSL_NO_VERIFY=true` 是最便捷的方式。更恰当的解决方案包括如下两步: -If the Git service has a certificate signed by a custom certificate authority (CA), the quickest hack is to set the `GIT_SSL_NO_VERIFY=true` environment variable (EnvVar) for the agent. The proper solution needs two things: - - * Add the custom CA's public certificate to the agent container from a config map to a path (e.g. `/usr/ca/myTrustedCA.pem`). - * Tell Git the path to this cert in an EnvVar `GIT_SSL_CAINFO=/usr/ca/myTrustedCA.pem` or in the `git-config` file mentioned above: + * 利用 config map 将自有 CA 的公钥映射到一个路径下的文件中,例如 `/usr/ca/myTrustedCA.pem`)。 + * 通过环境变量 `GIT_SSL_CAINFO=/usr/ca/myTrustedCA.pem` 或上面提到的 `git-config` 文件的方式,将证书路径告知 Git。 ``` @@ -218,26 +198,25 @@ If the Git service has a certificate signed by a custom certificate authority (C ``` -Note: In OpenShift v3.7 (and earlier), the config map and secret mount points [must not overlap][20], so we can't map to `/home/jenkins` and `/home/jenkins/dir` at the same time. This is why we didn't use the well-known file locations above. A fix is expected in OpenShift v3.9. +注:在 OpenShift v3.7 及早期版本中,config map 及 secret 的挂载点之间[不能相互覆盖][20],故我们不能同时映射 `/home/jenkins` 和 `/home/jenkins/dir`。因此,上面的代码中并没有使用常见的文件路径。预计 OpenShift v3.9 版本会修复这个问题。 ### Maven -To make a Maven build work, there are usually two things to do: +要完成 Maven 构建,一般需要完成如下两步: - * A corporate Maven repository (e.g., Apache Nexus) should be set up to act as a proxy for external repos. Use this as a mirror. - * This internal repository may have an HTTPS endpoint with a certificate signed by a custom CA. + * 建立一个社区 Maven 库 (例如 Apache Nexus),充当外部库的代理。将其当作镜像使用。 + * 这个内部库可能提供 HTTPS 服务,其中使用自建 CA 签名的证书。 +对于容器中运行构建的实践而言,使用内部 Maven 库是非常关键的,因为容器启动后并没有本地库或缓存,这导致每次构建时 Maven 都下载全部的 Jar 文件。在本地网络使用内部代理库下载明显快于从因特网下载。 -Having an internal Maven repository is practically essential if builds run in containers because they start with an empty local repository (cache), so Maven downloads all the JARs every time. Downloading from an internal proxy repo on the local network is obviously quicker than downloading from the Internet. - -The [Maven Jenkins agent][13] image supports an environment variable that can be used to set the URL for this proxy. Set the following in the Kubernetes plugin container template: +[Maven Jenkins 代理][13]镜像允许配置环境变量,指定代理的 URL。在 Kubernetes 插件的容器模板中设置如下: ``` MAVEN_MIRROR_URL=https://nexus.mycompany.com/repository/maven-public ``` -The build artifacts (JARs) should also be archived in a repository, which may or may not be the same as the one acting as a mirror for dependencies above. Maven `deploy` requires the repo URL in the `pom.xml` under [Distribution management][21] (this has nothing to do with the agent image): +构建好的 artifacts (JARs) 也应该保存到库中,可以是上面提到的用于提供依赖的镜像库,也可以是其它库。Maven 完成 `deploy` 操作需要在 `pom.xml` 的[分发管理][21] 下配置库 URL,这与代理镜像无关。 ``` @@ -263,9 +242,9 @@ The build artifacts (JARs) should also be archived in a repository, which may or ``` -Uploading the artifact may require authentication. In this case, username/password must be set in the `settings.xml` under the server ID matching the one in `pom.xml`. We need to mount a whole `settings.xml` with the URL, username, and password on the Maven Jenkins agent container from an OpenShift secret. We can also use environment variables as below: +上传 artifact 可能涉及认证。在这种情况下,需要在 `settings.xml` 中配置用户名/密码,其中 server ID 要与 `pom.xml` 文件中的 server ID 对应。我们可以使用 OpenShift secret 将包含 URL、用户名和密码的完整 `settings.xml` 映射到 Maven Jenkins 代理容器中。另外,也可以使用环境变量。具体如下: - * Add environment variables from a secret to the container: + * 利用 secret 为容器添加环境变量: ``` @@ -275,7 +254,7 @@ MAVEN_SERVER_PASSWORD=admin123 ``` - * Mount `settings.xml` from a config map to `/home/jenkins/.m2/settings.xml`: + * 利用 config map 将 `settings.xml` 挂载至 `/home/jenkins/.m2/settings.xml`: ``` @@ -313,9 +292,9 @@ MAVEN_SERVER_PASSWORD=admin123 ``` -Disable interactive mode (use batch mode) to skip the download log by using `-B` for Maven commands or by adding `false` to `settings.xml`. +禁用交互模式 (即使用批处理模式) 可以忽略下载日志,一种方式是在 Maven 命令中增加 `-B` 参数,另一种方式是在 `settings.xml` 配置文件中增加 `false` 配置。 -If the Maven repository's HTTPS endpoint uses a certificate signed by a custom CA, we need to create a Java KeyStore using the [keytool][22] containing the CA certificate as trusted. This KeyStore should be uploaded as a config map in OpenShift. Use the `oc` command to create a config map from files: +如果 Maven 库的 HTTPS 服务使用自建 CA 签名的证书,我们需要使用 [keytool][22] 工具创建一个将 CA 公钥添加至信任列表的 Java KeyStore。在 OpenShift 中使用 config map 将这个 Keystore 上传。使用 `oc` 命令基于文件创建一个 config map: ```  oc create configmap maven-settings --from-file=settings.xml=settings.xml --from- @@ -323,9 +302,9 @@ file=myTruststore.jks=myTruststore.jks ``` -Mount the config map somewhere on the Jenkins agent. In this example we use `/home/jenkins/.m2`, but only because we have `settings.xml` in the same config map. The KeyStore can go under any path. +将这个 config map 挂载至 Jenkins 代理容器。在本例中我们使用 `/home/jenkins/.m2` 目录,但这仅仅是因为配置文件 `settings.xml` 也对应这个 config map,KeyStore 可以放置在任意路径下。 -Then make the Maven Java process use this file as a trust store by setting Java parameters in the `MAVEN_OPTS` environment variable for the container: +接着在容器环境变量 `MAVEN_OPTS` 中设置 Java 参数,以便让 Maven 对应的 Java 进程使用该文件: ``` MAVEN_OPTS= @@ -335,30 +314,28 @@ MAVEN_OPTS= ``` -### Memory usage +### 内存使用量 -This is probably the most important part—if we don't set max memory correctly, we'll run into intermittent build failures after everything seems to work. +这可能是最重要的一部分设置,如果没有正确的设置最大内存,我们会遇到间歇性构建失败,虽然每个组件都似乎工作正常。 -Running Java in a container can cause high memory usage errors if we don't set the heap in the Java command line. The JVM [sees the total memory of the host machine][23] instead of the container's memory limit and sets the [default max heap][24] accordingly. This is typically much more than the container's memory limit, and OpenShift simply kills the container when a Java process allocates more memory for the heap. +如果没有在 Java 命令行中设置堆大小,在容器中运行 Java 可能导致高内存使用量的报错。JVM [可以利用全部的主机内存][23],因而使用[默认的堆大小限制][24]。这通常会超过容器的内存资源总额,故当 Java 进程为堆分配过多内存时,OpenShift 会直接杀掉容器。 -Although the `jenkins``-slave-base` image has a built-in [script to set max heap ][25]to half the container memory (this can be modified via EnvVar `CONTAINER_HEAP_PERCENT=0.50`), it only applies to the Jenkins agent Java process. In a Maven build, we have important additional Java processes running: +虽然 `jenkins` `-slave-base` 镜像包含一个内建[脚本设置堆最大为][25]容器内存的一半 (可以通过环境变量 `CONTAINER_HEAP_PERCENT=0.50` 修改),但这只适用于 Jenkins 代理节点中的 Java 进程。在 Maven 构建中,还有其它重要的 Java 进程运行: - * The `mvn` command itself is a Java tool. - * The [Maven Surefire-plugin][26] executes the unit tests in a forked JVM by default. + * `mvn` 命令本身就是一个 Java 工具。 + * [Maven Surefire 插件][26] 按默认参数派生的 JVM 用于运行单元测试。 +总结一下,容器中同时运行着三个重要的 Java 进程,预估内存使用量以避免 pod 被误杀是很重要的。每个进程都有不同的方式设置 JVM 参数: -At the end of the day, we'll have three Java processes running at the same time in the container, and it's important to estimate their memory usage to avoid unexpectedly killed pods. Each process has a different way to set JVM options: - - * Jenkins agent heap is calculated as mentioned above, but we definitely shouldn't let the agent have such a big heap. Memory is needed for the other two JVMs. Setting `JAVA_OPTS` works for the Jenkins agent. - * The `mvn` tool is called by the Jenkins job. Set `MAVEN_OPTS` to customize this Java process. - * The JVM spawned by the Maven `surefire` plugin for the unit tests can be customized by the [argLine][27] Maven property. It can be set in the `pom.xml`, in a profile in `settings.xml` or simply by adding `-DargLine=… to mvn` command in `MAVEN_OPTS`. + * 我们在上面提到了 Jenkins 代理容器堆最大值的计算方法,但我们显然不应该让代理容器使用如此大的堆,毕竟还有两个 JVM 需要使用内存。对于 Jenkins 代理容器,可以设置 `JAVA_OPTS`。 + * `mvn` 工具被 Jenkins 任务调用。设置 `JAVA_OPTS` 可以用于自定义这类 Java 进程。 + * Maven `surefire` 插件派生的用于单元测试的 JVM 可以通过 Maven [argLine][27] 属性自定义。可以在 `pom.xml` 或 `settings.xml` 的某个配置文件中设置,也可以直接在 `maven` 命令参数 `MAVEN_OPS` 中增加 `-DargLine=…`。 - -Here is an example of how to set these environment variables for the Maven agent container: +下面例子给出 Maven 代理容器环境变量设置方法: ``` - JAVA_OPTS=-Xms64m -Xmx64m +JAVA_OPTS=-Xms64m -Xmx64m MAVEN_OPTS=-Xms128m -Xmx128m -DargLine=${env.SUREFIRE_OPTS} @@ -366,17 +343,17 @@ SUREFIRE_OPTS=-Xms256m -Xmx256m ``` -These numbers worked in our tests with 1024Mi agent container memory limit building and running unit tests for a SpringBoot app. These are relatively low numbers and a bigger heap size; a higher limit may be needed for complex Maven projects and unit tests. +我们的测试环境是具有 1024Mi 内存限额的代理容器,使用上述参数可以正常构建一个 SpringBoot 应用并进行单元测试。测试环境使用的资源相对较小,对于复杂的 Maven 项目和对应的单元测试,我们需要更大的堆大小及更大的容器内存限额。 -Note: The actual memory usage of a Java8 process is something like `HeapSize + MetaSpace + OffHeapMemory`, and this can be significantly more than the max heap size set. With the settings above, the three Java processes took more than 900Mi memory in our case. See RSS memory for processes within the container: `ps -e -o ``pid``,user``,``rss``,comm``,args` +注:Java8 进程的实际内存使用量包括 `堆大小 + 元数据 + 堆外内存`,因此内存使用量会明显高于设置的最大堆大小。在我们上面的测试环境中,三个 Java 进程使用了超过 900Mi 的内存。可以在容器内查看进程的 RSS 内存使用情况,命令如下:`ps -e -o ``pid``,user``,``rss``,comm``,args`。 -The Jenkins agent images have both JDK 64 bit and 32 bit installed. For `mvn` and `surefire`, the 64-bit JVM is used by default. To lower memory usage, it makes sense to force 32-bit JVM as long as `-Xmx` is less than 1.5 GB: +Jenkins 代理镜像同时安装了 JDK 64 位和 32 位版本。对于 `mvn` 和 `surefire`,默认使用 64 位版本 JVM。为减低内存使用量,只要 `-Xmx` 不超过 1.5 GB,强制使用 32 位 JVM 都是有意义的。 ``` JAVA_HOME=/usr/lib/jvm/Java-1.8.0-openjdk-1.8.0.161–0.b14.el7_4.i386 ``` -Note that it's also possible to set Java arguments in the `JAVA_TOOL_OPTIONS` EnvVar, which is picked up by any JVM started. The parameters in `JAVA_OPTS` and `MAVEN_OPTS` overwrite the ones in `JAVA_TOOL_OPTIONS`, so we can achieve the same heap configuration for our Java processes as above without using `argLine`: +注意到我们可以在 `JAVA_TOOL_OPTIONS` 环境变量中设置 Java 参数,每个 JVM 启动时都会读取该参数。`JAVA_OPTS` 和 `MAVEN_OPTS` 中的参数会覆盖 `JAVA_TOOL_OPTIONS` 中的对应值,故我们可以不使用 `argLine`,实现对 Java 进程同样的堆配置: ``` JAVA_OPTS=-Xms64m -Xmx64m @@ -386,11 +363,11 @@ JAVA_TOOL_OPTIONS=-Xms256m -Xmx256m ``` -It's still a bit confusing, as all JVMs log `Picked up JAVA_TOOL_OPTIONS:` +但缺点是每个 JVM 的日志中都会显示 `Picked up JAVA_TOOL_OPTIONS:`,这可能让人感到迷惑。 -### Jenkins Pipeline +### Jenkins 流水线 -Following the settings above, we should have everything prepared to run a successful build. We can pull the code, download the dependencies, run the unit tests, and upload the artifact to our repository. Let's create a Jenkins Pipeline project that does this: +完成上述配置,我们应该已经可以完成一次成功的构建。我们可以获取源代码,下载依赖,运行单元测试并将 artifact 上传到我们的库中。我们可以通过创建一个 Jenkins 流水线项目来完成上述操作。 ``` pipeline { @@ -442,15 +419,15 @@ pipeline { ``` -For a real project, of course, the CI/CD pipeline should do more than just the Maven build; it could deploy to a development environment, run integration tests, promote to higher environments, etc. The learning articles linked above show examples of how to do those things. +当然,对应真实项目,CI/CD 流水线不仅仅完成 Maven 构建,还可以部署到开发环境,运行集成测试,提升至更接近于生产的环境等。上面给出的学习资料中有执行这些操作的案例。 -### Multiple containers +### 多容器 -One pod can be running multiple containers with each having their own resource limits. They share the same network interface, so we can reach started services on `localhost`, but we need to think about port collisions. Environment variables are set separately, but the volumes mounted are the same for all containers configured in one Kubernetes pod template. +一个 pod 可以运行多个容器,每个容器有单独的资源限制。这些容器共享网络接口,故我们可以从 `localhost` 访问已启动的服务,但我们需要考虑端口冲突的问题。在一个 Kubernetes pod 模板中,每个容器的环境变量是单独设置的,但挂载的卷是统一的。 -Bringing up multiple containers is useful when an external service is required for unit tests and an embedded solution doesn't work (e.g., database, message broker, etc.). In this case, this second container also starts and stops with the Jenkins agent. +当一个外部服务需要单元测试且嵌入式方案无法工作 (例如,数据库、消息中间件等) 时,可以启动多个容器。在这种情况下,第二个容器会随着 Jenkins 代理容器启停。 -See the Jenkins `config.xml` snippet where we start an `httpbin` service on the side for our Maven build: +查看 Jenkins `config.xml` 片段,其中我们启动了一个辅助的 `httpbin` 服务用于 Maven 构建: ``` @@ -508,9 +485,9 @@ See the Jenkins `config.xml` snippet where we start an `httpbin` service on the ``` -### Summary +### 总结 -For a summary, see the created OpenShift resources and the Kubernetes plugin configuration from Jenkins `config.xml` with the configuration described above. +作为总结,我们查看上面已描述配置的 Jenkins `config.xml` 对应创建的 OpenShift 资源以及 Kubernetes 插件的配置。 ``` apiVersion: v1 @@ -608,7 +585,7 @@ items: ``` -One additional config map was created from files: +基于文件创建另一个 config map: ```  oc create configmap maven-settings --from-file=settings.xml=settings.xml @@ -616,7 +593,7 @@ One additional config map was created from files: ``` -Kubernetes plugin configuration: +Kubernetes 插件配置如下: ``` @@ -914,16 +891,16 @@ MIIC6jCC... ``` -Happy builds! +尝试愉快的构建吧! -This was originally published on [ITNext][28] and is reprinted with permission. +原文发表于 [ITNext][28],已获得翻版授权。 -------------------------------------------------------------------------------- via: https://opensource.com/article/18/4/running-jenkins-builds-containers 作者:[Balazs Szeti][a] -译者:[译者ID](https://github.com/译者ID) +译者:[pinewall](https://github.com/pinewall) 校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) From 176d6bb3eb8eefb88b667458cac40c6e85137711 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 4 May 2018 13:02:54 +0800 Subject: [PATCH 0764/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20zzupdate=20-=20?= =?UTF-8?q?Single=20Command=20To=20Upgrade=20Ubuntu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...date - Single Command To Upgrade Ubuntu.md | 367 ++++++++++++++++++ 1 file changed, 367 insertions(+) create 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 new file mode 100644 index 0000000000..b3c1e2f480 --- /dev/null +++ b/sources/tech/20180502 zzupdate - Single Command To Upgrade Ubuntu.md @@ -0,0 +1,367 @@ +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 c6d31480ab47d876ea57720f40c32ff4af3a102d Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 4 May 2018 13:06:15 +0800 Subject: [PATCH 0765/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Cloud=20Command?= =?UTF-8?q?er=20=E2=80=93=20A=20Web=20File=20Manager=20With=20Console=20An?= =?UTF-8?q?d=20Editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eb File Manager With Console And Editor.md | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md diff --git a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md new file mode 100644 index 0000000000..0aae74d680 --- /dev/null +++ b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @@ -0,0 +1,143 @@ +Cloud Commander – A Web File Manager With Console And Editor +====== + +![](https://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-A-Web-File-Manager-With-Console-And-Editor-720x340.png) + +**Cloud commander** is a web-based file manager application that allows you to view, access, and manage the files and folders of your system from any computer, mobile, and tablet Pc via a web browser. It has two simple and classic panels, and automatically converts it’s size as per your device’s display size. It also has two built-in editors namely **Dword** and **Edward** with support of Syntax-highlighting and one **Console** with support of your system’s command line. So you can edit your files on the go. Cloud Commander server is a cross-platform application that runs on Linux, Windows and Mac OS X operating systems, and the client will run on any web browser. It is written using **JavaScript/Node.Js** , and is licensed under **MIT**. + +In this brief tutorial, let us see how to install Cloud Commander in Ubuntu 18.04 LTS server. + +### Prerequisites + +As I mentioned earlier, Cloud Commander is written using Node.Js. So, in order to install Cloud Commander we need to install Node.Js first. To do so, refer the following guide. + +### Install Cloud Commander + +After installing Node.Js, run the following command to install Cloud Commander: +``` +$ npm i cloudcmd -g + +``` + +Congratulations! Cloud Commander has been installed. Let us go ahead and see the basic usage of Cloud Commander. + +### Getting started with Cloud Commander + +Run the following command to start Cloud Commander: +``` +$ cloudcmd + +``` + +**Sample output:** +``` +url: http://localhost:8000 + +``` + +Now, open your web browser and navigate to the URL: ** ****. + +From now on, you can create, delete, view, manage files or folders right in the web browser from the local system or remote system, or mobile, tablet etc. + +![][2] + +As you can see in the above screenshot, Cloud Commander has two panels, ten hotkeys (F1 to F10), and Console. + +Each hotkey does a unique job. + + * F1 – Help + * F2 – Rename file/folder + * F3 – View files and folders + * F4 – Edit files + * F5 – Copy files/folders + * F6 – Move files/folders + * F7 – Create new directory + * F8 – Delete file/folder + * F9 – Open Menu + * F10 – Open config + + + +#### Cloud Commander console + +Click on the Console icon. This will open your default system’s shell. + +![][3] + +From this console you can do all sort of administration tasks such as installing packages, removing packages, update your system etc. You can even shutdown or reboot system. Therefore, Cloud Commander is not just a file manager, but also has the functionality of a remote administration tool. + +#### Creating files/folders + +To create a new file or folder Right click on any empty place and go to **New - >File or Directory**. + +![][4] + +#### View files + +You can view pictures, watch audio and video files. + +![][5] + +#### Upload files + +The other cool feature is we can easily upload a file to Cloud Commander system from any system or device. + +To upload a file, right click on any empty space in the Cloud Commander panel, and click on the **Upload** option. + +![][6] + +Select the files you want to upload. + +Also, you can upload files from the Cloud services like Google drive, Dropbox, Amazon cloud drive, Facebook, Twitter, Gmail, GtiHub, Picasa, Instagram and many. + +To upload files from Cloud, right click on any empty space in the panel and select **Upload from Cloud**. + +![][7] + +Select any web service of your choice, for example Google drive. Click **Connect to Google drive** button. + +![][8] + +In the next step, authenticate your google drive with Cloud Commander. Finally, select the files from your Google drive and click **Upload**. + +![][9] + +#### Update Cloud Commander + +To update Cloud Commander to the latest available version, run the following command: +``` +$ npm update cloudcmd -g + +``` + +#### Conclusion + +As far as I tested Cloud Commander, It worked like charm. I didn’t face a single issue during the testing in my Ubuntu server. Also, Cloud Commander is not just a web-based file manager, but also acts as a remote administration tool that performs most Linux administration tasks. You can create a files/folders, rename, delete, edit, and view them. Also, You can install, update, upgrade, and remove any package as the way you do in the local system from the Terminal. And, of course, you can even shutdown or restart the system from the Cloud Commander console itself. What do you need more? Give it a try, you will find it useful. + +That’s all for now. I will be here soon with another interesting article. Until then, stay tuned with OSTechNix. + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/cloud-commander-a-web-file-manager-with-console-and-editor/ + +作者:[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]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]:http://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-Google-Chrome_006-4.jpg +[3]:http://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-Google-Chrome_007-2.jpg +[4]:http://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-commander-file-folder-1.png +[5]:http://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-home-sk-Google-Chrome_008-1.jpg +[6]:http://www.ostechnix.com/wp-content/uploads/2016/05/cloud-commander-upload-2.png +[7]:http://www.ostechnix.com/wp-content/uploads/2016/05/upload-from-cloud-1.png +[8]:http://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-home-sk-Google-Chrome_009-2.jpg +[9]:http://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-home-sk-Google-Chrome_010-1.jpg From 3fd7e7690759f577d2cc8c2c2cfc98f6081bd6f4 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 4 May 2018 13:08:36 +0800 Subject: [PATCH 0766/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20buil?= =?UTF-8?q?d=20container=20images=20with=20Buildah?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... to build container images with Buildah.md | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 sources/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 new file mode 100644 index 0000000000..c18d14f322 --- /dev/null +++ b/sources/tech/20180503 How to build container images with Buildah.md @@ -0,0 +1,135 @@ +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 From 1689cbe6463204ac85c83c7f5c1913224f3d35f4 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 4 May 2018 13:10:31 +0800 Subject: [PATCH 0767/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Writing=20Syste?= =?UTF-8?q?md=20Services=20for=20Fun=20and=20Profit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ing Systemd Services for Fun and Profit.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/tech/20180502 Writing Systemd Services for Fun and Profit.md diff --git a/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md b/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md new file mode 100644 index 0000000000..042c46aedd --- /dev/null +++ b/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md @@ -0,0 +1,108 @@ +Writing Systemd Services for Fun and Profit +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/minetest.png?itok=Houi9zf9) + +Let's say you want to run a games server, a server that runs [Minetest][1], a very cool and open source mining and crafting sandbox game. You want to set it up for your school or friends and have it running on a server in your living room. Because, you know, if that’s good enough for the kernel mailing list admins, then it's good enough for you. + +However, you soon realize it is a chore to remember to run the server every time you switch your computer on and a nuisance to power down safely when you want to switch off. + +First, you have to run the server as a daemon: +``` +minetest --server & + +``` + +Take note of the PID (you'll need it later). + +Then you have to tell your friends the server is up by emailing or messaging them. After that you can start playing. + +Suddenly it is 3 am. Time to call it a day! But you can't just switch off your machine and go to bed. First, you have to tell the other players the server is coming down, locate the bit of paper where you wrote the PID we were talking about earlier, and kill the Minetest server gracefully... +``` +kill -2 + +``` + +...because just pulling the plug is a great way to end up with corrupted files. Then and only then can you power down your computer. + +There must be a way to make this easier. + +### Systemd Services to the Rescue + +Let's start off by making a systemd service you can run (manually) as a regular user and build up from there. + +Services you can run without admin privileges live in _~/.config/systemd/user/_ , so start by creating that directory: +``` +cd +mkdir -p ~/.config/systemd/user/ + +``` + +There are several types of systemd _units_ (the formal name of systemd scripts), such as _timers_ , _paths_ , and so on; but what you want is a service. Create a file in _~/.config/systemd/user/_ called _minetest.service_ and open it with your text editor and type the following into it: +``` +# minetest.service + +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple +ExecStart= /usr/games/minetest --server + +``` + +Notice how units have different sections: The `[Unit]` section is mainly informative. It contains information for users describing what the unit is and where you can read more about it. + +The meat of your script is in the `[Service]` section. Here you start by stating what kind of service it is using the `Type` directive. [There are several types][2] of service. If, for example, the process you run first sets up an environment and then calls in another process (which is the main process) and then exits, you would use the `forking` type; if you needed to block the execution of other units until the process in your unit finished, you would use `oneshot`; and so on. + +None of the above is the case for the Minetest server, however. You want to start the server, make it go to the background, and move on. This is what the `simple` type does. + +Next up is the `ExecStart` directive. This directive tells systemd what program to run. In this case, you are going to run `minetest` as headless server. You can add options to your executables as shown above, but you can't chain a bunch of Bash commands together. A line like: +``` +ExecStart: lsmod | grep nvidia > videodrive.txt + +``` + +Would not work. If you need to chain Bash commands, it is best to wrap them in a script and execute that. + +Also notice that systemd requires you give the full path to the program. So, even if you have to run something as simple as _ls_ you will have to use `ExecStart= /bin/ls`. + +There is also an `ExecStop` directive that you can use to customize how your service should be terminated. We'll be talking about this directive more in part two, but for now you must know that, if you don't specify an `ExecStop`, systemd will take it on itself to finish the process as gracefully as possible. + +There is a full list of directives in the _systemd.directives_ man page or, if you prefer, [you can check them out on the web][3] and click through to see what each does. + +Although only 6 lines long, your _minetest.service_ is already a fully functional systemd unit. You can run it by executing +``` +systemd --user start minetest + +``` + +And stop it with +``` +systemd --user stop minetest + +``` + +The `--user` option tells systemd to look for the service in your own directories and to execute the service with your user's privileges. + +That wraps up this part of our server management story. In part two, we’ll go beyond starting and stopping and look at how to send emails to players, alerting them of the server’s availability. Stay tuned. + +Learn more about Linux through the free ["Introduction to Linux" ][4]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/intro-to-linux/2018/5/writing-systemd-services-fun-and-profit + +作者:[Paul Brown][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/bro66 +[1]:https://www.minetest.net/ +[2]:http://man7.org/linux/man-pages/man5/systemd.service.5.html +[3]:http://man7.org/linux/man-pages/man7/systemd.directives.7.html +[4]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 8eb63c62c9562c1cf9c5204bba6a36a3af4c84bc Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 4 May 2018 14:30:05 +0800 Subject: [PATCH 0768/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Customizing=20y?= =?UTF-8?q?our=20text=20colors=20on=20the=20Linux=20command=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...r text colors on the Linux command line.md | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 sources/tech/20180502 Customizing your text colors on the Linux command line.md diff --git a/sources/tech/20180502 Customizing your text colors on the Linux command line.md b/sources/tech/20180502 Customizing your text colors on the Linux command line.md new file mode 100644 index 0000000000..381df0e53a --- /dev/null +++ b/sources/tech/20180502 Customizing your text colors on the Linux command line.md @@ -0,0 +1,163 @@ +Customizing your text colors on the Linux command line +====== + +![](https://images.idgesg.net/images/article/2018/05/numbers-100756457-large.jpg) +If you spend much time on the Linux command line (and you probably wouldn't be reading this if you didn't), you've undoubtedly noticed that the ls command displays your files in a number of different colors. You've probably also come to recognize some of the distinctions — directories appearing in one color, executable files in another, etc. + +How that all happens and what options are available for you to change the color assignments might not be so obvious. + +One way to get a big dose of data showing how these colors are assigned is to run the **dircolors** command. It will show you something like this: +``` +$ dircolors +LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do +=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg +=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01 +;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01 +;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=0 +1;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31 +:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*. +xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.t +bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.j +ar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.a +lz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.r +z=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*. +mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35: +*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35: +*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;3 +5:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01; +35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01 +;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01 +;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01 +;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;3 +5:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;3 +5:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;3 +6:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00; +36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00; +36:*.spx=00;36:*.xspf=00;36:'; +export LS_COLORS + +``` + +If you're good at parsing, you probably noticed that there's a pattern to this listing. Break it on the colons, and you'll see something like this: +``` +$ dircolors | tr ":" "\n" | head -10 +LS_COLORS='rs=0 +di=01;34 +ln=01;36 +mh=00 +pi=40;33 +so=01;35 +do=01;35 +bd=40;33;01 +cd=40;33;01 +or=40;31;01 + +``` + +OK, so we have a pattern here — a series of definitions that have one to three numeric components. Let's hone in on one of definition. +``` +pi=40;33 + +``` + +The first question someone is likely to ask is "What is pi?" We're working with colors and file types here, so this clearly isn't the intriguing number that starts with 3.14. No, this "pi" stands for "pipe" — a particular type of file on Linux systems that makes it possible to send data from one program to another. So, let's set one up. +``` +$ mknod /tmp/mypipe p +$ ls -l /tmp/mypipe +prw-rw-r-- 1 shs shs 0 May 1 14:00 /tmp/mypipe + +``` + +When we look at our pipe and a couple other files in a terminal window, the color differences are quite obvious. + +![font colors][1] Sandra Henry-Stocker + +The "40" in the definition of pi (shown above) makes the file show up in the terminal (or PuTTY) window with a black background. The 31 makes the font color red. Pipes are special files, and this special handling makes them stand out in a directory listing. + +The **bd** and **cd** definitions are identical to each other — 40;33;01 and have an extra setting. The settings cause block (bd) and character (cd) devices to be displayed with a black background, an orange font, and one other effect — the characters will be in bold. + +The following list shows the color and font assignments that are made by **file type** : +``` +setting file type +======= ========= +rs=0 reset to no color +di=01;34 directory +ln=01;36 link +mh=00 multi-hard link +pi=40;33 pipe +so=01;35 socket +do=01;35 door +bd=40;33;01 block device +cd=40;33;01 character device +or=40;31;01 orphan +mi=00 missing? +su=37;41 setuid +sg=30;43 setgid +ca=30;41 file with capability +tw=30;42 directory with sticky bit and world writable +ow=34;42 directory that is world writable +st=37;44 directory with sticky bit +ex=01;93 executable + +``` + +You may have noticed that in our **dircolors** command output, most of our definitions started with asterisks (e.g., *.wav=00;36). These define display attributes by **file extension** rather than file type. Here's a sampling: +``` +$ dircolors | tr ":" "\n" | tail -10 +*.mpc=00;36 +*.ogg=00;36 +*.ra=00;36 +*.wav=00;36 +*.oga=00;36 +*.opus=00;36 +*.spx=00;36 +*.xspf=00;36 +'; +export LS_COLORS + +``` + +These settings (all 00:36 in the listing above) would have these file names displaying in cyan. The available colors are shown below. + +![all colors][2] Sandra Henry-Stocker + +### How to change your settings + +The colors and font changes described require that you use an alias for ls that turns on the color feature. This is usually the default on Linux systems and will look like this: +``` +alias ls='ls --color=auto' + +``` + +If you wanted to turn off font colors, you could run the **unalias ls** command and your file listings would then show in only the default font color. + +You can alter your text colors by modifying your $LS_COLORS settings and exporting the modified setting: +``` +$ export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;... + +``` + +NOTE: The command above is truncated. + +If you want your modified text colors to be permanent, you would need to add your modified LS_COLORS definition to one of your startup files (e.g., .bashrc). + +### More on command line text + +You can find additional information on text colors in this [November 2016][3] post on NetworkWorld. + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3269587/linux/customizing-your-text-colors-on-the-linux-command-line.html + +作者:[Sandra Henry-Stocker][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.networkworld.com/author/Sandra-Henry_Stocker/ +[1]:https://images.idgesg.net/images/article/2018/05/font-colors-100756483-large.jpg +[2]:https://images.techhive.com/images/article/2016/11/all-colors-100691990-large.jpg +[3]:https://www.networkworld.com/article/3138909/linux/coloring-your-world-with-ls-colors.html From de27d19d845040553975ed03dcf312bd2a64a7e5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 4 May 2018 20:07:21 +0800 Subject: [PATCH 0769/1057] PRF:20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md @geekpi --- ...You To Find Non-free Software In Debian.md | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/translated/tech/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md b/translated/tech/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md index 7c42daae2c..5bbeabb478 100644 --- a/translated/tech/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md +++ b/translated/tech/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md @@ -1,44 +1,41 @@ -Vrms 助你在 Debian 中查找非自由软件 +vrms 助你在 Debian 中查找非自由软件 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/04/vrms-1-720x340.png) -有一天,我在阅读一篇有趣的指南,它解释了[**在数字海洋中的自由和开源软件之间的区别**][1]。在此之前,我认为两者都差不多。但是,我错了。它们之间有一些显著差异。在阅读那篇文章时,我想知道如何在 Linux 中找到非自由软件,因此有了这篇文章。 + +有一天,我在 Digital ocean 上读到一篇有趣的指南,它解释了[自由和开源软件之间的区别][1]。在此之前,我认为两者都差不多。但是,我错了。它们之间有一些显著差异。在阅读那篇文章时,我想知道如何在 Linux 中找到非自由软件,因此有了这篇文章。 ### 向 “Virtual Richard M. Stallman” 问好,这是一个在 Debian 中查找非自由软件的 Perl 脚本 -**Virtual Richard M. Stallman** ,简称 **vrms**,是一个用 Perl 编写的程序,它在你基于 Debian 的系统上分析已安装软件的列表,并报告所有来自非自由和 contrib 树的已安装软件包。对于那些疑惑的人,免费软件应该符合以下[**四项基本自由**][2]。 +**Virtual Richard M. Stallman** ,简称 **vrms**,是一个用 Perl 编写的程序,它在你基于 Debian 的系统上分析已安装软件的列表,并报告所有来自非自由和 contrib 树的已安装软件包。对于那些不太清楚区别的人,自由软件应该符合以下[**四项基本自由**][2]。 * **自由 0** – 不管任何目的,随意运行程序的自由。 - * **自由 1** – 自由研究程序如何工作,并根据你的需求进行调整。访问源代码是一个先决条件。 - * **自由 2** – 自由重新分发拷贝,这样你可以帮助别人。 - * **自由 3** – 自由改进程序,并向公众发布改进,以便整个社区获益。访问源代码是一个先决条件。 + * **自由 1** – 研究程序如何工作的自由,并根据你的需求进行调整。访问源代码是一个先决条件。 + * **自由 2** – 重新分发副本的自由,这样你可以帮助别人。 + * **自由 3** – 改进程序,并向公众发布改进的自由,以便整个社区获益。访问源代码是一个先决条件。 - - -任何不满足上述四个条件的软件都不被视为自由软件。简而言之,**自由软件意味着用户可以自由运行、拷贝、分发、研究、修改和改进软件。** +任何不满足上述四个条件的软件都不被视为自由软件。简而言之,**自由软件意味着用户有运行、复制、分发、研究、修改和改进软件的自由。** 现在让我们来看看安装的软件是自由的还是非自由的,好么? -Vrms 包存在于 Debian 及其衍生版(如 Ubuntu)的默认仓库中。因此,你可以使用 apt 包管理器安装它,使用下面的命令。 +vrms 包存在于 Debian 及其衍生版(如 Ubuntu)的默认仓库中。因此,你可以使用 `apt` 包管理器安装它,使用下面的命令。 + ``` $ sudo apt-get install vrms - ``` 安装完成后,运行以下命令,在基于 debian 的系统中查找非自由软件。 + ``` $ vrms - ``` 在我的 Ubuntu 16.04 LTS 桌面版上输出的示例。 + ``` - Non-free packages installed on ostechnix - + Non-free packages installed on ostechnix unrar Unarchiver for .rar files (non-free version) - 1 non-free packages, 0.0% of 2103 installed packages. - ``` ![][4] @@ -46,33 +43,30 @@ unrar Unarchiver for .rar files (non-free version) 如你在上面的截图中看到的那样,我的 Ubuntu 中安装了一个非自由软件包。 如果你的系统中没有任何非自由软件包,则应该看到以下输出。 + ``` No non-free or contrib packages installed on ostechnix! rms would be proud. - ``` -Vrms 不仅可以在 Debian 上找到非自由软件包,还可以在 Ubuntu、Linux Mint 和其他基于 deb 的系统中找到非自由软件包。 +vrms 不仅可以在 Debian 上找到非自由软件包,还可以在 Ubuntu、Linux Mint 和其他基于 deb 的系统中找到非自由软件包。 **限制** -Vrms 虽然有一些限制。就像我已经提到的那样,它列出了安装的非自由和 contrib 部分的软件包。但是,某些发行版并未遵循确保专有软件仅在 vrm 识别为“非自由”的仓库中存在,并且它们不努力维护分离。在这种情况下,Vrms 将不会识别非自由软件,并且始终会报告你的系统上安装了非自由软件。如果你使用的是像 Debian 和 Ubuntu 这样的发行版,遵循将专有软件保留在非自由仓库的策略,Vrms 一定会帮助你找到非自由软件包。 +vrms 虽然有一些限制。就像我已经提到的那样,它列出了安装的非自由和 contrib 部分的软件包。但是,某些发行版并未遵循确保专有软件仅在 vrms 识别为“非自由”的仓库中存在,并且它们不努力维护这种分离。在这种情况下,vrms 将不能识别非自由软件,并且始终会报告你的系统上安装了非自由软件。如果你使用的是像 Debian 和 Ubuntu 这样的发行版,遵循将专有软件保留在非自由仓库的策略,vrms 一定会帮助你找到非自由软件包。 就是这些。希望它是有用的。还有更好的东西。敬请关注! -祝世上所有的泰米尔人在泰米尔新年快乐! - 干杯! - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/the-vrms-program-helps-you-to-find-non-free-software-in-debian/ 作者:[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 e5674ddc7c453405c7a1409c0cc91df125751d52 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 4 May 2018 20:07:53 +0800 Subject: [PATCH 0770/1057] PUB:20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md @geekpi --- ... Vrms Program Helps You To Find Non-free Software In Debian.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md (100%) diff --git a/translated/tech/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md b/published/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md similarity index 100% rename from translated/tech/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md rename to published/20180414 The Vrms Program Helps You To Find Non-free Software In Debian.md From b21dc1c897b44bd764599731daccde45adf5b27c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 4 May 2018 20:29:52 +0800 Subject: [PATCH 0771/1057] PRF:20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md @geekpi --- ...th PGP - Part 3- Generating PGP Subkeys.md | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/translated/tech/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md b/translated/tech/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md index cd9c2c237d..35086cd037 100644 --- a/translated/tech/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md +++ b/translated/tech/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md @@ -1,43 +1,43 @@ -使用 PGP 保护代码完整性 - 第 3 部分:生成 PGP 子密钥 +使用 PGP 保护代码完整性(三):生成 PGP 子密钥 ====== + +> 在第三篇文章中,我们将解释如何生成用于日常工作的 PGP 子密钥。 + ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/binary.jpg?itok=h62HujOC) -在本系列教程中,我们提供了使用 PGP 的实用指南。在此之前,我们介绍了[基本工具和概念][1],并介绍了如何[生成并保护您的主 PGP 密钥][2]。在第三篇文章中,我们将解释如何生成 PGP 子密钥,以及它们在日常工作中使用。 +在本系列教程中,我们提供了使用 PGP 的实用指南。在此之前,我们介绍了[基本工具和概念][1],并介绍了如何[生成并保护您的主 PGP 密钥][2]。在第三篇文章中,我们将解释如何生成用于日常工作的 PGP 子密钥。 ### 清单 1. 生成 2048 位加密子密钥(必要) -   2. 生成 2048 位签名子密钥(必要) - -  3. 生成一个 2048 位验证子密钥(可选) - +  3. 生成一个 2048 位验证子密钥(推荐)   4. 将你的公钥上传到 PGP 密钥服务器(必要) -   5. 设置一个刷新的定时任务(必要) +### 注意事项 +现在我们已经创建了主密钥,让我们创建用于日常工作的密钥。我们创建 2048 位的密钥是因为很多专用硬件(我们稍后会讨论这个)不能处理更长的密钥,但同样也是出于实用的原因。如果我们发现自己处于一个 2048 位 RSA 密钥也不够好的世界,那将是由于计算或数学有了基本突破,因此更长的 4096 位密钥不会产生太大的差别。 -#### 注意事项 - -现在我们已经创建了主密钥,让我们创建用于日常工作的密钥。我们创建了 2048 位密钥,因为很多专用硬件(我们稍后会讨论这个)不能处理更长的密钥,但同样也是出于实用的原因。如果我们发现自己处于一个 2048 位 RSA 密钥也不够好的世界,那将是由于计算或数学的基本突破,因此更长的 4096 位密钥不会产生太大的差别。 - -##### 创建子密钥 +### 创建子密钥 要创建子密钥,请运行: + ``` $ gpg --quick-add-key [fpr] rsa2048 encr $ gpg --quick-add-key [fpr] rsa2048 sign - ``` -你也可以创建验证密钥,这能让你使用你的 PGP 密钥来使用 ssh: +用你密钥的完整指纹替换 `[fpr]`。 + +你也可以创建验证密钥,这能让你将你的 PGP 密钥用于 ssh: + ``` $ gpg --quick-add-key [fpr] rsa2048 auth - ``` -你可以使用 gpg --list-key [fpr] 来查看你的密钥信息: +你可以使用 `gpg --list-key [fpr]` 来查看你的密钥信息: + ``` pub rsa4096 2017-12-06 [C] [expires: 2019-12-06] 111122223333444455556666AAAABBBBCCCCDDDD @@ -45,55 +45,57 @@ uid [ultimate] Alice Engineer uid [ultimate] Alice Engineer sub rsa2048 2017-12-06 [E] sub rsa2048 2017-12-06 [S] - ``` -##### 上传你的公钥到密钥服务器 +### 上传你的公钥到密钥服务器 你的密钥创建已完成,因此现在需要你将其上传到一个公共密钥服务器,使其他人能更容易找到密钥。 (如果你不打算实际使用你创建的密钥,请跳过这一步,因为这只会在密钥服务器上留下垃圾数据。) + ``` $ gpg --send-key [fpr] - ``` 如果此命令不成功,你可以尝试指定一台密钥服务器以及端口,这很有可能成功: + ``` $ gpg --keyserver hkp://pgp.mit.edu:80 --send-key [fpr] - ``` 大多数密钥服务器彼此进行通信,因此你的密钥信息最终将与所有其他密钥信息同步。 -**关于隐私的注意事项:**密钥服务器是完全公开的,因此在设计上会泄露有关你的潜在敏感信息,例如你的全名、昵称以及个人或工作邮箱地址。如果你签名了其他人的钥匙或某人签名你的钥匙,那么密钥服务器还会成为你的社交网络的泄密者。一旦这些个人信息发送给密钥服务器,就不可能编辑或删除。即使你撤销签名或身份,它也不会将你的密钥记录删除,它只会将其标记为已撤消 - 这甚至会显得更突出。 +**关于隐私的注意事项:**密钥服务器是完全公开的,因此在设计上会泄露有关你的潜在敏感信息,例如你的全名、昵称以及个人或工作邮箱地址。如果你签名了其他人的钥匙或某人签名了你的钥匙,那么密钥服务器还会成为你的社交网络的泄密者。一旦这些个人信息发送给密钥服务器,就不可能被编辑或删除。即使你撤销签名或身份,它也不会将你的密钥记录删除,它只会将其标记为已撤消 —— 这甚至会显得更显眼。 也就是说,如果你参与公共项目的软件开发,以上所有信息都是公开记录,因此通过密钥服务器另外让这些信息可见,不会导致隐私的净损失。 -###### 上传你的公钥到 GitHub +### 上传你的公钥到 GitHub 如果你在开发中使用 GitHub(谁不是呢?),则应按照他们提供的说明上传密钥: +- [添加 PGP 密钥到你的 GitHub 账户](https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account/) + 要生成适合粘贴的公钥输出,只需运行: + ``` $ gpg --export --armor [fpr] - ``` -##### 设置一个刷新定时任务 +### 设置一个刷新定时任务 + +你需要定期刷新你的钥匙环,以获取其他人公钥的最新更改。你可以设置一个定时任务来做到这一点: -你需要定期刷新你的 keyring,以获取其他人公钥的最新更改。你可以设置一个定时任务来做到这一点: ``` $ crontab -e - ``` 在新行中添加以下内容: + ``` @daily /usr/bin/gpg2 --refresh >/dev/null 2>&1 - ``` -**注意:**检查你的 gpg 或 gpg2 命令的完整路径,如果你的 gpg 是旧式的 GnuPG v.1,请使用 gpg2。 +**注意:**检查你的 `gpg` 或 `gpg2` 命令的完整路径,如果你的 `gpg` 是旧式的 GnuPG v.1,请使用 gpg2。 +通过 Linux 基金会和 edX 的免费“[Introduction to Linux](https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux)” 课程了解关于 Linux 的更多信息。 -------------------------------------------------------------------------------- @@ -101,10 +103,10 @@ via: https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-p 作者:[Konstantin Ryabitsev][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/) 荣誉推出 [a]:https://www.linux.com/users/mricon -[1]:https://www.linux.com/blog/learn/2018/2/protecting-code-integrity-pgp-part-1-basic-pgp-concepts-and-tools -[2]:https://www.linux.com/blog/learn/pgp/2018/2/protecting-code-integrity-pgp-part-2-generating-and-protecting-your-master-pgp-key +[1]:https://linux.cn/article-9524-1.html +[2]:https://linux.cn/article-9529-1.html \ No newline at end of file From 356fb3e8c11951fc2efbf0e51d813eb71e923e2d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 4 May 2018 20:30:26 +0800 Subject: [PATCH 0772/1057] PUB:20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md @geekpi --- ...ng Code Integrity with PGP - Part 3- Generating PGP Subkeys.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md (100%) diff --git a/translated/tech/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md b/published/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md similarity index 100% rename from translated/tech/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md rename to published/20180228 Protecting Code Integrity with PGP - Part 3- Generating PGP Subkeys.md From f83655379923bde59c3d65e95b3f6a7b825903b2 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Sat, 5 May 2018 09:35:14 +0800 Subject: [PATCH 0773/1057] Update 20170925 Advanced image viewing tricks with ImageMagick.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 申请翻译。 --- .../20170925 Advanced image viewing tricks with ImageMagick.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md b/sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md index 7aabd73564..1adc133ef9 100644 --- a/sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md +++ b/sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md @@ -1,3 +1,5 @@ +FSSlc translating + Advanced image viewing tricks with ImageMagick ====== From 99a1015a3efdf4fca49c36f304ee49222abefd53 Mon Sep 17 00:00:00 2001 From: FSSlc Date: Sat, 5 May 2018 13:18:46 +0800 Subject: [PATCH 0774/1057] [Translated] 20170925 Advanced image viewing tricks with ImageMagick.md --- ...d image viewing tricks with ImageMagick.md | 115 ------------------ ...d image viewing tricks with ImageMagick.md | 108 ++++++++++++++++ 2 files changed, 108 insertions(+), 115 deletions(-) delete mode 100644 sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md create mode 100644 translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md diff --git a/sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md b/sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md deleted file mode 100644 index 1adc133ef9..0000000000 --- a/sources/tech/20170925 Advanced image viewing tricks with ImageMagick.md +++ /dev/null @@ -1,115 +0,0 @@ -FSSlc translating - -Advanced image viewing tricks with ImageMagick -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-photo-camera-green.png?itok=qiDqmXV1) - -In my [introduction to ImageMagick][1], I showed how to use the application's menus to edit and add effects to your images. In this follow-up, I'll show additional ways to use this open source image editor to view your images. - -### Another effect - -Before diving into advanced image viewing with ImageMagick, I want to share another interesting, yet simple, effect using the **convert** command, which I discussed in detail in my previous article. This involves the - **-edge** option, then **negate** : -``` -convert DSC_0027.JPG -edge 3 -negate edge3+negate.jpg -``` - -![Using the edge and negate options on an image.][3] - - -Before and after example of using the edge and negate options on an image. - -There are a number of things I like about the edited image--the appearance of the sea, the background and foreground vegetation, but especially the sun and its reflection, and also the sky. - -### Using display to view a series of images - -If you're a command-line user like I am, you know that the shell provides a lot of flexibility and shortcuts for complex tasks. Here I'll show one example: the way ImageMagick's **display** command can overcome a problem I've had reviewing images I import with the [Shotwell][4] image manager for the GNOME desktop. - -Shotwell creates a nice directory structure that uses each image's [Exif][5] data to store imported images based on the date they were taken or created. You end up with a top directory for the year, subdirectories for each month (01, 02, 03, and so on), followed by another level of subdirectories for each day of the month. I like this structure, because finding an image or set of images based on when they were taken is easy. - -This structure is not so great, however, when I want to review all my images for the last several months or even the whole year. With a typical image viewer, this involves a lot of jumping up and down the directory structure, but ImageMagick's **display** command makes it simple. For example, imagine that I want to look at all my pictures for this year. If I enter **display** on the command line like this: -``` -display -resize 35 % 2017 /*/*/*.JPG -``` - -I can march through the year, month by month, day by day. - -Now imagine I'm looking for an image, but I can't remember whether I took it in the first half of 2016 or the first half of 2017. This command: -``` -display -resize 35% 201[6-7]/0[1-6]/*/*.JPG -``` - -restricts the images shown to January through June of 2016 and 2017. - -### Using montage to view thumbnails of images - -Now say I'm looking for an image that I want to edit. One problem is that **display** shows each image's filename, but not its place in the directory structure, so it's not obvious where I can find that image. Also, when I (sporadically) download images from my camera, I clear them from the camera's storage, so the filenames restart at **DSC_0001.jpg** at unpredictable times. Finally, it can take a lot of time to go through 12 months of images when I use **display** to show an entire year. - -This is where the **montage** command, which puts thumbnail versions of a series of images into a single image, can be very useful. For example: -``` -montage -label %d/%f -title 2017 -tile 5x -resize 10% -geometry +4+4 2017/0[1-4]/*/*.JPG 2017JanApr.jpg -``` - -From left to right, this command starts by specifying a label for each image that consists of the filename ( **%f** ) and its directory ( **%d** ) structure, separated with **/**. Next, the command specifies the main directory as the title, then instructs the montage to tile the images in five columns, with each image resized to 10% (which fits my monitor's screen easily). The geometry setting puts whitespace around each image. Finally, it specifies which images to include in the montage, and an appropriate filename to save the montage ( **2017JanApr.jpg** ). So now the image **2017JanApr.jpg** becomes a reference I can use over and over when I want to view all my images from this time period. - -### Managing memory - -You might wonder why I specified just a four-month period (January to April) for this montage. Here is where you need to be a bit careful, because **montage** can consume a lot of memory. My camera creates image files that are about 2.5MB each, and I have found that my system's memory can pretty easily handle 60 images or so. When I get to around 80, my computer freezes when other programs, such as Firefox and Thunderbird, are running the background. This seems to relate to memory usage, which goes up to 80% or more of available RAM for **montage**. (You can check this by running **top** while you do this procedure.) If I shut down all other programs, I can manage 80 images before my system freezes. - -Here's how you can get some sense of how many files you're dealing with before running the **montage** command: -``` -ls 2017/0[1-4/*/*.JPG > filelist; wc -l filelist -``` - -The command **ls** generates a list of the files in our search and saves it to the arbitrarily named filelist. Then, the **wc** command with the **-l** option reports how many lines are in the file, in other words, how many files **ls** found. Here's my output: -``` -163 filelist -``` - -Oops! There are 163 images taken from January through April, and creating a montage of all of them would almost certainly freeze up my system. I need to trim down the list a bit, maybe just to March or even earlier. But what if I took a lot of pictures from April 20 to 30, and I think that's a big part of my problem. Here's how the shell can help us figure this out: -``` -ls 2017/0[1-3]/*/*.JPG > filelist; ls 2017/04/0[1-9]/*.JPG >> filelist; ls 2017/04/1[0-9]/*.JPG >> filelist; wc -l filelist -``` - -This is a series of four commands all on one line, separated by semicolons. The first command specifies the number of images taken from January to March; the second adds April 1 through 9 using the **> >** append operator; the third appends April 10 through 19. The fourth command, **wc -l** , reports: -``` -81 filelist -``` - -I know 81 files should be doable if I shut down my other applications. - -Managing this with the **montage** command is easy, since we're just transposing what we did above: -``` -montage -label %d/%f -title 2017 -tile 5x -resize 10% -geometry +4+4 2017/0[1-3]/*/*.JPG 2017/04/0[1-9]/*.JPG 2017/04/1[0-9]/*.JPG 2017Jan01Apr19.jpg -``` - -The last filename in the **montage** command will be the output; everything before that is input and is read from left to right. This took just under three minutes to run and resulted in an image about 2.5MB in size, but my system was sluggish for a bit afterward. - -### Displaying the montage - -When you first view a large montage using the **display** command, you may see that the montage's width is OK, but the image is squished vertically to fit the screen. Don't worry; just left-click the image and select **View > Original Size**. Click again to hide the menu. - -I hope this has been helpful in showing you new ways to view your images. In my next article, I'll discuss more complex image manipulation. - - -### About The Author -Greg Pittman;Greg Is A Retired Neurologist In Louisville;Kentucky;With A Long-Standing Interest In Computers;Programming;Beginning With Fortran Iv In The When Linux;Open Source Software Came Along;It Kindled A Commitment To Learning More;Eventually Contributing. He Is A Member Of The Scribus Team. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/9/imagemagick-viewing-images - -作者:[Greg Pittman][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/greg-p -[1]:https://opensource.com/article/17/8/imagemagick -[2]:/file/370946 -[3]:https://opensource.com/sites/default/files/u128651/edge3negate.jpg (Using the edge and negate options on an image.) -[4]:https://wiki.gnome.org/Apps/Shotwell -[5]:https://en.wikipedia.org/wiki/Exif diff --git a/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md b/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md new file mode 100644 index 0000000000..7d7300979e --- /dev/null +++ b/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md @@ -0,0 +1,108 @@ +ImageMagick 的一些高级图片查看技巧 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-photo-camera-green.png?itok=qiDqmXV1) +图片源于 [Internet Archive Book Images](https://www.flickr.com/photos/internetarchivebookimages/14759826206/in/photolist-ougY7b-owgz5y-otZ9UN-waBxfL-oeEpEf-xgRirT-oeMHfj-wPAvMd-ovZgsb-xhpXhp-x3QSRZ-oeJmKC-ovWeKt-waaNUJ-oeHPN7-wwMsfP-oeJGTK-ovZPKv-waJnTV-xDkxoc-owjyCW-oeRqJh-oew25u-oeFTm4-wLchfu-xtjJFN-oxYznR-oewBRV-owdP7k-owhW3X-oxXxRg-oevDEY-oeFjP1-w7ZB6f-x5ytS8-ow9C7j-xc6zgV-oeCpG1-oewNzY-w896SB-wwE3yA-wGNvCL-owavts-oevodT-xu9Lcr-oxZqZg-x5y4XV-w89d3n-x8h6fi-owbfiq),Opensource.com 修改,[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)协议 + +在我先前的[ImageMagick 入门:使用命令行来编辑图片](https://linux.cn/article-8851-1.html) 文章中,我展示了如何使用 ImageMagick 的菜单栏进行图片的编辑和变换风格。在这篇续文里,我将向你展示使用这个开源的图像编辑器来查看图片的额外方法。 + +### 别样的风格 + +在深入 ImageMagick 的高级图片查看技巧之前,我想先分享另一个使用 **convert** 达到的有趣但简单的效果,在上一篇文章中我已经详细地介绍了 **convert** 命令,这个技巧涉及这个命令的 `edge` 和 `negate` 选项: +``` +convert DSC_0027.JPG -edge 3 -negate edge3+negate.jpg +``` + +![在图片上使用 `edge` 和 `negate` 选项][3] +使用`edge` 和 `negate` 选项前后的图片对比 + +编辑后的图片让我更加喜爱,具体是因为如下因素:海的外观,作为前景和背景的植被,特别是太阳及其在海上的反射,最后是天空。 + +### 使用 `display` 来查看一系列图片 + +假如你跟我一样是个命令行用户,你就知道 shell 为复杂任务提供了更多的灵活性和快捷方法。下面我将展示一个例子来佐证这个观点。ImageMagick 的 **display** 命令可以克服我在 GNOME 桌面上使用 [Shotwell][4] 图像管理器导入图片时遇到的问题。 + +Shotwell 会根据每张导入图片的 [Exif][5] 数据,创建以图片被生成或者拍摄时的日期为名称的目录结构。最终的效果是最上层的目录以年命名,接着的子目录是以月命名 (01, 02, 03 等等),然后是以每月的日期命名的子目录。我喜欢这种结构,因为当我想根据图片被创建或者拍摄时的日期来查找它们时将会非常方便。 + +但这种结构也并不是非常完美的,当我想查看最近几个月或者最近一年的所有图片时就会很麻烦。使用常规的图片查看器,我将不停地在不同层级的目录间跳转,但 ImageMagick 的 **display** 命令可以使得查看更加简单。例如,假如我想查看最近一年的图片,我便可以在命令行中键入下面的 **display** 命令: +``` +display -resize 35% 2017/*/*/*.JPG +``` + +我可以匹配一年中的每一月和每一天。 + +现在假如我想查看某张图片,但我不确定我是在 2016 年的上半年还是在 2017 的上半年拍摄的,那么我便可以使用下面的命令来找到它: +``` +display -resize 35% 201[6-7]/0[1-6]/*/*.JPG +``` +限制查看的图片拍摄于 2016 和 2017 年的一月到六月 + +### 使用 `montage` 来查看图片的缩略图 + +假如现在我要查找一张我想要编辑的图片,使用 **display** 的一个问题是它只会显示每张图片的文件名,而不显示其在目录结构中的位置,所以想要找到那张图片并不容易。另外,假如我很偶然地在从相机下载图片的过程中将这些图片从相机的内存里面清除了它们,结果使得下次拍摄照片的名称又从 **DSC_0001.jpg** 开始命名,那么当使用 **display** 来展示一整年的图片时,将会在这 12 个月的图片中花费很长的时间来查找它们。 + +这时 **montage** 命令便可以派上用场了。它可以将一系列的图片放在一张图片中,这样就会非常有用。例如可以使用下面的命令来完成上面的任务: +``` +montage -label %d/%f -title 2017 -tile 5x -resize 10% -geometry +4+4 2017/0[1-4]/*/*.JPG 2017JanApr.jpg +``` + +从左到右,这个命令以标签开头,标签的形式是包含文件名( **%f** )和以 **/** 分割的目录( **%d** )结构,接着这个命令以目录的名称(2017)来作为标题,然后将图片排成 5 列,每个图片缩放为 10% (这个参数可以很好地匹配我的屏幕)。`geometry` 的设定将在每张图片的四周留白,最后在接上要处理的对象和一个合适的名称( **2017JanApr.jpg** )。现在图片 **2017JanApr.jpg** 便可以成为一个索引,使得我可以不时地使用它来查看这个时期的所有图片。 + +### 注意内存消耗 + +你可能会好奇为什么我在上面的合成图中只特别指定了为期 4 个月(从一月到四月)的图片。因为 **montage** 将会消耗大量内存,所以你需要多加注意。我的相机产生的图片每张大约有 2.5MB,我发现我的系统可以很轻松地处理 60 张图片。但一旦图片增加到 80 张,如果此时还有另外的程序(例如 Firefox 、Thunderbird)在后台工作,那么我的电脑将会死机,这似乎和内存使用相关,**montage**可能会占用可用 RAM 的 80% 乃至更多(你可以在此期间运行 **top** 命令来查看内存占用)。假如我关掉其他的程序,我便可以在我的系统死机前处理 80 张图片。 + +下面的命令可以让你知晓在你运行 **montage** 命令前你需要处理图片张数: +``` +ls 2017/0[1-4/*/*.JPG > filelist; wc -l filelist +``` + +**ls** 命令生成我们搜索的文件的列表,然后通过重定向将这个列表保存在任意以 filelist 为名称的文件中。接着带有 **-l** 选项的 **wc** 命令输出该列表文件共有多少行,换句话说,展示出需要处理的文件个数。下面是我运行命令后的输出: +``` +163 filelist +``` + +啊呀!从一月到四月我居然有 163 张图片,使用这些图片来创建一张合成图一定会使得我的系统死机的。我需要将这个列表减少点,可能只处理到 3 月份或者更早的图片。但如果我在4月20号到30号期间拍摄了很多照片,我想这便是问题的所在。下面的命令便可以帮助指出这个问题: +``` +ls 2017/0[1-3]/*/*.JPG > filelist; ls 2017/04/0[1-9]/*.JPG >> filelist; ls 2017/04/1[0-9]/*.JPG >> filelist; wc -l filelist +``` + +上面一行中共有 4 个命令,它们以分号分隔。第一个命令特别指定从一月到三月期间拍摄的照片;第二个命令使用 **>>** 将拍摄于 4 月 1 日至 9 日的照片追加到这个列表文件中;第三个命令将拍摄于 4 月 1 0 日到 19 日的照片追加到列表中。最终它的显示结果为: +``` +81 filelist +``` + +我知道假如我关掉其他的程序,处理 81 张图片是可行的。 + +使用 **montage** 来处理它们是很简单的,因为我们只需要将上面所做的处理添加到 **montage** 命令的后面即可: +``` +montage -label %d/%f -title 2017 -tile 5x -resize 10% -geometry +4+4 2017/0[1-3]/*/*.JPG 2017/04/0[1-9]/*.JPG 2017/04/1[0-9]/*.JPG 2017Jan01Apr19.jpg +``` + +从左到右,**montage** 命令后面最后的那个文件名将会作为输出,在它之前的都是输入。这个命令将花费大约 3 分钟来运行,并生成一张大小约为 2.5MB 的图片,但我的系统只是有一点反应迟钝而已。 + +### 展示合成图片 + +当你第一次使用 **display** 查看一张巨大的合成图片时,你将看到合成图的宽度很合适,但图片的高度被压缩了,以便和屏幕相适应。不要慌,只需要左击图片,然后选择 **View > Original Size** 便会显示整个图片。再次点击图片便可以使菜单栏隐藏。 + +我希望这篇文章可以在你使用新方法查看图片时帮助你。在我的下一篇文章中,我将讨论更加复杂的图片操作技巧。 + +### 作者简介 +Greg Pittman - Greg 肯塔基州路易斯维尔的一名退休的神经科医生,对计算机和程序设计有着长期的兴趣,最早可以追溯到 1960 年代的 Fortran IV 。当 Linux 和开源软件相继出现时,他开始学习更多的相关知识,并分享自己的心得。他是 Scribus 团队的成员。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/9/imagemagick-viewing-images + +作者:[Greg Pittman][a] +译者:[FSSlc](https://github.com/FSSlc) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/greg-p +[1]:https://opensource.com/article/17/8/imagemagick +[2]:/file/370946 +[3]:https://opensource.com/sites/default/files/u128651/edge3negate.jpg "Using the edge and negate options on an image." +[4]:https://wiki.gnome.org/Apps/Shotwell +[5]:https://en.wikipedia.org/wiki/Exif From 1345a1146107edc06cb740d93f15faf6ae299dee Mon Sep 17 00:00:00 2001 From: FSSlc Date: Sat, 5 May 2018 14:53:39 +0800 Subject: [PATCH 0775/1057] PRF 20140410 Recursion- dream within a dream.md --- ...0140410 Recursion- dream within a dream.md | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/translated/tech/20140410 Recursion- dream within a dream.md b/translated/tech/20140410 Recursion- dream within a dream.md index 3becf75ebd..d283bed402 100644 --- a/translated/tech/20140410 Recursion- dream within a dream.md +++ b/translated/tech/20140410 Recursion- dream within a dream.md @@ -1,47 +1,48 @@ -#[递归:梦中梦][1] -递归是很神奇的,但是在大多数的编程类书藉中对递归讲解的并不好。它们只是给你展示一个递归阶乘的实现,然后警告你递归运行的很慢,并且还有可能因为栈缓冲区溢出而崩溃。“你可以将头伸进微波炉中去烘干你的头发,但是需要警惕颅内高压以及让你的头发生爆炸,或者你可以使用毛巾来擦干头发。”这就是人们不愿意使用递归的原因。这是很糟糕的,因为在算法中,递归是最强大的。 +[递归:梦中梦][1] +====== + +**递归**是很神奇的,但是在大多数的编程类书藉中对递归讲解的并不好。它们只是给你展示一个递归阶乘的实现,然后警告你递归运行的很慢,并且还有可能因为栈缓冲区溢出而崩溃。“你可以将头伸进微波炉中去烘干你的头发,但是需要警惕颅内高压以及让你的头发生爆炸,或者你可以使用毛巾来擦干头发。”难怪人们不愿意使用递归。但这种建议是很糟糕的,因为在算法中,递归是一个非常强大的观点。 我们来看一下这个经典的递归阶乘: 递归阶乘 - factorial.c - ``` #include int factorial(int n) { - int previous = 0xdeadbeef; - - if (n == 0 || n == 1) { - return 1; - } + int previous = 0xdeadbeef; + + if (n == 0 || n == 1) { + return 1; + } - previous = factorial(n-1); - return n * previous; + previous = factorial(n-1); + return n * previous; } int main(int argc) { - int answer = factorial(5); - printf("%d\n", answer); + int answer = factorial(5); + printf("%d\n", answer); } ``` -函数的目的是调用它自己,这在一开始是让人很难理解的。为了解具体的内容,当调用 `factorial(5)` 并且达到 `n == 1` 时,[在栈上][3] 究竟发生了什么? +函数调用自身的这个观点在一开始是让人很难理解的。为了让这个过程更形象具体,下图展示的是当调用 `factorial(5)` 并且达到 `n == 1`这行代码 时,[栈上][3] 端点的情况: ![](https://manybutfinite.com/img/stack/factorial.png) -每次调用 `factorial` 都生成一个新的 [栈帧][4]。这些栈帧的创建和 [销毁][5] 是递归慢于迭代的原因。在调用返回之前,累积的这些栈帧可能会耗尽栈空间,进而使你的程序崩溃。 +每次调用 `factorial` 都生成一个新的 [栈帧][4]。这些栈帧的创建和 [销毁][5] 是使得递归版本的阶乘慢于其相应的迭代版本的原因。在调用返回之前,累积的这些栈帧可能会耗尽栈空间,进而使你的程序崩溃。 -而这些担心经常是存在于理论上的。例如,对于每个 `factorial` 的栈帧取 16 字节(这可能取决于栈排列以及其它因素)。如果在你的电脑上运行着现代的 x86 的 Linux 内核,一般情况下你拥有 8 GB 的栈空间,因此,`factorial` 最多可以被运行 ~512,000 次。这是一个 [巨大无比的结果][6],它相当于 8,971,833 比特,因此,栈空间根本就不是什么问题:一个极小的整数 - 甚至是一个 64 位的整数 - 在我们的栈空间被耗尽之前就早已经溢出了成千上万次了。 +而这些担心经常是存在于理论上的。例如,对于每个 `factorial` 的栈帧占用 16 字节(这可能取决于栈排列以及其它因素)。如果在你的电脑上运行着现代的 x86 的 Linux 内核,一般情况下你拥有 8 GB 的栈空间,因此,`factorial` 程序中的 `n` 最多可以达到 512,000 左右。这是一个 [巨大无比的结果][6],它将花费 8,971,833 比特来表示这个结果,因此,栈空间根本就不是什么问题:一个极小的整数 - 甚至是一个 64 位的整数 - 在我们的栈空间被耗尽之前就早已经溢出了成千上万次了。 -过一会儿我们再去看 CPU 的使用,现在,我们先从比特和字节回退一步,把递归看作一种通用技术。我们的阶乘算法总结为将整数 N、N-1、 … 1 推入到一个栈,然后将它们按相反的顺序相乘。实际上我们使用了程序调用栈来实现这一点,这是它的细节:我们在堆上分配一个栈并使用它。虽然调用栈具有特殊的特性,但是,你只是把它用作一种另外的数据结构。我希望示意图可以让你明白这一点。 +过一会儿我们再去看 CPU 的使用,现在,我们先从比特和字节回退一步,把递归看作一种通用技术。我们的阶乘算法可归结为:将整数 N、N-1、 … 1 推入到一个栈,然后将它们按相反的顺序相乘。实际上我们使用了程序调用栈来实现这一点,这是它的细节:我们在堆上分配一个栈并使用它。虽然调用栈具有特殊的特性,但是它也只是额外的一种数据结构,你可以随意处置。我希望示意图可以让你明白这一点。 -当你看到栈调用作为一种数据结构使用,有些事情将变得更加清晰明了:将那些整数堆积起来,然后再将它们相乘,这并不是一个好的想法。那是一种有缺陷的实现:就像你拿螺丝刀去钉钉子一样。相对更合理的是使用一个迭代过程去计算阶乘。 +当你将栈调用视为一种数据结构,有些事情将变得更加清晰明了:将那些整数堆积起来,然后再将它们相乘,这并不是一个好的想法。那是一种有缺陷的实现:就像你拿螺丝刀去钉钉子一样。相对更合理的是使用一个迭代过程去计算阶乘。 但是,螺丝钉太多了,我们只能挑一个。有一个经典的面试题,在迷宫里有一只老鼠,你必须帮助这只老鼠找到一个奶酪。假设老鼠能够在迷宫中向左或者向右转弯。你该怎么去建模来解决这个问题? -就像现实生活中的很多问题一样,你可以将这个老鼠找奶酪的问题简化为一个图,一个二叉树的每个结点代表在迷宫中的一个位置。然后你可以让老鼠在任何可能的地方都左转,而当它进入一个死胡同时,再返回来右转。这是一个老鼠行走的 [迷宫示例][7]: +就像现实生活中的很多问题一样,你可以将这个老鼠找奶酪的问题简化为一个图,一个二叉树的每个结点代表在迷宫中的一个位置。然后你可以让老鼠在任何可能的地方都左转,而当它进入一个死胡同时,再回溯回去,再右转。这是一个老鼠行走的 [迷宫示例][7]: ![](https://manybutfinite.com/img/stack/mazeGraph.png) @@ -55,40 +56,40 @@ int main(int argc) int explore(maze_t *node) { - int found = 0; + int found = 0; - if (node == NULL) - { - return 0; - } - if (node->hasCheese){ - return 1;// found cheese - } + if (node == NULL) + { + return 0; + } + if (node->hasCheese){ + return 1;// found cheese + } - found = explore(node->left) || explore(node->right); - return found; - } + found = explore(node->left) || explore(node->right); + return found; + } - int main(int argc) - { - int found = explore(&maze); - } + int main(int argc) + { + int found = explore(&maze); + } ``` 当我们在 `maze.c:13` 中找到奶酪时,栈的情况如下图所示。你也可以在 [GDB 输出][8] 中看到更详细的数据,它是使用 [命令][9] 采集的数据。 ![](https://manybutfinite.com/img/stack/mazeCallStack.png) -它展示了递归的良好表现,因为这是一个适合使用递归的问题。而且这并不奇怪:当涉及到算法时,递归是一种使用较多的算法,而不是被排除在外的。当进行搜索时、当进行遍历树和其它数据结构时、当进行解析时、当需要排序时:它的用途无处不在。正如众所周知的 pi 或者 e,它们在数学中像“神”一样的存在,因为它们是宇宙万物的基础,而递归也和它们一样:只是它在计算的结构中。 +它展示了递归的良好表现,因为这是一个适合使用递归的问题。而且这并不奇怪:当涉及到算法时,递归是规则,而不是例外。它出现在如下情景中:当进行搜索时、当进行遍历树和其它数据结构时、当进行解析时、当需要排序时:它无处不在。正如众所周知的 pi 或者 e,它们在数学中像“神”一样的存在,因为它们是宇宙万物的基础,而递归也和它们一样:只是它在计算的结构中。 -Steven Skienna 的优秀著作 [算法设计指南][10] 的精彩之处在于,他通过“战争故事” 作为手段来诠释工作,以此来展示解决现实世界中的问题背后的算法。这是我所知道的拓展你的算法知识的最佳资源。另一个较好的做法是,去读 McCarthy 的 [LISP 上的原创论文][11]。递归在语言中既是它的名字也是它的基本原理。这篇论文既可读又有趣,在工作中能看到大师的作品是件让人兴奋的事情。 +Steven Skienna 的优秀著作 [算法设计指南][10] 的精彩之处在于,他通过“战争故事” 作为手段来诠释工作,以此来展示解决现实世界中的问题背后的算法。这是我所知道的拓展你的算法知识的最佳资源。另一个读物是 McCarthy 的 [关于 LISP 实现的的原创论文][11]。递归在语言中既是它的名字也是它的基本原理。这篇论文既可读又有趣,在工作中能看到大师的作品是件让人兴奋的事情。 -回到迷宫问题上。虽然它在这里很难离开递归,但是并不意味着必须通过调用栈的方式来实现。你可以使用像 “RRLL” 这样的字符串去跟踪转向,然后,依据这个字符串去决定老鼠下一步的动作。或者你可以分配一些其它的东西来记录奶酪的状态。你仍然是去实现一个递归的过程,但是需要你实现一个自己的数据结构。 +回到迷宫问题上。虽然它在这里很难离开递归,但是并不意味着必须通过调用栈的方式来实现。你可以使用像 `RRLL` 这样的字符串去跟踪转向,然后,依据这个字符串去决定老鼠下一步的动作。或者你可以分配一些其它的东西来记录追寻奶酪的整个状态。你仍然是去实现一个递归的过程,但是需要你实现一个自己的数据结构。 那样似乎更复杂一些,因为栈调用更合适。每个栈帧记录的不仅是当前节点,也记录那个节点上的计算状态(在这个案例中,我们是否只让它走左边,或者已经尝试向右)。因此,代码已经变得不重要了。然而,有时候我们因为害怕溢出和期望中的性能而放弃这种优秀的算法。那是很愚蠢的! 正如我们所见,栈空间是非常大的,在耗尽栈空间之前往往会遇到其它的限制。一方面可以通过检查问题大小来确保它能够被安全地处理。而对 CPU 的担心是由两个广为流传的有问题的示例所导致的:哑阶乘(dumb factorial)和可怕的无记忆的 O(2n) [Fibonacci 递归][12]。它们并不是栈递归算法的正确代表。 -事实上栈操作是非常快的。通常,栈对数据的偏移是非常准确的,它在 [缓存][13] 中是热点,并且是由专门的指令来操作它。同时,使用你自己定义的堆上分配的数据结构的相关开销是很大的。经常能看到人们写的一些比栈调用递归更复杂、性能更差的实现方法。最后,现代的 CPU 的性能都是 [非常好的][14] ,并且一般 CPU 不会是性能瓶颈所在。要注意牺牲简单性与保持性能的关系。[测量][15]。 +事实上栈操作是非常快的。通常,栈对数据的偏移是非常准确的,它在 [缓存][13] 中是热点,并且是由专门的指令来操作它。同时,使用你自己定义的堆上分配的数据结构的相关开销是很大的。经常能看到人们写的一些比栈调用递归更复杂、性能更差的实现方法。最后,现代的 CPU 的性能都是 [非常好的][14] ,并且一般 CPU 不会是性能瓶颈所在。在考虑牺牲程序的简单性时要特别注意,就像经常考虑程序的性能及性能的[测量][15]那样。 下一篇文章将是探秘栈系列的最后一篇了,我们将了解尾调用、闭包、以及其它相关概念。然后,我们就该深入我们的老朋友—— Linux 内核了。感谢你的阅读! @@ -100,7 +101,7 @@ via:https://manybutfinite.com/post/recursion/ 作者:[Gustavo Duarte][a] 译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) +校对:[FSSlc](https://github.com/FSSlc) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 242e390dc3cd10d74f47a1d52e24322a22be04c3 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 5 May 2018 22:26:31 +0800 Subject: [PATCH 0776/1057] Update 20180413 Useful Resources for Those Who Want to Know More About Linux.md --- ...ul Resources for Those Who Want to Know More About Linux.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md b/sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md index c711c347d8..3ef2c91b6f 100644 --- a/sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md +++ b/sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + Useful Resources for Those Who Want to Know More About Linux ====== From 57a4f6e054b51266830b6ebf16b6db10eba2e1b9 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 6 May 2018 10:33:32 +0800 Subject: [PATCH 0777/1057] PRF:20140107 Caffeinated 6.828- Exercise- Shell.md @geekpi --- ...0107 Caffeinated 6.828- Exercise- Shell.md | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md b/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md index 50fb5b6167..126e8c2913 100644 --- a/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md +++ b/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md @@ -3,9 +3,10 @@ Caffeinated 6.828:练习 shell 通过在 shell 中实现多项功能,该作业将使你更加熟悉 Unix 系统调用接口和 shell。你可以在支持 Unix API 的任何操作系统(一台 Linux Athena 机器、装有 Linux 或 Mac OS 的笔记本电脑等)上完成此作业。请在第一次上课前将你的 shell 提交到[网站][1]。 -如果你在练习中遇到困难或不理解某些内容时,你不要害羞给[员工邮件列表][2]发送邮件,但我们确实希望全班的人能够自行处理这级别的 C 编程。如果你对 C 不是很熟悉,可以认为这个是你对 C 熟悉程度的检查。再说一次,如果你有任何问题,鼓励你向我们寻求帮助。 +如果你在练习中遇到困难或不理解某些内容时,你不要羞于给[员工邮件列表][2]发送邮件,但我们确实希望全班的人能够自行处理这级别的 C 编程。如果你对 C 不是很熟悉,可以认为这个是你对 C 熟悉程度的检查。再说一次,如果你有任何问题,鼓励你向我们寻求帮助。 下载 xv6 shell 的[框架][3],然后查看它。框架 shell 包含两个主要部分:解析 shell 命令并实现它们。解析器只能识别简单的 shell 命令,如下所示: + ``` ls > y cat < y | sort | uniq | wc > y1 @@ -13,31 +14,30 @@ cat y1 rm y1 ls | sort | uniq | wc rm y - ``` -将这些命令剪切并粘贴到 `t.sh `中。 +将这些命令剪切并粘贴到 `t.sh` 中。 + +你可以按如下方式编译框架 shell 的代码: -你可以按如下方式编译框架 shell: ``` $ gcc sh.c - ``` 它会生成一个名为 `a.out` 的文件,你可以运行它: + ``` $ ./a.out < t.sh - ``` -执行会崩溃,因为你还没有实现几个功能。在本作业的其余部分中,你将实现这些功能。 +执行会崩溃,因为你还没有实现其中的几个功能。在本作业的其余部分中,你将实现这些功能。 ### 执行简单的命令 实现简单的命令,例如: + ``` $ ls - ``` 解析器已经为你构建了一个 `execcmd`,所以你唯一需要编写的代码是 `runcmd` 中的 case ' '。要测试你可以运行 “ls”。你可能会发现查看 `exec` 的手册页是很有用的。输入 `man 3 exec`。 @@ -47,10 +47,10 @@ $ ls ### I/O 重定向 实现 I/O 重定向命令,这样你可以运行: + ``` echo "6.828 is cool" > x.txt cat < x.txt - ``` 解析器已经识别出 '>' 和 '<',并且为你构建了一个 `redircmd`,所以你的工作就是在 `runcmd` 中为这些符号填写缺少的代码。确保你的实现在上面的测试输入中正确运行。你可能会发现 `open`(`man 2 open`) 和 `close` 的 man 手册页很有用。 @@ -60,9 +60,9 @@ cat < x.txt ### 实现管道 实现管道,这样你可以运行命令管道,例如: + ``` $ ls | sort | uniq | wc - ``` 解析器已经识别出 “|”,并且为你构建了一个 `pipecmd`,所以你必须编写的唯一代码是 `runcmd` 中的 case '|'。测试你可以运行上面的管道。你可能会发现 `pipe`、`fork`、`close` 和 `dup` 的 man 手册页很有用。 @@ -71,7 +71,6 @@ $ ls | sort | uniq | wc ``` $ ./a.out < t.sh - ``` 无论是否完成挑战任务,不要忘记将你的答案提交给[网站][1]。 @@ -80,11 +79,10 @@ $ ./a.out < t.sh 如果你想进一步尝试,可以将所选的任何功能添加到你的 shell。你可以尝试以下建议之一: - * 实现由 `;` 分隔的命令列表 -  * 通过实现 `(` 和 `)` 来实现子 shell -  * 通过支持 `&` 和 `wait` 在后台执行命令 -  * 实现参数引用 - +* 实现由 `;` 分隔的命令列表 +* 通过实现 `(` 和 `)` 来实现子 shell +* 通过支持 `&` 和 `wait` 在后台执行命令 +* 实现参数引用 所有这些都需要改变解析器和 `runcmd` 函数。 @@ -95,7 +93,7 @@ via: https://sipb.mit.edu/iap/6.828/lab/shell/ 作者:[mit][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 55fff5f1f9c8846dbde728403510ce33146d1b1e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 6 May 2018 10:33:54 +0800 Subject: [PATCH 0778/1057] PUB:20140107 Caffeinated 6.828- Exercise- Shell.md @geekpi --- .../20140107 Caffeinated 6.828- Exercise- Shell.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20140107 Caffeinated 6.828- Exercise- Shell.md (100%) diff --git a/translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md b/published/20140107 Caffeinated 6.828- Exercise- Shell.md similarity index 100% rename from translated/tech/20140107 Caffeinated 6.828- Exercise- Shell.md rename to published/20140107 Caffeinated 6.828- Exercise- Shell.md From bde1d6a7238a7eda330adbb8e1ff9f4a9a930ee2 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sun, 6 May 2018 11:08:10 +0800 Subject: [PATCH 0779/1057] Delete 20180413 Useful Resources for Those Who Want to Know More About Linux.md --- ...Those Who Want to Know More About Linux.md | 129 ------------------ 1 file changed, 129 deletions(-) delete mode 100644 sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md diff --git a/sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md b/sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md deleted file mode 100644 index 3ef2c91b6f..0000000000 --- a/sources/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md +++ /dev/null @@ -1,129 +0,0 @@ -Translating by MjSeven - - -Useful Resources for Those Who Want to Know More About Linux -====== - -Linux is one of the most popular and versatile operating systems available. It can be used on a smartphone, computer and even a car. Linux has been around since the 1990s and is still one of the most widespread operating systems. - -Linux is actually used to run most of the Internet as it is considered to be rather stable compared to other operating systems. This is one of the [reasons why people choose Linux over Windows][1]. Besides, Linux provides its users with privacy and doesn’t collect their data at all, while Windows 10 and its Cortana voice control system always require updating your personal information. - -Linux has many advantages. However, people do not hear much about it, as it has been squeezed out from the market by Windows and Mac. And many people get confused when they start using Linux, as it’s a bit different from popular operating systems. - -So to help you out we’ve collected 5 useful resources for those who want to know more about Linux. - -### 1.[Linux for Absolute Beginners][2] - -If you want to learn as much about Linux as you can, you should consider taking a full course for beginners, provided by Eduonix. This course will introduce you to all features of Linux and provide you with all necessary materials to help you find out more about the peculiarities of how Linux works. - -You should definitely choose this course if: - - * you want to learn the details about the Linux operating system; - - * you want to find out how to install it; - - * you want to understand how Linux cooperates with your hardware; - - * you want to learn how to operate Linux command line. - - - - -### 2.[PC World: A Linux Beginner’s Guide][3] - -A free resource for those who want to learn everything about Linux in one place. PC World specializes in various aspects of working with computer operating systems, and it provides its subscribers with the most accurate and up-to-date information. Here you can also learn more about the [benefits of Linux][4] and latest news about his operating system. - -This resource provides you with information on: - - * how to install Linux; - - * how to use command line; - - * how to install additional software; - - * how to operate Linux desktop environment. - - - - -### 3.[Linux Training][5] - -A lot of people who work with computers are required to learn how to operate Linux in case Windows operating system suddenly crashes. And what can be better than using an official resource to start your Linux training? - -This resource provides online enrollment on the Linux training, where you can get the most updated information from the authentic source. “A year ago our IT department offered us a Linux training on the official website”, says Martin Gibson, a developer at [Assignmenthelper.com.au][6]. “We took this course because we needed to learn how to back up all our files to another system to provide our customers with maximum security, and this resource really taught us everything.” - -So you should definitely use this resource if: - - * you want to receive firsthand information about the operating system; - - * want to learn the peculiarities of how to run Linux on your computer; - - * want to connect with other Linux users and share your experience with them. - - - - -4. [The Linux Foundation: Training Videos][7] - -If you easily get bored from reading a lot of resources, this website is definitely for you. The Linux Foundation provides training videos, lectures and webinars, held by IT specialists, software developers and technical consultants. - -All the training videos are subdivided into categories for: - - * Developers: working with Linux Kernel, handling Linux Device Drivers, Linux virtualization etc.; - - * System Administrators: developing virtual hosts on Linux, building a Firewall, analyzing Linux performance etc.; - - * Users: getting started using Linux, introduction to embedded Linux and so on. - - - - -5. [LinuxInsider][8] - -Did you know that Microsoft was so amazed by the efficiency of Linux that it [allowed users to run Linux on Microsoft cloud computing device][9]? If you want to learn more about this operating system, Linux Insider provides its subscribers with the latest news on Linux operating systems, gives information about the latest updates and Linux features. - -On this resource, you will have the opportunity to: - - * participate in Linux community; - - * learn about how to run Linux on various devices; - - * check out reviews; - - * participate in blog discussions and read the tech blog. - - - - -### Wrapping up… - -Linux offers a lot of benefits, including complete privacy, stable operation and even malware protection. It’s definitely worth trying, learning how to use will help you better understand how your computer works and what it needs to operate smoothly. - -### About the Author -_Lucy Benton is a digital marketing specialist, business consultant and helps people to turn their dreams into the profitable business. Now she is writing for marketing and business resources. Also Lucy has her own blog_ [_Prowritingpartner.com_][10] _,where you can check her last publications._ - - --------------------------------------------------------------------------------- - -via: https://linuxaria.com/article/useful-resources-for-those-who-want-to-know-more-about-linux - -作者:[Lucy Benton][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://www.lifewire.com -[1]:https://www.lifewire.com/windows-vs-linux-mint-2200609 -[2]:https://www.eduonix.com/courses/system-programming/linux-for-absolute-beginners -[3]:https://www.pcworld.com/article/2918397/operating-systems/how-to-get-started-with-linux-a-beginners-guide.html -[4]:https://www.popsci.com/switch-to-linux-operating-system#page-4 -[5]:https://www.linux.com/learn/training -[6]:https://www.assignmenthelper.com.au/ -[7]:https://training.linuxfoundation.org/free-linux-training/linux-training-videos -[8]:https://www.linuxinsider.com/ -[9]:https://www.wired.com/2016/08/linux-took-web-now-taking-world/ -[10]:https://prowritingpartner.com/ -[11]:https://cdn.linuxaria.com/wp-content/plugins/flattr/img/flattr-badge-large.png -[12]:https://linuxaria.com/?flattrss_redirect&id=8570&md5=ee76fa2b44bdf6ef419a7f9906d3a5ad (Flattr) From 5d614bf8834636d8549f7ca0057c400b678fc257 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sun, 6 May 2018 11:08:38 +0800 Subject: [PATCH 0780/1057] Create 20180413 Useful Resources for Those Who Want to Know More About Linux.md --- ...Those Who Want to Know More About Linux.md | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md diff --git a/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md b/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md new file mode 100644 index 0000000000..68db7151bf --- /dev/null +++ b/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md @@ -0,0 +1,109 @@ +有用的资源,献给那些想更多了解 Linux 的人 +===== + +Linux 是最流行和多功能的操作系统之一,它可以用在智能手机,电脑甚至汽车上。自 20 世纪 90 年代以来,Linux 一直存在,并且仍然是最普遍的操作系统之一。 + +Linux 实际上用于运行大多数网络服务,因为与其他操作系统相比,它被认为是相当稳定的。这是[人们选择 Linux 多于 Windows的原因][1]之一。此外,Linux 为用户提供了隐私,并且根本不收集用户信息,而 Windows 10 及其 Cortana 语音控制系统总是需要更新你的个人信息。 + +Linux 有很多优点。然而,人们并没有听到太多关于它的消息,因为它已被 Windows 和 Mac 挤出市场。许多人开始使用 Linux 时会感到困惑,因为它与流行的操作系统有点不同。 + +为了帮助你,我们为那些想要了解更多关于 Linux 的人收集了 5 个有用的资源。 + +### 1.[ Linux 纯新手 ][2] + +如果你想尽可能多地学习 Linux,你应该考虑 Eduonix 为初学者提供的 Linux 完整教程。这个课程将向你介绍 Linux 的所有功能,并为你提供所有必要的资料,以帮助你了解更多关于 Linux 工作原理的特性。 + +如果你是以下情况,你应该选择本课程: + +* 你想了解有关 Linux 操作系统的详细信息; +* 你想知道如何安装它; +* 你想了解 Linux 如何与硬件配合使用; +* 你想学习如何操作 Linux 命令行。 + +### 2.[PC World: Linux 初学者指南][3] + +为想要在一个地方学习所有有关 Linux 的人提供免费资源。PC World 专注于计算机操作系统的各个方面,并为订阅用户提供最准确和最新的信息。在这里,你还可以了解更多关于 [Linux 的好处][4] 和关于其操作系统的最新消息。 + +该资源为你提供以下信息: + +* 如何安装 Linux; + +* 如何使用命令行; + +* 如何安装软件; + +* 如何操作 Linux 桌面环境。 + +### 3.[Linux 培训][5] + +很多使用计算机的人都需要学习如何操作 Linux,以防 Windows 操作系统突然崩溃。还有什么比使用官方资源来启动你的 Linux 培训更好呢? + +该资源提供了 Linux 训练的在线注册,你可以从官方来源获取最新信息。“一年前,我们的 IT 部门在官方网站上为我们提供了 Linux 培训” [Assignmenthelper.com.au][6] 的开发人员 Martin Gibson 说道。“我们选择了这门课,因为我们需要学习如何将我们的所有文件备份到另一个系统,为我们的客户提供最大的安全性,而且这个资源真的教会了我们所有的东西。” + +所以你肯定应该使用这个资源,如果: + +* 你想获得有关操作系统的第一手信息; + +* 想要了解如何在你的计算机上运行 Linux 的特性; + +* 想要与其他 Linux 用户联系并与他们分享你的经验。 + +### 4. [The Linux Foundation: 视频培训][7] + +如果你在阅读大量资源时容易感到无聊,那么该网站绝对适合你。Linux Foundation 提供由 IT 专家,软件开发技术人员和技术顾问举办的视频培训,讲座和在线研讨会。 + +所有培训视频分为以下类别: + +* 开发人员: 使用 Linux Kernel 来处理 Linux 设备驱动程序,Linux 虚拟化等; + +* 系统管理员:在 Linux 上开发虚拟主机,构建防火墙,分析 Linux 性能等; + +* 用户:开始使用 Linux,介绍嵌入式 Linux 等。 + +### 5. [LinuxInsider][8] + +你知道吗?微软对 Linux 的效率感到惊讶,它[允许用户在微软云计算设备上运行 Linux][9]。如果你想了解更多关于 Linux 操作系统的知识,Linux Insider 会向用户提供关于 Linux 操作系统的最新消息,以及最新更新和 Linux 特性的信息。 + +在此资源上,你将有机会: + +* 参与 Linux 社区; + +* 了解如何在各种设备上运行 Linux; + +* 看看评论; + +* 参与博客讨论并阅读科技博客。 + +### 总结一下 + +Linux 提供了很多好处,包括完全的隐私,稳定的操作甚至恶意软件保护。它绝对值得尝试,学习如何使用会帮助你更好地了解你的计算机如何工作以及它需要如何平稳运行。 + +### 关于作者 + +Lucy Benton 是一位数字营销专家,商业顾问,帮助人们将他们的梦想变为有利润的业务。现在她正在为营销和商业资源撰写。Lucy 还有自己的博客 [_Prowritingpartner.com_][10],在那里你可以查看她最近的发表。 + + +-------------------------------------------------------------------------------- + +via: https://linuxaria.com/article/useful-resources-for-those-who-want-to-know-more-about-linux + +作者:[Lucy Benton][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.lifewire.com +[1]:https://www.lifewire.com/windows-vs-linux-mint-2200609 +[2]:https://www.eduonix.com/courses/system-programming/linux-for-absolute-beginners +[3]:https://www.pcworld.com/article/2918397/operating-systems/how-to-get-started-with-linux-a-beginners-guide.html +[4]:https://www.popsci.com/switch-to-linux-operating-system#page-4 +[5]:https://www.linux.com/learn/training +[6]:https://www.assignmenthelper.com.au/ +[7]:https://training.linuxfoundation.org/free-linux-training/linux-training-videos +[8]:https://www.linuxinsider.com/ +[9]:https://www.wired.com/2016/08/linux-took-web-now-taking-world/ +[10]:https://prowritingpartner.com/ +[11]:https://cdn.linuxaria.com/wp-content/plugins/flattr/img/flattr-badge-large.png +[12]:https://linuxaria.com/?flattrss_redirect&id=8570&md5=ee76fa2b44bdf6ef419a7f9906d3a5ad (Flattr) From 2e669196e9016e1e84a0b720faeeb98404fc6693 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 6 May 2018 11:25:27 +0800 Subject: [PATCH 0781/1057] PRF&PUB:20140410 Recursion- dream within a dream.md @qhwdw @FSSlc https://linux.cn/article-9609-1.html --- ...0140410 Recursion- dream within a dream.md | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) rename {translated/tech => published}/20140410 Recursion- dream within a dream.md (77%) diff --git a/translated/tech/20140410 Recursion- dream within a dream.md b/published/20140410 Recursion- dream within a dream.md similarity index 77% rename from translated/tech/20140410 Recursion- dream within a dream.md rename to published/20140410 Recursion- dream within a dream.md index d283bed402..8056001960 100644 --- a/translated/tech/20140410 Recursion- dream within a dream.md +++ b/published/20140410 Recursion- dream within a dream.md @@ -1,11 +1,12 @@ -[递归:梦中梦][1] +递归:梦中梦 ====== -**递归**是很神奇的,但是在大多数的编程类书藉中对递归讲解的并不好。它们只是给你展示一个递归阶乘的实现,然后警告你递归运行的很慢,并且还有可能因为栈缓冲区溢出而崩溃。“你可以将头伸进微波炉中去烘干你的头发,但是需要警惕颅内高压以及让你的头发生爆炸,或者你可以使用毛巾来擦干头发。”难怪人们不愿意使用递归。但这种建议是很糟糕的,因为在算法中,递归是一个非常强大的观点。 +> “方其梦也,不知其梦也。梦之中又占其梦焉,觉而后知其梦也。” —— 《庄子·齐物论》 + +**递归**是很神奇的,但是在大多数的编程类书藉中对递归讲解的并不好。它们只是给你展示一个递归阶乘的实现,然后警告你递归运行的很慢,并且还有可能因为栈缓冲区溢出而崩溃。“你可以将头伸进微波炉中去烘干你的头发,但是需要警惕颅内高压并让你的头发生爆炸,或者你可以使用毛巾来擦干头发。”难怪人们不愿意使用递归。但这种建议是很糟糕的,因为在算法中,递归是一个非常强大的思想。 我们来看一下这个经典的递归阶乘: -递归阶乘 - factorial.c ``` #include @@ -28,15 +29,18 @@ int main(int argc) } ``` +*递归阶乘 - factorial.c* + + 函数调用自身的这个观点在一开始是让人很难理解的。为了让这个过程更形象具体,下图展示的是当调用 `factorial(5)` 并且达到 `n == 1`这行代码 时,[栈上][3] 端点的情况: ![](https://manybutfinite.com/img/stack/factorial.png) 每次调用 `factorial` 都生成一个新的 [栈帧][4]。这些栈帧的创建和 [销毁][5] 是使得递归版本的阶乘慢于其相应的迭代版本的原因。在调用返回之前,累积的这些栈帧可能会耗尽栈空间,进而使你的程序崩溃。 -而这些担心经常是存在于理论上的。例如,对于每个 `factorial` 的栈帧占用 16 字节(这可能取决于栈排列以及其它因素)。如果在你的电脑上运行着现代的 x86 的 Linux 内核,一般情况下你拥有 8 GB 的栈空间,因此,`factorial` 程序中的 `n` 最多可以达到 512,000 左右。这是一个 [巨大无比的结果][6],它将花费 8,971,833 比特来表示这个结果,因此,栈空间根本就不是什么问题:一个极小的整数 - 甚至是一个 64 位的整数 - 在我们的栈空间被耗尽之前就早已经溢出了成千上万次了。 +而这些担心经常是存在于理论上的。例如,对于每个 `factorial` 的栈帧占用 16 字节(这可能取决于栈排列以及其它因素)。如果在你的电脑上运行着现代的 x86 的 Linux 内核,一般情况下你拥有 8 GB 的栈空间,因此,`factorial` 程序中的 `n` 最多可以达到 512,000 左右。这是一个 [巨大无比的结果][6],它将花费 8,971,833 比特来表示这个结果,因此,栈空间根本就不是什么问题:一个极小的整数 —— 甚至是一个 64 位的整数 —— 在我们的栈空间被耗尽之前就早已经溢出了成千上万次了。 -过一会儿我们再去看 CPU 的使用,现在,我们先从比特和字节回退一步,把递归看作一种通用技术。我们的阶乘算法可归结为:将整数 N、N-1、 … 1 推入到一个栈,然后将它们按相反的顺序相乘。实际上我们使用了程序调用栈来实现这一点,这是它的细节:我们在堆上分配一个栈并使用它。虽然调用栈具有特殊的特性,但是它也只是额外的一种数据结构,你可以随意处置。我希望示意图可以让你明白这一点。 +过一会儿我们再去看 CPU 的使用,现在,我们先从比特和字节回退一步,把递归看作一种通用技术。我们的阶乘算法可归结为:将整数 N、N-1、 … 1 推入到一个栈,然后将它们按相反的顺序相乘。实际上我们使用了程序调用栈来实现这一点,这是它的细节:我们在堆上分配一个栈并使用它。虽然调用栈具有特殊的特性,但是它也只是又一种数据结构而已,你可以随意使用。我希望这个示意图可以让你明白这一点。 当你将栈调用视为一种数据结构,有些事情将变得更加清晰明了:将那些整数堆积起来,然后再将它们相乘,这并不是一个好的想法。那是一种有缺陷的实现:就像你拿螺丝刀去钉钉子一样。相对更合理的是使用一个迭代过程去计算阶乘。 @@ -48,7 +52,6 @@ int main(int argc) 每到边缘(线)都让老鼠左转或者右转来到达一个新的位置。如果向哪边转都被拦住,说明相关的边缘不存在。现在,我们来讨论一下!这个过程无论你是调用栈还是其它数据结构,它都离不开一个递归的过程。而使用调用栈是非常容易的: -递归迷宫求解 [下载][2] ``` #include @@ -75,21 +78,24 @@ int explore(maze_t *node) int found = explore(&maze); } ``` + +*递归迷宫求解 [下载][2]* + 当我们在 `maze.c:13` 中找到奶酪时,栈的情况如下图所示。你也可以在 [GDB 输出][8] 中看到更详细的数据,它是使用 [命令][9] 采集的数据。 ![](https://manybutfinite.com/img/stack/mazeCallStack.png) -它展示了递归的良好表现,因为这是一个适合使用递归的问题。而且这并不奇怪:当涉及到算法时,递归是规则,而不是例外。它出现在如下情景中:当进行搜索时、当进行遍历树和其它数据结构时、当进行解析时、当需要排序时:它无处不在。正如众所周知的 pi 或者 e,它们在数学中像“神”一样的存在,因为它们是宇宙万物的基础,而递归也和它们一样:只是它在计算的结构中。 +它展示了递归的良好表现,因为这是一个适合使用递归的问题。而且这并不奇怪:当涉及到算法时,*递归是规则,而不是例外*。它出现在如下情景中——进行搜索时、进行遍历树和其它数据结构时、进行解析时、需要排序时——它无处不在。正如众所周知的 pi 或者 e,它们在数学中像“神”一样的存在,因为它们是宇宙万物的基础,而递归也和它们一样:只是它存在于计算结构中。 -Steven Skienna 的优秀著作 [算法设计指南][10] 的精彩之处在于,他通过“战争故事” 作为手段来诠释工作,以此来展示解决现实世界中的问题背后的算法。这是我所知道的拓展你的算法知识的最佳资源。另一个读物是 McCarthy 的 [关于 LISP 实现的的原创论文][11]。递归在语言中既是它的名字也是它的基本原理。这篇论文既可读又有趣,在工作中能看到大师的作品是件让人兴奋的事情。 +Steven Skienna 的优秀著作 [算法设计指南][10] 的精彩之处在于,他通过 “战争故事” 作为手段来诠释工作,以此来展示解决现实世界中的问题背后的算法。这是我所知道的拓展你的算法知识的最佳资源。另一个读物是 McCarthy 的 [关于 LISP 实现的的原创论文][11]。递归在语言中既是它的名字也是它的基本原理。这篇论文既可读又有趣,在工作中能看到大师的作品是件让人兴奋的事情。 -回到迷宫问题上。虽然它在这里很难离开递归,但是并不意味着必须通过调用栈的方式来实现。你可以使用像 `RRLL` 这样的字符串去跟踪转向,然后,依据这个字符串去决定老鼠下一步的动作。或者你可以分配一些其它的东西来记录追寻奶酪的整个状态。你仍然是去实现一个递归的过程,但是需要你实现一个自己的数据结构。 +回到迷宫问题上。虽然它在这里很难离开递归,但是并不意味着必须通过调用栈的方式来实现。你可以使用像 `RRLL` 这样的字符串去跟踪转向,然后,依据这个字符串去决定老鼠下一步的动作。或者你可以分配一些其它的东西来记录追寻奶酪的整个状态。你仍然是实现了一个递归的过程,只是需要你实现一个自己的数据结构。 那样似乎更复杂一些,因为栈调用更合适。每个栈帧记录的不仅是当前节点,也记录那个节点上的计算状态(在这个案例中,我们是否只让它走左边,或者已经尝试向右)。因此,代码已经变得不重要了。然而,有时候我们因为害怕溢出和期望中的性能而放弃这种优秀的算法。那是很愚蠢的! -正如我们所见,栈空间是非常大的,在耗尽栈空间之前往往会遇到其它的限制。一方面可以通过检查问题大小来确保它能够被安全地处理。而对 CPU 的担心是由两个广为流传的有问题的示例所导致的:哑阶乘(dumb factorial)和可怕的无记忆的 O(2n) [Fibonacci 递归][12]。它们并不是栈递归算法的正确代表。 +正如我们所见,栈空间是非常大的,在耗尽栈空间之前往往会遇到其它的限制。一方面可以通过检查问题大小来确保它能够被安全地处理。而对 CPU 的担心是由两个广为流传的有问题的示例所导致的:哑阶乘dumb factorial和可怕的无记忆的 O( 2^n ) [Fibonacci 递归][12]。它们并不是栈递归算法的正确代表。 -事实上栈操作是非常快的。通常,栈对数据的偏移是非常准确的,它在 [缓存][13] 中是热点,并且是由专门的指令来操作它。同时,使用你自己定义的堆上分配的数据结构的相关开销是很大的。经常能看到人们写的一些比栈调用递归更复杂、性能更差的实现方法。最后,现代的 CPU 的性能都是 [非常好的][14] ,并且一般 CPU 不会是性能瓶颈所在。在考虑牺牲程序的简单性时要特别注意,就像经常考虑程序的性能及性能的[测量][15]那样。 +事实上栈操作是非常快的。通常,栈对数据的偏移是非常准确的,它在 [缓存][13] 中是热数据,并且是由专门的指令来操作它的。同时,使用你自己定义的在堆上分配的数据结构的相关开销是很大的。经常能看到人们写的一些比栈调用递归更复杂、性能更差的实现方法。最后,现代的 CPU 的性能都是 [非常好的][14] ,并且一般 CPU 不会是性能瓶颈所在。在考虑牺牲程序的简单性时要特别注意,就像经常考虑程序的性能及性能的[测量][15]那样。 下一篇文章将是探秘栈系列的最后一篇了,我们将了解尾调用、闭包、以及其它相关概念。然后,我们就该深入我们的老朋友—— Linux 内核了。感谢你的阅读! From 2ddc1a408012ba2f7f32fe8862cef1f817c97371 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 6 May 2018 13:49:53 +0800 Subject: [PATCH 0782/1057] PRF:20180220 How to format academic papers on Linux with groff -me.md @amwps290 --- ...academic papers on Linux with groff -me.md | 122 +++--------------- 1 file changed, 18 insertions(+), 104 deletions(-) diff --git a/translated/tech/20180220 How to format academic papers on Linux with groff -me.md b/translated/tech/20180220 How to format academic papers on Linux with groff -me.md index 55b2e48517..52027eccaf 100644 --- a/translated/tech/20180220 How to format academic papers on Linux with groff -me.md +++ b/translated/tech/20180220 How to format academic papers on Linux with groff -me.md @@ -1,64 +1,51 @@ -# 在 Linux 上使用 groff -me 格式化你的学术论文 +在 Linux 上使用 groff -me 格式化你的学术论文 +=========== + +> 学习用简单的宏为你的课程论文添加脚注、引用、子标题及其它格式。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_paperclips.png?itok=j48op49T) -当我在 1993 年发现 Linux 时,我还是一名本科生。我很兴奋在我的宿舍里拥有 Unix 系统的强大功能,但是尽管它有很多功能,Linux 却缺乏应用程序。像 LibreOffice 和 OpenOffice 这样的文字处理程序还需要几年的时间。如果你想使用文字处理器,你可能会将你的系统引导到 MS-DOS 中,并使用 WordPerfect、shareware GalaxyWrite 或类似的程序。 +当我在 1993 年发现 Linux 时,我还是一名本科生。我很兴奋在我的宿舍里拥有 Unix 系统的强大功能,但是尽管它有很多功能,但 Linux 却缺乏应用程序。像 LibreOffice 和 OpenOffice 这样的文字处理程序还需要几年的时间才出现。如果你想使用文字处理器,你可能会将你的系统引导到 MS-DOS 中,并使用 WordPerfect、共享软件 GalaxyWrite 或类似的程序。 -`nroff` 和 `troff ` 。它们是同一系统的不同接口:`nroff` 生成纯文本输出,适用于屏幕或行式打印机,而 `troff` 产生非常优美的输出,通常用于在激光打印机上打印。 - -这就是我的方法,因为我需要为我的课程写论文,但我更喜欢呆在 Linux 中。我从我们的 “大 Unix ” 校园计算机实验室得知,Unix 系统提供了一组文本格式化的程序。它们是同一系统的不同接口:生成纯文本的输出,适合于屏幕或行打印机,或者生成非常优美的输出,通常用于在激光打印机上打印。 +这就是我的方法,因为我需要为我的课程写论文,但我更喜欢呆在 Linux 中。我从我们的 “大 Unix” 校园计算机实验室得知,Unix 系统提供了一组文本格式化的程序 `nroff` 和 `troff ` ,它们是同一系统的不同接口:`nroff` 生成纯文本输出,适用于屏幕或行式打印机,而 `troff` 产生非常优美的输出,通常用于在激光打印机上打印。 在 Linux 上,`nroff` 和 `troff` 被合并为 GNU troff,通常被称为 [groff][1]。 我很高兴看到早期的 Linux 发行版中包含了某个版本的 groff,因此我着手学习如何使用它来编写课程论文。 我学到的第一个宏集是 `-me` 宏包,一个简单易学的宏集。 -关于 `groff` ,首先要了解的是它根据一组宏处理和格式化文本。一个宏通常是一个两个字符的命令,它自己设置在一行上,并带有一个引导点。宏可能包含一个或多个选项。当 groff 在处理文档时遇到这些宏中的一个时,它会自动对文本进行格式化。 +关于 `groff` ,首先要了解的是它根据一组宏来处理和格式化文本。宏通常是个两个字符的命令,它自己设置在一行上,并带有一个引导点。宏可能包含一个或多个选项。当 `groff` 在处理文档时遇到这些宏中的一个时,它会自动对文本进行格式化。 下面,我将分享使用 `groff -me` 编写课程论文等简单文档的基础知识。 我不会深入细节进行讨论,比如如何创建嵌套列表,保存和显示,以及使用表格和数字。 ### 段落 -让我们从一个简单的例子开始,在几乎所有类型的文档中都可以看到:段落。段落可以格式化第一行的缩进或不缩进(即,与左边齐平)。 包括学术论文,杂志,期刊和书籍在内的许多印刷文档都使用了这两种类型的组合,其中文档或章节中的第一个(主要)段落与左侧的所有段落以及所有其他(常规)段落缩进。 在 `groff -me`中,您可以使用两种段落类型:前导段落(`.lp`)和常规段落(`.pp`)。 +让我们从一个简单的例子开始,在几乎所有类型的文档中都可以看到:段落。段落可以格式化为首行缩进或不缩进(即,与左边齐平)。 包括学术论文,杂志,期刊和书籍在内的许多印刷文档都使用了这两种类型的组合,其中文档或章节中的第一个(主要)段落左侧对齐,而所有其他(常规)的段落缩进。 在 `groff -me`中,您可以使用两种段落类型:前导段落(`.lp`)和常规段落(`.pp`)。 ``` .lp - This is the first paragraph. - .pp - This is a standard paragraph. - ``` ### 文本格式 -用粗体格式化文本的宏是 `.b`,斜体格式是 `.i` 。 如果您将 `.b` 或 `.i` 放在一行上,则后面的所有文本将以粗体或斜体显示。 但更有可能你只是想用粗体或斜体来表示一个或几个词。 要将一个词加粗或斜体,将该单词放在与 `.b` 或 `.i` 相同的行上作为选项。 要用**粗体**或斜体格式化多个单词,请将文字用引号引起来。 +用粗体格式化文本的宏是 `.b`,斜体格式是 `.i` 。 如果您将 `.b` 或 `.i` 放在一行上,则后面的所有文本将以粗体或斜体显示。 但更有可能你只是想用粗体或斜体来表示一个或几个词。 要将一个词加粗或斜体,将该单词放在与 `.b` 或 `.i` 相同的行上作为选项。 要用粗体或斜体格式化多个单词,请将文字用引号引起来。 ``` .pp - You can do basic formatting such as - .i italics - or - .b "bold text." - ``` -在上面的例子中,粗体文本结尾的句点也是粗体。 在大多数情况下,这不是你想要的。 只要文字是粗体字,而不是后面的句点也是粗体字。 要获得您想要的效果,您可以向 `.b` 或 `.i` 添加第二个参数,以指示要以粗体或斜体显示的文本,但是正常类型的文本。 您可以这样做,以确保尾随句点不会以粗体显示。 +在上面的例子中,粗体文本结尾的句点也是粗体。 在大多数情况下,这不是你想要的。 只要文字是粗体字,而不是后面的句点也是粗体字。 要获得您想要的效果,您可以向 `.b` 或 `.i` 添加第二个参数,以指示以粗体或斜体显示的文本后面跟着的任意文本以正常类型显示。 您可以这样做,以确保尾随句点不会以粗体显示。 ``` .pp - You can do basic formatting such as - .i italics - or - .b "bold text" . - ``` ### 列表 @@ -67,64 +54,38 @@ or ``` .pp - Bullet lists are easy to make: - .bu - Apple - .bu - Banana - .bu - Pineapple - .pp - Numbered lists are as easy as: - .np - One - .np - Two - .np - Three - .pp - Note that numbered lists will reset at the next pp or lp. - ``` ### 副标题 -如果你正在写一篇长论文,你可能想把你的内容分成几部分。使用 `groff -me`,您可以创建编号的标题 (`.sh`) 和未编号的标题 (`.uh`)。在这两种方法中,将节标题作为参数括起来。对于编号的标题,您还需要提供标题级别 `:1` 将给出一个一级标题(例如,1)。同样,`2` 和 `3` 将给出第二和第三级标题,如 2.1 或 3.1.1。 +如果你正在写一篇长论文,你可能想把你的内容分成几部分。使用 `groff -me`,您可以创建编号的标题(`.sh`) 和未编号的标题 (`.uh`)。在这两种方法中,将节标题作为参数括起来。对于编号的标题,您还需要提供标题级别 `:1` 将给出一个一级标题(例如,`1`)。同样,`2` 和 `3` 将给出第二和第三级标题,如 `2.1` 或 `3.1.1`。 ``` .uh Introduction - .pp - Provide one or two paragraphs to describe the work - and why it is important. - .sh 1 "Method and Tools" - .pp - Provide a few paragraphs to describe how you - did the research, including what equipment you used - ``` ### 智能引号和块引号 @@ -133,135 +94,88 @@ did the research, including what equipment you used ``` .pp - Christine Peterson coined the phrase \*(lqopen source.\*(rq - ``` `groff -me` 中还有一个快捷方式来创建这些引号(`.q`),我发现它更易于使用。 ``` .pp - Christine Peterson coined the phrase - .q "open source." - ``` -如果引用的是跨越几行的较长的引用,则需要使用一个块引用。为此,在引用的开头和结尾插入块引用宏( - -`.(q`)。 +如果引用的是跨越几行的较长的引用,则需要使用一个块引用。为此,在引用的开头和结尾插入块引用宏(`.(q`)。 ``` .pp - Christine Peterson recently wrote about open source: - .(q - On April 7, 1998, Tim O'Reilly held a meeting of key - leaders in the field. Announced in advance as the first - .q "Freeware Summit," - by April 14 it was referred to as the first - .q "Open Source Summit." - .)q - ``` ### 脚注 -要插入脚注,请在脚注文本前后添加脚注宏(`.(f`),并使用内联宏(`\ **`)添加脚注标记。脚注标记应出现在文本中和脚注中。 +要插入脚注,请在脚注文本前后添加脚注宏(`.(f`),并使用内联宏(`\**`)添加脚注标记。脚注标记应出现在文本中和脚注中。 ``` .pp - Christine Peterson recently wrote about open source:\** - .(f - \**Christine Peterson. - .q "How I coined the term open source." - .i "OpenSource.com." - 1 Feb 2018. - .)f - .(q - On April 7, 1998, Tim O'Reilly held a meeting of key - leaders in the field. Announced in advance as the first - .q "Freeware Summit," - by April 14 it was referred to as the first - .q "Open Source Summit." - .)q - ``` ### 封面 -大多数课程论文都需要一个包含论文标题,姓名和日期的封面。 在 `groff -me` 中创建封面需要一些组件。 我发现最简单的方法是使用居中的文本块并在标题,名称和日期之间添加额外的行。 (我倾向于在每一行之间使用两个空行)。在文章顶部,从标题页(`.tp`)宏开始,插入五个空白行(`.sp 5`),然后添加居中文本(`.(c`) 和额外的空白行(`.sp 2`)。 +大多数课程论文都需要一个包含论文标题,姓名和日期的封面。 在 `groff -me` 中创建封面需要一些组件。 我发现最简单的方法是使用居中的文本块并在标题、名字和日期之间添加额外的行。 (我倾向于在每一行之间使用两个空行)。在文章顶部,从标题页(`.tp`)宏开始,插入五个空白行(`.sp 5`),然后添加居中文本(`.(c`) 和额外的空白行(`.sp 2`)。 ``` .tp - .sp 5 - .(c - .b "Writing Class Papers with groff -me" - .)c - .sp 2 - .(c - Jim Hall - .)c - .sp 2 - .(c - February XX, 2018 - .)c - .bp - ``` 最后一个宏(`.bp`)告诉 groff 在标题页后添加一个分页符。 ### 更多内容 -这些是用 `groff-me` 写一份专业的论文非常基础的东西,包括前导和缩进段落,粗体和斜体,有序和无需列表,编号和不编号的章节标题,块引用以及脚注。 +这些是用 `groff-me` 写一份专业的论文非常基础的东西,包括前导和缩进段落,粗体和斜体,有序和无需列表,编号和不编号的章节标题,块引用以及脚注。 -我已经包含一个示例 groff 文件来演示所有这些格式。 将 `lorem-ipsum.me` 文件保存到您的系统并通过 groff 运行。 `-Tps` 选项将输出类型设置为 `PostScript` ,以便您可以将文档发送到打印机或使用 `ps2pdf` 程序将其转换为 PDF 文件。 +我已经包含一个[示例 groff 文件](https://opensource.com/sites/default/files/lorem-ipsum.me_.txt)来演示所有这些格式。 将 `lorem-ipsum.me` 文件保存到您的系统并通过 groff 运行。 `-Tps` 选项将输出类型设置为 `PostScript` ,以便您可以将文档发送到打印机或使用 `ps2pdf` 程序将其转换为 [PDF 文件](https://opensource.com/sites/default/files/lorem-ipsum.me_.pdf)。 ``` groff -Tps -me lorem-ipsum.me > lorem-ipsum.me.ps - ps2pdf lorem-ipsum.me.ps lorem-ipsum.me.pdf - ``` -如果你想使用 groff-me 的更多高级功能,请参阅 Eric Allman 所著的 “使用 `Groff-me` 来写论文”,你可以在你系统的 groff 的 `doc` 目录下找到一个名叫 `meintro.me` 的文件。这份文档非常完美的说明了如何使用 `groff-me` 宏来格式化你的论文。 +如果你想使用 `groff -me` 的更多高级功能,请参阅 Eric Allman 所著的 “使用 Groff -me 来写论文”,你可以在你系统的 groff 的 `doc` 目录下找到一个名叫 `meintro.me` 的文件。这份文档非常完美的说明了如何使用 `groff-me` 宏来格式化你的论文。 -------------------------------------------------------------------------------- @@ -269,7 +183,7 @@ via: https://opensource.com/article/18/2/how-format-academic-papers-linux-groff- 作者:[Jim Hall][a] 译者:[amwps290](https://github.com/amwps290) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 28659ff543d3213a93783f6eaf831dcf29ba71e8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 6 May 2018 13:50:19 +0800 Subject: [PATCH 0783/1057] PUB:20180220 How to format academic papers on Linux with groff -me.md @amwps290 https://linux.cn/article-9610-1.html --- ...80220 How to format academic papers on Linux with groff -me.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180220 How to format academic papers on Linux with groff -me.md (100%) diff --git a/translated/tech/20180220 How to format academic papers on Linux with groff -me.md b/published/20180220 How to format academic papers on Linux with groff -me.md similarity index 100% rename from translated/tech/20180220 How to format academic papers on Linux with groff -me.md rename to published/20180220 How to format academic papers on Linux with groff -me.md From a0c37609b57accec3ead333b06c364e5dcf1d93e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 6 May 2018 18:07:10 +0800 Subject: [PATCH 0784/1057] PRF:20170925 Advanced image viewing tricks with ImageMagick.md @FSSlc --- ...d image viewing tricks with ImageMagick.md | 64 +++++++++++-------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md b/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md index 7d7300979e..57813c80c2 100644 --- a/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md +++ b/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md @@ -1,93 +1,108 @@ ImageMagick 的一些高级图片查看技巧 ====== +> 用这些 ImageMagick 命令行图像编辑应用的技巧更好的管理你的数码照片集。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-photo-camera-green.png?itok=qiDqmXV1) + 图片源于 [Internet Archive Book Images](https://www.flickr.com/photos/internetarchivebookimages/14759826206/in/photolist-ougY7b-owgz5y-otZ9UN-waBxfL-oeEpEf-xgRirT-oeMHfj-wPAvMd-ovZgsb-xhpXhp-x3QSRZ-oeJmKC-ovWeKt-waaNUJ-oeHPN7-wwMsfP-oeJGTK-ovZPKv-waJnTV-xDkxoc-owjyCW-oeRqJh-oew25u-oeFTm4-wLchfu-xtjJFN-oxYznR-oewBRV-owdP7k-owhW3X-oxXxRg-oevDEY-oeFjP1-w7ZB6f-x5ytS8-ow9C7j-xc6zgV-oeCpG1-oewNzY-w896SB-wwE3yA-wGNvCL-owavts-oevodT-xu9Lcr-oxZqZg-x5y4XV-w89d3n-x8h6fi-owbfiq),Opensource.com 修改,[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)协议 -在我先前的[ImageMagick 入门:使用命令行来编辑图片](https://linux.cn/article-8851-1.html) 文章中,我展示了如何使用 ImageMagick 的菜单栏进行图片的编辑和变换风格。在这篇续文里,我将向你展示使用这个开源的图像编辑器来查看图片的额外方法。 +在我先前的[ImageMagick 入门:使用命令行来编辑图片][1] 文章中,我展示了如何使用 ImageMagick 的菜单栏进行图片的编辑和变换风格。在这篇续文里,我将向你展示使用这个开源的图像编辑器来查看图片的另外方法。 ### 别样的风格 -在深入 ImageMagick 的高级图片查看技巧之前,我想先分享另一个使用 **convert** 达到的有趣但简单的效果,在上一篇文章中我已经详细地介绍了 **convert** 命令,这个技巧涉及这个命令的 `edge` 和 `negate` 选项: +在深入 ImageMagick 的高级图片查看技巧之前,我想先分享另一个使用 `convert` 达到的有趣但简单的效果,在[上一篇文章][1]中我已经详细地介绍了 `convert` 命令,这个技巧涉及这个命令的 `edge` 和 `negate` 选项: + ``` convert DSC_0027.JPG -edge 3 -negate edge3+negate.jpg ``` ![在图片上使用 `edge` 和 `negate` 选项][3] -使用`edge` 和 `negate` 选项前后的图片对比 -编辑后的图片让我更加喜爱,具体是因为如下因素:海的外观,作为前景和背景的植被,特别是太阳及其在海上的反射,最后是天空。 +*使用`edge` 和 `negate` 选项前后的图片对比* -### 使用 `display` 来查看一系列图片 +这些使我更喜爱编辑后的图片:海的外观,作为前景和背景的植被,特别是太阳及其在海上的反射,最后是天空。 -假如你跟我一样是个命令行用户,你就知道 shell 为复杂任务提供了更多的灵活性和快捷方法。下面我将展示一个例子来佐证这个观点。ImageMagick 的 **display** 命令可以克服我在 GNOME 桌面上使用 [Shotwell][4] 图像管理器导入图片时遇到的问题。 +### 使用 display 来查看一系列图片 -Shotwell 会根据每张导入图片的 [Exif][5] 数据,创建以图片被生成或者拍摄时的日期为名称的目录结构。最终的效果是最上层的目录以年命名,接着的子目录是以月命名 (01, 02, 03 等等),然后是以每月的日期命名的子目录。我喜欢这种结构,因为当我想根据图片被创建或者拍摄时的日期来查找它们时将会非常方便。 +假如你跟我一样是个命令行用户,你就知道 shell 为复杂任务提供了更多的灵活性和快捷方法。下面我将展示一个例子来佐证这个观点。ImageMagick 的 `display` 命令可以克服我在 GNOME 桌面上使用 [Shotwell][4] 图像管理器导入图片时遇到的问题。 + +Shotwell 会根据每张导入图片的 [Exif][5] 数据,创建以图片被生成或者拍摄时的日期为名称的目录结构。最终的效果是最上层的目录以年命名,接着的子目录是以月命名 (01、 02、 03 等等),然后是以每月的日期命名的子目录。我喜欢这种结构,因为当我想根据图片被创建或者拍摄时的日期来查找它们时将会非常方便。 + +但这种结构也并不是非常完美的,当我想查看最近几个月或者最近一年的所有图片时就会很麻烦。使用常规的图片查看器,我将不停地在不同层级的目录间跳转,但 ImageMagick 的 `display` 命令可以使得查看更加简单。例如,假如我想查看最近一年的图片,我便可以在命令行中键入下面的 `display` 命令: -但这种结构也并不是非常完美的,当我想查看最近几个月或者最近一年的所有图片时就会很麻烦。使用常规的图片查看器,我将不停地在不同层级的目录间跳转,但 ImageMagick 的 **display** 命令可以使得查看更加简单。例如,假如我想查看最近一年的图片,我便可以在命令行中键入下面的 **display** 命令: ``` display -resize 35% 2017/*/*/*.JPG ``` -我可以匹配一年中的每一月和每一天。 +我可以一个月又一个月,一天又一天地遍历这一年。 现在假如我想查看某张图片,但我不确定我是在 2016 年的上半年还是在 2017 的上半年拍摄的,那么我便可以使用下面的命令来找到它: + ``` display -resize 35% 201[6-7]/0[1-6]/*/*.JPG ``` -限制查看的图片拍摄于 2016 和 2017 年的一月到六月 -### 使用 `montage` 来查看图片的缩略图 +这限制查看的图片拍摄于 2016 和 2017 年的一月到六月 -假如现在我要查找一张我想要编辑的图片,使用 **display** 的一个问题是它只会显示每张图片的文件名,而不显示其在目录结构中的位置,所以想要找到那张图片并不容易。另外,假如我很偶然地在从相机下载图片的过程中将这些图片从相机的内存里面清除了它们,结果使得下次拍摄照片的名称又从 **DSC_0001.jpg** 开始命名,那么当使用 **display** 来展示一整年的图片时,将会在这 12 个月的图片中花费很长的时间来查找它们。 +### 使用 montage 来查看图片的缩略图 + +假如现在我要查找一张我想要编辑的图片,使用 `display` 的一个问题是它只会显示每张图片的文件名,而不显示其在目录结构中的位置,所以想要找到那张图片并不容易。另外,假如我很偶然地在从相机下载图片的过程中将这些图片从相机的内存里面清除了它们,结果使得下次拍摄照片的名称又从 `DSC_0001.jpg` 开始命名,那么当使用 `display` 来展示一整年的图片时,将会在这 12 个月的图片中花费很长的时间来查找它们。 + +这时 `montage` 命令便可以派上用场了。它可以将一系列的图片缩略图放在一张图片中,这样就会非常有用。例如可以使用下面的命令来完成上面的任务: -这时 **montage** 命令便可以派上用场了。它可以将一系列的图片放在一张图片中,这样就会非常有用。例如可以使用下面的命令来完成上面的任务: ``` montage -label %d/%f -title 2017 -tile 5x -resize 10% -geometry +4+4 2017/0[1-4]/*/*.JPG 2017JanApr.jpg ``` -从左到右,这个命令以标签开头,标签的形式是包含文件名( **%f** )和以 **/** 分割的目录( **%d** )结构,接着这个命令以目录的名称(2017)来作为标题,然后将图片排成 5 列,每个图片缩放为 10% (这个参数可以很好地匹配我的屏幕)。`geometry` 的设定将在每张图片的四周留白,最后在接上要处理的对象和一个合适的名称( **2017JanApr.jpg** )。现在图片 **2017JanApr.jpg** 便可以成为一个索引,使得我可以不时地使用它来查看这个时期的所有图片。 +从左到右,这个命令以标签开头,标签的形式是包含文件名(`%f`)和以 `/` 分割的目录(`%d`)结构,接着这个命令以目录的名称(2017)来作为标题,然后将图片排成 5 列,每个图片缩放为 10% (这个参数可以很好地匹配我的屏幕)。`geometry` 的设定将在每张图片的四周留白,最后指定那些图片要包括到这张合成图片中,以及一个合适的文件名称(`2017JanApr.jpg`)。现在图片 `2017JanApr.jpg` 便可以成为一个索引,使得我可以不时地使用它来查看这个时期的所有图片。 ### 注意内存消耗 -你可能会好奇为什么我在上面的合成图中只特别指定了为期 4 个月(从一月到四月)的图片。因为 **montage** 将会消耗大量内存,所以你需要多加注意。我的相机产生的图片每张大约有 2.5MB,我发现我的系统可以很轻松地处理 60 张图片。但一旦图片增加到 80 张,如果此时还有另外的程序(例如 Firefox 、Thunderbird)在后台工作,那么我的电脑将会死机,这似乎和内存使用相关,**montage**可能会占用可用 RAM 的 80% 乃至更多(你可以在此期间运行 **top** 命令来查看内存占用)。假如我关掉其他的程序,我便可以在我的系统死机前处理 80 张图片。 +你可能会好奇为什么我在上面的合成图中只特别指定了为期 4 个月(从一月到四月)的图片。因为 `montage` 将会消耗大量内存,所以你需要多加注意。我的相机产生的图片每张大约有 2.5MB,我发现我的系统可以很轻松地处理 60 张图片。但一旦图片增加到 80 张,如果此时还有另外的程序(例如 Firefox 、Thunderbird)在后台工作,那么我的电脑将会死机,这似乎和内存使用相关,`montage`可能会占用可用 RAM 的 80% 乃至更多(你可以在此期间运行 `top` 命令来查看内存占用)。假如我关掉其他的程序,我便可以在我的系统死机前处理 80 张图片。 + +下面的命令可以让你知晓在你运行 `montage` 命令前你需要处理图片张数: -下面的命令可以让你知晓在你运行 **montage** 命令前你需要处理图片张数: ``` ls 2017/0[1-4/*/*.JPG > filelist; wc -l filelist ``` -**ls** 命令生成我们搜索的文件的列表,然后通过重定向将这个列表保存在任意以 filelist 为名称的文件中。接着带有 **-l** 选项的 **wc** 命令输出该列表文件共有多少行,换句话说,展示出需要处理的文件个数。下面是我运行命令后的输出: +`ls` 命令生成我们搜索的文件的列表,然后通过重定向将这个列表保存在任意以名为 `filelist` 的文件中。接着带有 `-l` 选项的 `wc` 命令输出该列表文件共有多少行,换句话说,展示出了需要处理的文件个数。下面是我运行命令后的输出: + ``` 163 filelist ``` -啊呀!从一月到四月我居然有 163 张图片,使用这些图片来创建一张合成图一定会使得我的系统死机的。我需要将这个列表减少点,可能只处理到 3 月份或者更早的图片。但如果我在4月20号到30号期间拍摄了很多照片,我想这便是问题的所在。下面的命令便可以帮助指出这个问题: +啊呀!从一月到四月我居然有 163 张图片,使用这些图片来创建一张合成图一定会使得我的系统死机的。我需要将这个列表减少点,可能只处理到 3 月份或者更早的图片。但如果我在 4 月 20 号到 30 号期间拍摄了很多照片,我想这便是问题的所在。下面的命令便可以帮助指出这个问题: + ``` ls 2017/0[1-3]/*/*.JPG > filelist; ls 2017/04/0[1-9]/*.JPG >> filelist; ls 2017/04/1[0-9]/*.JPG >> filelist; wc -l filelist ``` -上面一行中共有 4 个命令,它们以分号分隔。第一个命令特别指定从一月到三月期间拍摄的照片;第二个命令使用 **>>** 将拍摄于 4 月 1 日至 9 日的照片追加到这个列表文件中;第三个命令将拍摄于 4 月 1 0 日到 19 日的照片追加到列表中。最终它的显示结果为: +上面一行中共有 4 个命令,它们以分号分隔。第一个命令特别指定从一月到三月期间拍摄的照片;第二个命令使用 `>>` 将拍摄于 4 月 1 日至 9 日的照片追加到这个列表文件中;第三个命令将拍摄于 4 月 10 日到 19 日的照片追加到列表中。最终它的显示结果为: + ``` 81 filelist ``` 我知道假如我关掉其他的程序,处理 81 张图片是可行的。 -使用 **montage** 来处理它们是很简单的,因为我们只需要将上面所做的处理添加到 **montage** 命令的后面即可: +使用 `montage` 来处理它们是很简单的,因为我们只需要将上面所做的处理添加到 `montage` 命令的后面即可: + ``` montage -label %d/%f -title 2017 -tile 5x -resize 10% -geometry +4+4 2017/0[1-3]/*/*.JPG 2017/04/0[1-9]/*.JPG 2017/04/1[0-9]/*.JPG 2017Jan01Apr19.jpg ``` -从左到右,**montage** 命令后面最后的那个文件名将会作为输出,在它之前的都是输入。这个命令将花费大约 3 分钟来运行,并生成一张大小约为 2.5MB 的图片,但我的系统只是有一点反应迟钝而已。 +从左到右,`montage` 命令后面最后的那个文件名将会作为输出,在它之前的都是输入。这个命令将花费大约 3 分钟来运行,并生成一张大小约为 2.5MB 的图片,但我的系统只是有一点反应迟钝而已。 ### 展示合成图片 -当你第一次使用 **display** 查看一张巨大的合成图片时,你将看到合成图的宽度很合适,但图片的高度被压缩了,以便和屏幕相适应。不要慌,只需要左击图片,然后选择 **View > Original Size** 便会显示整个图片。再次点击图片便可以使菜单栏隐藏。 +当你第一次使用 `display` 查看一张巨大的合成图片时,你将看到合成图的宽度很合适,但图片的高度被压缩了,以便和屏幕相适应。不要慌,只需要左击图片,然后选择 `View > Original Size` 便会显示整个图片。再次点击图片便可以使菜单栏隐藏。 我希望这篇文章可以在你使用新方法查看图片时帮助你。在我的下一篇文章中,我将讨论更加复杂的图片操作技巧。 ### 作者简介 + Greg Pittman - Greg 肯塔基州路易斯维尔的一名退休的神经科医生,对计算机和程序设计有着长期的兴趣,最早可以追溯到 1960 年代的 Fortran IV 。当 Linux 和开源软件相继出现时,他开始学习更多的相关知识,并分享自己的心得。他是 Scribus 团队的成员。 -------------------------------------------------------------------------------- @@ -96,13 +111,12 @@ via: https://opensource.com/article/17/9/imagemagick-viewing-images 作者:[Greg Pittman][a] 译者:[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/) 荣誉推出 [a]:https://opensource.com/users/greg-p -[1]:https://opensource.com/article/17/8/imagemagick -[2]:/file/370946 +[1]:https://linux.cn/article-8851-1.html [3]:https://opensource.com/sites/default/files/u128651/edge3negate.jpg "Using the edge and negate options on an image." [4]:https://wiki.gnome.org/Apps/Shotwell [5]:https://en.wikipedia.org/wiki/Exif From 937433bb4f63bad8b10e0227cd87f5458dd77a3c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 6 May 2018 18:07:59 +0800 Subject: [PATCH 0785/1057] PUB:20170925 Advanced image viewing tricks with ImageMagick.md @FSSlc https://linux.cn/article-9611-1.html --- .../20170925 Advanced image viewing tricks with ImageMagick.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170925 Advanced image viewing tricks with ImageMagick.md (100%) diff --git a/translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md b/published/20170925 Advanced image viewing tricks with ImageMagick.md similarity index 100% rename from translated/tech/20170925 Advanced image viewing tricks with ImageMagick.md rename to published/20170925 Advanced image viewing tricks with ImageMagick.md From 6568dfd055a5ee33ceae9d11ead4d0d019a91f4c Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 6 May 2018 23:13:07 +0800 Subject: [PATCH 0786/1057] Delete 20180115 2 scientific calculators for the Linux desktop.md --- ...tific calculators for the Linux desktop.md | 113 ------------------ 1 file changed, 113 deletions(-) delete mode 100644 sources/tech/20180115 2 scientific calculators for the Linux desktop.md diff --git a/sources/tech/20180115 2 scientific calculators for the Linux desktop.md b/sources/tech/20180115 2 scientific calculators for the Linux desktop.md deleted file mode 100644 index 8b993a1aae..0000000000 --- a/sources/tech/20180115 2 scientific calculators for the Linux desktop.md +++ /dev/null @@ -1,113 +0,0 @@ -2 scientific calculators for the Linux desktop -====== - -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 - -Every Linux desktop environment comes with at least a simple desktop calculator, but most of those simple calculators are just that: a simple tool for simple calculations. - -Fortunately, there are exceptions; programs that go far beyond square roots and a couple of trigonometric functions, yet are still easy to use. Here are two powerful calculator tools for Linux, plus a couple of bonus options. - -### SpeedCrunch - -[SpeedCrunch][1] is a high-precision scientific calculator with a simple Qt5 graphical interface and strong focus on the keyboard. - -![SpeedCrunch graphical interface][3] - - -SpeedCrunch at work - -It supports working with units and comes loaded with all kinds of functions. - -For example, by writing: -`2 * 10^6 newton / (meter^2)` - -you get: -`= 2000000 pascal` - -By default, SpeedCrunch delivers its results in the international unit system, but units can be transformed with the "in" instruction. - -For example: -`3*10^8 meter / second in kilo meter / hour` - -produces: -`= 1080000000 kilo meter / hour` - -With the `F5` key, all results will turn into scientific notation (`1.08e9 kilo meter / hour`), while with `F2` only numbers that are small enough or big enough will change. More options are available on the Configuration menu. - -The list of available functions is really impressive. It works on Linux, Windows, and MacOS, and it's licensed under GPLv2; you can access its source code on [Bitbucket][4]. - -### Qalculate! - -[Qalculate!][5] (with the exclamation point) has a long and complex history. - -The project offers a powerful library that can be used by other programs (the Plasma desktop can use it to perform calculations from krunner) and a graphical interface built on GTK3. It allows you to work with units, handle physical constants, create graphics, use complex numbers, matrices, and vectors, choose arbitrary precision, and more. - - -![Qalculate! Interface][7] - - -Looking for some physical constants on Qalculate! - -Its use of units is far more intuitive than SpeedCrunch's and it understands common prefixes without problem. Have you heard of an exapascal pressure? I hadn't (the Sun's core stops at `~26 PPa`), but Qalculate! has no problem understanding the meaning of `1 EPa`. Also, Qalculate! is more flexible with syntax errors, so you don't need to worry about closing all those parentheses: if there is no ambiguity, Qalculate! will give you the right answer. - -After a long period on which the project seemed orphaned, it came back to life in 2016 and has been going strong since, with more than 10 versions in just one year. It's licensed under GPLv2 (with source code on [GitHub][8]) and offers versions for Linux and Windows, as well as a MacOS port. - -### Bonus calculators - -#### ConvertAll - -OK, it's not a "calculator," yet this simple application is incredibly useful. - -Most unit converters stop at a long list of basic units and a bunch of common combinations, but not [ConvertAll][9]. Trying to convert from astronomical units per year into inches per second? It doesn't matter if it makes sense or not, if you need to transform a unit of any kind, ConvertAll is the tool for you. - -Just write the starting unit and the final unit in the corresponding boxes; if the units are compatible, you'll get the transformation without protest. - -The main application is written in PyQt5, but there is also an [online version written in JavaScript][10]. - -#### (wx)Maxima with the units package - -Sometimes (OK, many times) a desktop calculator is not enough and you need more raw power. - -[Maxima][11] is a computer algebra system (CAS) with which you can do derivatives, integrals, series, equations, eigenvectors and eigenvalues, Taylor series, Laplace and Fourier transformations, as well as numerical calculations with arbitrary precision, graph on two and three dimensions… we could fill several pages just listing its capabilities. - -[wxMaxima][12] is a well-designed graphical frontend for Maxima that simplifies the use of many Maxima options without compromising others. On top of the full power of Maxima, wxMaxima allows you to create "notebooks" on which you write comments, keep your graphics with your math, etc. One of the (wx)Maxima combo's most impressive features is that it works with dimension units. - -On the prompt, just type: -`load("unit")` - -press Shift+Enter, wait a few seconds, and you'll be ready to work. - -By default, the unit package works with the basic MKS units, but if you prefer, for instance, to get `N` instead of `kg*m/s2`, you just need to type: -`setunits(N)` - -Maxima's help (which is also available from wxMaxima's help menu) will give you more information. - -Do you use these programs? Do you know another great desktop calculator for scientists and engineers or another related tool? Tell us about them in the comments! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/scientific-calculators-linux - -作者:[Ricardo Berlasso][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/rgb-es -[1]:http://speedcrunch.org/index.html -[2]:/file/382511 -[3]:https://opensource.com/sites/default/files/u128651/speedcrunch.png (SpeedCrunch graphical interface) -[4]:https://bitbucket.org/heldercorreia/speedcrunch -[5]:https://qalculate.github.io/ -[6]:/file/382506 -[7]:https://opensource.com/sites/default/files/u128651/qalculate-600.png (Qalculate! Interface) -[8]:https://github.com/Qalculate -[9]:http://convertall.bellz.org/ -[10]:http://convertall.bellz.org/js/ -[11]:http://maxima.sourceforge.net/ -[12]:https://andrejv.github.io/wxmaxima/ From 5117c197ce9e920de2e9b333f12c5f3dffc7d07a Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 6 May 2018 23:14:39 +0800 Subject: [PATCH 0787/1057] =?UTF-8?q?zyk2290=E5=AE=8C=E6=88=90=E7=BF=BB?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tific calculators for the Linux desktop.md | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 translated/tech/2 scientific calculators for the Linux desktop.md diff --git a/translated/tech/2 scientific calculators for the Linux desktop.md b/translated/tech/2 scientific calculators for the Linux desktop.md new file mode 100644 index 0000000000..a39e4eb5e5 --- /dev/null +++ b/translated/tech/2 scientific calculators for the Linux desktop.md @@ -0,0 +1,118 @@ +两款 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 桌面环境都至少带有一个功能简单的桌面计算器,但大多数计算器只能进行一些简单的计算。 + +幸运的是,还是有例外的:不仅可以做得比开平方根和一些三角函数还多,而且还很简单。这里将介绍两款强大的计算器,外加一大堆额外的功能。 + +### SpeedCrunch + +[SpeedCrunch][1]是一款高精度科学计算器有着 Qt5 图像界面前端,并且强烈依赖键盘。 + +![SpeedCrunch graphical interface][3] + +SpeedCrunch 在工作时 + +It supports working with units and comes loaded with all kinds of functions. + +所有函数都支持与单位一起工作。 + +例如, + +`2 * 10^6 newton / (meter^2)` + +你可以得到 + +`= 2000000 pascal` + +SpeedCrunch 会默认地将结果转化为国际标准单位,但还是可以用"in"命令转换 + +例如: + +`3*10^8 meter / second in kilo meter / hour` + +结果是: +`= 1080000000 kilo meter / hour` + +`F5` 键可以将所有结果转为科学计数法 (`1.08e9 kilo meter / hour`),`F2`键可以只将那些很大的数或很小的数转为科学计数法。更多选项可以在配置(Configuration)页面找到。 + +可用的函数的列表看上去非常惊艳。它可以在 Linux 、 Windows、macOS.。许可证是GPLv2,你可以在[Bitbucket][4]上得到它的源码。 + +### Qalculate! + +[Qalculate!][5](有感叹号)有一段长而复杂的历史。 + +这个项目给了我们一个强大的库,而这个库可以被其它程序使用(在 Plasma 桌面中,krunner 可以用它来计算),以及一个用 GTK3 搭建的图形界面前端。它允许你转换单位,处理物理常量,创建图像,使用复数,矩阵以及向量,选择任意准确度,等等 + + +![Qalculate! Interface][7] + +正在在 Qalculate! 寻找物理常量 + +在使用单位上,Qalculate! 会比SppedCrunch 更加直观,而且可以识别一些常用前缀。你有听说过 exapascal 吗?反正我没有(太阳的中心大概在 `~26 PPa`),但 Qalculate! ,可以准确识别出 `1 EPa`。同时,Qalculate! 可以更加灵活地处理语法错误,所以你不需要担心打括号:如果没有歧义,Qalculate! 会直接给出正确答案。 + +一段时间之后这个计划看上去被遗弃了。但在2016年,它又变得强大了,在一年里更新了10个版本。它的许可证是 GPLv2 (源码在 [GitHub][8] 上),提供Linux 、Windows 、macOS的版本。 + +### Bonus calculators + +#### 转换一切 + +好吧,这不是“计算器”,但这个程序非常好用 + +大部分单位转换器只是一大个基本单位列表以及一大堆基本组合,但[ConvertAll][9]与它们不一样。有试过把光年转换为英尺每秒吗?不管它们说不说得通,只要你想转换任何种类的单位,ConvertAll 就是你要的工具。 + +只需要在相应的输入框内输入转换前和转换后的单位:如果单位相容,你会直接得到答案。 + +主程序是在 PyQt5 上搭建的,但也有[JavaScript 的在线版本][10]。 + +#### (wx)Maxima with the units package + +有时候(好吧,很多时候)一款桌面计算器时候不够你用的,然后你需要更多的原力(raw power?) + +[Maxima][11]是一款计算机代数系统(LCTT 译者注:进行符号运算的软件。这种系统的要件是数学表示式的符号运算),你可以用它计算导数、积分、、方程、特征值和特征向量、泰勒级数、拉普拉斯变换与傅立叶变换,以及任意精度的数字计算、二维或三维图像··· ···列出这些都够我们写几页纸的了。 + +[wxMaxima][12]是一个设计精湛的 Maxima 的图形前端,它简化了许多 Maxima 的选项,但并不会影响其它。在 Maxima 的基础上,wxMaxima 还允许你创建 “笔记本”(notebooks),你可以在上面写一些笔记,保存你的图像等。其中一项 (wx)Maxima 最惊艳的功能是它可以处理标注单位(dimension units)。 + +`load("unit")` + +只需要输入`load("unit")` + +按 Shift+Enter,等几秒钟的时间,然后你就可以开始了 + +默认地,单位包与基本 MKS 单位工作,但如果你喜欢,例如,要拿到 `N`为单位而不是 `kg*m/s2`,你只需要输入:`setunits(N)` + +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) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/rgb-es +[1]:http://speedcrunch.org/index.html +[2]:/file/382511 +[3]:https://opensource.com/sites/default/files/u128651/speedcrunch.png "SpeedCrunch graphical interface" +[4]:https://bitbucket.org/heldercorreia/speedcrunch +[5]:https://qalculate.github.io/ +[6]:/file/382506 +[7]:https://opensource.com/sites/default/files/u128651/qalculate-600.png "Qalculate! Interface" +[8]:https://github.com/Qalculate +[9]:http://convertall.bellz.org/ +[10]:http://convertall.bellz.org/js/ +[11]:http://maxima.sourceforge.net/ +[12]:https://andrejv.github.io/wxmaxima/ From aa4413f5f8293448ab174b65cb0888a84cfc93d9 Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 6 May 2018 23:16:46 +0800 Subject: [PATCH 0788/1057] Update and rename 2 scientific calculators for the Linux desktop.md to 2018115 2 scientific calculators for the Linux desktop.md --- ...> 2018115 2 scientific calculators for the Linux desktop.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename translated/tech/{2 scientific calculators for the Linux desktop.md => 2018115 2 scientific calculators for the Linux desktop.md} (95%) diff --git a/translated/tech/2 scientific calculators for the Linux desktop.md b/translated/tech/2018115 2 scientific calculators for the Linux desktop.md similarity index 95% rename from translated/tech/2 scientific calculators for the Linux desktop.md rename to translated/tech/2018115 2 scientific calculators for the Linux desktop.md index a39e4eb5e5..fc94edf4ad 100644 --- a/translated/tech/2 scientific calculators for the Linux desktop.md +++ b/translated/tech/2018115 2 scientific calculators for the Linux desktop.md @@ -77,7 +77,7 @@ SpeedCrunch 会默认地将结果转化为国际标准单位,但还是可以 有时候(好吧,很多时候)一款桌面计算器时候不够你用的,然后你需要更多的原力(raw power?) -[Maxima][11]是一款计算机代数系统(LCTT 译者注:进行符号运算的软件。这种系统的要件是数学表示式的符号运算),你可以用它计算导数、积分、、方程、特征值和特征向量、泰勒级数、拉普拉斯变换与傅立叶变换,以及任意精度的数字计算、二维或三维图像··· ···列出这些都够我们写几页纸的了。 +[Maxima][11]是一款计算机代数系统(LCTT 译者注:进行符号运算的软件。这种系统的要件是数学表示式的符号运算),你可以用它计算导数、积分、方程、特征值和特征向量、泰勒级数、拉普拉斯变换与傅立叶变换,以及任意精度的数字计算、二维或三维图像··· ···列出这些都够我们写几页纸的了。 [wxMaxima][12]是一个设计精湛的 Maxima 的图形前端,它简化了许多 Maxima 的选项,但并不会影响其它。在 Maxima 的基础上,wxMaxima 还允许你创建 “笔记本”(notebooks),你可以在上面写一些笔记,保存你的图像等。其中一项 (wx)Maxima 最惊艳的功能是它可以处理标注单位(dimension units)。 From 8bf029b81d59e005b1a263b4ff7468d2a91ff686 Mon Sep 17 00:00:00 2001 From: zyk Date: Sun, 6 May 2018 23:18:48 +0800 Subject: [PATCH 0789/1057] Rename 2018115 2 scientific calculators for the Linux desktop.md to 20180115 2 scientific calculators for the Linux desktop.md --- ...=> 20180115 2 scientific calculators for the Linux desktop.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{2018115 2 scientific calculators for the Linux desktop.md => 20180115 2 scientific calculators for the Linux desktop.md} (100%) diff --git a/translated/tech/2018115 2 scientific calculators for the Linux desktop.md b/translated/tech/20180115 2 scientific calculators for the Linux desktop.md similarity index 100% rename from translated/tech/2018115 2 scientific calculators for the Linux desktop.md rename to translated/tech/20180115 2 scientific calculators for the Linux desktop.md From cf2b57cd2a4043f9fb430be63c5e6c5c633370eb Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 7 May 2018 08:55:39 +0800 Subject: [PATCH 0790/1057] translated --- ...Android Studio in Ubuntu And Linux Mint.md | 101 ------------------ ...Android Studio in Ubuntu And Linux Mint.md | 98 +++++++++++++++++ 2 files changed, 98 insertions(+), 101 deletions(-) delete mode 100644 sources/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md create mode 100644 translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md diff --git a/sources/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md b/sources/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md deleted file mode 100644 index 7fb5b4facc..0000000000 --- a/sources/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md +++ /dev/null @@ -1,101 +0,0 @@ -translating---geekpi - - -Easily Install Android Studio in Ubuntu And Linux Mint -====== -[Android Studio][1], Google’s own IDE for Android development, is a nice alternative to Eclipse with ADT plugin. Android Studio can be installed from its source code but in this quick post, we shall see **how to install Android Studio in Ubuntu 18.04, 16.04 and corresponding Linux Mint variants**. - -Before you proceed to install Android Studio, make sure that you have [Java installed in Ubuntu][2]. - -![How to install Android Studio in Ubuntu][3] - -### Install Android Studio in Ubuntu and other distributions using Snap - -Ever since Ubuntu started focusing on Snap packages, more software have started providing easy to install Snap packages. Android Studio is one of them. Ubuntu users can simply find the Android Studio application in the Software Center and install it from there. - -![Install Android Studio in Ubuntu from Software Center][4] - -If you see an error while installing Android Studio from Software Center, you can use the [Snap commands][5] to install Android studio. -``` -sudo snap install android-studio --classic - -``` - -Easy peasy! - -### Alternative Method 1: Install Android Studio using umake in Ubuntu - -You can also easily install Android Studio using Ubuntu Developer Tools Center, now known as [Ubuntu Make][6]. Ubuntu Make provides a command line tool to install various development tools, IDE etc. Ubuntu Make is available in Ubuntu repository. - -To install Ubuntu Make, use the commands below in a terminal: - -`sudo apt-get install ubuntu-make` - -Once you have installed Ubuntu Make, use the command below to install Android Studio in Ubuntu: -``` -umake android - -``` - -It will give you a couple of options in the course of the installation. I presume that you can handle it. If you decide to uninstall Android Studio, you can use the same umake tool in the following manner: -``` -umake android --remove - -``` - -### Alternative Method 2: Install Android Studio in Ubuntu and Linux Mint via unofficial PPA - -Thanks to [Paolo Ratolo][7], we have a PPA which can be used to easily install Android Studio in Ubuntu 16.04, 14.04, Linux Mint and other Ubuntu based distributions. Just note that it will download around 650 MB of data. So mind your internet connection as well as data charges (if any). - -Open a terminal and use the following commands: -``` -sudo apt-add-repository ppa:paolorotolo/android-studio -sudo apt-get update -sudo apt-get install android-studio - -``` - -Was it not easy? While installing a program from source code is fun in a way, it is always nice to have such PPAs. Once we have seen how to install Android Studio, lets see how to uninstall it. - -### Uninstall Android Studio: - -If you don’t have already, install PPA Purge: -``` -sudo apt-get install ppa-purge - -``` - -Now use the PPA Purge to purge the installed PPA: -``` -sudo apt-get remove android-studio - -sudo ppa-purge ppa:paolorotolo/android-studio - -``` - -That’s it. I hope this quick helps you to **install Android Studio in Ubuntu and Linux Mint**. Before you run Android Studio, make sure to [install Java in Ubuntu][8] first. In similar posts, I advise you to read [how to install and configure Ubuntu SDK][9] and [how to easily install Microsoft Visual Studio in Ubuntu][10]. - -Any questions or suggestions are always welcomed. Ciao :) - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/install-android-studio-ubuntu-linux/ - -作者:[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]:http://developer.android.com/sdk/installing/studio.html -[2]:https://itsfoss.com/install-java-ubuntu-1404/ -[3]:https://itsfoss.com/wp-content/uploads/2014/04/Android_Studio_Ubuntu.jpeg -[4]:https://itsfoss.com/wp-content/uploads/2014/04/install-android-studio-snap-800x469.jpg -[5]:https://itsfoss.com/install-snap-linux/ -[6]:https://wiki.ubuntu.com/ubuntu-make -[7]:https://plus.google.com/+PaoloRotolo -[8]:https://itsfoss.com/install-java-ubuntu-1404/ (How To Install Java On Ubuntu 14.04) -[9]:https://itsfoss.com/install-configure-ubuntu-sdk/ -[10]:https://itsfoss.com/install-visual-studio-code-ubuntu/ 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 new file mode 100644 index 0000000000..cb8cabe4e8 --- /dev/null +++ b/translated/tech/20140403 Easily Install Android Studio in Ubuntu And Linux Mint.md @@ -0,0 +1,98 @@ +在 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]。 + +![How to install Android Studio in Ubuntu][3] + +### 使用 Snap 在 Ubuntu 和其他发行版中安装 Android Studio + +自从 Ubuntu 开始专注于 Snap 软件包以来,越来越多的软件开始提供易于安装的 Snap 软件包。Android Studio 就是其中之一。Ubuntu 用户可以直接在软件中心找到 Android Studio 程序并从那里安装。 + +![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 Make,请在终端中使用以下命令: + +`sudo apt-get install ubuntu-make` + +安装 Ubuntu Make 后,请使用以下命令在 Ubuntu 中安装 Android Studio: +``` +umake android + +``` + +在安装过程中它会给你的几个选项。我认为你可以处理。如果你决定卸载 Android Studio,则可以按照以下方式使用相同的 umake 工具: +``` +umake android --remove + +``` + +### 另一种方式 2:通过非官方的 PPA 在 Ubuntu 和 Linux Mint 中安装 Android Studio + +感谢 [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,现在来看看如何卸载它。 + +### 卸载 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]。 + +欢迎提出任何问题或建议。再见 :) + +-------------------------------------------------------------------------------- + +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) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/abhishek/ +[1]:http://developer.android.com/sdk/installing/studio.html +[2]:https://itsfoss.com/install-java-ubuntu-1404/ +[3]:https://itsfoss.com/wp-content/uploads/2014/04/Android_Studio_Ubuntu.jpeg +[4]:https://itsfoss.com/wp-content/uploads/2014/04/install-android-studio-snap-800x469.jpg +[5]:https://itsfoss.com/install-snap-linux/ +[6]:https://wiki.ubuntu.com/ubuntu-make +[7]:https://plus.google.com/+PaoloRotolo +[8]:https://itsfoss.com/install-java-ubuntu-1404/ (How To Install Java On Ubuntu 14.04) +[9]:https://itsfoss.com/install-configure-ubuntu-sdk/ +[10]:https://itsfoss.com/install-visual-studio-code-ubuntu/ From 3eb2d1bcb7b8426d7876108eac2b03cd73102dde Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 7 May 2018 09:00:24 +0800 Subject: [PATCH 0791/1057] translating --- ...80430 Easily Search And Install Google Web Fonts In Linux.md | 2 ++ 1 file changed, 2 insertions(+) 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 index cbed6ac244..4e3ce41b65 100644 --- 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 @@ -1,3 +1,5 @@ +translating---geekpi + Easily Search And Install Google Web Fonts In Linux ====== From 11cc03e7a81178417edb3b112107b33425ce2f6e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 09:20:28 +0800 Subject: [PATCH 0792/1057] PRF:20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md @geekpi --- ...aphical Activity Monitor, Written In Go.md | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/translated/tech/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md b/translated/tech/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md index 6df5c2dc11..78f07bad34 100644 --- a/translated/tech/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md +++ b/translated/tech/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md @@ -1,8 +1,9 @@ -另一个 TUI 图形活动监视器,使用 Go 编写 +Gotop:另一个 TUI 图形活动监视器,使用 Go 编写 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/04/Gotop-720x340.png) -你已经知道 “top” 命令,对么?是的,它提供类 Unix 操作系统中运行中的进程的动态实时信息。一些开发人员为 top 命令构建了图形前端,因此用户可以在图形窗口中轻松找到他们系统的活动。其中之一是 **Gotop**。顾名思义,Gotop 是一个 TUI 图形活动监视器,使用 **Go** 语言编写。它是完全免费、开源的,受到 [gtop][1] 和 [vtop][2] 的启发。 + +你已经知道 `top` 命令,对么?是的,它提供类 Unix 操作系统中运行中的进程的动态实时信息。一些开发人员为 `top` 命令构建了图形前端,因此用户可以在图形窗口中轻松找到他们系统的活动。其中之一是 **Gotop**。顾名思义,Gotop 是一个 TUI 图形活动监视器,使用 **Go** 语言编写。它是完全免费、开源的,受到了 [gtop][1] 和 [vtop][2] 的启发。 在此简要的指南中,我们将讨论如何安装和使用 Gotop 来监视 Linux 系统的活动。 @@ -11,21 +12,21 @@ Gotop 是用 Go 编写的,所以我们需要先安装它。要在 Linux 中安装 Go 语言,请参阅以下指南。 安装 Go 之后,使用以下命令下载最新的 Gotop 二进制文件。 + ``` $ sh -c "$(curl https://raw.githubusercontent.com/cjbassi/gotop/master/download.sh)" - ``` -然后,将下载的二进制文件移动到您的 $PATH 中,例如 **/usr/local/bin/**。 +然后,将下载的二进制文件移动到您的 `$PATH` 中,例如 `/usr/local/bin/`。 + ``` $ cp gotop /usr/local/bin - ``` 最后,用下面的命令使其可执行: + ``` $ chmod +x /usr/local/bin/gotop - ``` 如果你使用的是基于 Arch 的系统,Gotop 存在于 **AUR** 中,所以你可以使用任何 AUR 助手程序进行安装。 @@ -33,92 +34,91 @@ $ chmod +x /usr/local/bin/gotop 使用 [**Cower**][3]: ``` $ cower -S gotop - ``` 使用 [**Pacaur**][4]: + ``` $ pacaur -S gotop - ``` 使用 [**Packer**][5]: + ``` $ packer -S gotop - ``` 使用 [**Trizen**][6]: + ``` $ trizen -S gotop - ``` 使用 [**Yay**][7]: + ``` $ yay -S gotop - ``` 使用 [yaourt][8]: + ``` $ yaourt -S gotop - ``` ### 用法 Gotop 的使用非常简单!你所要做的就是从终端运行以下命令。 + ``` $ gotop - ``` 这样就行了!你将在简单的 TUI 窗口中看到系统 CPU、磁盘、内存、网络、CPU温度和进程列表的使用情况。 ![][10] -要仅显示CPU、内存和进程组件,请使用下面的 **-m** 标志 +要仅显示CPU、内存和进程组件,请使用下面的 `-m` 标志: + ``` $ gotop -m - ``` ![][11] 你可以使用以下键盘快捷键对进程表进行排序。 - * **c** – CPU - * **m** – 内存 - * **p** – PID + * `c` – CPU + * `m` – 内存 + * `p` – PID 对于进程浏览,请使用以下键。 - * **上/下** 箭头或者 **j/k** 键用于上移下移。 - * **Ctrl-d** 和 **Ctrl-u** – 上移和下移半页。 - * **Ctrl-f** 和 **Ctrl-b** – 上移和下移整页。 - * **gg** 和 **G** – 跳转顶部和底部。 + * `上/下` 箭头或者 `j/k` 键用于上移下移。 + * `Ctrl-d` 和 `Ctrl-u` – 上移和下移半页。 + * `Ctrl-f` 和 `Ctrl-b` – 上移和下移整页。 + * `gg` 和 `G` – 跳转顶部和底部。 -按下 **< TAB>** 切换进程分组。要杀死选定的进程或进程组,请输入 **dd**。要选择一个进程,只需点击它。要向下/向上滚动,请使用鼠标滚动按钮。要放大和缩小 CPU 和内存图,请使用 **h** 和 **l**。要显示帮助菜单,只需按 **?**。 - -**推荐阅读:** +按下 `TAB` 切换进程分组。要杀死选定的进程或进程组,请输入 `dd`。要选择一个进程,只需点击它。要向下/向上滚动,请使用鼠标滚动按钮。要放大和缩小 CPU 和内存的图形,请使用 `h` 和 `l`。要显示帮助菜单,只需按 `?`。 就是这些了。希望这有帮助。还有更多好东西。敬请关注! +### 资源 +- [Gotop GitHub Repository](https://github.com/cjbassi/gotop) -------------------------------------------------------------------------------- via: https://www.ostechnix.com/gotop-yet-another-tui-graphical-activity-monitor-written-in-go/ 作者:[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 eba1c362957b68aa89ae7e30d9e5feebdbe21af7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 09:20:51 +0800 Subject: [PATCH 0793/1057] PUB:20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md @geekpi --- ...9 Yet Another TUI Graphical Activity Monitor, Written In Go.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md (100%) diff --git a/translated/tech/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md b/published/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md similarity index 100% rename from translated/tech/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md rename to published/20180409 Yet Another TUI Graphical Activity Monitor, Written In Go.md From e438e95f36be00b66b06ba1fc969aca917cc4ca2 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 09:39:56 +0800 Subject: [PATCH 0794/1057] PRF:20180319 A Command Line Productivity Tool For Tracking Work Hours.md @leemeans --- ...oductivity Tool For Tracking Work Hours.md | 117 ++++++++---------- 1 file changed, 53 insertions(+), 64 deletions(-) diff --git a/translated/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md b/translated/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md index 35dc204c71..010c434fb1 100644 --- a/translated/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md +++ b/translated/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md @@ -1,53 +1,52 @@ -一个用于追踪工作时间的命令行生产力工具 +moro:一个用于追踪工作时间的命令行生产力工具 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/03/Moro-720x340.jpg) -保持对你的工作小时数的追踪将让你知晓在一个特定时间区间内你所完成的工作总量。在网络上有大量的基于GUI的生产力工具可以用来追踪工作小时数。但我却不能找到一个基于CLI的工具。今天我偶然发现了一个简单而奏效的叫做 **“Moro”** 的追踪工作时间数的工具。Moro是一个芬兰词汇,意为"Hello"。通过使用Moro,你可以找到你在完成某项特定任务时花费了多少时间。这个工具是免费且开源的,它是通过**NodeJS**编写的。 + +保持对你的工作小时数的追踪将让你知晓在一个特定时间区间内你所完成的工作总量。在网络上有大量的基于 GUI 的生产力工具可以用来追踪工作小时数。但我却不能找到一个基于 CLI 的工具。今天我偶然发现了一个简单而奏效的叫做 Moro 的追踪工作时间数的工具。Moro 是一个芬兰词汇,意为“Hello”。通过使用 Moro,你可以找到你在完成某项特定任务时花费了多少时间。这个工具是自由开源软件,它是通过 NodeJS 编写的。 ### Moro - 一个追踪工作时间的命令行生产力工具 -由于Moro是使用NodeJS编写的,保证你的系统上已经安装了(NodeJS)。如果你没有安装好NodeJS,跟随下面的链接在你的Linux中安装NodeJS和NPM。 +由于 Moro 是使用 NodeJS 编写的,保证你的系统上已经安装了 NodeJS。如果你没有安装好 NodeJS,跟随下面的链接在你的 Linux 中安装 NodeJS 和 NPM。 + +- [如何在 Linux 上安装 NodeJS](https://www.ostechnix.com/install-node-js-linux/) + +NodeJS 和NPM一旦装好,运行下面的命令来安装 Moro。 -NodeJS和NPM一旦装好,运行下面的命令来安装Moro。 ``` $ npm install -g moro - ``` ### 用法 -Moro的工作概念非常简单。它记录了你的工作开始时间,结束时间和在你的系统上的休息时间。在每天结束时,它将会告知你已经工作了多少时间。 +Moro 的工作概念非常简单。它记录了你的工作开始时间,结束时间和在你的系统上的休息时间。在每天结束时,它将会告知你已经工作了多少时间。 当你到达办公室时,只需键入: + ``` $ moro - ``` 示例输出: ``` -💙 Moro \o/ - -✔ You clocked in at: 9:20 - +♥ Moro \o/ +√ You clocked in at: 9:20 ``` -Moro将会把这个时间注册为你的开始时间。 +Moro 将会把这个时间注册为你的开始时间。 当你离开办公室时,再次键入: + ``` $ moro - ``` 示例输出: + ``` -💙 Moro \o/ - -✔ You clocked out at: 19:22 - +♥ Moro \o/ +√ You clocked out at: 19:22 ℹ Today looks like this so far: - ┌──────────────────┬─────────────────────────┐ │ Today you worked │ 9 Hours and 72 Minutes │ ├──────────────────┼─────────────────────────┤ @@ -60,43 +59,37 @@ $ moro │ Date │ 2018-03-19 │ └──────────────────┴─────────────────────────┘ ℹ Run moro --help to learn how to edit your clock in, clock out or break duration for today - ``` -Moro将会把这个时间注册为你的结束时间。 +Moro 将会把这个时间注册为你的结束时间。 -现在,Moro将会从结束时间减去开始时间然后从总的时间减去另外的30分钟作为休息时间并给你在那天总的工作时间。抱歉,我的数学计算过程解释实在糟糕。假设你在早上10:00来工作并在晚上17:30离开。所以,你总共在办公室呆了7.30小时(例如17.30-10)。然后在总的时间减去休息时间(默认是30分钟)。因此,你的总工作时间是7小时。明白了?很好! +现在,Moro 将会从结束时间减去开始时间,然后从总的时间减去另外的 30 分钟作为休息时间,并给你在那天总的工作时间。抱歉,我的数学计算过程解释实在糟糕。假设你在早上 10:00 来工作并在晚上 17:30 离开。所以,你总共在办公室呆了 7:30 小时(例如 17:30-10)。然后在总的时间减去休息时间(默认是 30 分钟)。因此,你的总工作时间是 7 小时。明白了?很好! -**注意:**不要像我在写这个手册的时候一样把“moro”和“more”弄混了。 +**注意:**不要像我在写这个手册的时候一样把 “moro” 和 “more” 弄混了。 查看你注册的所有小时数,运行: + ``` $ moro report --all - ``` 以防万一,如果你忘记注册开始时间或者结束时间,你一样可以在之后指定这些值。 -例如,将上午10点注册为开始时间,运行: +例如,将上午 10 点注册为开始时间,运行: + ``` $ moro hi 10:00 - -💙 Moro \o/ - -✔ You clocked in at: 10:00 - +♥ Moro \o/ +√ You clocked in at: 10:00 ⏰ Working until 18:00 will make it a full (7.5 hours) day - ``` -注册17:30作为结束时间: +注册 17:30 作为结束时间: + ``` $ moro bye 17:30 - -💙 Moro \o/ - -✔ You clocked out at: 17:30 - +♥ Moro \o/ +√ You clocked out at: 17:30 ℹ Today looks like this so far: ┌──────────────────┬───────────────────────┐ @@ -111,79 +104,75 @@ $ moro bye 17:30 │ Date │ 2018-03-19 │ └──────────────────┴───────────────────────┘ ℹ Run moro --help to learn how to edit your clock in, clock out or break duration for today - ``` -你已经知道Moro默认将会减去30分钟的休息时间。如果你需要设置一个自定义的休息时间,你可以简单使用以下命令: +你已经知道 Moro 默认将会减去 30 分钟的休息时间。如果你需要设置一个自定义的休息时间,你可以简单使用以下命令: + ``` $ moro break 45 - ``` -现在,休息时间是45分钟了。 +现在,休息时间是 45 分钟了。 若要清除所有的数据: + ``` $ moro clear --yes - -💙 Moro \o/ - -✔ Database file deleted successfully - +♥ Moro \o/ +√ Database file deleted successfully ``` -**添加笔记** +#### 添加笔记 + +有时候,你想要在工作时添加笔记。不必去寻找一个独立的作笔记的应用。Moro 将会帮助你添加笔记。要添加笔记,只需运行: -有时候,你想要在工作时添加笔记。不必去寻找一个独立的作笔记的应用。Moro将会帮助你添加笔记。要添加笔记,只需运行: ``` $ moro note mynotes - ``` 要在之后搜索所有已经注册的笔记,只需做: + ``` $ moro search mynotes - ``` -**修改默认设置** +#### 修改默认设置 -默认的完整工作时间是7.5小时。这是因为开发者来自芬兰,这是官方的工作小时数。但是你也可以修改这个设置为你的国家的工作小时数。 +默认的完整工作时间是 7.5 小时。这是因为开发者来自芬兰,这是官方的工作小时数。但是你也可以修改这个设置为你的国家的工作小时数。 + +举个例子,要将其设置为 7 小时,运行: -举个例子,要将其设置为7小时,运行: ``` $ moro config --day 7 - ``` -同样地,默认的休息时间也可以像下面这样从30分钟修改: +同样地,默认的休息时间也可以像下面这样从 30 分钟修改: + ``` $ moro config --break 45 - ``` -**备份你的数据** +#### 备份你的数据 -正如我已经说了的,Moro将时间追踪信息存储在你的家目录,文件名是**.moro-data.db**。 +正如我已经说了的,Moro 将时间追踪信息存储在你的家目录,文件名是 `.moro-data.db`。 -但是,你可以保存备份数据库到不同的位置。要这样做的话,像下面这样将**.moro-data.db**文件移到你选择的一个不同的位置并告知Moro使用那个数据库文件。 +但是,你可以保存备份数据库到不同的位置。要这样做的话,像下面这样将 `.moro-data.db` 文件移到你选择的一个不同的位置并告知 Moro 使用那个数据库文件。 ``` $ moro config --database-path /home/sk/personal/moro-data.db - ``` -在上面的每一个命令,我都已经把默认的数据库文件分配到了**/home/sk/personal**目录。 +在上面的每一个命令,我都已经把默认的数据库文件分配到了 `/home/sk/personal` 目录。 需要帮助的话,运行: + ``` $ moro --help - ``` -正如你所见,Moro是非常简单而又能用于追踪你完成你的工作使用了多少时间的。对于自由职业者和任何想要在一定时间范围内完成事情的人,它将会是有用的。 +正如你所见,Moro 是非常简单而又能用于追踪你完成你的工作使用了多少时间的。对于自由职业者和任何想要在一定时间范围内完成事情的人,它将会是有用的。 -并且,这些只是今天的(内容)。希望这些(内容)能够有所帮助。更多的好东西将会出现。请保持关注! +并且,这些只是今天的内容。希望这些内容能够有所帮助。更多的好东西将会出现。请保持关注! 干杯! @@ -194,7 +183,7 @@ via: https://www.ostechnix.com/moro-a-command-line-productivity-tool-for-trackin 作者:[SK][a] 译者:[leemeans](https://github.com/leemeans) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8c25b7f5f6beaa2ac1c220c76034afb8e282c4af Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 09:40:18 +0800 Subject: [PATCH 0795/1057] PUB:20180319 A Command Line Productivity Tool For Tracking Work Hours.md @leemeans https://linux.cn/article-9613-1.html --- ...19 A Command Line Productivity Tool For Tracking Work Hours.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180319 A Command Line Productivity Tool For Tracking Work Hours.md (100%) diff --git a/translated/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md b/published/20180319 A Command Line Productivity Tool For Tracking Work Hours.md similarity index 100% rename from translated/tech/20180319 A Command Line Productivity Tool For Tracking Work Hours.md rename to published/20180319 A Command Line Productivity Tool For Tracking Work Hours.md From 90c7e6ed68f64f86b5993e7a9f4200414f15909f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 10:16:19 +0800 Subject: [PATCH 0796/1057] PRF:20180126 How To Manage NodeJS Packages Using Npm.md @MjSeven --- ...How To Manage NodeJS Packages Using Npm.md | 129 +++++++++++------- 1 file changed, 81 insertions(+), 48 deletions(-) diff --git a/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md b/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md index e443576852..e9805185e9 100644 --- a/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md +++ b/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md @@ -1,29 +1,32 @@ -如何使用 Npm 管理 NodeJS 包 +如何使用 npm 管理 NodeJS 包 ===== ![](https://www.ostechnix.com/wp-content/uploads/2018/01/npm-720x340.png) -前一段时间,我们发布了一个[**使用 PIP 管理 Python 包**][3]的指南。今天,我们将讨论如何使用 Npm 管理 NodeJS 包。NPM 是最大的软件注册中心,包含 600,000 多个包。每天,世界各地的开发人员通过 npm 共享和下载软件包。在本指南中,我将解释使用 npm 基础知识,例如安装包(本地和全局)、安装特定版本的包、更新、删除和管理 NodeJS 包等等。 +前一段时间,我们发布了一个[使用 pip 管理 Python 包][3]的指南。今天,我们将讨论如何使用 npm 管理 NodeJS 包。npm 是最大的软件注册中心,包含 600,000 多个包。每天,世界各地的开发人员通过 npm 共享和下载软件包。在本指南中,我将解释使用 npm 基础知识,例如安装包(本地和全局)、安装特定版本的包、更新、删除和管理 NodeJS 包等等。 -### 使用 Npm 管理 NodeJS 包 - -##### 安装 NPM +### 安装 npm 用于 npm 是用 NodeJS 编写的,我们需要安装 NodeJS 才能使用 npm。要在不同的 Linux 发行版上安装 NodeJS,请参考下面的链接。 +- [在 Linux 上安装 NodeJS](https://www.ostechnix.com/install-node-js-linux/) + 检查 node 安装的位置: + ``` $ which node /home/sk/.nvm/versions/node/v9.4.0/bin/node ``` 检查它的版本: + ``` $ node -v v9.4.0 ``` 进入 Node 交互式解释器: + ``` $ node > .help @@ -38,43 +41,46 @@ $ node ``` 检查 npm 安装的位置: + ``` $ which npm /home/sk/.nvm/versions/node/v9.4.0/bin/npm ``` 还有版本: + ``` $ npm -v 5.6.0 ``` -棒极了!Node 和 NPM 已安装并能工作!正如你可能已经注意到,我已经在我的 $HOME 目录中安装了 NodeJS 和 NPM,这样是为了避免在全局模块时出现权限问题。这是 NodeJS 团队推荐的方法。 +棒极了!Node 和 npm 已安装好!正如你可能已经注意到,我已经在我的 `$HOME` 目录中安装了 NodeJS 和 NPM,这样是为了避免在全局模块时出现权限问题。这是 NodeJS 团队推荐的方法。 那么,让我们继续看看如何使用 npm 管理 NodeJS 模块(或包)。 -##### 安装 NodeJS 模块 +### 安装 NodeJS 模块 -NodeJS 模块可以安装在本地或全局(系统范围)。现在我将演示如何在本地安装包。 +NodeJS 模块可以安装在本地或全局(系统范围)。现在我将演示如何在本地安装包(LCTT 译注:即将包安装到一个 NodeJS 项目当中,所以下面会先创建一个空项目做演示)。 -**在本地安装包** +#### 在本地安装包 -为了在本地管理包,我们通常使用 **package.json** 文件来管理。 +为了在本地管理包,我们通常使用 `package.json` 文件来管理。 首先,让我们创建我们的项目目录。 + ``` $ mkdir demo -``` -``` $ cd demo ``` -在项目目录中创建一个 package.json 文件。为此,运行: +在项目目录中创建一个 `package.json` 文件。为此,运行: + ``` $ npm init ``` -输入你的包的详细信息,例如名称,版本,作者,github 页面等等,或者按下 ENTER 键接受默认值并键入 **YES** 确认。 +输入你的包的详细信息,例如名称、版本、作者、GitHub 页面等等,或者按下回车键接受默认值并键入 `yes` 确认。 + ``` This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. @@ -112,19 +118,22 @@ About to write to /home/sk/demo/package.json: Is this ok? (yes) yes ``` -上面的命令初始化你的项目并创建了 package.json 文件。 +上面的命令初始化你的项目并创建了 `package.json` 文件。 你也可以使用命令以非交互式方式执行此操作: + ``` npm init --y ``` -现在让我们安装名为 [**commander**][2] 的包。 +现在让我们安装名为 [commander][2] 的包。 + ``` $ npm install commander ``` 示例输出: + ``` npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN demo@1.0.0 No repository field. @@ -133,11 +142,12 @@ npm WARN demo@1.0.0 No repository field. added 1 package in 2.519s ``` -这将在项目的根目录中创建一个名为 **" node_modules"** 的目录(如果它不存在的话),并在其中下载包。 +这将在项目的根目录中创建一个名为 `node_modules` 的目录(如果它不存在的话),并在其中下载包。 + +让我们检查 `pachage.json` 文件。 -让我们检查 pachage.json 文件。 ``` -$ cat package.json +$ cat package.json { "name": "demo", "version": "1.0.0", @@ -148,30 +158,33 @@ $ cat package.json }, "author": "", "license": "ISC", - **"dependencies": {** -**"commander": "^2.13.0"** + "dependencies": { + "commander": "^2.13.0" } } ``` -你会看到添加了依赖文件,版本号前面的插入符号 ( **^** ) 表示在安装时,npm 将取出它可以找到的最高版本的包。 +你会看到添加了依赖文件,版本号前面的插入符号 ( `^` ) 表示在安装时,npm 将取出它可以找到的最高版本的包。 + ``` $ ls node_modules/ commander ``` -package.json 文件的优点是,如果你的项目目录中有 package.json 文件,只需键入 "npm install",那么 npm 将查看文件中列出的依赖关系并下载它们。你甚至可以与其他开发人员共享它或将其推送到你的 GitHub 仓库。因此,当他们键入 “npm install” 时,他们将获得你拥有的所有相同的包。 +`package.json` 文件的优点是,如果你的项目目录中有 `package.json` 文件,只需键入 `npm install`,那么 `npm` 将查看文件中列出的依赖关系并下载它们。你甚至可以与其他开发人员共享它或将其推送到你的 GitHub 仓库。因此,当他们键入 `npm install` 时,他们将获得你拥有的所有相同的包。 -你也可能会注意到另一个名为 **package-lock.json** 的文件,该文件确保在项目安装的所有系统上都保持相同的依赖关系。 +你也可能会注意到另一个名为 `package-lock.json` 的文件,该文件确保在项目安装的所有系统上都保持相同的依赖关系。 + +要在你的程序中使用已安装的包,使用实际代码在项目目录中创建一个 `index.js`(或者其他任何名称)文件,然后使用以下命令运行它: -要在你的程序中使用已安装的包,使用实际代码在项目目录中创建一个 **index.js**(或者其他任何名称)文件,然后使用以下命令运行它: ``` $ node index.js ``` -**在全局安装包** +#### 在全局安装包 如果你想使用一个包作为命令行工具,那么最好在全局安装它。这样,无论你的当前目录是哪个目录,它都能正常工作。 + ``` $ npm install async -g + async@2.6.0 @@ -179,23 +192,27 @@ added 2 packages in 4.695s ``` 或者 + ``` $ npm install async --global ``` 要安装特定版本的包,我们可以: + ``` $ npm install async@2.6.0 --global ``` -##### 更新 NodeJS 模块 +### 更新 NodeJS 模块 + +要更新本地包,转到 `package.json` 所在的项目目录并运行: -要更新本地包,转到 package.json 所在的项目目录并运行: ``` $ npm update ``` 然后,运行以下命令确保所有包都更新了。 + ``` $ npm outdated ``` @@ -203,6 +220,7 @@ $ npm outdated 如果没有需要更新的,那么它返回空。 要找出哪一个全局包需要更新,运行: + ``` $ npm outdated -g --depth=0 ``` @@ -210,32 +228,37 @@ $ npm outdated -g --depth=0 如果没有输出,意味着所有包都已更新。 更新单个全局包,运行: + ``` $ npm update -g ``` 更新所有的全局包,运行: + ``` -$ npm update -g +$ npm update -g ``` -##### 列出 NodeJS 模块 +### 列出 NodeJS 模块 列出本地包,转到项目目录并运行: + ``` $ npm list demo@1.0.0 /home/sk/demo └── commander@2.13.0 ``` -如你所见,我在本地安装了 "commander" 这个包。 +如你所见,我在本地安装了 `commander` 这个包。 要列出全局包,从任何位置都可以运行以下命令: + ``` $ npm list -g ``` 示例输出: + ``` /home/sk/.nvm/versions/node/v9.4.0/lib ├─┬ async@2.6.0 @@ -252,7 +275,8 @@ $ npm list -g 该命令将列出所有模块及其依赖关系。 -要仅仅列出顶级模块,使用 -depth=0 选项: +要仅仅列出顶级模块,使用 `-depth=0` 选项: + ``` $ npm list -g --depth=0 /home/sk/.nvm/versions/node/v9.4.0/lib @@ -260,43 +284,48 @@ $ npm list -g --depth=0 └── npm@5.6.0 ``` -##### 寻找 NodeJS 模块 +#### 寻找 NodeJS 模块 + +要搜索一个模块,使用 `npm search` 命令: -要搜索一个模块,使用 "npm search" 命令: ``` npm search ``` 例如: + ``` $ npm search request ``` -该命令将显示包含搜索字符串 "request" 的所有模块。 +该命令将显示包含搜索字符串 `request` 的所有模块。 ##### 移除 NodeJS 模块 -要删除本地包,转到项目目录并运行以下命令,这会从 **node_modules** 目录中删除包: +要删除本地包,转到项目目录并运行以下命令,这会从 `node_modules` 目录中删除包: + ``` $ npm uninstall ``` -要从 **package.json** 文件中的依赖关系中删除它,使用如下所示的 **save** 标志: +要从 `package.json` 文件中的依赖关系中删除它,使用如下所示的 `save` 选项: + ``` $ npm uninstall --save - ``` 要删除已安装的全局包,运行: + ``` $ npm uninstall -g ``` -##### 清楚 NPM 缓存 +### 清除 npm 缓存 -默认情况下,NPM 在安装包时,会将其副本保存在 $HOME 目录中名为 npm 的缓存文件夹中。所以,你可以在下次安装时不必再次下载。 +默认情况下,npm 在安装包时,会将其副本保存在 `$HOME` 目录中名为 `.npm` 的缓存文件夹中。所以,你可以在下次安装时不必再次下载。 查看缓存模块: + ``` $ ls ~/.npm ``` @@ -304,28 +333,33 @@ $ ls ~/.npm 随着时间的推移,缓存文件夹会充斥着大量旧的包。所以不时清理缓存会好一些。 从 npm@5 开始,npm 缓存可以从 corruption 问题中自行修复,并且保证从缓存中提取的数据有效。如果你想确保一切都一致,运行: + ``` $ npm cache verify ``` -清楚整个缓存,运行: +清除整个缓存,运行: + ``` $ npm cache clean --force ``` -##### 查看 NPM 配置 +### 查看 npm 配置 + +要查看 npm 配置,键入: -要查看 NPM 配置,键入: ``` $ npm config list ``` -或者 +或者: + ``` $ npm config ls ``` 示例输出: + ``` ; cli configs metrics-registry = "https://registry.npmjs.org/" @@ -339,26 +373,25 @@ user-agent = "npm/5.6.0 node/v9.4.0 linux x64" ``` 要显示当前的全局位置: + ``` $ npm config get prefix /home/sk/.nvm/versions/node/v9.4.0 ``` -好吧,这就是全部了。我们刚才介绍的只是基础知识,NPM 是一个广泛话题。有关更多详细信息,参阅 [**NPM Getting Started**][3] 指南。 +好吧,这就是全部了。我们刚才介绍的只是基础知识,npm 是一个广泛话题。有关更多详细信息,参阅 [**NPM Getting Started**][3] 指南。 希望这对你有帮助。更多好东西即将来临,敬请关注! 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/manage-nodejs-packages-using-npm/ 作者:[SK][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 506db60d4f7b70e7d81ffe07d89fecc28e67d8d1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 10:16:53 +0800 Subject: [PATCH 0797/1057] PUB:20180126 How To Manage NodeJS Packages Using Npm.md @MjSeven https://linux.cn/article-9614-1.html --- .../20180126 How To Manage NodeJS Packages Using Npm.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180126 How To Manage NodeJS Packages Using Npm.md (100%) diff --git a/translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md b/published/20180126 How To Manage NodeJS Packages Using Npm.md similarity index 100% rename from translated/tech/20180126 How To Manage NodeJS Packages Using Npm.md rename to published/20180126 How To Manage NodeJS Packages Using Npm.md From c5c61e31143f4b9ac8bcd4896c83db2f215d3f29 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 22:07:05 +0800 Subject: [PATCH 0798/1057] PRF:20180320 Dry - An Interactive CLI Manager For Docker Containers.md @pinewall --- ...ctive CLI Manager For Docker Containers.md | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/translated/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md b/translated/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md index a38910e274..1855ebb265 100644 --- a/translated/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md +++ b/translated/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md @@ -1,8 +1,9 @@ -Dry – 一个命令行交互式 Docker 容器管理器 +Dry:一个命令行交互式 Docker 容器管理器 ====== -Docker 是一种实现操作系统级别虚拟化或容器化的软件。 -基于 Linux 内核的 cgroups 和 namespaces 等资源隔离特性,Docker 可以在单个 Linux 实例中运行多个独立的容器。 +Docker 是一种所谓容器化的操作系统级的虚拟化软件。 + +基于 Linux 内核的 cgroup 和 namespace 等资源隔离特性,Docker 可以在单个 Linux 实例中运行多个独立的容器。 通过将应用依赖和相关库打包进容器,Docker 使得应用可以在容器中安全隔离地运行。 @@ -10,25 +11,26 @@ Docker 是一种实现操作系统级别虚拟化或容器化的软件。 [Dry][1] 是一个管理并监控 Docker 容器和镜像的命令行工具。 -Dry 给出容器相关的信息,包括对应镜像、容器名称、网络、容器中运行的命令及容器状态;如果运行在 Docker Swarm 中,工具还会给出 Swarm 集群的各种状态信息。 +Dry 可以给出容器相关的信息,包括对应镜像、容器名称、网络、容器中运行的命令及容器状态;如果运行在 Docker Swarm 中,工具还会给出 Swarm 集群的各种状态信息。 -Dry 可以连接至本地或远程的 Docker 守护进程。如果连接本地 Docker,Docker 主机显示为`unix:///var/run/docker.sock`。 +Dry 可以连接至本地或远程的 Docker 守护进程。如果连接本地 Docker,Docker 主机显示为 `unix:///var/run/docker.sock`。 如果连接远程 Docker,Docker 主机显示为 `tcp://IP Address:Port Number` 或 `tcp://Host Name:Port Number`。 -Dry 可以提供类似 `docker ps` 的指标输出,但输出比 “docker ps” 内容详实、富有色彩。 +Dry 可以提供类似 `docker ps` 的指标输出,但输出比 `docker ps` 内容详实、富有色彩。 相比 Docker,Dry 还可以手动添加一个额外的名称列,用于降低记忆难度。 -***推荐阅读:** +**推荐阅读:** -**(#)** [Portainer – 用于 Docker 管理的简明 GUI][2] -**(#)** [Rancher – 适用于生产环境的完备容器管理平台][3] -**(#)** [cTop – Linux环境下容器管理与监控的命令行工具][4] +- [Portainer – 用于 Docker 管理的简明 GUI][2] +- [Rancher – 适用于生产环境的完备容器管理平台][3] +- [cTop – Linux环境下容器管理与监控的命令行工具][4] ### 如何在 Linux 中安装 Dry -在 Linux 中,可以通过一个简单的 shell 脚本安装最新版本的 dry 工具。Dry 不依赖外部库。对于绝大多数的 Docker 命令,dry 提供类似样式的命令。 +在 Linux 中,可以通过一个简单的 shell 脚本安装最新版本的 Dry 工具。Dry 不依赖外部库。对于绝大多数的 Docker 命令,Dry 提供类似样式的命令。 + ``` $ curl -sSf https://moncho.github.io/dry/dryup.sh | sudo sh % Total % Received % Xferd Average Speed Time Time Time Current @@ -38,41 +40,40 @@ dryup: downloading dry binary ######################################################################## 100.0% dryup: Moving dry binary to its destination dryup: dry binary was copied to /usr/local/bin, now you should 'sudo chmod 755 /usr/local/bin/dry' - ``` -使用如下命令将文件权限变更为 `755` +使用如下命令将文件权限变更为 `755`: + ``` $ sudo chmod 755 /usr/local/bin/dry - ``` -对于使用 Arch Linux 的用户,可以使用 **[Packer][5]** or **[Yaourt][6]** 包管理器,从 AUR 源安装该工具。 +对于使用 Arch Linux 的用户,可以使用 **[Packer][5]** 或 **[Yaourt][6]** 包管理器,从 AUR 源安装该工具。 ``` $ yaourt -S dry-bin 或者 $ packer -S dry-bin - ``` 如果希望在 Docker 容器中运行 dry,可以运行如下命令。前提条件是已确认在操作系统中安装了 Docker。 **推荐阅读:** -**(#)** [如何在 Linux 中安装 Docker][7] -**(#)** [如何在 Linux 中玩转 Docker 镜像][8] -**(#)** [如何在 Linux 中玩转 Docker 容器][9] -**(#)** [如何在 Docker 容器中安装并运行应用程序][10] + +- [如何在 Linux 中安装 Docker][7] +- [如何在 Linux 中玩转 Docker 镜像][8] +- [如何在 Linux 中玩转 Docker 容器][9] +- [如何在 Docker 容器中安装并运行应用程序][10] + ``` $ docker run -it -v /var/run/docker.sock:/var/run/docker.sock moncho/dry - ``` ### 如何启动并运行 Dry 在控制台运行 `dry` 命令即可启动该工具,其默认输出如下: + ``` $ dry - ``` ![][12] @@ -80,18 +81,20 @@ $ dry ### 如何使用 Dry 监控 Docker 你可以在 dry 的界面中按下 `m` 键打开监控模式。 + ![][13] ### 如何使用 Dry 管理容器 -在选中的容器上单击 `Enter` 键,即可管理容器。Dry 提供如下操作:查看日志,查看、杀死、删除容器,停止、启动、重启容器,查看容器状态及镜像历史记录等。 +在选中的容器上单击回车键,即可管理容器。Dry 提供如下操作:查看日志,查看、杀死、删除容器,停止、启动、重启容器,查看容器状态及镜像历史记录等。 + ![][14] ### 如何监控容器资源利用率 用户可以使用 `Stats+Top` 选项查看指定容器的资源利用率。 -该操作需要在容器管理界面完成(在上一步的基础上,点击 `Stats+Top` 选项)。另外,也可以按下 `s` 打开容器资源利用率界面。 +该操作需要在容器管理界面完成(在上一步的基础上,点击 `Stats+Top` 选项)。另外,也可以按下 `s` 打开容器资源利用率界面。 ![][15] @@ -100,35 +103,39 @@ $ dry 可以使用 `F8` 键查看容器、镜像及本地卷的磁盘使用情况。 该界面明确地给出容器、镜像和卷的总数,哪些处于使用状态,以及整体磁盘使用情况、可回收空间大小的详细信息。 + ![][16] ### 如何查看已下载的镜像 按下 `2` 键即可列出全部的已下载镜像。 + ![][17] ### 如何查看网络列表 按下 `3` 键即可查看全部网络及网关。 + ![][18] ### 如何查看全部 Docker 容器 按下 `F2` 键即可列出列出全部容器,包括运行中和已关闭的容器。 + ![][19] ### Dry 快捷键 -查看帮助页面或 [dry github][1] 即可查看全部快捷键。 +查看帮助页面或 [dry GitHub][1] 即可查看全部快捷键。 -------------------------------------------------------------------------------- via: https://www.2daygeek.com/dry-an-interactive-cli-manager-for-docker-containers/ 作者:[Magesh Maruthamuthu][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 3f839ef90efd1749690b7581f06ab016b3e43246 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 22:07:28 +0800 Subject: [PATCH 0799/1057] PUB:20180320 Dry - An Interactive CLI Manager For Docker Containers.md @pinewall https://linux.cn/article-9615-1.html --- ...0320 Dry - An Interactive CLI Manager For Docker Containers.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180320 Dry - An Interactive CLI Manager For Docker Containers.md (100%) diff --git a/translated/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md b/published/20180320 Dry - An Interactive CLI Manager For Docker Containers.md similarity index 100% rename from translated/tech/20180320 Dry - An Interactive CLI Manager For Docker Containers.md rename to published/20180320 Dry - An Interactive CLI Manager For Docker Containers.md From dcf1489c95cf852730b16310435852efc601ac45 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 22:20:32 +0800 Subject: [PATCH 0800/1057] PRF:20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md @geekpi --- ...ual machine snapshot with virsh command.md | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/translated/tech/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md b/translated/tech/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md index bf8744918d..d30177c34f 100644 --- a/translated/tech/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md +++ b/translated/tech/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md @@ -1,24 +1,26 @@ 如何使用 virsh 命令创建、还原和删除 KVM 虚拟机快照 ====== -[![KVM-VirtualMachine-Snapshot][1]![KVM-VirtualMachine-Snapshot][2]][2] -在虚拟化平台上进行系统管理工作时经常在开始主要活动比如部署补丁和代码前先设置一个虚拟机快照。 +![KVM-VirtualMachine-Snapshot][2] + +在虚拟化平台上进行系统管理工作时,经常需要在开始重大操作比如部署补丁和代码前先设置一个虚拟机快照snapshot。 虚拟机**快照**是特定时间点的虚拟机磁盘的副本。换句话说,快照保存了给定的时间点虚拟机的状态和数据。 ### 我们可以在哪里使用虚拟机快照? -如果你在使用基于 **KVM** 的**虚拟机管理程序**,那么可以使用 virsh 命令获取虚拟机或域快照。快照在一种情况下变得非常有用,当你已经在虚拟机上安装或应用了最新的补丁,但是由于某些原因,虚拟机上的程序变得不稳定,程序团队想要还原所有的更改和补丁。如果你在应用补丁之前设置了虚拟机的快照,那么可以使用快照将虚拟机恢复到之前的状态。 +如果你在使用基于 **KVM** 的**虚拟机管理程序**,那么可以使用 `virsh` 命令获取虚拟机或域快照。快照在一种情况下变得非常有用,当你已经在虚拟机上安装或应用了最新的补丁,但是由于某些原因,虚拟机上的程序变得不稳定,开发团队想要还原所有的更改和补丁。如果你在应用补丁之前设置了虚拟机的快照,那么可以使用快照将虚拟机恢复到之前的状态。 + +**注意:**我们只能对磁盘格式为 **Qcow2** 的虚拟机的进行快照,并且 kvm 的 `virsh` 命令不支持 raw 磁盘格式,请使用以下命令将原始磁盘格式转换为 qcow2。 -**注意:**我们只能设置磁盘格式为 **Qcow2** 的虚拟机的快照,并且 kvm virsh 命令不支持 raw 磁盘格式,请使用以下命令将原始磁盘格式转换为 qcow2。 ``` # qemu-img convert -f raw -O qcow2 image-name.img image-name.qcow2 - ``` ### 创建 KVM 虚拟机(域)快照 -我假设 KVM 管理程序已经在 CentOS 7 / RHEL 7 机器上配置好了,并且有虚拟机正在运行。我们可以使用下面的 virsh 命令列出虚拟机管理程序中的所有虚拟机, +我假设 KVM 管理程序已经在 CentOS 7 / RHEL 7 机器上配置好了,并且有虚拟机正在运行。我们可以使用下面的 `virsh` 命令列出虚拟机管理程序中的所有虚拟机, + ``` [root@kvm-hypervisor ~]# virsh list --all  Id    Name                           State @@ -29,35 +31,33 @@  103   overcloud-compute1             running  114   webserver                      running  115   Test-MTN                       running -[root@kvm-hypervisor ~]# - ``` -假设我们想创建 ‘ **webserver** ‘ 虚拟机的快照,运行下面的命令, +假设我们想创建 webserver 虚拟机的快照,运行下面的命令, **语法:** ``` # virsh snapshot-create-as –domain {vm_name} –name {snapshot_name} –description “enter description here” ``` + ``` [root@kvm-hypervisor ~]# virsh snapshot-create-as --domain webserver --name webserver_snap --description "snap before patch on 4Feb2018" Domain snapshot webserver_snap created -[root@kvm-hypervisor ~]# - ``` -创建快照后,我们可以使用下面的命令列出与虚拟机相关的快照, +创建快照后,我们可以使用下面的命令列出与虚拟机相关的快照: + ``` [root@kvm-hypervisor ~]# virsh snapshot-list webserver  Name                 Creation Time             State ------------------------------------------------------------  webserver_snap       2018-02-04 15:05:05 +0530 running [root@kvm-hypervisor ~]# - ``` -要列出虚拟机快照的详细信息,请运行下面的 virsh 命令, +要列出虚拟机快照的详细信息,请运行下面的 `virsh` 命令: + ``` [root@kvm-hypervisor ~]# virsh snapshot-info --domain webserver --snapshotname webserver_snap Name:           webserver_snap @@ -69,50 +69,44 @@ Parent:         - Children:       0 Descendants:    0 Metadata:       yes -[root@kvm-hypervisor ~]# - ``` -我们可以使用下面的 qemu-img 命令查看快照的大小, +我们可以使用下面的 `qemu-img` 命令查看快照的大小: + ``` [root@kvm-hypervisor ~]# qemu-img info /var/lib/libvirt/images/snaptestvm.img - ``` -[![qemu-img-command-output-kvm][1]![qemu-img-command-output-kvm][3]][3] +![qemu-img-command-output-kvm][3] ### 还原 KVM 虚拟机快照 -假设我们想要将 webserver 虚拟机还原到我们在上述步骤中创建的快照。使用下面的 virsh 命令将 Webserver 虚拟机恢复到其快照 “**webserver_snap**” 上。 +假设我们想要将 webserver 虚拟机还原到我们在上述步骤中创建的快照。使用下面的 `virsh` 命令将 Webserver 虚拟机恢复到其快照 webserver_snap 时。 **语法:** ``` # virsh snapshot-revert {vm_name} {snapshot_name} ``` + ``` [root@kvm-hypervisor ~]# virsh snapshot-revert webserver webserver_snap -[root@kvm-hypervisor ~]# - ``` ### 删除 KVM 虚拟机快照 -要删除 KVM 虚拟机快照,首先使用 “**virsh snapshot-list**” 命令获取虚拟机的快照详细信息,然后使用 “**virsh snapshot-delete**” 命令删除快照。如下示例所示: +要删除 KVM 虚拟机快照,首先使用 `virsh snapshot-list` 命令获取虚拟机的快照详细信息,然后使用 `virsh snapshot-delete` 命令删除快照。如下示例所示: + ``` [root@kvm-hypervisor ~]# virsh snapshot-list --domain webserver  Name                 Creation Time             State ------------------------------------------------------------  webserver_snap       2018-02-04 15:05:05 +0530 running -[root@kvm-hypervisor ~]# - [root@kvm-hypervisor ~]# virsh snapshot-delete --domain webserver --snapshotname webserver_snap Domain snapshot webserver_snap deleted -[root@kvm-hypervisor ~]# - ``` -这就是本文的全部内容,我希望你们能够了解如何使用 virsh 命令来管理 KVM 虚拟机快照。请分享你的反馈,并不要犹豫地分享给你的技术朋友🙂 +这就是本文的全部内容,我希望你们能够了解如何使用 `virsh` 命令来管理 KVM 虚拟机快照。请分享你的反馈,并不要犹豫地分享给你的技术朋友🙂 -------------------------------------------------------------------------------- @@ -120,7 +114,7 @@ via: https://www.linuxtechi.com/create-revert-delete-kvm-virtual-machine-snapsho 作者:[Pradeep Kumar][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 f789b38addb97613eb8ab4318cd23e07598061d3 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 22:20:49 +0800 Subject: [PATCH 0801/1057] PUB:20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md @geekpi --- ... and Delete KVM Virtual machine snapshot with virsh command.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md (100%) diff --git a/translated/tech/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md b/published/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md similarity index 100% rename from translated/tech/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md rename to published/20180205 How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command.md From 45d40c7b14be24339f1af662ca4d8b6b1e511612 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 22:56:45 +0800 Subject: [PATCH 0802/1057] PRF:20180403 Why I love ARM and PowerPC.md @kennethXia --- .../20180403 Why I love ARM and PowerPC.md | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/translated/tech/20180403 Why I love ARM and PowerPC.md b/translated/tech/20180403 Why I love ARM and PowerPC.md index c92ba36b19..60ed069e36 100644 --- a/translated/tech/20180403 Why I love ARM and PowerPC.md +++ b/translated/tech/20180403 Why I love ARM and PowerPC.md @@ -1,30 +1,33 @@ -为啥我喜欢 ARM 和 PowerPC +为什么我喜欢 ARM 和 PowerPC? ====== +> 一个学生在搜寻强劲而节能的工作站的历程中怎样对开源系统的热情与日俱增的。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) -最近我被问起为啥在博客和推特里经常提到 [ARM][1] 和 [PowerPC][2]。我有两个答案:一个是个人原因,另一个是技术上的。 + +最近我被问起为什么在博客和推特里经常提到 [ARM][1] 和 [PowerPC][2]。我有两个答案:一个是个人原因,另一个是技术上的。 ### 个人原因 -从前,我是学环境保护的。在我读博的时候,我准备买个新电脑。作为一个环保人士,我需要一台强劲且环保的电脑。这就是我开始对 PowerPC 感兴趣的原因,我找到了 [Pegasos][3], 一台 [Genesi][4] 公司制造的 PowerPC 工作站。 +从前,我是学环境保护的。在我读博的时候,我准备买个新电脑。作为一个环保人士,我需要一台强劲且节能的电脑。这就是我开始对 PowerPC 感兴趣的原因,我找到了 [Pegasos][3],这是一台 [Genesi][4] 公司制造的 PowerPC 工作站。 -我还用过 [RS/6000][5] (PowerPC), [SGI][6] (MIPS), [HP-UX][7] (PA-RISC),和[VMS][8] (Alpha)的服务器和工作站,由于我的 PC 使用 Linux 而非 Windows,所以使用不同的 CPU 架构对我来说并没有什么区别。 [Pegasos][9] 是我第一台工作站,它很小而且对家用来说性能足够。 +我还用过 [RS/6000][5] (PowerPC)、 [SGI][6] (MIPS)、 [HP-UX][7] (PA-RISC)和 [VMS][8] (Alpha)的服务器和工作站,由于我的 PC 使用 Linux 而非 Windows,所以使用不同的 CPU 架构对我来说并没有什么区别。 [Pegasos][9] 是我第一台工作站,它小型而节能而且对家用来说性能足够。 -很快我就开始为 Genesi 工作,为 Pegasos 移植 [openSUSE][10], Ubuntu 和其他 Linux 发行版,并提供质量保证和社区支持。继 Pegasos 之后是 [EFIKA][11],另一款基于 PowerPC 的开发板。在用过工作站之后,刚开始使用嵌入式系统会感觉有点奇怪。但是作为第一代普及价位的开发板,这是一场革命的开端。 +很快我就开始为 Genesi 工作,为 Pegasos 移植 [openSUSE][10]、 Ubuntu 和其他 Linux 发行版,并提供质量保证和社区支持。继 Pegasos 之后是 [EFIKA][11],这是另一款基于 PowerPC 的开发板。在用过工作站之后,刚开始使用嵌入式系统会感觉有点奇怪。但是作为第一代普及价位的开发板,这是一场革命的开端。 -在我收到 Genesi 的另一块有趣的开发板的时候,我开始了一个大规模的服务器项目:基于 ARM 的 [Smarttop][12] 和 [Smartbook][13]。我最喜欢的 Linux 发行版————openSUSE,也收到了一打这种机器。这在当时 ARM 电脑非常稀缺的情况下,极大地促进了 ARM 版 openSUSE 项目的开发。 +我工作于一个大规模的服务器项目时,我收到 Genesi 的另一块有趣的开发板:基于 ARM 的 [Smarttop][12] 和 [Smartbook][13]。我最喜欢的 Linux 发行版——openSUSE,也收到了一打这种机器。这在当时 ARM 电脑非常稀缺的情况下,极大地促进了 ARM 版 openSUSE 项目的开发。 -尽管最近我很忙,我尽量保持对 ARM 和 PowerPC 新闻的关注。这有助于我支持非 x86 平台上的 SysLog-NG 用户。只要有半个小时的空,我就会去捣鼓一下 ARM 机器。我在[树莓派2][14]上做了很多 [syslog-ng][15] 的测试,结果令人振奋。我最近在树莓派上做了个音乐播放器,用了一块 USB 声卡和[音乐播放守护进程][17],我经常使用它。 +尽管最近我很忙,我尽量保持对 ARM 和 PowerPC 新闻的关注。这有助于我支持非 x86 平台上的 syslog-ng 用户。只要有半个小时的空,我就会去捣鼓一下 ARM 机器。我在[树莓派2][14]上做了很多 [syslog-ng][15] 的测试,结果令人振奋。我最近在树莓派上做了个音乐播放器,用了一块 USB 声卡和[音乐播放守护进程][17],我经常使用它。 ### 技术方面 美好的多样性:它创造了竞争,而竞争创造了更好的产品。虽然 x86 是一款强劲的通用处理器,但 ARM 和 PowerPC (以及许多其他)这样的芯片在多种特定场景下显得更适合。 -如果你有一部运行[安卓][18]的移动设备或者[苹果][19]的 iPhone 或 iPad,极有可能它使用的就是 基于ARM 的 SoC (片上系统)。网络存储服务器也一样。原因很简单:省电。你不会希望手机一直在充电,也不想为你的路由器付更多的电费。 +如果你有一部运行[安卓][18]的移动设备或者[苹果][19]的 iPhone 或 iPad,极有可能它使用的就是基于ARM 的 SoC (片上系统)。网络存储服务器也一样。原因很简单:省电。你不会希望手机一直在充电,也不想为你的路由器付更多的电费。 -ARM 亦在使用 64-bit ARMv8 芯片征战服务器市场。很多任务只需要极少的计算能力,另一方面省电和快速IO才是关键,比如思维存储(译者注:原文为 think storage),静态网页服务器,电子邮件和其他网络/存储相关的功能。一个最好的例子就是 [Ceph][20],一个分布式的面向对象文件系统。[SoftIron][21] 就是一个基于 ARMv8 开发版,使用 CentOS 作为基准软件,运行在 Ceph 上的完整存储应用。 +ARM 亦在使用 64 位 ARMv8 芯片征战企业级服务器市场。很多任务只需要极少的计算能力,另一方面省电和快速 IO 才是关键,想想存储、静态网页服务器、电子邮件和其他网络/存储相关的功能。一个最好的例子就是 [Ceph][20],一个分布式的面向对象文件系统。[SoftIron][21] 就是一个基于 ARMv8 开发版,使用 CentOS 作为基准软件,运行在 Ceph 上的完整存储应用。 -众所周知 PowerPC 是旧版苹果 [Mac][22] 电脑上的 CPU。虽然它不再作为通用桌面电脑的 CPU ,它依然在路由器和电信设备里发挥作用。而且 [IBM][23] 仍在为高端服务器制造芯片。几年前,随着 Power8 的引入, IBM 在 [OpenPower 基金会][24] 的支持下开放了架构。 Power8 对于关心内存带宽的设备,比如 HPC , 大数据,数据挖掘来说,是非常理想的平台。目前,Power9 也正呼之欲出。 +众所周知 PowerPC 是旧版苹果 [Mac][22] 电脑上的 CPU。虽然它不再作为通用桌面电脑的 CPU ,它依然在路由器和电信设备里发挥作用。而且 [IBM][23] 仍在为高端服务器制造芯片。几年前,随着 Power8 的引入, IBM 在 [OpenPower 基金会][24] 的支持下开放了架构。 Power8 对于关心内存带宽的设备,比如 HPC 、大数据、数据挖掘来说,是非常理想的平台。目前,Power9 也正呼之欲出。 这些都是服务器应用,但也有计划用于终端用户。猛禽工程团队正在开发一款基于 [Power9 的工作站][25],也有一个基于飞思卡尔/恩智浦 QORIQ E6500 芯片[制造笔记本] [26]的倡议。当然,这些电脑并不适合所有人,你不能在它们上面安装 Windows 游戏或者商业应用。但它们对于 PowerPC 开发人员和爱好者,或者任何想要完全开放系统的人来说是理想的选择,因为从硬件到固件到应用程序都是开放的。 @@ -32,7 +35,7 @@ ARM 亦在使用 64-bit ARMv8 芯片征战服务器市场。很多任务只需 我的梦想是完全没有 x86 的环境,不是因为我讨厌 x86 ,而是因为我喜欢多样化而且总是希望使用最适合工作的工具。如果你看看猛禽工程网页上的[图][27],根据不同的使用情景, ARM 和 POWER 完全可以代替 x86 。现在,我在笔记本的 x86 虚拟机上编译、打包和测试 syslog-ng。如果能用上足够强劲的 ARMv8 或者 PowerPC 电脑,无论工作站还是服务器,我就能避免在 x86 上做这些事。 -现在我正在等待下一代[菠萝本][28]的到来,就像我在二月份 [FOSDEM][29] 上说的,下一代有望提供更高的性能。和 Chrome 本不同的是,这个 ARM 笔记本设计用于运行 Linux 而非仅是个客户端(译者注:Chrome 笔记本只提供基于网页的应用)。作为桌面系统,我在寻找 ARMv8 工作站级别的硬件。有些已经接近完成——就像 Avantek 公司的 [雷神X 台式机][30]——不过他们还没有装备最新最快最重要也最节能的 ARMv8 CPU。当这些都实现了,我将用我的 Pixel C 笔记本运行安卓。它不像 Linux 那样简单灵活,但它以强大的 ARM SoC 和 Linux 内核为基础。 +现在我正在等待下一代[菠萝本][28]的到来,就像我在二月份 [FOSDEM][29] 上说的,下一代有望提供更高的性能。和 Chrome 本不同的是,这个 ARM 笔记本设计用于运行 Linux 而非仅是个客户端(LCTT 译注:Chrome 笔记本只提供基于网页的应用)。作为桌面系统,我在寻找 ARMv8 工作站级别的硬件。有些已经接近完成——就像 Avantek 公司的 [雷神 X 台式机][30]——不过他们还没有装备最新最快最重要也最节能的 ARMv8 CPU。当这些都实现了,我将用我的 Pixel C 笔记本运行安卓。它不像 Linux 那样简单灵活,但它以强大的 ARM SoC 和 Linux 内核为基础。 -------------------------------------------------------------------------------- @@ -40,7 +43,7 @@ via: https://opensource.com/article/18/4/why-i-love-arm-and-powerpc 作者:[Peter Czanik][a] 译者:[kennethXia](https://github.com/kennethXia) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e09d695bc7312d27cfccf5db5b3ea3f972333971 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 22:57:56 +0800 Subject: [PATCH 0803/1057] PUB: 20180403 Why I love ARM and PowerPC.md @kennethXia https://linux.cn/article-9617-1.html --- .../tech => published}/20180403 Why I love ARM and PowerPC.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180403 Why I love ARM and PowerPC.md (100%) diff --git a/translated/tech/20180403 Why I love ARM and PowerPC.md b/published/20180403 Why I love ARM and PowerPC.md similarity index 100% rename from translated/tech/20180403 Why I love ARM and PowerPC.md rename to published/20180403 Why I love ARM and PowerPC.md From 89a6ee610d2e102ae2929366b0943bd945dc5de8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 23:37:16 +0800 Subject: [PATCH 0804/1057] PRF:20180416 4 cool new projects to try in COPR for April.md @geekpi --- ...l new projects to try in COPR for April.md | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/translated/tech/20180416 4 cool new projects to try in COPR for April.md b/translated/tech/20180416 4 cool new projects to try in COPR for April.md index 518020ccc7..3536925896 100644 --- a/translated/tech/20180416 4 cool new projects to try in COPR for April.md +++ b/translated/tech/20180416 4 cool new projects to try in COPR for April.md @@ -1,10 +1,11 @@ -4 月 COPR 中 4 个新的酷项目 +4 月 COPR 中的 4 个新酷项目 ====== ![](https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg) -COPR 是一个人仓库[收集][1],它不在 Fedora 中运行。某些软件不符合易于打包的标准。或者它可能不符合其他 Fedora 标准,尽管它是免费且开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 基础设施支持或项目签名。但是,它可能是尝试新软件或实验软件的一种很好的方式。 -这是 COPR 中一系列新的和有趣的项目。 +COPR 是一个个人软件仓库[集合][1],它包含 Fedora 所没有提供的软件。这些软件或不符合易于打包的标准,或者它可能不符合其他 Fedora 标准,尽管它是自由且开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件并没有得到 Fedora 基础设施支持,也没有由该项目背书。但是,它可能是尝试新软件或实验软件的一种很好的方式。 + +这是 COPR 中一些新的和有趣的项目。 ### Anki @@ -17,28 +18,28 @@ COPR 是一个人仓库[收集][1],它不在 Fedora 中运行。某些软件 #### 安装说明 仓库目前为 Fedora 27、28 和 Rawhide 提供 Anki。要安装 Anki,请使用以下命令: + ``` sudo dnf copr enable thomasfedb/anki sudo dnf install anki - ``` ### Fd -[Fd][5] 是一个命令行工具,它是简单而稍快的替代 [find][6] 的方法。它可以并行地查找项目。fd 也使用彩色输出,并默认忽略隐藏文件和 .gitignore 中指定模式的文件。 +[Fd][5] 是一个命令行工具,它是简单而稍快的替代 [find][6] 的方法。它可以并行地查找项目。fd 也使用彩色输出,并默认忽略隐藏文件和 `.gitignore` 中指定模式的文件。 #### 安装说明 -仓库目前为 Fedora 26、27、28 和 Rawhide 提供 fd。要安装 fd,请使用以下命令: +仓库目前为 Fedora 26、27、28 和 Rawhide 提供 `fd`。要安装 fd,请使用以下命令: + ``` sudo dnf copr enable keefle/fd sudo dnf install fd - ``` ### KeePass -[KeePass][7]是一个密码管理器。它将所有密码保存在一个由主密钥或密钥文件锁定的端对端加密数据库中。密码可以组织成组并由程序的内置生成器生成。其他功能包括自动输入,它可以为选定的表单输入用户名和密码。 +[KeePass][7] 是一个密码管理器。它将所有密码保存在一个由主密钥或密钥文件锁定的端对端加密数据库中。密码可以组织成组并由程序的内置生成器生成。其他功能包括自动输入,它可以为选定的表单输入用户名和密码。 虽然 KeePass 已经在 Fedora 中,但这个仓库提供了最新版本。 @@ -47,10 +48,10 @@ sudo dnf install fd #### 安装说明 仓库目前为 Fedora 26 和 27 提供 KeePass。要安装 KeePass,请使用以下命令: + ``` sudo dnf copr enable mavit/keepass sudo dnf install keepass - ``` ### jo @@ -60,10 +61,10 @@ sudo dnf install keepass #### 安装说明 目前,仓库为 Fedora 26、27 和 Rawhide 以及 EPEL 6 和 7 提供 jo。要安装 jo,请使用以下命令: + ``` sudo dnf copr enable ganto/jo sudo dnf install jo - ``` @@ -72,9 +73,9 @@ sudo dnf install jo via: https://fedoramagazine.org/4-try-copr-april-2018/ 作者:[Dominik Turecek][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/wy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c0289e475c561081b71b79d2fac25fa8a132037d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 7 May 2018 23:37:39 +0800 Subject: [PATCH 0805/1057] PUB:20180416 4 cool new projects to try in COPR for April.md @geekpi --- .../20180416 4 cool new projects to try in COPR for April.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180416 4 cool new projects to try in COPR for April.md (100%) diff --git a/translated/tech/20180416 4 cool new projects to try in COPR for April.md b/published/20180416 4 cool new projects to try in COPR for April.md similarity index 100% rename from translated/tech/20180416 4 cool new projects to try in COPR for April.md rename to published/20180416 4 cool new projects to try in COPR for April.md From 2755b6c17296d51858fa2237cea08cfa11e800c9 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 8 May 2018 08:38:18 +0800 Subject: [PATCH 0806/1057] translated --- .../tech/20180427 How to use FIND in Linux.md | 92 ------------------- .../tech/20180427 How to use FIND in Linux.md | 88 ++++++++++++++++++ 2 files changed, 88 insertions(+), 92 deletions(-) delete mode 100644 sources/tech/20180427 How to use FIND in Linux.md create mode 100644 translated/tech/20180427 How to use FIND in Linux.md diff --git a/sources/tech/20180427 How to use FIND in Linux.md b/sources/tech/20180427 How to use FIND in Linux.md deleted file mode 100644 index 42da1784de..0000000000 --- a/sources/tech/20180427 How to use FIND in Linux.md +++ /dev/null @@ -1,92 +0,0 @@ -translating---geekpi - -How to use FIND in Linux -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux31x_cc.png?itok=Pvim4U-B) - -In [a recent Opensource.com article][1], Lewis Cowles introduced the `find` command. - -`find` is one of the more powerful and flexible command-line programs in the daily toolbox, so it's worth spending a little more time on it. - -At a minimum, `find` takes a path to find things. For example: -``` -find / - -``` - -will find (and print) every file on the system. And since everything is a file, you will get a lot of output to sort through. This probably doesn't help you find what you're looking for. You can change the path argument to narrow things down a bit, but it's still not really any more helpful than using the `ls` command. So you need to think about what you're trying to locate. - -Perhaps you want to find all the JPEG files in your home directory. The `-name` argument allows you to restrict your results to files that match the given pattern. -``` -find ~ -name '*jpg' - -``` - -But wait! What if some of them have an uppercase extension? `-iname` is like `-name`, but it is case-insensitive. -``` -find ~ -iname '*jpg' - -``` - -Great! But the 8.3 name scheme is so 1985. Some of the pictures might have a .jpeg extension. Fortunately, we can combine patterns with an "or," represented by `-o`. -``` -find ~ ( -iname 'jpeg' -o -iname 'jpg' ) - -``` - -We're getting closer. But what if you have some directories that end in jpg? (Why you named a directory `bucketofjpg` instead of `pictures` is beyond me.) We can modify our command with the `-type` argument to look only for files. -``` -find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f - -``` - -Or maybe you'd like to find those oddly named directories so you can rename them later: -``` -find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type d - -``` - -It turns out you've been taking a lot of pictures lately, so let's narrow this down to files that have changed in the last week. -``` -find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f -mtime -7 - -``` - -`ctime`), modification time (`mtime`), or access time (`atime`). These are in days, so if you want finer-grained control, you can express it in minutes instead (`cmin`, `mmin`, and `amin`, respectively). Unless you know exactly the time you want, you'll probably prefix the number with `+` (more than) or `–` (less than). - -You can do time filters based on file status change time (), modification time (), or access time (). These are in days, so if you want finer-grained control, you can express it in minutes instead (, and, respectively). Unless you know exactly the time you want, you'll probably prefix the number with(more than) or(less than). - -But maybe you don't care about your pictures. Maybe you're running out of disk space, so you want to find all the gigantic (let's define that as "greater than 1 gigabyte") files in the `log` directory: -``` -find /var/log -size +1G - -``` - -Or maybe you want to find all the files owned by bcotton in `/data`: -``` -find /data -owner bcotton - -``` - -You can also look for files based on permissions. Perhaps you want to find all the world-readable files in your home directory to make sure you're not oversharing. -``` -find ~ -perm -o=r - -``` - -This post only scratches the surface of what `find` can do. Combining tests with Boolean logic can give you incredible flexibility to find exactly the files you're looking for. And with arguments like `-exec` or `-delete`, you can have `find` take action on what it... finds. Have any favorite `find` expressions? Share them in the comments! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/how-use-find-linux - -作者:[Ben Cotton][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/bcotton -[1]:https://opensource.com/article/18/4/how-find-files-linux diff --git a/translated/tech/20180427 How to use FIND in Linux.md b/translated/tech/20180427 How to use FIND in Linux.md new file mode 100644 index 0000000000..1fcbd9b766 --- /dev/null +++ b/translated/tech/20180427 How to use FIND in Linux.md @@ -0,0 +1,88 @@ +如何在 Linux 中使用 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` 命令。 + +`find` 是日常工具箱中功能更强大、更灵活的命令行工具之一,因此值得花费更多的时间。 + +最简单的,`find` 跟上路径寻找一些东西。例如: +``` +find / + +``` + +它将找到(并打印)系统中的每个文件。而且由于一切都是文件,你会得到很多输出需要排序。这可能不会帮助你找到你要找的东西。你可以改变路径参数来缩小范围,但它不会比使用 `ls` 命令更有帮助。所以你需要考虑你想要找的东西。 + +也许你想在主目录中找到所有的 JPEG 文件。 `-name` 参数允许你将结果限制为与给定模式匹配的文件。 +``` +find ~ -name '*jpg' + +``` + +可是等等!如果它们中的一些是大写的扩展名会怎么样?`-iname` 就像 `-name`,但是不区分大小写。 +``` +find ~ -iname '*jpg' + +``` + +很好!但是 8.3 名称方案是如此的老。一些图片可能是 .jpeg 扩展名。幸运的是,我们可以将模式用 “or” 表示为 `-o`,来组合。 +``` +find ~ ( -iname 'jpeg' -o -iname 'jpg' ) + +``` + +我们正在接近。但是如果你有一些以 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`)。 除非你确切地知道你想要的时间,否则你可能会在 + (大于)或 - (小于)的后面加上数字。 + +但也许你不关心你的照片。也许你的磁盘空间不够用,所以你想在 `log` 目录下找到所有巨大的(让我们定义为“大于 1GB”)文件: +``` +find /var/log -size +1G + +``` + +或者,也许你想在 `/ data` 中找到 bcotton 拥有的所有文件: +``` +find /data -owner bcotton + +``` + +你还可以根据权限查找文件。也许你想在你的主目录中找到对所有人可读的文件,以确保你不会过度分享。 +``` +find ~ -perm -o=r + +``` + +这篇文章只说了 `find` 能做什么的表面。将测试与布尔逻辑相结合可以为你提供难以置信的灵活性,以便准确找到要查找的文件。并且像 `-exec` 或 `-delete` 这样的参数,你可以让 `find` 对它发现的内容采取行动。你有任何最喜欢的 `find` 表达式么?在评论中分享它们! + +-------------------------------------------------------------------------------- + +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) + +本文由 [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 From a96139af6b12b71f434607dfdc22788c495be96e Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 8 May 2018 08:41:00 +0800 Subject: [PATCH 0807/1057] translating --- .../tech/20180503 How to build container images with Buildah.md | 2 ++ 1 file changed, 2 insertions(+) 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 index c18d14f322..9c1489f120 100644 --- a/sources/tech/20180503 How to build container images with Buildah.md +++ b/sources/tech/20180503 How to build container images with Buildah.md @@ -1,3 +1,5 @@ +translating---geekpi + How to build container images with Buildah ====== From 905abbd5b0301e5da77d243e1c43b7c519f26a9c Mon Sep 17 00:00:00 2001 From: icecoobe Date: Tue, 8 May 2018 13:36:29 +0800 Subject: [PATCH 0808/1057] icecoobe translating --- sources/tech/20180427 How to Compile a Linux Kernel.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180427 How to Compile a Linux Kernel.md b/sources/tech/20180427 How to Compile a Linux Kernel.md index cc71b7fbae..47f26a90eb 100644 --- a/sources/tech/20180427 How to Compile a Linux Kernel.md +++ b/sources/tech/20180427 How to Compile a Linux Kernel.md @@ -1,3 +1,5 @@ +icecoobe translating + How to Compile a Linux Kernel ====== From 4e029224f27810037a996b67697cf72d0f69e5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= Date: Tue, 8 May 2018 19:02:45 +0800 Subject: [PATCH 0809/1057] 2018-03-31 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bottom line interpreted in English meaning 2018-4-2 2018-04-02 2018-04-04 2018-04-05 2018-04-06 2018-04-07 2018-04-08 2018-04-09 2018-04-10 "in the wild" refers to "release to public after development" 2018-04-12 2018-04-13 2018-04-14 2018-04-15 2018-04-16 2018-04-17 Security by Obscurity 2018-04-19 2018-04-20 2018-04-21 done ahead due to cold 2018-04-22 2018-04-24.Eve 2018-04-25 2018-04-26 2018-04-30 what is slipping in the wild? 2018-5-2 2018-05-02 2018-05-03 confusing translation of a long sentence what really fucking sentence means? the end 可恶的最后一段还有斯诺登人名中间那个点打不出来啊 self check second check last check terminated check move files --- ...tter than Windows or macOS for security.md | 104 ----------------- ...tter than Windows or macOS for security.md | 105 ++++++++++++++++++ 2 files changed, 105 insertions(+), 104 deletions(-) delete mode 100644 sources/talk/20180206 Why Linux is better than Windows or macOS for security.md create mode 100644 translated/talk/20180206 Why Linux is better than Windows or macOS for security.md diff --git a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md b/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md deleted file mode 100644 index 7ff2effe28..0000000000 --- a/sources/talk/20180206 Why Linux is better than Windows or macOS for security.md +++ /dev/null @@ -1,104 +0,0 @@ -fuzheng1998 translating - -为什么 Linux 比 Windows 和 macOS 的安全性好 -====== - -![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg) - -企业投入了大量时间、精力和金钱来保障系统的安全性。安全意识最强的可能就是有一个安全的运转中心。他们肯定用了防火墙以及反病毒软件。他们也可能花费大量时间监控网络,寻找可能违约的泄密异常。 What with IDS, SIEM and NGFWs, they deploy a veritable alphabet of defenses. - -然而又有多少人想过数字化操作的基石之一:就是部署在员工的个人电脑上的操作系统?选择桌面操作系统时安全性是一个考虑因素吗? - -这就产生了一个 IT 人士都应该能回答的问题:哪种操作系统对于一般性使用最安全呢? - -我们问了一些专家他们对于以下三种选项的看法:Windows, 最复杂的平台也是最易受欢迎的桌面操作系统;macOS X,基于 FreeBSD 的 Unix 操作系统,驱动着苹果的 Macintosh 系列机运行;还有 Linux,这里我们指的是所有的 Linux 发行版以及与基于 Unix 的操作系统相关的系统。 - -### 我们怎么会这样How we got here - -One reason enterprises might not have evaluated the security of the OS they deployed to the workforce is that they made the choice years ago. Go back far enough and all operating systems were reasonably safe, because the business of hacking into them and stealing data or installing malware was in its infancy. And once an OS choice is made, it’s hard to consider a change. Few IT organizations would want the headache of moving a globally dispersed workforce to an entirely new OS. Heck, they get enough pushback when they move users to a new version of their OS of choice. - -Still, would it be wise to reconsider? Are the three leading desktop OSes different enough in their approach to security to make a change worthwhile? - -当然商业系统面临的威胁近几年已经改变了。攻击变得成熟多了。The lone teen hacker that once dominated the public imagination has been supplanted by well-organized networks of criminals and shadowy, government-funded organizations with vast computing resources. - -想你们许多人一样,我已经有了很多那儿的亲身经历:我曾经在许多 Windows 电脑上被恶意软件和病毒感染,我甚至被 Mac 文件的宏病毒感染了。 More recently, a widespread automated hack circumvented the security on my website and infected it with malware. The effects of such malware were always initially subtle, something you wouldn’t even notice, until the malware ended up so deeply embedded in the system that performance started to suffer noticeably. One striking thing about the infestations was that I was never specifically targeted by the miscreants; nowadays, it’s as easy to attack 100,000 computers with a botnet as it is to attack a dozen. - -### 操作系统真的重要吗?Does the OS really matter? - -给你的用户部署的那个操作系统确实对你的安全态度产生了影响,但那并不是一个可靠的安全措施For one thing, a breach these days is more likely to come about because an attacker probed your users, not your systems. A [survey][1] of hackers who attended a recent DEFCON conference revealed that “84 percent use social engineering as part of their attack strategy.” Deploying a secure operating system is an important starting point, but without user education, strong firewalls and constant vigilance, even the most secure networks can be invaded. And of course there’s always the risk of user-downloaded software, extensions, utilities, plug-ins and other software that appears benign but becomes a path for malware to appear on the system. - -无论你选择哪种平台,保持你系统安全最好的方法之一就是确保立即应用了软件更新。Once a patch is in the wild, after all, the hackers can reverse engineer it and find a new exploit they can use in their next wave of attacks. - -而且别忘了最基本的。别用 root 权限,别授权用户连接到网络中的老服务器上。教你的用户如何挑选一个真正的好密码并且使用例如 [1Password][2] 这样的工具让他们在使用不同密码网站和账户更加简单。 - -Because the bottom line is that every decision you make regarding your systems will affect your security, even the operating system your users do their work on. - -**[ To comment on this story, visit[Computerworld's Facebook page][3]. ]** - -### Windows,流行之选 - -If you’re a security manager, it is extremely likely that the questions raised by this article could be rephrased like so: Would we be more secure if we moved away from Microsoft Windows? To say that Windows dominates the enterprise market is to understate the case. [NetMarketShare][4] estimates that a staggering 88% of all computers on the internet are running a version of Windows. - -If your systems fall within that 88%, you’re probably aware that Microsoft has continued to beef up security in the Windows system. Among its improvements have been rewriting and re-rewriting its operating system codebase, adding its own antivirus software system, improving firewalls and implementing a sandbox architecture, where programs can’t access the memory space of the OS or other applications. - -But the popularity of Windows is a problem in itself. The security of an operating system can depend to a large degree on the size of its installed base. For malware authors, Windows provides a massive playing field. Concentrating on it gives them the most bang for their efforts. -As Troy Wilkinson, CEO of Axiom Cyber Solutions, explains, “Windows always comes in last in the security world for a number of reasons, mainly because of the adoption rate of consumers. With a large number of Windows-based personal computers on the market, hackers historically have targeted these systems the most.” - -It’s certainly true that, from Melissa to WannaCry and beyond, much of the malware the world has seen has been aimed at Windows systems. - -### macOS X 以及用默默无闻换取的安全security through obscurity - -If the most popular OS is always going to be the biggest target, then can using a less popular option ensure security? That idea is a new take on the old — and entirely discredited — concept of “security through obscurity,” which held that keeping the inner workings of software proprietary and therefore secret was the best way to defend against attacks. - -Wilkinson flatly states that macOS X “is more secure than Windows,” but he hastens to add that “macOS used to be considered a fully secure operating system with little chance of security flaws, but in recent years we have seen hackers crafting additional exploits against macOS.” - -In other words, the attackers are branching out and not ignoring the Mac universe. - -Security researcher Lee Muson of Comparitech says that “macOS is likely to be the pick of the bunch” when it comes to choosing a more secure OS, but he cautions that it is not impenetrable, as once thought. Its advantage is that “it still benefits from a touch of security through obscurity versus the still much larger target presented by Microsoft’s offering.” - -Joe Moore of Wolf Solutions gives Apple a bit more credit, saying that “off the shelf, macOS X has a great track record when it comes to security, in part because it isn’t as widely targeted as Windows and in part because Apple does a pretty good job of staying on top of security issues.” - -### 最终胜者是 … - -You probably knew this from the beginning: The clear consensus among experts is that Linux is the most secure operating system. But while it’s the OS of choice for servers, enterprises deploying it on the desktop are few and far between. - -And if you did decide that Linux was the way to go, you would still have to decide which distribution of the Linux system to choose, and things get a bit more complicated there. Users are going to want a UI that seems familiar, and you are going to want the most secure OS. - -As Moore explains, “Linux has the potential to be the most secure, but requires the user be something of a power user.” So, not for everyone. - -Linux distros that target security as a primary feature include [Parrot Linux][5], a Debian-based distro that Moore says provides numerous security-related tools right out of the box. - -Of course, an important differentiator is that Linux is open source. The fact that coders can read and comment upon each other’s work might seem like a security nightmare, but it actually turns out to be an important reason why Linux is so secure, says Igor Bidenko, CISO of Simplex Solutions. “Linux is the most secure OS, as its source is open. Anyone can review it and make sure there are no bugs or back doors.” - -Wilkinson elaborates that “Linux and Unix-based operating systems have less exploitable security flaws known to the information security world. Linux code is reviewed by the tech community, which lends itself to security: By having that much oversight, there are fewer vulnerabilities, bugs and threats.” - -That’s a subtle and perhaps counterintuitive explanation, but by having dozens — or sometimes hundreds — of people read through every line of code in the operating system, the code is actually more robust and the chance of flaws slipping into the wild is diminished. That had a lot to do with why PC World came right out and said Linux is more secure. As Katherine Noyes [explains][6], “Microsoft may tout its large team of paid developers, but it’s unlikely that team can compare with a global base of Linux user-developers around the globe. Security can only benefit through all those extra eyeballs.” - -Another factor cited by PC World is Linux’s better user privileges model: Windows users “are generally given administrator access by default, which means they pretty much have access to everything on the system,” according to Noyes’ article. Linux, in contrast, greatly restricts “root.” - -Noyes also noted that the diversity possible within Linux environments is a better hedge against attacks than the typical Windows monoculture: There are simply a lot of different distributions of Linux available. And some of them are differentiated in ways that specifically address security concerns. Security Researcher Lee Muson of Comparitech offers this suggestion for a Linux distro: “The[Qubes OS][7] is as good a starting point with Linux as you can find right now, with an [endorsement from Edward Snowden][8] massively overshadowing its own extremely humble claims.” Other security experts point to specialized secure Linux distributions such as [Tails Linux][9], designed to run securely and anonymously directly from a USB flash drive or similar external device. - -### 构建安全性的动力Building security momentum - -Inertia is a powerful force. Although there is clear consensus that Linux is the safest choice for the desktop, there has been no stampede to dump Windows and Mac machines in favor of it. Nonetheless, a small but significant increase in Linux adoption would probably result in safer computing for everyone, because in market share loss is one sure way to get Microsoft’s and Apple’s attention. In other words, if enough users switch to Linux on the desktop, Windows and Mac PCs are very likely to become more secure platforms. - --------------------------------------------------------------------------------- - -via: https://www.computerworld.com/article/3252823/linux/why-linux-is-better-than-windows-or-macos-for-security.html - -作者:[Dave Taylor][a] -译者:[fuzheng1998](https://github.com/fuzheng1998) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.computerworld.com/author/Dave-Taylor/ -[1]:https://www.esecurityplanet.com/hackers/fully-84-percent-of-hackers-leverage-social-engineering-in-attacks.html -[2]:http://www.1password.com -[3]:https://www.facebook.com/Computerworld/posts/10156160917029680 -[4]:https://www.netmarketshare.com/operating-system-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22deviceType%22%3A%7B%22%24in%22%3A%5B%22Desktop%2Flaptop%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22platform%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22platformsDesktop%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222017-02%22%2C%22dateEnd%22%3A%222018-01%22%2C%22segments%22%3A%22-1000%22%7D -[5]:https://www.parrotsec.org/ -[6]:https://www.pcworld.com/article/202452/why_linux_is_more_secure_than_windows.html -[7]:https://www.qubes-os.org/ -[8]:https://twitter.com/snowden/status/781493632293605376?lang=en -[9]:https://tails.boum.org/about/index.en.html 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 new file mode 100644 index 0000000000..63735b29a9 --- /dev/null +++ b/translated/talk/20180206 Why Linux is better than Windows or macOS for security.md @@ -0,0 +1,105 @@ +fuzheng1998 translating + +为什么 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 一样,他们部署了一个名副其实的防御字母表。 + +然而又有多少人想过数字化操作的基础之一:部署在员工的个人电脑上的操作系统?选择桌面操作系统的安全性是一个考虑的因素吗? + +这就产生了一个 IT 人士都应该能回答的问题:一般部署哪种操作系统最安全呢? + +我们问了一些专家他们对于以下三种选项的看法:Windows,最复杂的平台也是最受欢迎的桌面操作系统;macOS X,基于 FreeBSD 的 Unix 操作系统,驱动着苹果的 Macintosh 系列运行;还有 Linux,这里我们指的是所有的 Linux 发行版以及与基于 Unix 的操作系统相关的系统。 + +### 我们怎么会这样 + +企业可能没有评估他们部署到工作人员的操作系统的安全性的一个原因是,他们多年前就已经做出了选择。退一步讲,所有操作系统都还算安全,因为侵入他们,窃取数据或安装恶意软件的业务还处于起步阶段。而且一旦选择了操作系统,就很难再想改变。很少有 IT 组织希望将全球分散的员工队伍转移到全新的操作系统上。唉,他们已经受够了把用户搬到一个选好的新版本操作系统时的负面反响。 + +还有,重新考虑它是高明的吗?这三款领先的桌面操作系统在安全方面的差异是否足以值得我们去做出改变呢? + +当然商业系统面临的威胁近几年已经改变了。攻击变得成熟多了。曾经支配了公众想象力的独自的青少年黑客已经被组织良好的犯罪分子网络以及具有庞大计算资源的政府资助组织的网络所取代。 + +像你们许多人一样,我已经有了很多那儿的亲身经历:我曾经在许多 Windows 电脑上被恶意软件和病毒感染,我甚至被 Mac 文件的宏病毒感染了。最近,一个广泛传播的自动黑客绕开了网站的保护程序并用恶意软件感染了它。这种恶意软件的影响一开始是隐形的,甚至有些东西你没注意,直到恶意软件最终深深地植入系统以至于它的性能开始变差。一件有关病毒蔓延的震惊之事是我从未被不法之徒特定针对过;当今世界,用僵尸网络攻击 100,000 台电脑容易得就像一次攻击几台电脑一样。 + +### 操作系统真的很重要吗? + +给你的用户部署的那个操作系统确实对你的安全态度产生了影响,但那并不是一个可靠的安全措施。首先,现在的攻击很可能会发生,因为攻击者探测了你的用户,而不是你的系统。一项对参与过 DEFCON 会议黑客的[调查][1]表明“84%的人使用社交工程作为攻击策略的一部分。”部署安全操作系统只是一个重要的起点,但如果没有用户培训,强大的防火墙和持续的警惕性,即使是最安全的网络也会受到入侵。当然,用户下载的软件,扩展程序,实用程序,插件和其他软件的风险始终良好,但却成为恶意软件出现在系统上的一种途径. + +无论你选择哪种平台,保持你系统安全最好的方法之一就是确保立即应用了软件更新。一旦补丁正式发布,黑客就可以对其进行反向工程并找到一种新的漏洞,以便在下一波攻击中使用。 + +而且别忘了最基本的操作。别用 root 权限,别授权用户连接到网络中的老服务器上。教您的用户如何挑选一个真正的好密码并且使用例如 [1Password][2] 这样的工具,以便在每个他们使用的帐户和网站上拥有不同的密码 + +因为底线是您对系统做出的每一个决定都会影响您的安全性,即使您的用户工作使用的操作系统也是如此。 + +**[ 若要给这个故事写评论, 请访问 [Computerworld's 的 Facebook 主页][3]. ]** + +### Windows,流行之选 + +若你是一个安全管理人员,很可能文章中提出的问题就会变成这样:是否我们远离微软的 Windows 会更安全呢?说 Windows 主导商业市场都是低估事实了。[NetMarketShare][4] 估计互联网上 88% 的电脑令人震惊地运行着 Windows 的版本之一。 + +如果你的系统在这 88% 之中,你可能知道微软会继续加强 Windows 系统的安全性。改进重写了或者重新改写了他的代码库,增加了它的反病毒软件系统,改进了防火墙以及实现了沙箱架构,这样在沙箱里的程序就不能访问系统的内存空间或者其他应用程序。 + +但可能 Windows 的流行本身就是个问题操作系统的安全性可能很大程度上依赖于装机用户量的规模。对于恶意软件作者来说,Windows 提供了大的施展平台。专注其中可以让他们的努力发挥最大作用。 + +像 Troy Wilkinson,Axiom Cyber Solutions 的 CEO 解释的的那样,“Windows 总是因为很多原因安全性保障来的最晚,主要是因为消费者的采用率。由于市场上大量基于 Windows 的个人电脑,黑客历来最有针对性地将这些系统作为目标。” + +可以肯定地说,从梅丽莎病毒到 WannaCry 或者更强的,许多世界上可见的恶意软件早已对准了 Windows 系统. + +### macOS X 以及通过隐匿实现的安全 + +如果最流行的操作系统总是成为大目标,那么用一个不流行的操作系统能确保安全吗?这个主意是老法新用——而且是完全不可信的概念——“通过隐匿实现的安全,” 这保持了软件专有的持续内部运作因此不为人知是抵御攻击的最好方法。 + +Wilkinson 坦言,macOS X “比 Windows 更安全”,但他急于补充说,“macOS 曾被认为是一个安全漏洞很小的完全安全的操作系统,但近年来,我们看到黑客制造了额外的漏洞攻击苹果系统。” + +换句话说,攻击者会扩大活动范围而不会无视 Mac 领域。 + +Comparitech 的安全研究员 Lee Muson 说,在选择更安全的操作系统时,“macOS很可能是被挑选的一员”,但他提醒说,这一想法并不令人费解。它的优势在于“它仍然受益于通过隐匿实现的安全感和微软提供的更大的目标。” + +Wolf Solutions 公司的 Joe Moore 给予了苹果更多的信任,称“现成的 macOS X 在安全方面有着良好的记录,部分原因是它不像 Windows 那么广泛,而且部分原因是苹果公司在安全问题上干的不错。” + +### 最终胜者是 … + +你可能一开始就知道它:专家们的明确共识是 Linux 是最安全的操作系统。然而,尽管它是服务器的首选操作系统,但将其部署在桌面上的企业却很少。 + +如果你确定 Linux 是要选择的系统,你仍然需要决定选择哪种 Linux 系统,并且事情会变得更加复杂。 用户需要一个看起来很熟悉的用户界面,而你需要最安全的操作系统。 + +像 Moore 解释的那样,“Linux 有可能是最安全的,但要求用户是很强大的用户。”所以,它不是针对所有人的。 + +将安全性作为主要功能的 Linux 发行版包括 Parrot Linux,这是一个基于 Debian 的发行版,Moore 说,它提供了许多与安全相关开箱即用的工具。 + +当然,一个重要的区别是 Linux 是开源的。Simplex Solutions 的 CISO Igor Bidenko 说,编码人员可以阅读和评论彼此工作的现实看起来像是一场安全噩梦,但这确实是让 Linux 如此安全的重要原因。 “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”权限。 + +Noyes 还指出,Linux 环境下的多样性可能比典型的 Windows 单一文化更好地对抗攻击:Linux 有很多不同的发行版。其中一些以其特别的安全关注点进行差异化。Comparitech 的安全研究员 Lee Muson 为 Linux 发行版提供了这样的建议:“Qubes OS 对于 Linux 来说是一个很好的出发点,现在你可以发现,爱德华斯诺登的认可大大地掩盖了它自己极其卑劣的主张。”其他安全性专家指向专门的安全 Linux 发行版,如 Tails Linux,它旨在直接从 USB 闪存驱动器或类似的外部设备安全地匿名运行。 + +### 构建安全趋势 + +惯性是一股强大的力量。虽然人们有明确的共识,认为 Linux 是桌面系统的最安全选择,但并没有出现让 Windows 和 Mac 机器倾倒的倾向。尽管如此,Linux 采用率的小幅增长却可能会产生对所有人都更加安全的计算,因为市场份额的丧失是确定能获得微软和苹果公司关注的一个方式。换句话说,如果有足够的用户在桌面上切换到 Linux,Windows 和 Mac PC 很可能成为更安全的平台。 + +-------------------------------------------------------------------------------- + +via: https://www.computerworld.com/article/3252823/linux/why-linux-is-better-than-windows-or-macos-for-security.html + +作者:[Dave Taylor][a] +译者:[fuzheng1998](https://github.com/fuzheng1998) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.computerworld.com/author/Dave-Taylor/ +[1]:https://www.esecurityplanet.com/hackers/fully-84-percent-of-hackers-leverage-social-engineering-in-attacks.html +[2]:http://www.1password.com +[3]:https://www.facebook.com/Computerworld/posts/10156160917029680 +[4]:https://www.netmarketshare.com/operating-system-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22deviceType%22%3A%7B%22%24in%22%3A%5B%22Desktop%2Flaptop%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22platform%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22platformsDesktop%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222017-02%22%2C%22dateEnd%22%3A%222018-01%22%2C%22segments%22%3A%22-1000%22%7D +[5]:https://www.parrotsec.org/ +[6]:https://www.pcworld.com/article/202452/why_linux_is_more_secure_than_windows.html +[7]:https://www.qubes-os.org/ +[8]:https://twitter.com/snowden/status/781493632293605376?lang=en +[9]:https://tails.boum.org/about/index.en.html From b91e2d0ef7b833af21f476da8672b7cc34cf16e9 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 8 May 2018 19:07:53 +0800 Subject: [PATCH 0810/1057] PRF:20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md @MjSeven --- ...ode in the same VM with no code changes.md | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/translated/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md b/translated/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md index 5ffe1a6fc6..58d1df78fe 100644 --- a/translated/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md +++ b/translated/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md @@ -1,4 +1,4 @@ -我们可以在同一个虚拟机中运行 Python 2 和 Python 3 代码而不需要更改代码吗? +我们可以在同一个虚拟机中运行 Python 2 和 3 代码而不需要更改代码吗? ===== 从理论上来说,可以。Zed Shaw 说过一句著名的话,如果不行,那么 Python 3 一定不是图灵完备的。但在实践中,这是不现实的,我将通过给你们举几个例子来说明原因。 @@ -6,9 +6,8 @@ ### 对于字典(dict)来说,这意味着什么? 让我们来想象一台拥有 Python 6 的虚拟机,它可以读取 Python 3.6 编写的 `module3.py`。但是在这个模块中,它可以导入 Python 2.7 编写的 `module2.py`,并成功使用它,没有问题。这显然是实验代码,但假设 `module2.py` 包含以下的功能: + ``` - - def update_config_from_dict(config_dict): items = config_dict.items() while items: @@ -28,14 +27,13 @@ def update_in_place(config_dict): del config_dict[k] elif new_value != v: config_dict[k] = v - ``` -现在,当我们想从 `module3` 中调用这些函数时,我们遇到了一个问题:Python 3.6 中的字典类型与 Python 2.7 中的字典类型不同。在 Python 2 中,dicts 是无序的,它们的 `.keys()`, `.values()`, `.items()` 方法返回了正确的序列,这意味着调用 `.items()` 会在字典中创建状态的副本。在 Python 3 中,这些方法返回字典当前状态的动态视图。 +现在,当我们想从 `module3` 中调用这些函数时,我们遇到了一个问题:Python 3.6 中的字典类型与 Python 2.7 中的字典类型不同。在 Python 2 中,字典是无序的,它们的 `.keys()`, `.values()`, `.items()` 方法返回了正确的序列,这意味着调用 `.items()` 会在字典中创建状态的副本。在 Python 3 中,这些方法返回字典当前状态的动态视图。 这意味着如果 `module3` 调用 `module2.update_config_from_dict(some_dictionary)`,它将无法运行,因为 Python 3 中 `dict.items()` 返回的值不是一个列表,并且没有 `.pop()` 方法。反过来也是如此。如果 `module3` 调用 `module2.config_to_dict()`,它可能会返回一个 Python 2 的字典。现在调用 `.items()` 突然返回一个列表,所以这段代码无法正常工作(这对 Python 3 字典来说工作正常): -``` +``` def main(cmdline_options): d = module2.config_to_dict() items = d.items() @@ -45,7 +43,6 @@ def main(cmdline_options): d[k] = v for k, v in items: print(f'Config with cmdline overrides: {k}={v}') - ``` 最后,使用 `module2.update_in_place()` 会失败,因为 Python 3 中 `.items()` 的值现在不允许在迭代过程中改变。 @@ -54,7 +51,7 @@ def main(cmdline_options): ### Python 应该神奇地知道类型并会自动转换! -为什么拥有 Python 6 的虚拟机无法识别 Python 3 的代码,在 Python 2 中调用 `some_dict.keys()` 时,我们还有别的意思吗?好吧,Python 不知道代码的作者在编写代码时,她所认为的 `some_dict` 应该是什么。代码中没有任何内容表明它是否是一个字典。在 Python 2 中没有类型注释,因为它们是可选的,即使在 Python 3 中,大多数代码也不会使用它们。 +为什么我们的 Python 6 的虚拟机无法识别 Python 3 的代码,在 Python 2 中调用 `some_dict.keys()` 时,我们还有别的意思吗?好吧,Python 不知道代码的作者在编写代码时,她所认为的 `some_dict` 应该是什么。代码中没有任何内容表明它是否是一个字典。在 Python 2 中没有类型注释,因为它们是可选的,即使在 Python 3 中,大多数代码也不会使用它们。 在运行时,当你调用 `some_dict.keys()` 的时候,Python 只是简单地在对象上查找一个属性,该属性恰好隐藏在 `some_dict` 名下,并试图在该属性上运行 `__call__()`。这里有一些关于方法绑定,描述符,slots 等技术问题,但这是它的核心。我们称这种行为为“鸭子类型”。 @@ -62,33 +59,33 @@ def main(cmdline_options): ### 好的,让我们在运行时做出这个决定 -Python 6 的虚拟机可以通过标记每个属性查找来实现这一点,信息是“来自 py2 的调用”或“来自 py3 的调用”,并使对象发送正确的属性。这会让事情变得很慢,并且使用更多的内存。这将要求我们使用用户代码使用的代理将两种版本的给定类型保留在内存中。我们需要将这些对象的状态同步到用户背后,使工作加倍。毕竟,新字典的内存表示与 Python 2 不同。 +Python 6 的虚拟机可以标记每个属性,通过查找“来自 py2 的调用”或“来自 py3 的调用”的信息来实现这一点,并使对象发送正确的属性。这会让它变得很慢,并且使用更多的内存。这将要求我们在内存中保留两种版本的代码,并通过代理来使用它们。我们需要加倍付出努力,在用户背后同步这些对象的状态。毕竟,新字典的内存表示与 Python 2 不同。 -如果你在思考字典问题,考虑 Python 3 中的 Unicode 字符串和 Python 2 中的字节(byte)字符串的所有问题。 +如果你已经被字典问题绕晕了,那么再想想 Python 3 中的 Unicode 字符串和 Python 2 中的字节(byte)字符串的各种问题吧。 -### 一切都会丢失吗?Python 3 不能运行旧代码? +### 没有办法了吗?Python 3 根本就不能运行旧代码吗? -一切都不会丢失。每天都会有项目移植到 Python 3。将 Python 2 代码移植到两个版本的 Python 上推荐方法是在代码上运行 [Python-Modernize][1]。它会捕获那些在 Python 3 上不起作用的代码,并使用 [six][2] 库将其替换,以便它在 Python 2 和 Python 3 上运行。这是对 `2to3` 的改编,它正在生成 Python 3-only 代码。`Modernize` 是首选,因为它提供了更多的增量迁移路线。所有的这些在 Python 文档中的 [Porting Python 2 Code to Python 3][3]文档中都有很好的概述。 +不会。每天都会有项目移植到 Python 3。将 Python 2 代码移植到两个版本的 Python 上推荐方法是在你的代码上运行 [Python-Modernize][1]。它会捕获那些在 Python 3 上不起作用的代码,并使用 [six][2] 库将其替换,以便它在 Python 2 和 Python 3 上运行。这是 `2to3` 的一个改编版本,用于生成仅针对 Python 3 代码。`Modernize` 是首选,因为它提供了更多的增量迁移路线。所有的这些在 Python 文档中的 [Porting Python 2 Code to Python 3][3]文档中都有很好的概述。 -但是,等一等,你不是说 Python 6 的虚拟机不能自动执行此操作吗?对。`Modernize` 查看你的代码,并试图猜测哪些是安全的。它会做出一些不必要的改变,还会错过其他必要的改变。但是,它不会帮助你处理字符串。如果你的代码没有保留“来自外部的二进制数据”和“流程中的文本数据”之间的界限,那么这种转换并非微不足道。 +但是,等一等,你不是说 Python 6 的虚拟机不能自动执行此操作吗?对。`Modernize` 查看你的代码,并试图猜测哪些是安全的。它会做出一些不必要的改变,还会错过其他必要的改变。但是,它不会帮助你处理字符串。如果你的代码没有在“来自外部的二进制数据”和“流程中的文本数据”之间保持界限,那么这种转换就不会那么轻易。 -因此,迁移大项目不能自动完成,并且涉及人类进行测试,发现问题并修复它们。它工作吗?是的,我曾帮助[将一百万行代码迁移到 Python 3][4],并且交换没有造成事故。这一举措重获了我们服务器内存的 1/3,并使代码运行速度提高了 12%。那是在 Python 3.5 上,但是 Python 3.6 的速度要快得多,根据你的工作量,你甚至可以达到 [4 倍加速][5]。 +因此,大项目的迁移不能自动完成,并且需要人类进行测试,发现问题并修复它们。它工作吗?是的,我曾帮助[将一百万行代码迁移到 Python 3][4],并且这种切换没有造成事故。这一举措让我们重新获得了 1/3 的服务器内存,并使代码运行速度提高了 12%。那是在 Python 3.5 上,但是 Python 3.6 的速度要快得多,根据你的工作量,你甚至可以达到 [4 倍加速][5]。 ### 亲爱的 Zed -hi,伙计,我关注你已经超过 10 年了。我一直在观察,当你感到沮丧的时候,你对 Mongrel 没有任何信任,尽管 Rails 生态系统几乎全部都在上面运行。当你重新设计它并开始 Mongrel 2 项目时,我一直在观察。我一直在关注你使用 Fossil 这一令人惊讶的举动。随着你发布 “Rails 是一个贫民窟”的帖子,我看到你突然离开了 Ruby 社区。当你开始编写 “Learn Python The Hard Way” 并且开始推荐它时,我感到非常兴奋。2013 年我在 [DjangoCon Europe][6] 见过你,我们谈了很多关于绘画,唱歌和倦怠的内容。关于[这张你的照片][7]是我在 Instagram 上的第一篇文章。 +hi,伙计,我关注你已经超过 10 年了。我一直在观察,当你感到沮丧的时候,你对 Mongrel 没有任何信任,尽管 Rails 生态系统几乎全部都在上面运行。当你重新设计它并开始 Mongrel 2 项目时,我一直在观察。我一直在关注你使用 Fossil 这一令人惊讶的举动。随着你发布 “Rails 是一个贫民窟”的帖子,我看到你突然离开了 Ruby 社区。当你开始编写《笨方法学 Python》并且开始推荐它时,我感到非常兴奋。2013 年我在 [DjangoCon Europe][6] 见过你,我们谈了很多关于绘画,唱歌和倦怠的内容。[你的这张照片][7]是我在 Instagram 上的第一个帖子。 -你几乎把另一个“贫民区”的行动与 [“反对 Python 3” 案例][8] 文章拉到一起。我认为你本意是好的,但是这篇文章引起了很多混乱,包括许多人认为你认为 Python 3 不是图灵完整的。我花了好几个小时让人们相信,你是在开玩笑。但是,鉴于你对 Python 学习方式的重大贡献,我认为这是值得的。特别是你为 Python 3 更新了你的书。感谢你做这件事。如果我们社区中真的有人要求因你的帖子为由将你和你的书列入黑名单,把他们请出去。这是一个双输的局面,这是错误的。 +你几乎把另一个“贫民区”的行动与 [“反对 Python 3” 案例][8] 文章拉到一起。我认为你本意是好的,但是这篇文章引起了很多混淆,包括许多人觉得你认为 Python 3 不是图灵完整的。我花了好几个小时让人们相信,你是在开玩笑。但是,鉴于你对《笨方法学 Python》的重大贡献,我认为这是值得的。特别是你为 Python 3 更新了你的书。感谢你做这件事。如果我们社区中真的有人因你的帖子为由要求将你和你的书列入黑名单,而请他们出去。这是一个双输的局面,这是错误的。 -在记录中,没有一个核心 Python 开发人员认为 Python 2 到 Python 3 的转换过程会顺利而且计划得当,[包括 Guido van Rossum][9]。真的,可以看那个视频,这有点事后诸葛亮的意思了。从这个意义上说,我们实际上是积极地相互认同的。如果我们再做一次,它会看起来不一样。但在这一点上,[在 2020 年 1 月 1 日,Python 2 将会到达终结][10]。大多数第三方库已经支持 Python 3,甚至开始发布只支持 Python 3 版本(参见[Django][11]或 [科学项目关于 Python 3 的声明][12])。 +说实话,没有一个核心 Python 开发人员认为 Python 2 到 Python 3 的转换过程会顺利而且计划得当,[包括 Guido van Rossum][9]。真的,可以看那个视频,这有点事后诸葛亮的意思了。从这个意义上说,*我们实际上是积极地相互认同的*。如果我们再做一次,它会看起来不一样。但在这一点上,[在 2020 年 1 月 1 日,Python 2 将会到达终结][10]。大多数第三方库已经支持 Python 3,甚至开始发布只支持 Python 3 的版本(参见 [Django][11] 或 [科学项目关于 Python 3 的声明][12])。 -我们也积极地就另一件事达成一致。就像你于 Mongrel 一样,Python 核心开发人员是志愿者,他们的工作没有得到报酬。我们大多数人在这个项目上投入了大量的时间和精力,因此[我们自然而然敏感][13]于那些对他们的贡献不屑一顾和激烈的评论。特别是如果这个信息既攻击目前的事态,又要求更多的自由劳动。 +我们也积极地就另一件事达成一致。就像你于 Mongrel 一样,Python 核心开发人员是志愿者,他们的工作没有得到报酬。我们大多数人在这个项目上投入了大量的时间和精力,因此[我们自然而然敏感][13]于那些对他们的贡献不屑一顾和激烈的评论。特别是如果这个信息既攻击目前的事态,又要求更多的自由贡献。 -我希望到 2018 年你会让忘记 2016 发布的帖子,有一堆好的反驳。[我特别喜欢 eevee][14](译注:eevee 是一个为 Blender 设计的渲染器)。它特别针对“一起运行 Python 2 和 Python 3 ”的场景,这是不现实的,就像在同一个虚拟机中运行 Ruby 1.8 和 Ruby 2.x 一样,或者像 Lua 5.3 和 Lua 5.1 同时运行一样。你甚至不能用 libc.so.6 运行针对 libc.so.5 编译的 C 二进制文件。然而,我发现最令人惊讶的是,你声称 Python 核心开发者是“有目的地”创造诸如 2to3 之类的破坏工具,这些由 Guido 创建,其最大利益就是让每个人尽可能顺利,快速地迁移。我很高兴你在之后的帖子中放弃了这个说法,但是你必须意识到你会激怒那些阅读原始版本的人。对蓄意伤害的指控最好有强有力的证据支持。 +我希望到 2018 年你会让忘记 2016 发布的帖子,有一堆好的反驳。[我特别喜欢 eevee][14](LCTT 译注:eevee 是一个为 Blender 设计的渲染器)。它特别针对“一起运行 Python 2 和 Python 3 ”的场景,这是不现实的,就像在同一个虚拟机中运行 Ruby 1.8 和 Ruby 2.x 一样,或者像 Lua 5.3 和 Lua 5.1 同时运行一样。你甚至不能用 libc.so.6 运行针对 libc.so.5 编译的 C 二进制文件。然而,我发现最令人惊讶的是,你声称 Python 核心开发者是“有目的地”创造诸如 2to3 之类的破坏工具,这些由 Guido 创建,其最大利益就是让每个人尽可能顺利,快速地迁移。我很高兴你在之后的帖子中放弃了这个说法,但是你必须意识到你会激怒那些阅读了原始版本的人。对蓄意伤害的指控最好有强有力的证据支持。 -但看起来你仍然会这样做。[就在今天][15]你说 Python 核心开发者“忽略”尝试解决 API 的问题,特别是 `six`。正如我上面写的那样,Python 文档中的官方移植指南涵盖了 “six”。更重要的是,`six` 是由 Python 2.7 的发布管理者 Benjamin Peterson 编写。很多人学会了编程,这要归功于你,而且由于你在网上有大量的粉丝,人们会阅读这样的推文,他们会相信它的价值,这是有害的。 +但看起来你仍然会这样做。[就在今天][15]你说 Python 核心开发者“忽略”尝试解决 API 的问题,特别是 `six`。正如我上面写的那样,Python 文档中的官方移植指南涵盖了 `six`。更重要的是,`six` 是由 Python 2.7 的发布管理者 Benjamin Peterson 编写。很多人学会了编程,这要归功于你,而且由于你在网上有大量的粉丝,人们会阅读这样的推文,他们会相信它的价值,这是有害的。 -我有一个建议,让我们把 “Python 3 管理不善”的争议搁置起来。Python 2 正在死亡,这个过程会很慢,并且它是丑陋而血腥的,但它是一条单行道。争论那些没有用。相反,让我们专注于我们现在可以做什么来使 Python 3.8 比其他任何 Python 版本更好。也许你更喜欢看外面的角色,但作为这个社区的成员,你会更有影响力。请说“我们”而不是“他们”。 +我有一个建议,让我们把 “Python 3 管理不善”的争议搁置起来。Python 2 正在死亡,这个过程会很慢,并且它是丑陋而血腥的,但它是一条单行道。争论那些没有用。相反,让我们专注于我们现在可以做什么来使 Python 3.8 比其他任何 Python 版本更好。也许你更喜欢看外面的角色,但作为这个社区的成员,你会更有影响力。请说“我们”而不是“他们”。 -------------------------------------------------------------------------------- @@ -96,9 +93,9 @@ hi,伙计,我关注你已经超过 10 年了。我一直在观察,当你 via: http://lukasz.langa.pl/13/could-we-run-python-2-and-python-3-code-same-vm/ 作者:[Łukasz Langa][a] -译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 06f61d676ff974fdab37ca9b25dfb137dd7f9d02 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 8 May 2018 19:10:18 +0800 Subject: [PATCH 0811/1057] PUB:20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md @MjSeven https://linux.cn/article-9619-1.html --- ...hon 2 and Python 3 code in the same VM with no code changes.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md (100%) diff --git a/translated/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md b/published/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md similarity index 100% rename from translated/tech/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md rename to published/20180325 Could we run Python 2 and Python 3 code in the same VM with no code changes.md From 859bf4b5d31bb1c7f234779a40714b7c86c0c613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= <24203166+fuzheng1998@users.noreply.github.com> Date: Tue, 8 May 2018 19:16:03 +0800 Subject: [PATCH 0812/1057] delete xxx translating --- ...206 Why Linux is better than Windows or macOS for security.md | 1 - 1 file changed, 1 deletion(-) 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 63735b29a9..aa71a676b7 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 @@ -1,4 +1,3 @@ -fuzheng1998 translating 为什么 Linux 比 Windows 和 macOS 的安全性好 ====== From d80c5862df760e81681a77403b3194734cee6ac3 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 8 May 2018 23:52:48 +0800 Subject: [PATCH 0813/1057] PRF:20180314 How to measure particulate matter with a Raspberry Pi.md @HankChow --- ... particulate matter with a Raspberry Pi.md | 85 ++++++++----------- 1 file changed, 34 insertions(+), 51 deletions(-) diff --git a/translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md b/translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md index 0ca5af0fcf..47046dcd26 100644 --- a/translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md +++ b/translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md @@ -1,134 +1,120 @@ -如何使用树莓派测定颗粒物 +如何使用树莓派测定颗粒物(PM 2.5) ====== +> 使用两个简单的硬件设备和几行代码构建一个空气质量探测器。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bubblehands_fromRHT_520_0612LL.png?itok=_iQ2dO3S) + 我们在东南亚的学校定期测定空气中的颗粒物。这里的测定值非常高,尤其是在二到五月之间,干燥炎热、土地干旱等各种因素都对空气质量产生了不利的影响。我将会在这篇文章中展示如何使用树莓派来测定颗粒物。 ### 什么是颗粒物? -颗粒物就是粉尘或者空气中的微小颗粒。其中 PM10 和 PM2.5 之间的差别就是 PM10 指的是粒径小于10微米的颗粒,而 PM2.5 指的是粒径小于2.5微米的颗粒。在粒径小于2.5微米的的情况下,由于它们能被吸入肺泡中并且对呼吸系统造成影响,因此颗粒越小,对人的健康危害越大。 +颗粒物就是粉尘或者空气中的微小颗粒。其中 PM10 和 PM2.5 之间的差别就是 PM10 指的是粒径小于 10 微米的颗粒,而 PM2.5 指的是粒径小于 2.5 微米的颗粒。在粒径小于 2.5 微米的的情况下,由于它们能被吸入肺泡中并且对呼吸系统造成影响,因此颗粒越小,对人的健康危害越大。 世界卫生组织的建议[颗粒物浓度][1]是: - * 年均 PM10 不高于20 µg/m³ - * 年均 PM2.5 不高于10 µg/m³ - * 不允许超标时,日均 PM10 不高于50 µg/m³ - * 不允许超标时,日均 PM2.5 不高于25 µg/m³ + * 年均 PM10 不高于 20 µg/m³ + * 年均 PM2.5 不高于 10 µg/m³ + * 不允许超标时,日均 PM10 不高于 50 µg/m³ + * 不允许超标时,日均 PM2.5 不高于 25 µg/m³ -以上数值实际上是低于大多数国家的标准的,例如欧盟对于 PM10 所允许的年均值是不高于40 µg/m³。 +以上数值实际上是低于大多数国家的标准的,例如欧盟对于 PM10 所允许的年均值是不高于 40 µg/m³。 -### 什么是空气质量指数(AQI, Air Quality Index)? +### 什么是空气质量指数Air Quality Index(AQI)? -空气质量指数按照颗粒物的测定值来评价空气质量的好坏,然而由于各国之间的计算方式有所不同,这个指数并没有统一的标准。维基百科上关于[空气质量指数][2]的词条对此给出了一个概述。我们学校则以[美国环境保护协会][3](EPA, Environment Protection Agency)建立的分类法来作为依据。 +空气质量指数是按照颗粒物的测定值来评价空气质量的好坏,然而由于各国之间的计算方式有所不同,这个指数并没有统一的标准。维基百科上关于[空气质量指数][2]的词条对此给出了一个概述。我们学校则以[美国环境保护协会][3]Environment Protection Agency(EPA)建立的分类法来作为依据。 ![空气质量指数][5] -空气质量指数 +*空气质量指数* ### 测定颗粒物需要哪些准备? 测定颗粒物只需要以下两种器材: + * 树莓派(款式不限,最好带有 WiFi) * SDS011 颗粒物传感器 - - ![颗粒物传感器][7] -颗粒物传感器 +*颗粒物传感器* -如果是只带有 Micro USB的树莓派Zero W,那还需要一根连接到标准 USB 端口的适配线,只需要20美元,而传感器则自带适配串行接口的 USB 适配器。 +如果是只带有 Micro USB 的树莓派 Zero W,那还需要一根连接到标准 USB 端口的适配线,只需要 20 美元,而传感器则自带适配串行接口的 USB 适配器。 ### 安装过程 对于树莓派,只需要下载对应的 Raspbian Lite 镜像并且[写入到 Micro SD 卡][8]上就可以了(网上很多教程都有介绍如何设置 WLAN 连接,我就不细说了)。 如果要使用 SSH,那还需要在启动分区建立一个名为 `ssh` 的空文件。树莓派的 IP 通过路由器或者 DHCP 服务器获取,随后就可以通过 SSH 登录到树莓派了(默认密码是 raspberry): + ``` $ ssh pi@192.168.1.5 - ``` 首先我们需要在树莓派上安装一下这些包: + ``` $ sudo apt install git-core python-serial python-enum lighttpd - ``` 在开始之前,我们可以用 `dmesg` 来获取 USB 适配器连接的串行接口: + ``` $ dmesg - [ 5.559802] usbcore: registered new interface driver usbserial - [ 5.559930] usbcore: registered new interface driver usbserial_generic - [ 5.560049] usbserial: USB Serial support registered for generic - [ 5.569938] usbcore: registered new interface driver ch341 - [ 5.570079] usbserial: USB Serial support registered for ch341-uart - [ 5.570217] ch341 1–1.4:1.0: ch341-uart converter detected - [ 5.575686] usb 1–1.4: ch341-uart converter now attached to ttyUSB0 - ``` 在最后一行,可以看到接口 `ttyUSB0`。然后我们需要写一个 Python 脚本来读取传感器的数据并以 JSON 格式存储,在通过一个 HTML 页面就可以把数据展示出来了。 ### 在树莓派上读取数据 -首先创建一个传感器实例,每5分钟读取一次传感器的数据,持续30秒,这些数值后续都可以调整。在每两次测定的间隔,我们把传感器调到睡眠模式以延长它的使用寿命(厂商认为元件的寿命大约8000小时)。 +首先创建一个传感器实例,每 5 分钟读取一次传感器的数据,持续 30 秒,这些数值后续都可以调整。在每两次测定的间隔,我们把传感器调到睡眠模式以延长它的使用寿命(厂商认为元件的寿命大约 8000 小时)。 我们可以使用以下命令来下载 Python 脚本: + ``` $ wget -O /home/pi/aqi.py https://raw.githubusercontent.com/zefanja/aqi/master/python/aqi.py - ``` 另外还需要执行以下两条命令来保证脚本正常运行: + ``` -$ sudo chown pi:pi /var/wwww/html/ - -$ echo[] > /var/wwww/html/aqi.json - +$ sudo chown pi:pi /var/www/html/ +$ echo '[]' > /var/www/html/aqi.json ``` 下面就可以执行脚本了: + ``` -$ chmod +x aqi.py - +$ chmod +x aqi.p $ ./aqi.py - PM2.5:55.3, PM10:47.5 - PM2.5:55.5, PM10:47.7 - PM2.5:55.7, PM10:47.8 - PM2.5:53.9, PM10:47.6 - PM2.5:53.6, PM10:47.4 - PM2.5:54.2, PM10:47.3 - … - ``` ### 自动化执行脚本 只需要使用诸如 crontab 的服务,我们就不需要每次都手动启动脚本了。按照以下命令打开 crontab 文件: + ``` $ crontab -e - ``` 在文件末尾添加这一行: + ``` @reboot cd /home/pi/ && ./aqi.py - ``` 现在我们的脚本就会在树莓派每次重启后自动执行了。 @@ -138,17 +124,14 @@ $ crontab -e 我们在前面已经安装了一个轻量级的 web 服务器 `lighttpd`,所以我们需要把 HTML、JavaScript、CSS 文件放置在 `/var/www/html` 目录中,这样就能通过电脑和智能手机访问到相关数据了。执行下面的三条命令,可以下载到对应的文件: ``` -$ wget -O /var/wwww/html/index.html https://raw.githubusercontent.com/zefanja/aqi/master/html/index.html - -$ wget -O /var/wwww/html/aqi.js https://raw.githubusercontent.com/zefanja/aqi/master/html/aqi.js - -$ wget -O /var/wwww/html/style.css https://raw.githubusercontent.com/zefanja/aqi/master/html/style.css - +$ wget -O /var/www/html/index.html https://raw.githubusercontent.com/zefanja/aqi/master/html/index.html +$ wget -O /var/www/html/aqi.js https://raw.githubusercontent.com/zefanja/aqi/master/html/aqi.js +$ wget -O /var/www/html/style.css https://raw.githubusercontent.com/zefanja/aqi/master/html/style.css ``` 在 JavaScript 文件中,实现了打开 JSON 文件、提取数据、计算空气质量指数的过程,随后页面的背景颜色将会根据 EPA 的划分标准而变化。 -你只需要用浏览器访问树莓派的地址,就可以看到当前颗粒物浓度值等数据了。[http://192.168.1.5:][9] +你只需要用浏览器访问树莓派的地址,就可以看到当前颗粒物浓度值等数据了: [http://192.168.1.5:][9] 这个页面比较简单而且可扩展,比如可以添加一个展示过去数小时历史数据的表格等等。 @@ -158,7 +141,7 @@ $ wget -O /var/wwww/html/style.css https://raw.githubusercontent.com/zefanja/aqi 在资金相对紧张的情况下,树莓派是一种选择。除此以外,还有很多可以用来测定颗粒物的应用,包括室外固定装置、移动测定设备等等。我们学校则同时采用了这两种:固定装置在室外测定全天颗粒物浓度,而移动测定设备在室内检测空调过滤器的效果。 -[Luftdaten.info][12]提供了一个如何设计类似的传感器的介绍,其中的软件效果出众,而且因为它没有使用树莓派,所以硬件更是小巧。 +[Luftdaten.info][12] 提供了一个如何设计类似的传感器的介绍,其中的软件效果出众,而且因为它没有使用树莓派,所以硬件更是小巧。 对于学生来说,设计一个颗粒物传感器确实算得上是一个优秀的课外项目。 @@ -170,7 +153,7 @@ via: https://opensource.com/article/18/3/how-measure-particulate-matter-raspberr 作者:[Stephan Tetzel][a] 译者:[HankChow](https://github.com/HankChow) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a06f461de49f8608b4bae7022cb68f47e60f2fbe Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 8 May 2018 23:53:14 +0800 Subject: [PATCH 0814/1057] PUB:20180314 How to measure particulate matter with a Raspberry Pi.md @HankChow https://linux.cn/article-9620-1.html --- ...80314 How to measure particulate matter with a Raspberry Pi.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180314 How to measure particulate matter with a Raspberry Pi.md (100%) diff --git a/translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md b/published/20180314 How to measure particulate matter with a Raspberry Pi.md similarity index 100% rename from translated/tech/20180314 How to measure particulate matter with a Raspberry Pi.md rename to published/20180314 How to measure particulate matter with a Raspberry Pi.md From 31e4f0ae2c73a8ea4f50285cdae2f81a9b82a246 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 9 May 2018 00:30:46 +0800 Subject: [PATCH 0815/1057] PRF:20171213 Will DevOps steal my job-.md @qhwdw --- .../20171213 Will DevOps steal my job-.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/translated/tech/20171213 Will DevOps steal my job-.md b/translated/tech/20171213 Will DevOps steal my job-.md index 065d638bfa..53b7511dbe 100644 --- a/translated/tech/20171213 Will DevOps steal my job-.md +++ b/translated/tech/20171213 Will DevOps steal my job-.md @@ -1,4 +1,4 @@ -DevOps 将让你失业? +DevOps 会让你失业吗? ====== >你是否担心工作中自动化将代替人?可能是对的,但是这并不是件坏事。 @@ -8,19 +8,19 @@ DevOps 将让你失业? 这是一个很正常的担心:DevOps 最终会让你失业?毕竟,DevOps 意味着开发人员做运营,对吗?DevOps 是自动化的。如果我的工作都自动化了,我去做什么?实行持续分发和容器化意味着运营已经过时了吗?对于 DevOps 来说,所有的东西都是代码:基础设施是代码、测试是代码、这个和那个都是代码。如果我没有这些技能怎么办? -[DevOps][1] 是一个即将到来的变化,将颠覆这一领域,狂热的拥挤者们正在谈论,如何使用 [三种方法][2] 去改变世界 —— 即 DevOps 的三大基础 —— 去推翻一个旧的世界。它是势不可档的。那么,问题来了 —— DevOps 将会让我失业吗? +[DevOps][1] 是一个即将到来的变化,它将颠覆这一领域,狂热的拥挤者们正在谈论,如何使用 [三种方法][2] 去改变世界 —— 即 DevOps 的三大基础 —— 去推翻一个旧的世界。它是势不可档的。那么,问题来了 —— DevOps 将会让我失业吗? -### 第一个担心:再也不需要我了 +### 第一个担心:再也不需要我了 -由于开发者来管理应用程序的整个生命周期,接受 DevOps 的理念很容易。容器化可能是影响这一想法的重要因素。当容器化在各种场景下铺开之后,它们被吹嘘成开发者构建、测试、和部署他们代码的一站式解决方案。DevOps 对于运营、测试、以及 QA 团队来说,有什么作用呢? +由于开发者来管理应用程序的整个生命周期,接受 DevOps 的理念很容易。容器化可能是影响这一想法的重要因素。当容器化在各种场景下铺开之后,它们被吹嘘成开发者构建、测试和部署他们代码的一站式解决方案。DevOps 对于运营、测试、以及 QA 团队来说,有什么作用呢? -这源于对 DevOps 原则的误解。DevOps 的第一原则,或者第一方法是,_系统思考_ ,或者强调整体管理方法和了解应用程序或服务的整个生命周期。这并不意味着应用程序的开发者将学习和管理整个过程。相反,是拥有各个专业和技能的人共同合作,以确保成功。让开发者对这一过程完全负责的作法,几乎是将开发者置于使用者的对立面—— 本质上就是 “将鸡蛋放在了一个篮子里”。 +这源于对 DevOps 原则的误解。DevOps 的第一原则,或者第一方法是,系统思考Systems Thinking,或者强调整体管理方法和了解应用程序或服务的整个生命周期。这并不意味着应用程序的开发者将学习和管理整个过程。相反,是拥有各个专业和技能的人共同合作,以确保成功。让开发者对这一过程完全负责的作法,几乎是将开发者置于使用者的对立面 —— 本质上就是 “将鸡蛋放在了一个篮子里”。 在 DevOps 中有一个为你保留的专门职位。就像将一个受过传统教育的、拥有线性回归和二分查找知识的软件工程师,被用去写一些 Ansible playbooks 和 Docker 文件,这是一种浪费。而对于那些拥有高级技能,知道如何保护一个系统和优化数据库执行的系统管理员,被浪费在写一些 CSS 和设计用户流这样的工作上。写代码、做测试、和维护应用程序的高效团队一般是跨学科、跨职能的、拥有不同专业技术和背景的人组成的混编团队。 ### 第二个担心:我的工作将被自动化 -或许是,或许不是,DevOps 可能在有时候是自动化的同义词。当自动化构建、测试、部署、监视、以及提醒等事项,已经占据了整个应用程序生命周期管理的时候,还会给我们剩下什么工作呢?这种对自动化的关注可能与第二个方法有关:_放大反馈循环_。DevOps 的第二个方法是在团队和部署的应用程序之间,采用相反的方向优先处理快速反馈 —— 从监视和维护部署、测试、开发、等等,通过强调,使反馈更加重要并且可操作。虽然这第二种方式与自动化并不是特别相关,许多自动化工具团队在它们的部署流水线中使用,以促进快速提醒和快速行动,或者基于对使用者的支持业务中产生的反馈来改进。传统的做法是靠人来完成的,这就可以理解为什么自动化可能会导致未来一些人失业的焦虑了。 +或许是,或许不是,DevOps 可能在有时候是自动化的同义词。当自动化构建、测试、部署、监视,以及提醒等事项,已经占据了整个应用程序生命周期管理的时候,还会给我们剩下什么工作呢?这种对自动化的关注可能与第二个方法有关:放大反馈循环Amplify Feedback Loops。DevOps 的第二个方法是在团队和部署的应用程序之间,采用相反的方向优先处理快速反馈 —— 从监视和维护部署、测试、开发、等等,通过强调,使反馈更加重要并且可操作。虽然这第二种方式与自动化并不是特别相关,许多自动化工具团队在它们的部署流水线中使用,以促进快速提醒和快速行动,或者基于对使用者的支持业务中产生的反馈来改进。传统的做法是靠人来完成的,这就可以理解为什么自动化可能会导致未来一些人失业的焦虑了。 自动化只是一个工具,它并不能代替人。聪明的人使用它来做一些重复的工作,不去开发智力和创造性的财富,而是去按红色的 “George Jetson” 按钮是一种极大的浪费。让每天工作中的苦活自动化,意味着有更多的时间去解决真正的问题和即将到来的创新的解决方案。人类需要解决更多的 “怎么做和为什么” 问题,而计算机只能处理 “复制和粘贴”。 @@ -28,17 +28,17 @@ DevOps 将让你失业? ### 第三个担心:我没有这些技能怎么办 -"我怎么去继续做这些事情?我不懂如何自动化。现在所有的工作都是代码 —— 我不是开发人员,我不会做 DevOps 中写代码的工作“,第三个担心是一种不自信的担心。由于文化的改变,是的,团队将也会要求随之改变,一些人可能担心,他们缺乏继续做他们工作的技能。 +“我怎么去继续做这些事情?我不懂如何自动化。现在所有的工作都是代码 —— 我不是开发人员,我不会做 DevOps 中写代码的工作”,第三个担心是一种不自信的担心。由于文化的改变,是的,团队将也会要求随之改变,一些人可能担心,他们缺乏继续做他们工作的技能。 -然而,大多数人或许已经比他们所想的更接近。Dockerfile 是什么,或者像 Puppet 或 Ansible 配置管理是什么,但是环境即代码,系统管理员已经写了 shell 脚本和 Python 程序去处理他们重复的任务。学习更多的知识并使用已有的工具处理他们的更多问题 —— 编排、部署、维护即代码 —— 尤其是当从繁重的手动任务中解放出来,专注于成长时。 +然而,大多数人或许已经比他们所想的更接近。Dockerfile 是什么,或者像 Puppet 或 Ansible 配置管理是什么,这就是环境即代码,系统管理员已经写了 shell 脚本和 Python 程序去处理他们重复的任务。学习更多的知识并使用已有的工具处理他们的更多问题 —— 编排、部署、维护即代码 —— 尤其是当从繁重的手动任务中解放出来,专注于成长时。 -在 DevOps 的使用者中去回答这第三个担心,第三个方法是:_一种不断实验和学习的文化_。尝试、失败、并从错误中吸取教训而不是责怪它们的能力,是设计出更有创意的解决方案的重要因素。第三个方法是为前两个方法授权—— 允许快速检测和修复问题,并且开发人员可以自由地尝试和学习,其它的团队也是如此。从未使用过配置管理或者写过自动供给基础设施程序的运营团队也要自由尝试并学习。测试和 QA 团队也要自由实现新测试流水线,并且自动批准和发布新流程。在一个拥抱学习和成长的文化中,每个人都可以自由地获取他们需要的技术,去享受工作带来的成功和喜悦。 +在 DevOps 的使用者中去回答这第三个担心,第三个方法是:一种不断实验和学习的文化A Culture of Continual Experimentation and Learning。尝试、失败,并从错误中吸取教训而不是责怪它们的能力,是设计出更有创意的解决方案的重要因素。第三个方法是为前两个方法授权 —— 允许快速检测和修复问题,并且开发人员可以自由地尝试和学习,其它的团队也是如此。从未使用过配置管理或者写过自动供给基础设施程序的运营团队也要自由尝试并学习。测试和 QA 团队也要自由实现新测试流水线,并且自动批准和发布新流程。在一个拥抱学习和成长的文化中,每个人都可以自由地获取他们需要的技术,去享受工作带来的成功和喜悦。 ### 结束语 在一个行业中,任何可能引起混乱的实践或变化都会产生担心和不确定,DevOps 也不例外。对自己工作的担心是对成百上千的文章和演讲的合理回应,其中列举了无数的实践和技术,而这些实践和技术正致力于授权开发者对行业的各个方面承担职责。 -然而,事实上,DevOps 是 "[一个跨学科的沟通实践,致力于研究构建、进化、和运营快速变化的弹性系统][3]"。 DevOps 意味着终结 ”筒仓“,但并不专业化。它是受委托去做苦差事的自动化系统,解放你,让你去做人类更擅长做的事:思考和想像。并且,如果你愿意去学习和成长,它将不会终结你解决新的、挑战性的问题的机会。 +然而,事实上,DevOps 是 “[一个跨学科的沟通实践,致力于研究构建、进化、和运营快速变化的弹性系统][3]”。 DevOps 意味着终结 “筒仓”,但并不专业化。它是受委托去做苦差事的自动化系统,解放你,让你去做人类更擅长做的事:思考和想像。并且,如果你愿意去学习和成长,它将不会终结你解决新的、挑战性的问题的机会。 DevOps 会让你失业吗?会的,但它同时给你提供了更好的工作。 @@ -48,7 +48,7 @@ via: https://opensource.com/article/17/12/will-devops-steal-my-job 作者:[Chris Collins][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 932dea940a7b8d7397d17806c42952fe616eff81 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 9 May 2018 00:31:17 +0800 Subject: [PATCH 0816/1057] PUB:20171213 Will DevOps steal my job-.md @qhwdw https://linux.cn/article-9621-1.html --- .../tech => published}/20171213 Will DevOps steal my job-.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171213 Will DevOps steal my job-.md (100%) diff --git a/translated/tech/20171213 Will DevOps steal my job-.md b/published/20171213 Will DevOps steal my job-.md similarity index 100% rename from translated/tech/20171213 Will DevOps steal my job-.md rename to published/20171213 Will DevOps steal my job-.md From 3c9ddba7394c6bad71b7b34fc506a9e061268c1a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 9 May 2018 00:43:06 +0800 Subject: [PATCH 0817/1057] PRF:20180326 4 command line note-taking applications for Linux.md @geekpi --- ...line note-taking applications for Linux.md | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/translated/tech/20180326 4 command line note-taking applications for Linux.md b/translated/tech/20180326 4 command line note-taking applications for Linux.md index d948ae0798..7f706a65dc 100644 --- a/translated/tech/20180326 4 command line note-taking applications for Linux.md +++ b/translated/tech/20180326 4 command line note-taking applications for Linux.md @@ -1,32 +1,41 @@ -Linux 下的 4 个命令行笔记记录程序 -====== +4 个 Linux 下的命令行笔记程序 +=============== + +> 这些工具可以让你在 Linux 命令行下简单而有效地记录笔记和保存信息。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/note-taking.jpeg?itok=fiF5EBEb) -当你需要保存代码段或 URL、想法或引用时,可能会启动文本编辑器或使用[桌面][1]或[基于 Web 的] [2]笔记记录工具。但那些不是你唯一的选择。如果你在终端窗口中工作,则可以使用 Linux 命令行下的许多笔记记录工具之一。 + +当你需要保存代码段或 URL、想法或引用时,可能会启动文本编辑器或使用[桌面][1]或[基于 Web 的][2]笔记记录工具。但那些不是你唯一的选择。如果你在终端窗口中工作,则可以使用 Linux 命令行下的许多笔记记录工具之一。 我们来看看这四个程序。 ### tnote -[tnote][3] 使在终端窗口中记笔记很简单 - 几乎太简单了。 +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/tnote.png?itok=M84ABZcr) -tnote 是一个 Python 脚本。首次启动时,它会要求你输入密码和口令来加密存储笔记的[ SQLite 数据库][4]。完成之后,按 “A” 创建一个笔记。输入你的笔记,然后按 CTRL-D 保存。 +[tnote][3] 使在终端窗口中记笔记很简单 —— 几乎太简单了。 -一旦你有几个(或多个)笔记,你可以查看它们或搜索特定的笔记,单词或短语或标签。tnote 不包含很多功能,但它确实实现了任务。 +tnote 是一个 Python 脚本。首次启动时,它会要求你输入密码和口令来加密存储笔记的 [SQLite 数据库][4]。完成之后,按 `A` 创建一个笔记。输入你的笔记,然后按 `CTRL-D` 保存。 + +一旦你有几个(或多个)笔记,你可以查看它们或搜索特定的笔记,单词或短语或标签。tnote 没有很多功能,但它确实实现了任务。 ### Terminal Velocity -如果你使用的是 Mac OS,你可能会看到一个名为 [Notational Velocity][5] 的流行开源笔记程序,这是一种记录笔记的简单有效方法。[Terminal Velocity][6] 在将 Notational Velocity 体验带入命令行方面做得很好。 +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/terminal_velocity.png?itok=rkWejQ7_) + +如果你使用过 Mac OS,你可能会看到一个名为 [Notational Velocity][5] 的流行开源笔记程序,这是一种记录笔记的简单有效方法。[Terminal Velocity][6] 在将 Notational Velocity 体验带入命令行方面做得很好。 Terminal Velocity 打开你的默认文本编辑器(由你的 `.profile` 或 `.bashrc` 文件中的 `$EDITOR` 变量设置)。输入你的笔记,然后保存。该笔记出现在 Terminal Velocity 窗口的列表中。 -使用键盘上的箭头键滚动查看你的笔记列表。要查看或编辑笔记,请按 Enter 键。如果你有一长串笔记,则可以在 `Find or Create` 字段中输入笔记标题的前几个字符以缩小列表的范围。在那里滚动笔记并按下 Enter 键将其打开。 +使用键盘上的箭头键滚动查看你的笔记列表。要查看或编辑笔记,请按回车键。如果你有一长串笔记,则可以在 `Find or Create` 字段中输入笔记标题的前几个字符以缩小列表的范围。在那里滚动笔记并按下回车键将其打开。 ### pygmynote +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/pygmynote.png?itok=Z8qEC4dq) + 在本文中的四个应用中,[pygmynote][7] 可能是最不用户友好的。然而,它是最灵活的。 -像 tnote 一样,pygmynote 将你的笔记和附件保存在 SQLite 数据库中。当你启动它时,pygmynote 看起来并不特别有用。在任何时候,输入 `help` 并按下 Enter 键获取命令列表。 +像 tnote 一样,pygmynote 将你的笔记和附件保存在 SQLite 数据库中。当你启动它时,pygmynote 看起来并不特别有用。在任何时候,输入 `help` 并按下回车键获取命令列表。 你可以添加、编辑、查看和搜索笔记,并在笔记中添加[标签][8]。标签使找到笔记更容易,特别是如果你有很多笔记的时候。 @@ -34,6 +43,8 @@ pygmynote 的灵活性在于它能够将附件添加到笔记中。这些附件 ### jrnl +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/jrnl.png?itok=Mx7QIgYj) + [jrnl][9] 是这里的一个奇怪应用。正如你可能从它的名字中猜到的那样,jrnl 意在成为一种日记工具。但这并不意味着你不能记笔记。 jrnl 做得很好。 当你第一次启动 jrnl 时,它会询问你想把文件 `journal.txt` (它存储你的笔记)保存的位置以及是否需要密码保护。如果你决定添加密码,那么你在应用内的操作都需要输入密码。 @@ -50,7 +61,7 @@ via: https://opensource.com/article/18/3/command-line-note-taking-applications 作者:[Scott Nesbitt][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 41c8348cf4882cf46a5a201e68657b76ae340433 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 9 May 2018 00:43:26 +0800 Subject: [PATCH 0818/1057] PUB:20180326 4 command line note-taking applications for Linux.md @geekpi --- .../20180326 4 command line note-taking applications for Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180326 4 command line note-taking applications for Linux.md (100%) diff --git a/translated/tech/20180326 4 command line note-taking applications for Linux.md b/published/20180326 4 command line note-taking applications for Linux.md similarity index 100% rename from translated/tech/20180326 4 command line note-taking applications for Linux.md rename to published/20180326 4 command line note-taking applications for Linux.md From 59cd5503c3fde9339fc790c1a293d735e95d45a4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 9 May 2018 08:44:51 +0800 Subject: [PATCH 0819/1057] PRF:20180413 Finding what you-re looking for on Linux.md @MjSeven --- ...inding what you-re looking for on Linux.md | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/translated/tech/20180413 Finding what you-re looking for on Linux.md b/translated/tech/20180413 Finding what you-re looking for on Linux.md index b554ff50c8..68a360ded1 100644 --- a/translated/tech/20180413 Finding what you-re looking for on Linux.md +++ b/translated/tech/20180413 Finding what you-re looking for on Linux.md @@ -1,86 +1,88 @@ 在 Linux 上寻找你正在寻找的东西 ===== +> 怎样在 Linux 系统上使用 find、locate、mlocate、which、 whereis、 whatis 和 apropos 命令寻找文件。 + ![](https://images.idgesg.net/images/article/2018/04/binoculars-100754967-large.jpg) -在 Linux 系统上找到你要找的东西并不难 - 一个文件或一个命令 - 但是有很多种方法可以寻找。 -### 7 个命令来寻找 Linux 文件 +在 Linux 系统上找到你要找的文件或命令并不难, 有很多种方法可以寻找。 -#### find +### find + +最显然的无疑是 `find` 命令,并且 `find` 变得比过去几年更容易使用了。它过去需要一个搜索的起始位置,但是现在,如果你想将搜索限制在当下目录中,你还可以使用仅包含文件名或正则表达式的 `find` 命令。 -最明显的无疑是 **find** 命令,并且 find 变得比以前更容易使用。它过去需要一个搜索的起始位置,但是现在,如果你想将搜索限制在本地目录中,你还可以使用仅包含文件名或正则表达式的 find 命令。 ``` $ find e* empty examples.desktop - ``` -这样,它就像 **ls** 命令一样工作,并没有做太多的搜索。 +这样,它就像 `ls` 命令一样工作,并没有做太多的搜索。 + +对于更专业的搜索,`find` 命令需要一个起点和一些搜索条件(除非你只是希望它提供该起点目录的递归列表)。命令 `find -type f` 从当前目录开始将递归列出所有常规文件,而 `find ~nemo -type f -empty` 将在 nemo 的主目录中找到空文件。 -对于更专业的搜索,find 命令需要一个起点和一些搜索条件(除非你只是希望它提供该起点目录的递归列表)。命令 **find -type f** 从当前目录开始将递归列出所有常规文件,而 **find ~nemo -type f -empty** 将在 nemo 的主目录中找到空文件。 ``` $ find ~nemo -type f -empty /home/nemo/empty - ``` -**同样在网络世界:[11 个毫无意义但是很棒的 Linux 终端技巧][1]。** +参见:[11 个好玩的 Linux 终端技巧][1]。 #### locate -**locate** 命令的名称表明它与 find 命令基本相同,但它的工作原理完全不同。**find** 命令可以根据各种条件 - 名称,大小,所有者,权限,状态(如空)等等选择文件并作为搜索选择深度,**locate** 命令通过名为 /var/lib/mlocate/mlocate.db 的文件查找你要查找的内容。该数据文件会定期更新,因此你刚创建的文件的位置它可能无法找到。如果这让你感到困扰,你可以运行 updatedb 文件并立即获得更新。 +`locate` 命令的名称表明它与 `find` 命令基本相同,但它的工作原理完全不同。`find` 命令可以根据各种条件 —— 名称、大小、所有者、权限、状态(如空文件)等等选择文件并作为搜索选择深度,`locate` 命令通过名为 `/var/lib/mlocate/mlocate.db` 的文件查找你要查找的内容。该数据文件会定期更新,因此你刚创建的文件的位置它可能无法找到。如果这让你感到困扰,你可以运行 `updatedb` 命令立即获得更新。 + ``` $ sudo updatedb - ``` #### mlocate -**mlocate** 命令的工作类似于 **locate** 命令,它使用与 locate 相同的 mlocate.db 文件。 +`mlocate` 命令的工作类似于 `locate` 命令,它使用与 `locate` 相同的 `mlocate.db` 文件。 #### which -**which** 命令的工作方式与 **find** 命令和 **locate** 命令有很大的区别。它使用你的搜索路径并检查其上的每个目录,以查找具有你要查找的文件名的可执行文件。一旦找到一个,它会停止搜索并显示该可执行文件的完整路径。 +`which` 命令的工作方式与 `find` 命令和 `locate` 命令有很大的区别。它使用你的搜索路径(`$PATH`)并检查其上的每个目录中具有你要查找的文件名的可执行文件。一旦找到一个,它会停止搜索并显示该可执行文件的完整路径。 + +`which` 命令的主要优点是它回答了“如果我输入此命令,将运行什么可执行文件?”的问题。它会忽略不可执行文件,并且不会列出系统上带有该名称的所有可执行文件 —— 列出的就是它找到的第一个。如果你想查找具有某个名称的所有可执行文件,则可以像这样运行 `find` 命令,但是要比非常高效 `which` 命令用更长的时间。 -**which** 命令的主要优点是它回答了“如果我输入此命令,将运行什么可执行文件?”的问题。它会忽略不可执行文件,并且不会列出系统上带有该名称的所有可执行文件 - 列出的就是它找到的第一个。如果你想查找具有某个名称的所有可执行文件,则可以像这样运行 find 命令,但运行非常高效 **which** 命令可能需要相当长的时间。 ``` $ find / -name locate -perm -a=x 2>/dev/null /usr/bin/locate /etc/alternatives/locate - ``` -在这个 find 命令中,我们在寻找名为 “locate” 的所有可执行文件(任何人都可以运行的文件)。我们也选择了不要查看所有“拒绝访问”的消息,否则这些消息会混乱我们的屏幕。 +在这个 `find` 命令中,我们在寻找名为 “locate” 的所有可执行文件(任何人都可以运行的文件)。我们也选择了不要查看所有“拒绝访问”的消息,否则这些消息会混乱我们的屏幕。 #### whereis -**whereis** 命令与 **which** 命令非常类似,但它提供了更多信息。它不仅仅是寻找可执行文件,它还寻找手册页(man page)和源文件。像 **which** 命令一样,它使用搜索路径($PATH) 来驱动搜索。 +`whereis` 命令与 `which` 命令非常类似,但它提供了更多信息。它不仅仅是寻找可执行文件,它还寻找手册页(man page)和源文件。像 `which` 命令一样,它使用搜索路径(`$PATH`) 来驱动搜索。 + ``` $ whereis locate locate: /usr/bin/locate /usr/share/man/man1/locate.1.gz - ``` #### whatis -**whatis** 命令有其独特的使命。它不是实际查找文件,而是在手册页中查找有关所询问命令的信息,并从手册页的顶部提供该命令的简要说明。 +`whatis` 命令有其独特的使命。它不是实际查找文件,而是在手册页中查找有关所询问命令的信息,并从手册页的顶部提供该命令的简要说明。 + ``` $ whatis locate locate (1) - find files by name - ``` 如果你询问你刚刚设置的脚本,它不会知道你指的是什么,并会告诉你。 + ``` $ whatis cleanup cleanup: nothing appropriate. - ``` #### apropos -当你知道你想要做什么,但不知道应该使用什么命令来执行此操作时,**apropos** 命令很有用。例如,如果你想知道如何查找文件,那么 “apropos find” 和 “apropos locate” 会提供很多建议。 +当你知道你想要做什么,但不知道应该使用什么命令来执行此操作时,`apropos` 命令很有用。例如,如果你想知道如何查找文件,那么 `apropos find` 和 `apropos locate` 会提供很多建议。 + ``` $ apropos find File::IconTheme (3pm) - find icon directories @@ -114,22 +116,20 @@ updatedb (8) - update a database for mlocate updatedb.mlocate (8) - update a database for mlocate whereis (1) - locate the binary, source, and manual page files for a... which (1) - locate a command - ``` ### 总结 Linux 上可用于查找和识别文件的命令有很多种,但它们都非常有用。 - -------------------------------------------------------------------------------- via: https://www.networkworld.com/article/3268768/linux/finding-what-you-re-looking-for-on-linux.html 作者:[Sandra Henry-Stocker][a] -译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 5a965dcecfed9017ddd6d70328a8e35c361545b2 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 9 May 2018 08:46:28 +0800 Subject: [PATCH 0820/1057] PUB:20180413 Finding what you-re looking for on Linux.md @MjSeven https://linux.cn/article-9623-1.html --- ...80413 Finding what you-re looking for on Linux.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename {translated/tech => published}/20180413 Finding what you-re looking for on Linux.md (98%) diff --git a/translated/tech/20180413 Finding what you-re looking for on Linux.md b/published/20180413 Finding what you-re looking for on Linux.md similarity index 98% rename from translated/tech/20180413 Finding what you-re looking for on Linux.md rename to published/20180413 Finding what you-re looking for on Linux.md index 68a360ded1..6dbb99413e 100644 --- a/translated/tech/20180413 Finding what you-re looking for on Linux.md +++ b/published/20180413 Finding what you-re looking for on Linux.md @@ -28,7 +28,7 @@ $ find ~nemo -type f -empty 参见:[11 个好玩的 Linux 终端技巧][1]。 -#### locate +### locate `locate` 命令的名称表明它与 `find` 命令基本相同,但它的工作原理完全不同。`find` 命令可以根据各种条件 —— 名称、大小、所有者、权限、状态(如空文件)等等选择文件并作为搜索选择深度,`locate` 命令通过名为 `/var/lib/mlocate/mlocate.db` 的文件查找你要查找的内容。该数据文件会定期更新,因此你刚创建的文件的位置它可能无法找到。如果这让你感到困扰,你可以运行 `updatedb` 命令立即获得更新。 @@ -36,11 +36,11 @@ $ find ~nemo -type f -empty $ sudo updatedb ``` -#### mlocate +### mlocate `mlocate` 命令的工作类似于 `locate` 命令,它使用与 `locate` 相同的 `mlocate.db` 文件。 -#### which +### which `which` 命令的工作方式与 `find` 命令和 `locate` 命令有很大的区别。它使用你的搜索路径(`$PATH`)并检查其上的每个目录中具有你要查找的文件名的可执行文件。一旦找到一个,它会停止搜索并显示该可执行文件的完整路径。 @@ -54,7 +54,7 @@ $ find / -name locate -perm -a=x 2>/dev/null 在这个 `find` 命令中,我们在寻找名为 “locate” 的所有可执行文件(任何人都可以运行的文件)。我们也选择了不要查看所有“拒绝访问”的消息,否则这些消息会混乱我们的屏幕。 -#### whereis +### whereis `whereis` 命令与 `which` 命令非常类似,但它提供了更多信息。它不仅仅是寻找可执行文件,它还寻找手册页(man page)和源文件。像 `which` 命令一样,它使用搜索路径(`$PATH`) 来驱动搜索。 @@ -63,7 +63,7 @@ $ whereis locate locate: /usr/bin/locate /usr/share/man/man1/locate.1.gz ``` -#### whatis +### whatis `whatis` 命令有其独特的使命。它不是实际查找文件,而是在手册页中查找有关所询问命令的信息,并从手册页的顶部提供该命令的简要说明。 @@ -79,7 +79,7 @@ $ whatis cleanup cleanup: nothing appropriate. ``` -#### apropos +### apropos 当你知道你想要做什么,但不知道应该使用什么命令来执行此操作时,`apropos` 命令很有用。例如,如果你想知道如何查找文件,那么 `apropos find` 和 `apropos locate` 会提供很多建议。 From cfb29a93ee04df3119e36af24d816ba98da44477 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 9 May 2018 09:02:23 +0800 Subject: [PATCH 0821/1057] translated --- ...e your Python with an interactive shell.md | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/sources/tech/20180425 Enhance your Python with an interactive shell.md b/sources/tech/20180425 Enhance your Python with an interactive shell.md index 4d1f6a9a9d..28f8175e5b 100644 --- a/sources/tech/20180425 Enhance your Python with an interactive shell.md +++ b/sources/tech/20180425 Enhance your Python with an interactive shell.md @@ -1,74 +1,72 @@ -translating---geekpi - -Enhance your Python with an interactive shell +使用交互式 shell 来增强你的 Python ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/03/python-shells-816x345.jpg) -The Python programming language has become one of the most popular languages used in IT. One reason for this success is it can be used to solve a variety of problems. From web development to data science, machine learning to task automation, the Python ecosystem is rich in popular frameworks and libraries. This article presents some useful Python shells available in the Fedora packages collection to make development easier. +Python 编程语言已经成为 IT 中使用的最流行的语言之一。成功的一个原因是它可以用来解决各种问题。从网站开发到数据科学、机器学习到任务自动化,Python 生态系统有丰富的框架和库。本文将介绍 Fedora 软件包集合中提供的一些有用的 Python shell 来简化开发。 ### Python Shell -The Python Shell lets you use the interpreter in an interactive mode. It’s very useful to test code or try a new library. In Fedora you can invoke the default shell by typing python3 in a terminal session. Some more advanced and enhanced shells are available to Fedora, though. +Python Shell 让你以交互模式使用解释器。在测试代码或尝试新库时非常有用。在 Fedora 中,你可以通过在终端会话中输入 python3 来调用默认的 shell。虽然 Fedora 提供了一些更高级和增强的 shell。 ### IPython -IPython provides many useful enhancements to the Python shell. Examples include tab completion, object introspection, system shell access and command history retrieval. Many of these features are also used by the [Jupyter Notebook][1] , since it uses IPython underneath. +IPython 为 Python shell 提供了许多有用的增强功能。例子包括 tab 补全,对象内省,系统 shell 访问和命令历史检索。许多功能也被 [Jupyter Notebook][1] 使用,因为它底层使用 IPython。 -#### Install and run IPython +#### 安装和运行 IPython ``` dnf install ipython3 ipython3 ``` -Using tab completion prompts you with possible choices. This features comes in handy when you use an unfamiliar library. +使用 tab 补全会提示你可能的选择。当你使用不熟悉的库时,此功能会派上用场。 ![][2] -If you need more information, use the documentation by typing the ? command. For more details, you can use the ?? command. +如果你需要更多信息,输入 ? 命令使用文档。有关更多详细信息,你可以使用 ?? 命令。 ![][3] -Another cool feature is the ability to execute a system shell command using the ! character. The result of the command can then be referenced in the IPython shell. +另一个很酷的功能是使用 ! 字符执行系统 shell 命令的能力。然后可以在 IPython shell 中引用该命令的结果。 ![][4] -A comprehensive list of IPython features is available in the [official documentation][5]. +IPython 完整的功能列表可在[官方文档][5]中找到。 ### bpython -bpython doesn’t do as much as IPython, but nonetheless it provides a useful set of features in a simple and lightweight package. Among other features, bpython provides: +bpython 并不能像 IPython 做那么多,但它却在一个简单轻量级包中提供了一系列有用功能。除其他功能之外,bpython 提供: - * In-line syntax highlighting - * Autocomplete with suggestions as you type - * Expected parameter list - * Ability to send or save code to a pastebin service or file + * 内嵌语法高亮显示 + * 在你输入时提供自动补全建议 + * 可预期的参数列表 + * 能够将代码发送或保存到 pastebin 服务或文件中 -#### Install and run bpython +#### 安装和运行 bpython ``` dnf install bpython3 bpython3 ``` -As you type, bpython offers you choices to autocomplete your code. +在你输入的时候,bpython 为你提供了选择来自动补全你的代码。 ![][6] -When you call a function or method, the expected parameters and the docstring are automatically displayed. +当你调用函数或方法时,会自动显示需要的参数和文档字符串。 ![][7] -Another neat feature is the ability to open the current bpython session in an external editor (Vim by default) using the function key F7. This is very useful when testing more complex programs. +另一个很好的功能是可以使用功能键 F7 在外部编辑器(默认为 Vim)中打开当前的 bpython 会话。这在测试更复杂的程序时非常有用。 -For more details about configuration and features, consult the bpython [documentation][8]. +有关配置和功能的更多细节,请参考 bpython [文档][8]。 -### Conclusion +### 总结 -Using an enhanced Python shell is a good way to increase productivity. It gives you enhanced features to write a quick prototype or try out a new library. Are you using an enhanced Python shell? Feel free to mention it in the comment section below. +使用增强的 Python shell 是提高生产力的好方法。它为你提供增强的功能来编写快速原型或尝试新库。你在使用增强的 Python shell 吗?请随意在评论区留言。 -Photo by [David Clode][9] on [Unsplash][10] +图片由 [David Clode][9] 在 [Unsplash][10] 上发布 -------------------------------------------------------------------------------- @@ -77,7 +75,7 @@ via: https://fedoramagazine.org/enhance-python-interactive-shell/ 作者:[Clément Verna][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From af73579eed032ae839d511bab4b6009103edc361 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 9 May 2018 09:03:53 +0800 Subject: [PATCH 0822/1057] translated --- .../20180425 Enhance your Python with an interactive shell.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20180425 Enhance your Python with an interactive shell.md (100%) diff --git a/sources/tech/20180425 Enhance your Python with an interactive shell.md b/translated/tech/20180425 Enhance your Python with an interactive shell.md similarity index 100% rename from sources/tech/20180425 Enhance your Python with an interactive shell.md rename to translated/tech/20180425 Enhance your Python with an interactive shell.md From 9d163128f8cc654fb4c8107e57b2adc6bcd6ac2a Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 9 May 2018 09:07:41 +0800 Subject: [PATCH 0823/1057] translating --- sources/tech/20171221 A Commandline Food Recipes Manager.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20171221 A Commandline Food Recipes Manager.md b/sources/tech/20171221 A Commandline Food Recipes Manager.md index 63fe9a76ab..7a70cb172f 100644 --- a/sources/tech/20171221 A Commandline Food Recipes Manager.md +++ b/sources/tech/20171221 A Commandline Food Recipes Manager.md @@ -1,3 +1,5 @@ +translating---geekpi + HeRM’s - A Commandline Food Recipes Manager ====== ![配图](https://www.ostechnix.com/wp-content/uploads/2017/12/herms-720x340.jpg) From f4077dd58b8d59aa9aa42cc50c6baa197b183cd1 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 9 May 2018 14:21:49 +0800 Subject: [PATCH 0824/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=204=20Firefox=20e?= =?UTF-8?q?xtensions=20to=20install=20now?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...507 4 Firefox extensions to install now.md | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 sources/tech/20180507 4 Firefox extensions to install now.md diff --git a/sources/tech/20180507 4 Firefox extensions to install now.md b/sources/tech/20180507 4 Firefox extensions to install now.md new file mode 100644 index 0000000000..77032f0345 --- /dev/null +++ b/sources/tech/20180507 4 Firefox extensions to install now.md @@ -0,0 +1,75 @@ +4 Firefox extensions to install now +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/redpanda_firefox_pet_animal.jpg?itok=aSpKsyna) +As I mentioned in my [original article][1] on Firefox extensions, the web browser has become a critical component of the computing experience for many users. Modern browsers have evolved into powerful and extensible platforms, and extensions can add or modify their functionality. Extensions for Firefox are built using the WebExtensions API, a cross-browser development system. + +In the first article, I asked readers: "Which extensions should you install?" To reiterate, that decision largely comes down to how you use your browser, your views on privacy, how much you trust extension developers, and other personal preferences. Since that article was published, one extension I recommended (Xmarks) has been discontinued. Additionally, that article received a ton of feedback that has been taken into account for this update. + +Once again, I'd like to point out that browser extensions often require the ability to read and/or change everything on the web pages you visit. You should consider the ramifications of this very carefully. If an extension has modify access to all the web pages you visit, it could act as a keylogger, intercept credit card information, track you online, insert advertisements, and perform a variety of other nefarious activities. That doesn't mean every extension will surreptitiously do these things, but you should carefully consider the installation source, the permissions involved, your risk profile, and other factors before you install any extension. Keep in mind you can use profiles to manage how an extension impacts your attack surface—for example, using a dedicated profile with no extensions to perform tasks such as online banking. + +With that in mind, here are four open source Firefox extensions you may want to consider. + +### uBlock Origin + +![ublock origin ad blocker screenshot][2] + +My first recommendation remains unchanged. [uBlock Origin][3] is a fast, low memory, wide-spectrum blocker that allows you to not only block ads but also enforce your own content filtering. The default behavior of uBlock Origin is to block ads, trackers, and malware sites using multiple, predefined filter lists. From there it allows you to arbitrarily add lists and rules, or even lock down to a default-deny mode. Despite being powerful, the extension has proven to be efficient and performant. It continues to be updated regularly and is one of the best options available for this functionality. + +### Privacy Badger + +![privacy badger ad blocker][4] + +My second recommendation also remains unchanged. If anything, privacy has been brought even more to the forefront since my previous article, making this extension an easy recommendation. As the name indicates, [Privacy Badger][5] is a privacy-focused extension that blocks ads and other third-party trackers. It's a project of the Electronic Freedom Foundation, which says: + +> "Privacy Badger was born out of our desire to be able to recommend a single extension that would automatically analyze and block any tracker or ad that violated the principle of user consent; which could function well without any settings, knowledge, or configuration by the user; which is produced by an organization that is unambiguously working for its users rather than for advertisers; and which uses algorithmic methods to decide what is and isn't tracking." + +Why is Privacy Badger on this list when the previous item may seem similar? A couple reasons. The first is that it fundamentally works differently than uBlock Origin. The second is that a practice of defense in depth is a sound policy to follow. Speaking of defense in depth, the EFF also maintains [HTTPS Everywhere][6] to automatically ensure https is used for many major websites. When you're installing Privacy Badger, you may want to consider HTTPS Everywhere as well. + +In case you were starting to think this article was simply going to be a rehash of the last one, here's where my recommendations diverge. + +### Bitwarden + +![Bitwarden][7] + +When recommending LastPass in the previous article, I mentioned it was likely going to be a controversial selection. That certainly proved true. Whether you should use a password manager at all—and if you do, whether you should choose one that has a browser plugin—is a hotly debated topic, and the answer very much depends on your personal risk profile. I asserted that most casual computer users should use one because it's much better than the most common alternative: using the same weak password everywhere. I still believe that. + +[Bitwarden][8] has really matured since the last time I checked it out. Like LastPass, it is user-friendly, supports two-factor authentication, and is reasonably secure. Unlike LastPass, it is [open source][9]. It can be used with or without the browser plugin and supports importing from other solutions including LastPass. The core functionality is completely free, and there is a premium version that is $10/year. + +### Vimium-FF + +![Vimium][10] + +[Vimium][11] is another open source extension that provides Firefox keyboard shortcuts for navigation and control in the spirit of Vim. They call it "The Hacker's Browser." Modifier keys are specified as **< c-x>**, **< m-x>**, and **< a-x>** for Ctrl+x, Meta+x, and Alt+x, respectively, and the defaults can be easily customized. Once you have Vimium installed, you can see this list of key bindings at any time by typing **?**. Note that if you prefer Emacs, there are also a couple of extensions for those keybindings as well. Either way, I think keyboard shortcuts are an underutilized productivity booster. + +### Bonus: Grammarly + +Not everyone is lucky enough to write a column on Opensource.com—although you should seriously consider writing for the site; if you have questions, are interested, or would like a mentor, reach out and let's chat. But even without a column to write, proper grammar is beneficial in a large variety of situations. Enter [Grammarly][12]. This extension is not open source, unfortunately, but it does make sure everything you type is clear, effective, and mistake-free. It does this by scanning your text for common and complex grammatical mistakes, spanning everything from subject-verb agreement to article use to modifier placement. Basic functionality is free, with a premium version with additional checks available for a monthly charge. I used it for this article and it caught multiple errors that my proofreading didn't. + +Again, Grammarly is the only extension included on this list that is not open source, so if you know of a similar high-quality open source replacement, let us know in the comments. + +These extensions are ones I've found useful and recommend to others. Let me know in the comments what you think of the updated recommendations. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/firefox-extensions + +作者:[Jeremy Garcia][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/jeremy-garcia +[1]:https://opensource.com/article/18/1/top-5-firefox-extensions +[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/ublock.png?itok=_QFEbDmq (ublock origin ad blocker screenshot) +[3]:https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/ +[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/privacy_badger_1.0.1.png?itok=qZXQeKtc (privacy badger ad blocker screenshot) +[5]:https://www.eff.org/privacybadger +[6]:https://www.eff.org/https-everywhere +[7]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/bitwarden.png?itok=gZPrCYoi (Bitwarden) +[8]:https://bitwarden.com/ +[9]:https://github.com/bitwarden +[10]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/vimium.png?itok=QRESXjWG (Vimium) +[11]:https://addons.mozilla.org/en-US/firefox/addon/vimium-ff/ +[12]:https://www.grammarly.com/ From 8b737171bfd7b3e9bda280ed17ca7bf3469ea7b5 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 9 May 2018 14:24:25 +0800 Subject: [PATCH 0825/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20reading=20l?= =?UTF-8?q?ist=20for=20Linux=20and=20open=20source=20fans?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ing list for Linux and open source fans.md | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 sources/tech/20180507 A reading list for Linux and open source fans.md diff --git a/sources/tech/20180507 A reading list for Linux and open source fans.md b/sources/tech/20180507 A reading list for Linux and open source fans.md new file mode 100644 index 0000000000..b0ef168cfe --- /dev/null +++ b/sources/tech/20180507 A reading list for Linux and open source fans.md @@ -0,0 +1,162 @@ +A reading list for Linux and open source fans +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_stack_library_reading.jpg?itok=uulcS8Sw) +I recently asked our writer community to share with us what they're reading. These folks come from all different walks of life and roles in tech. What they have in common is that they are living and breathing Linux and open source every day. + +Drink in this fantastic list. Many of them are free and available to download. + +You may see books you've been meaning to get around to, books that are completely new to you, and some that feel like old friends. + +We'd love to hear what you think of this list. Share with us in the comments below or on [Twitter][1] with #Linuxbooks #opensourcebooks. + +### 17 books to add to your reading list + +**Plus, a bonus fiction read.** + +[23 Years of FreeDOS][2] by Jim Hall + +Last year, the [FreeDOS][3] Project turned 23 years old. While there's nothing special about 23 years, the project decided to celebrate that milestone by sharing stories about how different people use or contribute to FreeDOS. The free, CC BY eBook is a collection of essays that describe the history of FreeDOS since 1994, and how people use FreeDOS today. (Recommendation and review by [Jim Hall][4]) + +[Eloquent JavaScript][5] by Marijn Haverbeke + +This book teaches you how to write beautifully crafted programs using one of the most ubiquitous programming languages: [Javascript][6]. Learn the basics and advanced concepts of the language, and how to write programs that run in the browser or Node.js environment. The book also includes five fun projects so you can dive into actual programming while making a platform game or even writing your own programming language. (Recommendation and review by [Rahul Thakoor][7]) + +[_Forge Your Future with Open Source_][8] by VM (Vicky) Brasseur + +If you're looking to contribute to open source, but you don't know how to start, this is the book for you. It covers how to find a project to join and how to make your first contributions. (Recommendation and review by [Ben Cotton][9]) + +[_Git for Teams_][10] by Emma Jane Hogbin Westby + +Git is a widely-used version control system for individuals and teams alike, but its power means it can be complex. This book provides guidance on how to effectively use [git][11] in a team environment. For more, read our [in-depth review][12]. (Recommendation and review by [Ben Cotton][9]) + +[Getting to Yes][13] by Fisher, Ury, and Patton + +The Harvard Negotiation Project, formed in the 1970s, was an academic effort involving economists, psychologists, sociologists, and political scientists to create a framework for negotiations which allows better outcomes for all involved. Their framework and techniques have been used in a diverse set of circumstances, including the Camp David Accords between Egypt and Israel in 1978. + +Principled Negotiation involves understanding the real interests of the participants in a negotiation and using this knowledge to generate options acceptable to all. The same techniques can be used to resolve interpersonal issues, negotiations over cars and houses, discussions with insurance companies, and so on. + +What does this have to do with open source software development? Everything in open source is a negotiation, in some sense. Submitting a bug report is outlining a position—that something does not work correctly—and requesting that someone reprioritize their work to fix it. A heated discussion on a mailing list over the right way to do something or a comment on a feature request is a negotiation, often with imperfect knowledge, about the scope and goals of the project. + +Reframing these conversations as explorations, trying to understand why the other person is asking for something, and being transparent about the reasons why you believe another viewpoint to apply, can dramatically change your relationships and effectiveness working in an open source project. (Recommendation and review by [Dave Neary][14]) + +[Just for Fun: The Story of an Accidental Revolutionary][15] by Linus Torvalds et al. + +Linux is an amazing and powerful operating system that spawned a movement to transparency and openness. And, the open source ethos that drives it flies in the face of traditional models of business and capital appreciation. In this book, learn about the genius of Linus the man and [Linux][16] the operating system. Get insight into the experiences that shaped Linus's life and fueled his transformation from a nerdy young man who enjoyed toying with his grandfather's clock to the master programmer of the world's predominant operating system. (Recommendation and review by [Don Watkins][17]) + +[Linux in a Month of Lunches][18] by Steven Ovadia + +This book is designed to teach non-technical users how to use desktop [Linux][19] in about an hour a day. The book covers everything from choosing a desktop environment to installing software, to using Git. At the end of the month, readers can use Linux fulltime, replacing their other operating systems. (Recommendation and review by [Steven Ovadia][20]) + +[Linux in Action][21] by David Clinton + +This book introduces serious Linux administration tools for anyone interested in getting more out of their tech, including IT professionals, developers, [DevOps][22] specialists, and more. Rather than teaching skills in isolation, the book is organized around practical projects like automating off-site data backups, securing a web server, and creating a VPN to safely connect an organization's resources. [Read more][23] by this author. (Recommendation and review by [David Clinton][24]) + +[Make: Linux for Makers][25] by Aaron Newcomb + +This book is a must-read for anyone wanting to create and innovate with the [Raspberry Pi][26]. This book will have you up and operating your Raspberry Pi while at the same time understanding the nuances of it Raspbian Linux operating system. This is a masterful basic text that will help any maker unlock the potential of the Raspberry Pi. It’s concise and well written with a lot of fantastic illustrations and practical examples. (Recommendation by Jason Hibbets | Review by [Don Watkins][17]) + +[Managing Humans: Biting and Humorous Tales of a Software Engineering Manager][27] by Michael Lopp + +Michael Lopp is better known by the nom de plume Rands, author of the popular blog [Rands in Repose][28]. This book is an edited, curated collection of blog posts, all related to the management of software development teams. What I love about the book and the blog, is that Rands starts from the fundamental principle that the most complex part of software development is human interactions. The book covers a range of topics about reading a group, understanding the personalities that make it up, and figuring out how to get the best out of everyone. + +These things are universal, and as an open source community manager, I come across them all the time. How do you know if someone might be burning out? How do you run a good meeting? How do you evolve the culture of a project and team as it grows? How much process is the right amount? Regardless of the activity, questions like these arise all the time, and Rands's irreverent, humorous take is educational and entertaining. (Recommendation and review by [Dave Neary][14]) + +[Open Sources: Voices from the Open Source Revolution][29] (O'Reilly, 1999) + +This book is a must-read for all open source enthusiasts. Linus Torvalds, Eric S. Raymond, Richard Stallman, Michael Tiemann, Tim O'Reilly, and other important figures in the open source movement share their thoughts on the forward momentum of [open source software][30]. (Recommendation by [Jim Hall][4] | Review by Jen Wike Huger) + +[Producing Open Source Software: How to Run a Successful Free Software Project][31] by Karl Fogel + +This book is for anyone who wants to build an open source community, is already building one, or wants to better understand trends in successful open source project community development. Karl Fogel analyzes and studies traits and characteristics of successful open source projects and how they have developed a community around the project. The book offers helpful advice to community managers (or want-to-be community managers) on how to navigate community development around a project. This is a rare book that takes a deeper look into open source community development and offers plenty of ingredients for success, but you have to take it and create the recipe for your project or community. (Recommendation and review by [Justin Flory][32]) + +[Programming with Robots][33] by Albert W. Schueller + +This book introduces the basics of programming using the Lego Mindstorms NXT. Instead of writing abstract programs, learn how to program devices that can sense and interface with the physical world. Learn how software and hardware interact with each other while experimenting with sensors, motors or making music using code. (Recommendation and review by [Rahul Thakoor][7]) + +[The AWK programming language][34] by Alfred V. Aho, Brian W. Kernighan, and Peter J. Weinberger + +This book, written by the creators of awk, follows a pattern similar to other books about *nix tools written by the original Bell Labs Unix team and published in the 1970s-1990s, explaining the rationale and intended use of awk in clear and compact prose, liberally sprinkled with examples that start simply and are further elaborated by the need to deal with more fully-detailed problems and edge cases. When published, the typical reader of this book would have been someone who had files of textual or numeric data that needed to be processed and transformed, and who wanted to be able to easily create lookup tables, apply regular expressions, react to structure changes within the input, apply mathematical transformations to numbers and easily format the output. + +While that characterization still applies, today the book can also provide a window back into the time when the only user interface available was a terminal, when "modularity" created the ability to string together numerous single-purpose utility programs in shell scripts to create data transformation pipelines that crunched the data and produced the reports that everyone expected of computers. Today, awk should be a part of the operations toolbox, providing a fine ability to further process configuration and log files, and this book still provides a great introduction to that process. (Recommendation by [Jim Hall][4] | Review by [Chris Hermansen][35]) + +[Think Python: Think Like a Computer Scientist][36] by Allen Downey + +This book about [Python][37] is part of [a series][38] that covers other languages as well, like Java, [Perl][39], etc. It moves past simple language syntax downloads and approaches the topic through the lens of how a problem solver would build a solution. It's both a great introductory guide to programming through a layering of concepts, but it can serve the dabbler who is looking to develop skills in an area such as classes or inheritance with chapters that have examples and exercises to then apply the skills taught. (Recommendation and review by [Steve Morris][40]) + +[Understanding Open Source and Free Software Licensing][41] (O'Reilly, 2004) + +"This book bridges the gap between the open source vision and the practical implications of its legal underpinnings. If open source and free software licenses interest you, this book will help you understand them. If you're an open source/free software developer, this book is an absolute necessity." (Recommendation by [Jim Hall][4] | review from [Amazon][42]) + +[Unix Text Processing][43] by Dale Dougherty and Tim O'Reilly + +This book was written in 1987 as an introduction to Unix systems and how writers could use Unix tools to do work. It's still a useful resource for beginners to learn the basics of the Unix shell, the vi editor, awk and shell scripts, and the nroff and troff typesetting system. The original edition is out of print, but O'Reilly has made the book available for free via their website. (Recommendation and review by [Jim Hall][4]) + +### Bonus: Fiction book + +[Station Eleven][44] by Emily St. John Mandel + +This story is set in a near future, twenty years after the earth's population has been decimated by a mysterious and deadly flu. We follow Kirsten Raymonde, a young woman who is traveling near the Great Lakes with a nomadic theatre group because "Survival is insufficient," as she makes her way through the post-apocalyptic world. It's a wonderful story, well worth reading. + +What struck me about the book is how tenuous our relationship with technology actually is. In the Douglas Adams book "Mostly Harmless", there is a great line: "Left to his own devices he couldn't build a toaster. He could just about make a sandwich and that was it." This is the world of Kristin Raymonde. Everyone has been left to their own devices: There is no electricity because no one can work the power grid. No cars, no oil refineries. + +There is a fascinating passage where one inventor has rigged up a generator with a bicycle and is trying to turn on a laptop, trying to see if there is still an internet. We discover the Museum of Civilization, stocked with objects which have no use, which has been left over from the old world: passports, mobile phones, credit cards, stilettoes. + +All of the world's technology becomes useless. (Recommendation and review by [Dave Neary][14]) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/list-books-Linux-open-source + +作者:[Jen Wike Huger][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/remyd +[1]:https://twitter.com/opensourceway +[2]:http://www.freedos.org/ebook/ +[3]:https://opensource.com/article/18/5/node/44116 +[4]:https://opensource.com/users/jim-hall +[5]:https://eloquentjavascript.net/ +[6]:https://opensource.com/article/18/5/node/32826 +[7]:https://opensource.com/users/rahul27 +[8]:https://pragprog.com/book/vbopens/forge-your-future-with-open-source +[9]:https://opensource.com/users/bcotton +[10]:http://gitforteams.com/ +[11]:https://opensource.com/article/18/5/node/43741 +[12]:https://opensource.com/business/15/11/git-for-teams-review +[13]:http://www.williamury.com/books/getting-to-yes/ +[14]:https://opensource.com/users/dneary +[15]:http://a.co/749s27n +[16]:https://opensource.com/article/18/5/node/19796 +[17]:https://opensource.com/users/don-watkins +[18]:https://manning.com/ovadia +[19]:https://opensource.com/article/18/5/node/42626 +[20]:https://opensource.com/users/stevenov +[21]:https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9 +[22]:https://opensource.com/article/18/5/node/44696 +[23]:https://bootstrap-it.com/index.php/books/ +[24]:https://opensource.com/users/dbclinton +[25]:https://www.makershed.com/products/make-linux-for-makers +[26]:https://opensource.com/article/18/5/node/35731 +[27]:https://www.amazon.com/Managing-Humans-Humorous-Software-Engineering/dp/1484221575/ref=dp_ob_title_bk +[28]:http://randsinrepose.com/ +[29]:https://www.oreilly.com/openbook/opensources/book/index.html +[30]:https://opensource.com/article/18/5/node/42001 +[31]:https://producingoss.com/ +[32]:https://opensource.com/users/justinflory +[33]:http://engineering.nyu.edu/gk12/amps-cbri/pdf/RobotC%20FTC%20Books/notesRobotC.pdf +[34]:https://archive.org/details/pdfy-MgN0H1joIoDVoIC7 +[35]:https://opensource.com/users/clhermansen +[36]:http://greenteapress.com/thinkpython2/thinkpython2.pdf +[37]:https://opensource.com/article/18/5/node/40481 +[38]:http://greenteapress.com/wp/ +[39]:https://opensource.com/article/18/5/node/35141 +[40]:https://opensource.com/users/smorris12 +[41]:http://shop.oreilly.com/product/9780596005818.do +[42]:https://www.amazon.com/Understanding-Open-Source-Software-Licensing/dp/0596005814 +[43]:http://www.oreilly.com/openbook/utp/ +[44]:http://www.emilymandel.com/stationeleven.html From ec90184c5027e1a91deb20a89082534a1b315886 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 9 May 2018 14:26:38 +0800 Subject: [PATCH 0826/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20Beginners?= =?UTF-8?q?=20Guide=20To=20Cron=20Jobs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20180504 A Beginners Guide To Cron Jobs.md | 230 ++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 sources/tech/20180504 A Beginners Guide To Cron Jobs.md diff --git a/sources/tech/20180504 A Beginners Guide To Cron Jobs.md b/sources/tech/20180504 A Beginners Guide To Cron Jobs.md new file mode 100644 index 0000000000..22b1749444 --- /dev/null +++ b/sources/tech/20180504 A Beginners Guide To Cron Jobs.md @@ -0,0 +1,230 @@ +A Beginners Guide To Cron Jobs +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/05/cron-jobs1-720x340.jpg) +**Cron** is one of the most useful utility that you can find in any Unix-like operating system. It is used to schedule commands at a specific time. These scheduled commands or tasks are known as “Cron Jobs”. Cron is generally used for running scheduled backups, monitoring disk space, deleting files (for example log files) periodically which are no longer required, running system maintenance tasks and a lot more. In this brief guide, we will see the basic usage of Cron Jobs in Linux. + +### The Beginners Guide To Cron Jobs + +The typical format of a cron job is: +``` +Minute(0-59) Hour(0-24) Day_of_month(1-31) Month(1-12) Day_of_week(0-6) Command_to_execute + +``` + +Just memorize the cron job format or print the following illustration and keep it in your desk. + +![][2] + +In the above picture, the asterisks refers the specific blocks of time. + +To display the contents of the **crontab** file of the currently logged in user: +``` +$ crontab -l + +``` + +To edit the current user’s cron jobs, do: +``` +$ crontab -e + +``` + +If it is the first time, you will be asked to editor to edit the jobs. +``` +no crontab for sk - using an empty one + +Select an editor. To change later, run 'select-editor'. + 1. /bin/nano <---- easiest + 2. /usr/bin/vim.basic + 3. /usr/bin/vim.tiny + 4. /bin/ed + +Choose 1-4 [1]: + +``` + +Choose any one that suits you. Here it is how a sample crontab file looks like. + +![][3] + +In this file, you need to add your cron jobs. + +To edit the crontab of a different user, for example ostechnix, do: +``` +$ crontab -u ostechnix -e + +``` + +Let us see some examples. + +To run a cron job **every minute** , the format should be like below. +``` +* * * * * + +``` + +To run cron job every 5 minute, add the following in your crontab file. +``` +*/5 * * * * + +``` + +To run a cron job at every quarter hour (every 15th minute), add this: +``` +*/15 * * * * + +``` + +To run a cron job every hour at 30 minutes, run: +``` +30 * * * * + +``` + +You can also define multiple time intervals separated by commas. For example, the following cron job will run three times every hour, at minutes 0, 5 and 10: +``` +0,5,10 * * * * + +``` + +Run a cron job every half hour: +``` +*/30 * * * * + +``` + +Run a job every hour: +``` +0 * * * * + +``` + +Run a job every 2 hours: +``` +0 */2 * * * + +``` + +Run a job every day (It will run at 00:00): +``` +0 0 * * * + +``` + +Run a job every day at 3am: +``` +0 3 * * * + +``` + +Run a job every sunday: +``` +0 0 * * SUN + +``` + +Or, +``` +0 0 * * 0 + +``` + +It will run at exactly at 00:00 on Sunday. + +Run a job on every day-of-week from Monday through Friday i.e every weekday: +``` +0 0 * * 1-5 + +``` + +The job will start at 00:00. + +Run a job every month: +``` +0 0 1 * * + +``` + +Run a job at 16:15 on day-of-month 1: +``` +15 16 1 * * + +``` + +Run a job at every quarter i.e on day-of-month 1 in every 3rd month: +``` +0 0 1 */3 * + +``` + +Run a job on a specific month at a specific time: +``` +5 0 * 4 * + +``` + +The job will start at 00:05 in April. + +Run a job every 6 months: +``` +0 0 1 */6 * + +``` + +This cron job will start at 00:00 on day-of-month 1 in every 6th month. + +Run a job every year: +``` +0 0 1 1 * + +``` + +This cron job will start at 00:00 on day-of-month 1 in January. + +We can also use the following strings to define job. + +@reboot Run once, at startup. @yearly Run once a year. @annually (same as @yearly). @monthly Run once a month. @weekly Run once a week. @daily Run once a day. @midnight (same as @daily). @hourly Run once an hour. + +For example, to run a job every time the server is rebooted, add this line in your crontab file. +``` +@reboot + +``` + +To remove all cron jobs for the current user: +``` +$ crontab -r + +``` + +There is also a dedicated website named [**crontab.guru**][4] for learning cron jobs examples. This site provides a lot of cron job examples. + +For more details, check man pages. +``` +$ man crontab + +``` + +And, that’s all for now. At this point, you might have a basic understanding of cron jobs and how to use them in real time. More good stuffs to come. Stay tuned!! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/ + +作者:[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]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]:http://www.ostechnix.com/wp-content/uploads/2018/05/cron-job-format-1.png +[3]:http://www.ostechnix.com/wp-content/uploads/2018/05/cron-jobs-1.png +[4]:https://crontab.guru/ From c89e26ce9a5f9bfb17a8fdffc3db45ab715be7e5 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 9 May 2018 14:35:30 +0800 Subject: [PATCH 0827/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Systemd=20Servi?= =?UTF-8?q?ces:=20Beyond=20Starting=20and=20Stopping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Services- Beyond Starting and Stopping.md | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md diff --git a/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md b/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md new file mode 100644 index 0000000000..10dec9e5df --- /dev/null +++ b/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md @@ -0,0 +1,181 @@ +Systemd Services: Beyond Starting and Stopping +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/systemd-minetest-2.jpg?itok=bXO0ggHL) +[In the previous article][1], we showed how to create a systemd service that you can run as a regular user to start and stop your game server. As it stands, however, your service is still not much better than running the server directly. Let's jazz it up a bit by having it send out emails to the players, alerting them when the server becomes available and warning them when it is about to be turned off: +``` +# minetest.service + +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple + +ExecStart= /usr/games/minetest --server +ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" "Minetest Starting up" + +TimeoutStopSec= 180 +ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" " +  Minetest Stopping in 2 minutes" +ExecStop= /bin/sleep 120 +ExecStop= /bin/kill -2 $MAINPID + +``` + +There are a few new things in here. First, there's the `ExecStartPost` directive. You can use this directive for anything you want to run right after the main application starts. In this case, you run a custom script, `mtsendmail` (see below), that sends an email to your friends telling them that the server is up. +``` +#!/bin/bash +# mtsendmail +echo $1 | mutt -F /home//.muttrc -s "$2" my_minetest@mailing_list.com + +``` + +You can use [Mutt][2], a command-line email client, to shoot off your messages. Although the script shown above is to all practical effects only one line long, remember you can't have a line with pipes and redirections as a systemd unit argument, so you have to wrap it in a script. + +For the record, there is also an `ExecStartPre` directive for things you want to execute before starting the service proper. + +Next up, you have a block of commands that close down the server. The `TimeoutStopSec` directive pushes up the time before systemd bails on shutting down the service. The default time out value is round about 90 seconds. Anything longer, and systemd will force the service to close down and report a failure. But, as you want to give your users a couple of minutes before closing the server completely, you are going to push the default up to three minutes. This will stop systemd from thinking the closedown has failed. + +Then the close down proper starts. Although there is no `ExecStopPre` as such, you can simulate running stuff before closing down your server by using more than one `ExecStop` directive. They will be executed in order, from topmost to bottommost, and will allow you to send out a message before the server is actually stopped. + +With that in mind, the first thing you do is shoot off an email to your friends, warning them the server is going down. Then you wait two minutes. Finally you close down the server. Minetest likes to be closed down with [Ctrl] + [c], which translates into an interrupt signal ( _SIGINT_ ). That is what you do when you issue the `kill -2 $MAINPID` command. `$MAINPID` is a systemd variable for your service that points to the PID of the main application. + +This is much better! Now, when you run +``` +systemctl --user start minetest + +``` + +The service will start up the Minetest server and send out an email to your users. Likewise when you are about to close down, but giving two minutes to users to log off. + +### Starting at Boot + +The next step is to make your service available as soon as the machine boots up, and close down when you switch it off at night. + +Start be moving your service out to where the system services live, The directory youa re looking for is _/etc/systemd/system/_ : +``` +sudo mv /home//.config/systemd/user/minetest.service /etc/systemd/system/ + +``` + +If you were to try and run the service now, it would have to be with superuser privileges: +``` +sudo systemctl start minetest + +``` + +But, what's more, if you check your service's status with +``` +sudo systemctl status minetest + +``` + +You would see it had failed miserably. This is because systemd does not have any context, no links to worlds, textures, configuration files, or details of the specific user running the service. You can solve this problem by adding the `User` directive to your unit: +``` +# minetest.service + +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple +User= + +ExecStart= /usr/games/minetest --server +ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" +  "Minetest Starting up" + +TimeoutStopSec= 180 +ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" +  "Minetest Stopping in 2 minutes" +ExecStop= /bin/sleep 120 +ExecStop= /bin/kill -2 $MAINPID + +``` + +The `User` directive tells systemd which user's environment it should use to correctly run the service. You could use root, but that would probably be a security hazard. You could also use your personal user and that would be a bit better, but what many administrators do is create a specific user for each service, effectively isolating the service from the rest of the system and users. + +The next step is to make your service start when you boot up and stop when you power down your computer. To do that you need to _enable_ your service, but, before you can do that, you have to tell systemd where to _install_ it. + +In systemd parlance, _installing_ means telling systemd when in the boot sequence should your service become activated. For example the _cups.service_ , the service for the _Common UNIX Printing System_ , will have to be brought up after the network framework is activated, but before any other printing services are enabled. Likewise, the _minetest.service_ uses a user's email (among other things) and will have to be slotted in when the network is up and services for regular users become available. + +You do all that by adding a new section and directive to your unit: +``` +... +[Install] +WantedBy= multi-user.target + +``` + +You can read this as "wait until we have everything ready for a multiples user system." Targets in systemd are like the old run levels and can be used to put your machine into one state or another, or, like here, to tell your service to wait until a certain state has been reached. + +Your final _minetest.service_ file will look like this: +``` +# minetest.service +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple +User= + +ExecStart= /usr/games/minetest --server +ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" +  "Minetest Starting up" + +TimeoutStopSec= 180 +ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" +  "Minetest Stopping in 2 minutes" +ExecStop= /bin/sleep 120 +ExecStop= /bin/kill -2 $MAINPID + +[Install] +WantedBy= multi-user.target + +``` + +Before trying it out, you may have to do some adjustments to your email script: +``` +#!/bin/bash +# mtsendmail + +sleep 20 +echo $1 | mutt -F /home//.muttrc -s "$2" my_minetest@mailing_list.com +sleep 10 + +``` + +This is because the system will need some time to set up the emailing system (so you wait 20 seconds) and also some time to actually send the email (so you wait 10 seconds). Notice that these are the wait times that worked for me. You may have to adjust these for your own system. + +And you're done! Run: +``` +sudo systemctl enable minetest + +``` + +and the Minetest service will come online when you power up and gracefully shut down when you power off, warning your users in the process. + +### Conclusion + +The fact that Debian, Ubuntu, and distros of the same family have a special package called _minetest-server_ that does some of the above for you (but no messaging!) should not deter you from setting up your own customised services. In fact, the version you set up here is much more versatile and does more than Debian's default server. + +Furthermore, the process described here will allow you to set up most simple servers as services, whether they are for games, web applications, or whatever. And those are the first steps towards veritable systemd guruhood. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2018/5/systemd-services-beyond-starting-and-stopping + +作者:[Paul Brown][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/bro66 +[1]:https://www.linux.com/blog/learn/intro-to-linux/2018/5/writing-systemd-services-fun-and-profit +[2]:http://www.mutt.org/ From 55e6026cdacfdd1a4f9cbaa439b886fb6b0ae106 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 9 May 2018 21:02:00 +0800 Subject: [PATCH 0828/1057] Update 20170213 Getting Started with Taskwarrior.md --- sources/tech/20170213 Getting Started with Taskwarrior.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20170213 Getting Started with Taskwarrior.md b/sources/tech/20170213 Getting Started with Taskwarrior.md index 3fccc15498..303fc4ecc9 100644 --- a/sources/tech/20170213 Getting Started with Taskwarrior.md +++ b/sources/tech/20170213 Getting Started with Taskwarrior.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + Getting Started with Taskwarrior ====== Taskwarrior is a flexible [command-line task management program][1]. In their [own words][2]: From 76eb4ca3cc172c13400f83a3e61d93ee080ec0d9 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 10 May 2018 08:53:32 +0800 Subject: [PATCH 0829/1057] 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 b97b5cd394fde8cba0807d99edc0d1e20fc2123f Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 10 May 2018 08:56:30 +0800 Subject: [PATCH 0830/1057] Delete 20170213 Getting Started with Taskwarrior.md --- ...170213 Getting Started with Taskwarrior.md | 241 ------------------ 1 file changed, 241 deletions(-) delete mode 100644 sources/tech/20170213 Getting Started with Taskwarrior.md diff --git a/sources/tech/20170213 Getting Started with Taskwarrior.md b/sources/tech/20170213 Getting Started with Taskwarrior.md deleted file mode 100644 index 303fc4ecc9..0000000000 --- a/sources/tech/20170213 Getting Started with Taskwarrior.md +++ /dev/null @@ -1,241 +0,0 @@ -Translating by MjSeven - - -Getting Started with Taskwarrior -====== -Taskwarrior is a flexible [command-line task management program][1]. In their [own words][2]: - -Taskwarrior manages your TODO list from your command line. It is flexible, fast, efficient, unobtrusive, does its job then gets out of your way. - -Taskwarrior is highly customizable, but can also be used "right out of the box." In this article, we'll show you the basic commands to add and complete tasks. Then we'll cover a couple more advanced commands. And finally, we'll show you some basic configuration settings to begin customizing your setup. - -### Installing Taskwarrior - -Taskwarrior is available in the Fedora repositories, so installing it is simple: -``` -sudo dnf install task - -``` - -Once installed, run `task`. This first run will create a `~/.taskrc` file for you. -``` -$ **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. - -``` - -### Adding Tasks - -Adding tasks is fast and unobtrusive. -``` -$ **task add Plant the wheat** -Created task 1. - -``` - -Run `task` or `task list` to show upcoming tasks. -``` -$ **task list** - -ID Age Description Urg - 1 8s Plant the wheat 0 - -1 task - -``` - -Let's add a few more tasks to round out the example. -``` -$ **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. - -``` - -Run `task` again to view the list. -``` -[task next] - -ID Age Description Urg - 1 3min Plant the wheat 0 - 2 22s Tend the wheat 0 - 3 16s Cut the wheat 0 - 4 8s Take the wheat to the mill to be ground into flour 0 - 5 2s Bake a cake 0 - -5 tasks - -``` - -### Completing Tasks - -To mark a task as complete, look up its ID and run: -``` -$ **task 1 done** -Completed task 1 'Plant the wheat'. -Completed 1 task. - -``` - -You can also mark a task done with its description. -``` -$ **task 'Tend the wheat' done** -Completed task 1 'Tend the wheat'. -Completed 1 task. - -``` - -With `add`, `list` and `done`, you're all ready to get started with Taskwarrior. - -### Setting Due Dates - -Many tasks do not require a due date: -``` -task add Finish the article on Taskwarrior - -``` - -But sometimes, setting a due date is just the kind of motivation you need to get productive. Use the `due` modifier when adding a task to set a specific due date. -``` -task add Finish the article on Taskwarrior due:tomorrow - -``` - -`due` is highly flexible. It accepts specific dates ("2017-02-02"), or ISO-8601 ("2017-02-02T20:53:00Z"), or even relative time ("8hrs"). See the [Date & Time][3] documentation for all the examples. - -Dates go beyond due dates too. Taskwarrior has `scheduled`, `wait`, and `until`. -``` -task add Proof the article on Taskwarrior scheduled:thurs - -``` - -Once the date (Thursday in this example) passes, the task is tagged with the `READY` virtual tag. It will then show up in the `ready` report. -``` -$ **task ready** - -ID Age S Description Urg - 1 2s 1d Proof the article on Taskwarrior 5 - -``` - -To remove a date, `modify` the task with a blank value: -``` -$ task 1 modify scheduled: - -``` - -### Searching Tasks - -No task list is complete without the ability to search with regular expressions, right? -``` -$ **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 - -``` - -### Customizing Taskwarrior - -Remember that file we created back in the beginning (`~/.taskrc`). Let's take at the defaults: -``` -# [Created by task 2.5.1 2/9/2017 16:39:14] -# Taskwarrior program configuration file. -# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-color', -# 'man task-sync' or 'man taskrc' - -# Here is an example of entries that use the default, override and blank values -# variable=foo -- By specifying a value, this overrides the default -# variable= -- By specifying no value, this means no default -# #variable=foo -- By commenting out the line, or deleting it, this uses the default - -# Use the command 'task show' to see all defaults and overrides - -# Files -data.location=~/.task - -# Color theme (uncomment one to use) -#include /usr//usr/share/task/light-16.theme -#include /usr//usr/share/task/light-256.theme -#include /usr//usr/share/task/dark-16.theme -#include /usr//usr/share/task/dark-256.theme -#include /usr//usr/share/task/dark-red-256.theme -#include /usr//usr/share/task/dark-green-256.theme -#include /usr//usr/share/task/dark-blue-256.theme -#include /usr//usr/share/task/dark-violets-256.theme -#include /usr//usr/share/task/dark-yellow-green.theme -#include /usr//usr/share/task/dark-gray-256.theme -#include /usr//usr/share/task/dark-gray-blue-256.theme -#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 - - -``` - -The only active option right now is `data.location=~/.task`. To view active configuration settings (including the built-in defaults), run `show`. -``` -task show - -``` - -To change a setting, use `config`. -``` -$ **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. - -``` - -### Examples - -These are just some of the things you can do with Taskwarrior. - -Assign a project to your tasks: -``` -task 'Fix leak in the roof' modify project:Home - -``` - -Use `start` to mark what you were working on. This can help you remember what you were working on after the weekend: -``` -task 'Fix bug #141291' start - -``` - -Use relevant tags: -``` -task add 'Clean gutters' +weekend +house - -``` - -Be sure to read the [complete documentation][4] to learn all the ways you can catalog and organize your tasks. - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/getting-started-taskwarrior/ - -作者:[Link Dupont][a] -译者:[译者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/linkdupont/ -[1]:https://taskwarrior.org/ -[2]:https://taskwarrior.org/docs/start.html -[3]:https://taskwarrior.org/docs/dates.html -[4]:https://taskwarrior.org/docs/ From 2f96ab39e2e7129eaaa987b6a798d0c8df8a7e45 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Thu, 10 May 2018 08:57:03 +0800 Subject: [PATCH 0831/1057] Create 20170213 Getting Started with Taskwarrior.md --- ...170213 Getting Started with Taskwarrior.md | 240 ++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 translated/tech/20170213 Getting Started with Taskwarrior.md diff --git a/translated/tech/20170213 Getting Started with Taskwarrior.md b/translated/tech/20170213 Getting Started with Taskwarrior.md new file mode 100644 index 0000000000..2edf0562d5 --- /dev/null +++ b/translated/tech/20170213 Getting Started with Taskwarrior.md @@ -0,0 +1,240 @@ +Taskwarrior 入门 +===== + +Taskwarrior 是一个灵活的[命令行任务管理程序][1],用他们[自己的话说][2]: + +Taskwarrior 是从你的命令行管理你的 TODO 列表。它灵活,快速,高效,不显眼,它默默做自己的事情让你避免自己管理。 + +Taskwarrior 是高度可定制的,但也可以“立即使用”。在本文中,我们将向你展示添加和完成任务的基本命令,然后我们将介绍几个更高级的命令。最后,我们将向你展示一些基本的配置设置,以开始自定义你的设置。 + +### 安装 Taskwarrior + +Taskwarrior 在 Fedora 仓库中是可用的,所有安装它很容易: +``` +sudo dnf install task + +``` + +一旦完成安装,运行 `task`。第一次运行将会创建一个 `~/.taskrc` 文件。 +``` +$ **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** +Created task 1. + +``` + +运行 `task` 或者 `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` 来查看列表。 +``` +[task next] + +ID Age Description Urg + 1 3min Plant the wheat 0 + 2 22s Tend the wheat 0 + 3 16s Cut the wheat 0 + 4 8s Take the wheat to the mill to be ground into flour 0 + 5 2s Bake a cake 0 + +5 tasks + +``` + +### 完成任务 + +将一个任务标记为完成, 查找其 ID 并运行: +``` +$ **task 1 done** +Completed task 1 'Plant the wheat'. +Completed 1 task. + +``` + +你也可以用它的描述来标记一个任务已完成。 +``` +$ **task 'Tend the wheat' done** +Completed task 1 'Tend the wheat'. +Completed 1 task. + +``` + +通过使用 `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] 文档。 + +日期也会超出截止日期,Taskwarrior 有 `scheduled`, `wait` 和 `until` 选项。 +``` +task add Proof the article on Taskwarrior scheduled:thurs + +``` + +一旦日期(本例中的星期四)通过,该任务就会被标记为 `READY` 虚拟标记。它会显示在 `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** + +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. +# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-color', +# 'man task-sync' or 'man taskrc' + +# Here is an example of entries that use the default, override and blank values +# variable=foo -- By specifying a value, this overrides the default +# variable= -- By specifying no value, this means no default +# #variable=foo -- By commenting out the line, or deleting it, this uses the default + +# Use the command 'task show' to see all defaults and overrides + +# Files +data.location=~/.task + +# Color theme (uncomment one to use) +#include /usr//usr/share/task/light-16.theme +#include /usr//usr/share/task/light-256.theme +#include /usr//usr/share/task/dark-16.theme +#include /usr//usr/share/task/dark-256.theme +#include /usr//usr/share/task/dark-red-256.theme +#include /usr//usr/share/task/dark-green-256.theme +#include /usr//usr/share/task/dark-blue-256.theme +#include /usr//usr/share/task/dark-violets-256.theme +#include /usr//usr/share/task/dark-yellow-green.theme +#include /usr//usr/share/task/dark-gray-256.theme +#include /usr//usr/share/task/dark-gray-blue-256.theme +#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`。 +``` +task show + +``` + +改变设置,使用 `config`。 +``` +$ **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 + +``` + +务必阅读[完整文档][4]以了解你可以编目和组织任务的所有方式。 + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/getting-started-taskwarrior/ + +作者:[Link Dupont][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/linkdupont/ +[1]:https://taskwarrior.org/ +[2]:https://taskwarrior.org/docs/start.html +[3]:https://taskwarrior.org/docs/dates.html +[4]:https://taskwarrior.org/docs/ From 6936285bb4c0e346a357e2e1d07ef6b312c3fe54 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 10 May 2018 09:01:53 +0800 Subject: [PATCH 0832/1057] 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 0833/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Impr?= =?UTF-8?q?ove=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 0834/1057] 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 0835/1057] 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 0836/1057] 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 0837/1057] 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 0838/1057] 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 0839/1057] 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 0840/1057] 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 0841/1057] 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 0842/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Person=20with?= =?UTF-8?q?=20diabetes=20finds=20open=20source=20and=20builds=20her=20own?= =?UTF-8?q?=20medical=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 0843/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=204MLinux=20Reviv?= =?UTF-8?q?es=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 0844/1057] 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 0845/1057] 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 0846/1057] 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 0847/1057] 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 0848/1057] 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 0849/1057] 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 0850/1057] 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 0851/1057] 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 0852/1057] 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 0853/1057] 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 0854/1057] 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 0855/1057] 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 0856/1057] 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 0857/1057] 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 0858/1057] 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 0859/1057] 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 0860/1057] 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 0861/1057] 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 0862/1057] 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 0863/1057] 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 0864/1057] 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 0865/1057] 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 0866/1057] 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 0867/1057] 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 0868/1057] 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 0869/1057] 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 0870/1057] 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 0871/1057] 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 0872/1057] 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 0873/1057] 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 0874/1057] 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 0875/1057] 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 0876/1057] 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 0877/1057] 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 0878/1057] [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 0879/1057] 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 0880/1057] 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 0881/1057] 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 0882/1057] 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 0883/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20Methods=20T?= =?UTF-8?q?o=20Install=20Latest=20Python3=20Package=20On=20CentOS=206=20Sy?= =?UTF-8?q?stem?= 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 0884/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Analyzing=20Ans?= =?UTF-8?q?ible=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 0885/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Disp?= =?UTF-8?q?lay=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 0886/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20MidnightBSD=20C?= =?UTF-8?q?ould=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 0887/1057] 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 0888/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Chec?= =?UTF-8?q?k=20Ubuntu=20Version=20and=20Other=20System=20Information=20Eas?= =?UTF-8?q?ily?= 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 0889/1057] =?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 0890/1057] 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 0891/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=2011=20Methods=20?= =?UTF-8?q?To=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 0892/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Looking=20at=20?= =?UTF-8?q?the=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 0893/1057] 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 0894/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Orbital=20Apps?= =?UTF-8?q?=20=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 0895/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20UKTools=20-=20E?= =?UTF-8?q?asy=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 0896/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20a=20unive?= =?UTF-8?q?rsity=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 0897/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20the=20fou?= =?UTF-8?q?r=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 0898/1057] 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 0899/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Creating=20smal?= =?UTF-8?q?l=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 0900/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Get=20more=20do?= =?UTF-8?q?ne=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 0901/1057] 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 0902/1057] 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 0903/1057] 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 0904/1057] 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 0905/1057] 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 0906/1057] 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 0907/1057] 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 0908/1057] 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 0909/1057] 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 0910/1057] 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 0911/1057] 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 0912/1057] =?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 0913/1057] 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 0914/1057] 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 0915/1057] 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 0916/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20useful=20th?= =?UTF-8?q?ings=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 0917/1057] 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 0918/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20LikeCoin,=20a?= =?UTF-8?q?=20cryptocurrency=20for=20creators=20of=20openly=20licensed=20c?= =?UTF-8?q?ontent?= 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 0919/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Chec?= =?UTF-8?q?k=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 0920/1057] 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 0921/1057] 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 0922/1057] 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 0923/1057] 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 0924/1057] 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 0925/1057] 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 0926/1057] 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 0927/1057] 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 0928/1057] 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 0929/1057] [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 0930/1057] 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 0931/1057] 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 0932/1057] 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 0933/1057] 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 8bfea82fc54f3653fc3cf6af6f1282c826b38ff9 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 15 May 2018 22:18:38 +0800 Subject: [PATCH 0934/1057] add translation tag --- ...hods To Install Latest Python3 Package On CentOS 6 System.md | 2 ++ 1 file changed, 2 insertions(+) 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 index 6de6e9e416..646b046015 100644 --- 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 @@ -1,3 +1,5 @@ +pinewall translating + 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. From 8876285ff079a277bed0a2d8f25fefec2a6b0fd8 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 15 May 2018 22:22:46 +0800 Subject: [PATCH 0935/1057] add translation tag --- .../20180502 Writing Systemd Services for Fun and Profit.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md b/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md index 042c46aedd..04203cccd7 100644 --- a/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md +++ b/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md @@ -1,3 +1,5 @@ +pinewall translating + Writing Systemd Services for Fun and Profit ====== From fa6ac8b50da1b641f73f8b3ed6990a42d6f40bcb Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 15 May 2018 22:24:00 +0800 Subject: [PATCH 0936/1057] add translation tag --- .../20180507 Systemd Services- Beyond Starting and Stopping.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md b/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md index 10dec9e5df..30c4968847 100644 --- a/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md +++ b/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md @@ -1,3 +1,5 @@ +pinewall translating + Systemd Services: Beyond Starting and Stopping ====== From 89509b6902be87ecb6b9bd351bf710b76af9fc76 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 16 May 2018 08:12:43 +0800 Subject: [PATCH 0937/1057] 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 0938/1057] 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 0939/1057] 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 0940/1057] 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 0941/1057] 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 0942/1057] 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 0943/1057] 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 0944/1057] 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) From fd9c168a539d31736279fbc61d331c7f5c876b07 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 16 May 2018 12:23:31 +0800 Subject: [PATCH 0945/1057] Delete 20171221 How to create mobile-friendly documentation.md --- ...to create mobile-friendly documentation.md | 98 ------------------- 1 file changed, 98 deletions(-) delete mode 100644 sources/tech/20171221 How to create mobile-friendly documentation.md diff --git a/sources/tech/20171221 How to create mobile-friendly documentation.md b/sources/tech/20171221 How to create mobile-friendly documentation.md deleted file mode 100644 index eb1b7444d2..0000000000 --- a/sources/tech/20171221 How to create mobile-friendly documentation.md +++ /dev/null @@ -1,98 +0,0 @@ -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) -I'm not sold on the whole idea of [mobile first][1], but I do know that more people than ever are using mobile devices like smartphones and tablets to get information on the go. That includes online software and hardware documentation, much of which is lengthy and poorly suited for small screens. Often, it doesn't scale properly, and it can be difficult to navigate. - -When people access documentation using a mobile device, they usually want a quick hit of information to learn how to perform a task or solve a problem. They don't want to wade through seemingly endless pages to find the specific piece of information they need. Fortunately, it's not hard to address this problem. Here are a few tips to help you structure your documentation to meet the needs of mobile readers. - -### Think short - -That means short sentences, short paragraphs, and short procedures. You're not writing a novel or a piece of long-form journalism. Make your documentation concise. Use as few words as possible to get ideas and information across. - -Use a radio news report as a guide: Focus on the key elements and explain them in simple, direct language. Don't make your reader wade through screen after screen of turgid text. - -Focus on the key elements and explain them in simple, direct language. - -Also, get straight to the point. Focus on the information readers need when they need it. Documentation published online shouldn't resemble the thick manuals of yore. Don't lump everything together on a single page. Break your information into smaller chunks. Here's how to do that: - -### Think topics - -Also, get straight to the point. Focus on the information readers need when they need it. Documentation published online shouldn't resemble the thick manuals of yore. Don't lump everything together on a single page. Break your information into smaller chunks. Here's how to do that: - -In the technical writing world, topics are individual, stand-alone chunks of information. Each topic comprises a single page on your site. Readers should be able to get the information they need--and only that information--from a specific topic. To make that happen, choose which topics to include in your documentation and decide how to organize them: - -### Think DITA - -[Darwin Information Typing Architecture][2], or DITA, is an XML model for writing and publishing. It's been [widely adopted][3] in the technical writing world, especially for longer documentation sets. - -I'm not suggesting that you convert your documentation to XML (unless you really want to). Instead, consider applying DITA's concept of separate types of topics to your documentation: - - * General: overview information - * Task: step-by-step procedures - * Concept: background or conceptual information - * Reference: specialized information like API references or data dictionaries - * Glossary: to define terms - * Troubleshooting: information on problems users may encounter and how to fix them - - - -You'll wind up with a lot of individual pages. To connect those pages: - -### Think linking - -Many content management systems, wikis, and publishing frameworks include some form of navigation--usually a table of contents or [breadcrumbs][4]. It's the kind of navigation that fades into the background on a mobile device. - -For stronger navigation, add explicit links between topics. Place those links at the end of each topic with the heading **See Also** or **Related Topics**. Each section should contain two to five links that point to overview, concept, and reference topics related to the current topic. - -If you need to point to information outside of your documentation set, make sure the link opens in a new browser tab. That sends the reader to another site while also keeping them on your site. - -If you need to point to information outside of your documentation set, make sure the link opens in a new browser tab. - -That takes care of the text. What about graphics? - -### Think unadorned - -That takes care of the text. What about graphics? - -With a few exceptions, images don't add much to documentation. Take a critical look at each image in your documentation. Then ask: - - * Does it serve a purpose? - * Does it enhance the documentation? - * Will readers miss this image if I remove it? - - - -With a few exceptions, images don't add much to documentation. - -If the answer to those questions is no, remove the image. - -If the answer to those questions is no, remove the image. - -On the other hand, if you absolutely can't do without an image, make it [responsive][5]. That way, the image will automatically resize to fit in a smaller screen. - -If you're still not sure about an image, Opensource.com community moderator Ben Cotton offers an [excellent explanation][6] of when to use screen captures in documentation. - -### A final thought - -With a little effort, you can structure your documentation to work well for mobile device users. Another plus: These changes improve documentation for desktop computer and laptop users, too. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/12/think-mobile - -作者:[Scott Nesbitt][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/chrisshort -[1]:https://www.uxmatters.com/mt/archives/2012/03/mobile-first-what-does-it-mean.php -[2]:https://en.wikipedia.org/wiki/Darwin_Information_Typing_Architecture -[3]:http://dita.xml.org/book/list-of-organizations-using-dita -[4]:https://en.wikipedia.org/wiki/Breadcrumb_(navigation) -[5]:https://en.wikipedia.org/wiki/Responsive_web_design -[6]:https://opensource.com/business/15/9/when-does-your-documentation-need-screenshots From 073a1fdccf973c87da68cf92e5e3e3a643203c98 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 16 May 2018 12:23:56 +0800 Subject: [PATCH 0946/1057] Create 20171221 How to create mobile-friendly documentation.md --- ...to create mobile-friendly documentation.md | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 translated/tech/20171221 How to create mobile-friendly documentation.md diff --git a/translated/tech/20171221 How to create mobile-friendly documentation.md b/translated/tech/20171221 How to create mobile-friendly documentation.md new file mode 100644 index 0000000000..61efa2bca1 --- /dev/null +++ b/translated/tech/20171221 How to create mobile-friendly documentation.md @@ -0,0 +1,82 @@ +如何创建适合移动设备的文档 +===== +to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些没有翻译 + +![配图](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd) +我并不是完全相信[移动为先][1]的理念,但是我确实发现更多的人使用只能手机和平板电脑等移动设备来获取信息。这包括在线的软件和硬件文档,但它们大部分都是冗长的,不适合小屏幕。通常情况下,它的伸缩性不太好,而且很难导航。 + +当用户使用移动设备访问文档时,他们通常需要迅速获取信息以了解如何执行任务或解决问题,他们不想通过看似无尽的页面来寻找他们需要的特定信息。幸运的是,解决这个问题并不看来。以下是一些提示,可以帮助你构建文档以满足移动阅读器的需求。 + +### 简短一点 + +这意味着简短的句子,简短的段落和简短的程序。你不是在写一部长篇小说或一段长新闻。使你的文档简洁。尽可能使用少量的语言来获得想法和信息。 + +以广播新闻报道为示范:关注关键要素,用简单直接的语言对其进行解释。不要让你的读者在屏幕上看到冗长的文字。 + +另外,直接切入重点。关注读者需要的信息。在线发布的文档不应该像以前厚厚的手册一样。不要把所有东西都放在一个页面上,把你的信息分成更小的块。接下来是怎样做到这一点: + +### 主题 + +在技术写作的世界里,主题是独立的,独立的信息块。每个主题都包含你网站上的单个页面。读者应该能从特定的主题中获取他们需要的信息 -- 并且只是那些信息。要做到这一点,选择哪些主题要包含在文档中并决定如何组织它们: + +### 考虑 DITA + +[Darwin Information Typing Architecture][2] 或 DITA 是用于编写和发布的一个 XML 模型。它在技术写作中被[广泛采用][3],特别是对于教程的文档集。 + +我并不是建议你将文档转换为 XML(除非你真的想)。相反,考虑将 DITA 的不同类型主题的概念应用到你的文档中: + +* 一般:概述信息 +* 任务:分布程序 +* 概念:背景或概念信息 +* 参考:API 参考或数据字典等专用信息 +* 术语表:定义术语 +* 故障排除:有关用户可能遇到的问题以及如何解决问题的信息 + +你会得到很多单独的页面。要连接这些页面: + +### 考虑链接 + +许多内容管理系统,维基和发布框架都包含某种形式的导航 - 通常是目录或[面包屑][4],这是一种在移动设备上淡入背景的导航。 + +为了加强导航,在主题之间添加明确的链接。将这些链接放在每个主题末尾的标题**另请参阅**或**相关主题**。每个部分应包含两到五个链接,指向与当前主题相关的概述,概念和参考主题。 + +如果你需要指向文档集之外的信息,请确保链接在浏览器新的选项中打开。这将把读者送到另一个网站,同时也将读者留你的网站上。 + +这解决了文本问题,那么图片呢? + +### 考虑不使用图片 + +除少数情况之外,图片不会增加太多文档。仔细查看文档中的每个图片,然后问自己: + +* 它有用吗? +* 它是否增强了文档? +* 如果删除它,读者会错过这张图片吗? + +如果回答否,那么移除图片。 + +另一方面,如果你绝对不能没有图片,就让它变成[响应式的][5]。这样,图片就会自动调整以适应更小的屏幕。 + +如果你仍然不确定图片是否应该出现,Opensource.com 社区版主 Ben Cotton 提供了一个关于在文档中使用屏幕截图的[极好的解释][6]。 + +### 最后的想法 + +通过较少的努力,你就可以构建文档以便移动设备用户很好的阅读。另外还有:这些更改也改进了桌面计算机和笔记本电脑用户的文档。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/12/think-mobile + +作者:[Scott Nesbitt][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/chrisshort +[1]:https://www.uxmatters.com/mt/archives/2012/03/mobile-first-what-does-it-mean.php +[2]:https://en.wikipedia.org/wiki/Darwin_Information_Typing_Architecture +[3]:http://dita.xml.org/book/list-of-organizations-using-dita +[4]:https://en.wikipedia.org/wiki/Breadcrumb_(navigation) +[5]:https://en.wikipedia.org/wiki/Responsive_web_design +[6]:https://opensource.com/business/15/9/when-does-your-documentation-need-screenshots From 70abc4b1f51d1f38e19c3e90c224c0751d4eb81a Mon Sep 17 00:00:00 2001 From: qhwdw Date: Wed, 16 May 2018 14:02:08 +0800 Subject: [PATCH 0947/1057] Translated by qhwdw --- ...80308 Dynamic Linux Routing with Quagga.md | 112 ------------------ ...80308 Dynamic Linux Routing with Quagga.md | 111 +++++++++++++++++ 2 files changed, 111 insertions(+), 112 deletions(-) delete mode 100644 sources/tech/20180308 Dynamic Linux Routing with Quagga.md create mode 100644 translated/tech/20180308 Dynamic Linux Routing with Quagga.md diff --git a/sources/tech/20180308 Dynamic Linux Routing with Quagga.md b/sources/tech/20180308 Dynamic Linux Routing with Quagga.md deleted file mode 100644 index 967295ac89..0000000000 --- a/sources/tech/20180308 Dynamic Linux Routing with Quagga.md +++ /dev/null @@ -1,112 +0,0 @@ -Translating by qhwdw -Dynamic Linux Routing with Quagga -============================================================ - - -![network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/network_visualization.png?itok=P3Ve7eO1 "network") -Learn how to use the Quagga suite of routing protocols to manage dynamic routing.[Creative Commons Attribution][1][Wikimedia Commons: Martin Grandjean][2] - -So far in this series, we have learned the intricacies of IPv4 addressing in [Linux LAN Routing for Beginners: Part 1][4] and how to create static routes manually in [Linux LAN Routing for Beginners: Part 2][5]. - -Now we're going to use [Quagga][6] to manage dynamic routing for us, just set it and forget it. Quagga is a suite of routing protocols: OSPFv2, OSPFv3, RIP v1 and v2, RIPng, and BGP-4, which are all managed by the zebra daemon. - -OSPF means Open Shortest Path First. OSPF is an interior gateway protocol (IGP); it is for LANs and LANs connected over the Internet. Every OSPF router in your network contains the topology for the whole network, and calculates the best paths through the network. OSPF automatically multicasts any network changes that it detects. You can divide up your network into areas to keep routing tables manageable; the routers in each area only need to know the next hop out of their areas rather than the entire routing table for your network. - -RIP, Routing Information Protocol, is an older protocol. RIP routers periodically multicast their entire routing tables to the network, rather than just the changes as OSPF does. RIP measure routes by hops, and sees any destination over 15 hops as unreachable. RIP is simple to set up, but OSPF is a better choice for speed, efficiency, and scalability. - -BGP-4 is the Border Gateway Protocol version 4\. This is an exterior gateway protocol (EGP) for routing Internet traffic. You won't use BGP unless you are an Internet service provider. - -### Preparing for OSPF - -In our little KVM test lab, there are two virtual machines representing two different networks, and one VM acting as the router. Create two networks: net1 is 192.168.110.0/24 and net2 is 192.168.120.0/24\. It's all right to enable DHCP because you are going to go into your three virtual machines and give each of them static addresses. Host 1 is on net1, Host 2 is on net2, and Router is on both networks. Give Host 1 a gateway of 192.168.110.126, and Host 2 gets 192.168.120.136. - -* Host 1: 192.168.110.125 - -* Host 2: 192.168.120.135 - -* Router: 192.168.110.126 and 192.168.120.136 - -Install Quagga on your router, which on most Linuxes is the quagga package. On Debian there is a separate documentation package, quagga-doc. Uncomment this line in `/etc/sysctl.conf` to enable packet forwarding: - -``` -net.ipv4.ip_forward=1 -``` - -Then run the `sysctl -p` command to load the change. - -### Configuring Quagga - -Look in your Quagga package for example configuration files, such as `/usr/share/doc/quagga/examples/ospfd.conf.sample`. Configuration files should be in `/etc/quagga`, unless your particular Linux flavor does something creative with them. Most Linuxes ship with just two files in this directory, `vtysh.conf` and `zebra.conf`. These provide minimal defaults to enable the daemons to run. zebra always has to run first, and again, unless your distro has done something strange, it should start automatically when you start ospfd. Debian/Ubuntu is a special case, which we will get to in a moment. - -Each router daemon gets its own configuration file, so we must create `/etc/quagga/ospfd.conf`, and populate it with these lines: - -``` -!/etc/quagga/ospfd.conf -hostname router1 -log file /var/log/quagga/ospfd.log -router ospf - ospf router-id 192.168.110.15 - network 192.168.110.0/0 area 0.0.0.0 - network 192.168.120.0/0 area 0.0.0.0 -access-list localhost permit 127.0.0.1/32 -access-list localhost deny any -line vty - access-class localhost -``` - -You may use either the exclamation point or hash marks to comment out lines. Let's take a quick walk through these options. - -* **hostname** is whatever you want. This isn't a normal Linux hostname, but the name you see when you log in with `vtysh` or `telnet`. - -* **log file** is whatever file you want to use for the logs. - -* **router** specifies the routing protocol. - -* **ospf router-id** is any 32-bit number. An IP address of the router is good enough. - -* **network** defines the networks your router advertises. - -* The **access-list** entries restrict `vtysh`, the Quagga command shell, to the local machine, and deny remote administration. - -### Debian/Ubuntu - -Debian, Ubuntu, and possibly other Debian derivatives require one more step before you can launch the daemon. Edit `/etc/quagga/daemons` so that all lines say `no` except `zebra`=yes and `ospfd=yes`. - -Then, to launch `ospfd` on Debian launch Quagga: - -``` -# systemctl start quagga -``` - -On most other Linuxes, including Fedora and openSUSE, start `ospfd`: - -``` -# systemctl start ospfd -``` - -Now Host 1 and Host 2 should ping each other, and the router. - -That was a lot of words to describe a fairly simple setup. In real life the router will connect to two switches and provide a gateway for all the computers attached to those switches. You could add more network interfaces to your router to provide routing for more networks, or connect directly to another router, or to a LAN backbone that connects to other routers. - -You probably don't want to hassle with configuring network interfaces manually. The easy way is to advertise your router with your DHCP server. If you use Dnsmasq then you get DHCP and DNS all in one. - -There are many more configuration options, such as encrypted password protection. See the official documentation at [Quagga Routing Suite][7]. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/3/dynamic-linux-routing-quagga - -作者:[CARLA SCHRODER ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/licenses/category/creative-commons-attribution -[2]:https://commons.wikimedia.org/wiki/File:Network_Visualization.png -[3]:https://www.linux.com/files/images/networkvisualizationpng -[4]:https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginners-part-1 -[5]:https://www.linux.com/learn/intro-to-linux/2018/3/linux-lan-routing-beginners-part-2 -[6]:https://www.quagga.net/ -[7]:https://www.quagga.net/ diff --git a/translated/tech/20180308 Dynamic Linux Routing with Quagga.md b/translated/tech/20180308 Dynamic Linux Routing with Quagga.md new file mode 100644 index 0000000000..bfa7ad3c89 --- /dev/null +++ b/translated/tech/20180308 Dynamic Linux Routing with Quagga.md @@ -0,0 +1,111 @@ +使用 Quagga 实现 Linux 动态路由 +============================================================ + + +![network](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/network_visualization.png?itok=P3Ve7eO1 "network") +学习如何使用 Quagga 套件的路由协议去管理动态路由。[Creative Commons Attribution][1][Wikimedia Commons: Martin Grandjean][2] + +迄今为止,本系列文章中,我们已经在 [Linux 局域网路由新手指南:第 1 部分][4] 中学习了复杂的 IPv4 地址,在  [Linux 局域网路由新手指南:第 2 部分][5] 中学习了如何去手工创建静态路由。 + +今天,我们继续使用 [Quagga][6] 去管理动态路由,这是一个安装完后就不用理它的的软件。Quagga 是一个支持 OSPFv2、OSPFv3、RIP v1 和 v2、RIPng、以及 BGP-4 的路由协议套件,并全部由 zebra 守护程序管理。 + +OSPF 的意思是最短路径优先。OSPF 是一个内部网关协议(IGP);它可以用在局域网和跨因特网的局域网互联中。在你的网络中的每个 OSPF 路由器都包含整个网络的拓扑,并计算通过网络的最短路径。OSPF 会通过多播的方式自动对外传播它检测到的网络变化。你可以将你的网络分割为区域,以保持路由表的可管理性;每个区域的路由器只需要知道离开它的区域的下一跳接口地址,而不用记录你的网络的整个路由表。 + +RIP,路由信息协议,是一个很老的协议,RIP 路由器向网络中周期性多播它的整个路由表,而不是像 OSPF 那样只多播网络的变化。RIP 通过跳数来测量路由,任何超过 15 跳的路由它均视为不可到达。RIP 设置很简单,但是 OSPF 在速度、效率、以及弹性方面更佳。 + +BGP-4 是边界网关协议版本 4。这是用于因特网流量路由的外部网关协议(EGP)。你不会用到 BGP 协议的,除非你是因特网服务提供商。 + +### 准备使用 OSPF + +在我们的小型 KVM 测试实验室中,用两台虚拟机表示两个不同的网络,然后将另一台虚拟机配置为路由器。创建两个网络:net1 是 192.168.110.0/24 而 net2 是 192.168.120.0/24。启用 DHCP 是明智的,否则你要分别进入这三个虚拟机,去为它们设置静态地址。Host 1 在 net1 中,Host 2 在 net2 中,而路由器同时与这两个网络连接。设置 Host 1 的网关地址为 192.168.110.126,Host 2 的网关地址为 192.168.120.136。 + +* Host 1: 192.168.110.125 + +* Host 2:192.168.120.135 + +* Router:192.168.110.126 和 192.168.120.136 + +在路由器上安装 Quagga。在大多数 Linux 中它是一个 quagga 包。在 Debian 上还有一个单独的文档包 quagga-doc。取消 `/etc/sysctl.conf` 配置文件中如下这一行的注释去启用包转发功能: + +``` +net.ipv4.ip_forward=1 +``` + +然后,运行 `sysctl -p` 命令让变化生效。 + +### 配置 Quagga + +查看你的 Quagga 包中的示例配置文件,比如,`/usr/share/doc/quagga/examples/ospfd.conf.sample`。除非你的 Linux 版本按你的喜好做了创新,否则,一般情况下配置文件应该在 `/etc/quagga` 目录中。大多数 Linux 版本在这个目录下有两个文件,`vtysh.conf`  和 `zebra.conf`。它们提供了守护程序运行所需要的最小配置。除非你的发行版做了一些特殊的配置,否则,zebra 总是首先运行,当你启动 ospfd 的时候,它将自动启动。Debian/Ubuntu 是一个特例,稍后我们将会说到它。 + +每个路由器守护程序将读取它自己的配置文件,因此,我们必须创建 `/etc/quagga/ospfd.conf`,并输入如下内容: + +``` +!/etc/quagga/ospfd.conf +hostname router1 +log file /var/log/quagga/ospfd.log +router ospf + ospf router-id 192.168.110.15 + network 192.168.110.0/0 area 0.0.0.0 + network 192.168.120.0/0 area 0.0.0.0 +access-list localhost permit 127.0.0.1/32 +access-list localhost deny any +line vty + access-class localhost +``` + +你可以使用感叹号(!)或者井号(#)去注释掉这些行。我们来快速浏览一下这些选项。 + +* **hostname** 是你希望的任何内容。这里不是一般意义上的 Linux 主机名,但是,当你使用 `vtysh` 或者 `telnet` 登入时,你将看到它们。 + +* **log file** 是你希望用于保存日志的任意文件。 + +* **router** 指定路由协议。 + +* **ospf router-id** 是任意的 32 位数字。使用路由器的一个 IP 地址就是很好的选择。 + +* **network** 定义你的路由器要通告的网络。 + +* **access-list** 限制 `vtysh` 登入,它是 Quagga 命令行 shell,它允许本地机器登入,并拒绝任何远程管理。 + +### Debian/Ubuntu + +在你启动守护程序之前,Debian/Ubuntu 相对其它的 Debian 衍生版可能多需要一步到多步。编辑 `/etc/quagga/daemons` ,除了 `zebra`=yes 和 `ospfd=yes` 外,使其它所有的行的值为 `no`。 + +然后,在 Debian 上运行 `ospfd` 去启动 Quagga: + +``` +# systemctl start quagga +``` + +在大多数的其它 Linux 上,包括 Fedora 和 openSUSE,用如下命令启动 `ospfd`: + +``` +# systemctl start ospfd +``` + +现在,Host 1 和 Host 2 将可以互相 ping 通对方和路由器。 + +这里用了许多篇幅去描述非常简单的设置。在现实中,路由器将连接两个交换机,然后为连接到这个交换机上的所有电脑提供一个网关。你也可以在你的路由器上添加更多的网络接口,这样你的路由器就可以为更多的网络提供路由服务,或者也可以直接连接到其它路由器上,或者连接到连接其它路由器的骨干网络上。 + +你或许不愿意如此麻烦地手工配置网络接口。最简单的方法是使用你的 DHCP 服务器去宣告你的路由器。如果你使用了 Dnsmasq,那么你就有了一个 DHCP 和 DNS 的一体化解决方案。 + +还有更多的配置选项,比如,加密的密码保护。更多内容请查看 [Quagga 路由套件][7] 的官方文档。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/3/dynamic-linux-routing-quagga + +作者:[CARLA SCHRODER ][a] +译者:[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/licenses/category/creative-commons-attribution +[2]:https://commons.wikimedia.org/wiki/File:Network_Visualization.png +[3]:https://www.linux.com/files/images/networkvisualizationpng +[4]:https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginners-part-1 +[5]:https://www.linux.com/learn/intro-to-linux/2018/3/linux-lan-routing-beginners-part-2 +[6]:https://www.quagga.net/ +[7]:https://www.quagga.net/ From 1008644d9592bbdff3095665866b463016ed3601 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Wed, 16 May 2018 19:52:30 +0800 Subject: [PATCH 0948/1057] Translated by qhwdw --- ...03 3 ways robotics affects the CIO role.md | 53 ------------------- ...03 3 ways robotics affects the CIO role.md | 52 ++++++++++++++++++ 2 files changed, 52 insertions(+), 53 deletions(-) delete mode 100644 sources/tech/20171103 3 ways robotics affects the CIO role.md create mode 100644 translated/tech/20171103 3 ways robotics affects the CIO role.md 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 deleted file mode 100644 index e89b72ee1a..0000000000 --- a/sources/tech/20171103 3 ways robotics affects the CIO role.md +++ /dev/null @@ -1,53 +0,0 @@ -Translating by qhwdw -3 ways robotics affects the CIO role -====== -![配图](https://enterprisersproject.com/sites/default/files/styles/620x350/public/cio_ai.png?itok=toMIgELj) -As 2017 comes to a close, many CIOs are solidifying their goals for 2018. Perhaps yours involve robotic process automation (RPA.) For years, RPA has been a distant concept for many companies. But as organizations are forced to become ever more nimble and efficient, the potential benefits of RPA bear examining. - -According to a recent[ survey][1] by Redwood Software and Sapio Research, IT decision makers believe that 59 percent of business processes can be automated in the next five years, creating new speed and efficiency while relieving their human counterparts of repetitive manual workloads. However, 20 percent of companies with more than 1000 employees currently have no RPA strategy in place. - -For CIOs, RPA has implications for your role in the business and for your team. Here are three ways that the role of the CIO and other IT decision makers can change as RPA gains prominence in 2018: - -### Added opportunity to be strategic change agents - -As the pressure grows to do more with less, internal processes matter greatly. In every enterprise, employees across departments are performing critical - yet mundane - tasks every single day. These tasks may be boring and repetitive, but they must be performed quickly, and often with no room for error. - -**[ For advice on maximizing your automation strategy's ROI, see our related article,[How to improve ROI on automation: 4 tips][2]. ]** - -From back-office operations in finance to procurement, supply chain, accounting, customer service, and human resources, nearly every position within an organization is plagued with at least some monotonous tasks. For CIOs, this opens up an opportunity to unite the business with IT and spearhead strategic change with RPA. - -Having evolved far beyond screen-scraping technology of the past, robots are now customizable, plug-and-play solutions that can be built to an organization's specific needs. With such a process-centric approach, companies can automate not only tasks previously executed by humans, but also application and system-specific tasks, such as ERP and other enterprise applications. - -Enabling a greater level of automation for end-to-end processes is where the value lies. CIOs will be on the front line of this opportunity. - -### Renewed focus on people and training - -Technology shifts can be unnerving to employees, especially when these changes involve automating substantial portions of their daily duties. The CIO should articulate how RPA will change roles and responsibilities for the better, and fuel data-driven, strategic decisions that will ultimately impact the bottom line. - -When implementing RPA, it's important to convey that humans will always be critical to the success of the organization, and that success requires the right balance of technology and human skills. - -CIOs should also analyze workflow and implement better processes that go beyond mimicking end-user specific tasks. Through end-to-end process automation, CIOs can enable employees to shine. - -Because it will be important to upskill and retrain employees throughout the automation process, CIOs must be prepared to collaborate with the C-suite to determine training programs that help employees navigate the change with confidence. - -### Demand for long-term thinking - -To succeed with robotic process automation, brands must take a long-term approach. This will require a scalable solution, which in turn will benefit the entire business model, including customers. When Amazon introduced faster delivery options for Prime customers, for example, it didn't just retool the entire order fulfillment process in its warehouses; it automated its online customer experience to make it simpler, faster, and easier than ever for consumers to place orders. - -In the coming year, CIOs can approach technology in the same way, architecting holistic solutions to change the way an organization operates. Reducing headcount will net only so much in bottom-line results, but process automation allows CIOs to think bigger through optimization and empowerment. This approach gives CIOs the opportunity to build credibility for the long haul, for themselves and for RPA. This in turn will enhance the CIO's role as a navigator and contributor to the organization's overall success. - -For CIOs, taking a long-term, strategic approach to RPA success takes time and hard work. Nevertheless, CIOs who commit the time to create a strategy that balances manpower and technology will deliver value now and in the future. - --------------------------------------------------------------------------------- - -via: https://enterprisersproject.com/article/2017/11/3-ways-robotics-affects-cio-role - -作者:[Dennis Walsh][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/dennis-walsh -[1]:https://www.redwood.com/press-releases/it-decision-makers-speak-59-of-business-processes-could-be-automated-by-2022/ -[2]:https://enterprisersproject.com/article/2017/11/how-improve-roi-automation-4-tips?sc_cid=70160000000h0aXAAQ diff --git a/translated/tech/20171103 3 ways robotics affects the CIO role.md b/translated/tech/20171103 3 ways robotics affects the CIO role.md new file mode 100644 index 0000000000..ae4f3e4f9c --- /dev/null +++ b/translated/tech/20171103 3 ways robotics affects the CIO role.md @@ -0,0 +1,52 @@ +机器人学影响 CIO 角色的 3 种方式 +====== +![配图](https://enterprisersproject.com/sites/default/files/styles/620x350/public/cio_ai.png?itok=toMIgELj) +随着 2017 即将结束,许多 CIO 们的 2018 年目标也将确定。或许你们将参与到机器人流程自动化(RPA)中。多年以来,RPA 对许多公司来说只是一个可望不可及的概念。但是随着组织被迫变得越来越敏捷高效,RPA 所具有的潜在优势开始受到重视。 + +根据 Redwood Sofeware 和 Sapio Research 的最新 [研究报告][1],IT 决策者们相信,未来 5 年有 59% 的业务可以被自动化处理,从而产生新的速度和效率,并且消减相应的重复性的人工工作量的岗位。但是,目前在相应岗位上没有实施 RPA 的公司中,有 20% 的公司员工超过 1000 人。 + +对于 CIO 们来说,RPA 会潜在影响你在业务中的角色和你的团队。随着 RPA 的地位在 2018 年中越来越重要,CIO 们和其它 IT 决策者的角色也能会受到如下三种方式的改变: + +### 成为战略性变革代理人的机会增加 + +随着压力的增长,用最少的时间做更多的事,内部流程越来越重要。在每个企业中,员工们每天做着既重要又枯燥的一些任务。这些任务可能是枯燥且重复性的任务,但是要求他们必须快速完成且不能出错。 + +**[有关你的自动化策略的 ROI 建议,查看我们相关的文章,[如何在自动化方面提升 ROI:4 个小提示][2]。]** + +在财务中从后台的一些操作到采购、供应链、账务、客户服务、以及人力资源,在一个组织中几乎所有的岗位都有一些枯燥的任务。这就为 CIO 们提供了一个机会,将 IT 与业务联合起来,成为使用 RPA 进行战略变革的先锋。 + +除了过去的屏幕抓取技术,机器人现在已经实现可定制化,即插即用的解决方案可以根据企业的需要进行设计。使用这种以流程为中心的方法,企业不仅可以将以前由人来完成的任务进行自动化,也可以将应用程序和系统特定任务自动化,比如 ERP 和企业其它应用程序。 + +为端到端的流程实施更高级别的自动化将是 CIO 们的价值所在。CIO 们将会站在这种机遇的最前沿。 + +### 重新关注人和培训 + +技术的变动将让员工更加恐慌,尤其是当这些自动化的变动涉及到他们每日职责的相当大的部分。CIO 们应该清楚地告诉他们,RPA 将如何让他们的角色和责任变得更好,以及用数据说明的、最终将影响到他们底线的战略决策。 + +当实施 RPA 时,清晰明确地表达出“人对组织的成功来说是很重要的”信息是很关键的,并且,这种成功需要使技术和人的技能实现适当的平衡。 + +CIO 们也应该分析工作流并实施更好的流程,这种流程能够超越以前由终端用户完成的特定任务。通过端到端的流程自动化,CIO 们可以让员工表现更加出色。 + +因为在整个自动化的过程中,提升和培训员工技术是很重要的,CIO 们必须与企业高管们一起去决定,帮助员工自信地应对变化的培训项目。 + +### 需要长远的规划 + +为确保机器人流程自动化的成功,甲方必须有一个长期的方法。这将要求一个弹性的解决方案,它将对整个业务模型有好处,包括消费者。比如,当年亚马逊为他的 Prime 消费者推广快速投递服务时,他们不仅在他们的仓库中重新调整了订单交付流程,他们也自动化了他们的在线客户体验,让它们变得更简化、更快速,并且让消费者比以前更容易下订单。 + +在即将到来的一年里,CIO 们可以用同样的方法来应用技术,构建整体的解决方案来改变组织的动作方式。裁员只会让最终效益产生很大影响,但是流程自动化将使 CIO 们能够通过优化和授权来考虑更大的问题。这种方法让 CIO 们去为他们自己和 RPA 构建长期的信誉。这反过来将强化 CIO 们作为探路者的角色,并为整个组织的成功作出贡献。 + +对于 CIO 们来说,采用一个长期的、策略性的方法让 RPA 成功,需要时间和艰苦的努力。尽管如此,那些致力于创建一种人力和技术平衡战略的 CIO 们,将会在现在和将来实现更大的价值。 + +-------------------------------------------------------------------------------- + +via: https://enterprisersproject.com/article/2017/11/3-ways-robotics-affects-cio-role + +作者:[Dennis Walsh][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://enterprisersproject.com/user/dennis-walsh +[1]:https://www.redwood.com/press-releases/it-decision-makers-speak-59-of-business-processes-could-be-automated-by-2022/ +[2]:https://enterprisersproject.com/article/2017/11/how-improve-roi-automation-4-tips?sc_cid=70160000000h0aXAAQ From 529d3fc0a8a9b03963cf65db094ba58e2e71adf9 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Wed, 16 May 2018 20:17:40 +0800 Subject: [PATCH 0949/1057] submit tech/20180502 Writing Systemd Services for Fun and Profit.md --- ...ing Systemd Services for Fun and Profit.md | 110 ------------------ ...ing Systemd Services for Fun and Profit.md | 106 +++++++++++++++++ 2 files changed, 106 insertions(+), 110 deletions(-) delete mode 100644 sources/tech/20180502 Writing Systemd Services for Fun and Profit.md create mode 100644 translated/tech/20180502 Writing Systemd Services for Fun and Profit.md diff --git a/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md b/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md deleted file mode 100644 index 04203cccd7..0000000000 --- a/sources/tech/20180502 Writing Systemd Services for Fun and Profit.md +++ /dev/null @@ -1,110 +0,0 @@ -pinewall translating - -Writing Systemd Services for Fun and Profit -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/minetest.png?itok=Houi9zf9) - -Let's say you want to run a games server, a server that runs [Minetest][1], a very cool and open source mining and crafting sandbox game. You want to set it up for your school or friends and have it running on a server in your living room. Because, you know, if that’s good enough for the kernel mailing list admins, then it's good enough for you. - -However, you soon realize it is a chore to remember to run the server every time you switch your computer on and a nuisance to power down safely when you want to switch off. - -First, you have to run the server as a daemon: -``` -minetest --server & - -``` - -Take note of the PID (you'll need it later). - -Then you have to tell your friends the server is up by emailing or messaging them. After that you can start playing. - -Suddenly it is 3 am. Time to call it a day! But you can't just switch off your machine and go to bed. First, you have to tell the other players the server is coming down, locate the bit of paper where you wrote the PID we were talking about earlier, and kill the Minetest server gracefully... -``` -kill -2 - -``` - -...because just pulling the plug is a great way to end up with corrupted files. Then and only then can you power down your computer. - -There must be a way to make this easier. - -### Systemd Services to the Rescue - -Let's start off by making a systemd service you can run (manually) as a regular user and build up from there. - -Services you can run without admin privileges live in _~/.config/systemd/user/_ , so start by creating that directory: -``` -cd -mkdir -p ~/.config/systemd/user/ - -``` - -There are several types of systemd _units_ (the formal name of systemd scripts), such as _timers_ , _paths_ , and so on; but what you want is a service. Create a file in _~/.config/systemd/user/_ called _minetest.service_ and open it with your text editor and type the following into it: -``` -# minetest.service - -[Unit] -Description= Minetest server -Documentation= https://wiki.minetest.net/Main_Page - -[Service] -Type= simple -ExecStart= /usr/games/minetest --server - -``` - -Notice how units have different sections: The `[Unit]` section is mainly informative. It contains information for users describing what the unit is and where you can read more about it. - -The meat of your script is in the `[Service]` section. Here you start by stating what kind of service it is using the `Type` directive. [There are several types][2] of service. If, for example, the process you run first sets up an environment and then calls in another process (which is the main process) and then exits, you would use the `forking` type; if you needed to block the execution of other units until the process in your unit finished, you would use `oneshot`; and so on. - -None of the above is the case for the Minetest server, however. You want to start the server, make it go to the background, and move on. This is what the `simple` type does. - -Next up is the `ExecStart` directive. This directive tells systemd what program to run. In this case, you are going to run `minetest` as headless server. You can add options to your executables as shown above, but you can't chain a bunch of Bash commands together. A line like: -``` -ExecStart: lsmod | grep nvidia > videodrive.txt - -``` - -Would not work. If you need to chain Bash commands, it is best to wrap them in a script and execute that. - -Also notice that systemd requires you give the full path to the program. So, even if you have to run something as simple as _ls_ you will have to use `ExecStart= /bin/ls`. - -There is also an `ExecStop` directive that you can use to customize how your service should be terminated. We'll be talking about this directive more in part two, but for now you must know that, if you don't specify an `ExecStop`, systemd will take it on itself to finish the process as gracefully as possible. - -There is a full list of directives in the _systemd.directives_ man page or, if you prefer, [you can check them out on the web][3] and click through to see what each does. - -Although only 6 lines long, your _minetest.service_ is already a fully functional systemd unit. You can run it by executing -``` -systemd --user start minetest - -``` - -And stop it with -``` -systemd --user stop minetest - -``` - -The `--user` option tells systemd to look for the service in your own directories and to execute the service with your user's privileges. - -That wraps up this part of our server management story. In part two, we’ll go beyond starting and stopping and look at how to send emails to players, alerting them of the server’s availability. Stay tuned. - -Learn more about Linux through the free ["Introduction to Linux" ][4]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/intro-to-linux/2018/5/writing-systemd-services-fun-and-profit - -作者:[Paul Brown][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/bro66 -[1]:https://www.minetest.net/ -[2]:http://man7.org/linux/man-pages/man5/systemd.service.5.html -[3]:http://man7.org/linux/man-pages/man7/systemd.directives.7.html -[4]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20180502 Writing Systemd Services for Fun and Profit.md b/translated/tech/20180502 Writing Systemd Services for Fun and Profit.md new file mode 100644 index 0000000000..cec8c0ac74 --- /dev/null +++ b/translated/tech/20180502 Writing Systemd Services for Fun and Profit.md @@ -0,0 +1,106 @@ +编写有趣且有价值的 Systemd 服务 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/minetest.png?itok=Houi9zf9) + +让我们假设你希望搭建一个游戏服务器,运行 [Minetest][1] 这款非常酷、开源的、以采集 & 合成为主题的沙盒游戏。你希望将游戏运行在位于客厅的服务器中,以便搭建完成后可供你的学校或朋友使用。考虑到内核邮件列表管理就是通过这种方式完成的,那么对你来说也是足够的。 + +但你很快发现每次开机之后需要启动服务器,每次关机之前需要安全地关闭服务器,十分繁琐和麻烦。 + +最初,你可能用守护进程的方式运行服务器: +``` +minetest --server & + +``` +记住进程 PID 以便后续使用。 + +接着,你还需要通过邮件或短信的方式将服务器已经启动的信息告知你的朋友。然后你就可以开始游戏了。 + +转眼之间,已经凌晨三点,今天的战斗即将告一段落。但在你关闭主机、睡个好觉之前,还需要做一些操作。首先,你需要通知其它玩家服务器即将关闭,找到记录我们之前提到的 PID 的纸条,然后友好地关闭 Minetest 服务器。 +``` +kill -2 + +``` + +因为直接关闭主机电源很可能导致文件损坏。下一步也是最后一步,关闭主机电源。 + +一定有方法能让事情变得更简单。 + +### 让 Systemd 服务拯救你 + +让我们从构建一个普通用户可以(手动)运行的 systemd 服务开始,然后再逐步增加内容。 + +不需要管理员权限即可运行的服务位于 _~/.config/systemd/user/_,故首先需要创建这个目录: +``` +cd +mkdir -p ~/.config/systemd/user/ + +``` +有很多类型的 systemd _units_ (曾经叫做 systemd 脚本),包括 _timers_ 和 _paths_ 等,但我们这里关注的是 service 类型。在 _~/.config/systemd/user/_ 目录中创建 _minetest.service_ 文件,使用文本编辑器打开并输入如下内容: +``` +# minetest.service + +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple +ExecStart= /usr/games/minetest --server + +``` + +可以看到 units 中包含不同的段,其中 `[Unit]` 段主要为用户提供信息,给出 unit 的描述及如何获得更多相关文档。 + +脚本核心位于 `[Service]` 段,首先使用 `Type` 指令确定服务类型。服务[有多种类型][2],下面给出两个示例。如果你运行的进程设置环境变量、调用另外一个进程(主进程)、退出运行,那么你应该使用的服务类型为 `forking`。如果你希望在你的 unit 对应进程结束运行前阻断其他 units 运行,那么你应该使用的服务类型为 `oneshot`。 + +但 Minetest 服务器的情形与上面两种都不同,你希望启动服务器并使其在后台持续运行;这种情况下应该使用 `simple` 类型。 + +下面来看 `ExecStart` 指令,它给出 systemd 需要运行的程序。在本例中,你希望在后台运行 `minetest` 服务器。如上所示,你可以在可执行程序后面添加参数,但不能将一系列 Bash 命令通过管道连接起来。下面给出的例子无法工作: +``` +ExecStart: lsmod | grep nvidia > videodrive.txt + +``` + +如果你需要将 Bash 命令通过管道连接起来,可以将其封装到一个脚本中,然后运行该脚本。 + +还需要注意一点,systemd 要求你给出程序的完整路径。故如果你想使用 `simeple` 类型运行类似 _ls_ 的命令,你需要使用 `ExecStart= /bin/ls`。 + +另外还有 `ExecStop` 指令用于定制服务终止的方式。我们会在第二部分讨论这个指令,但你要了解,如果你没有指定 `ExecStop`,systemd 会帮你尽可能友好地终止进程。 + +_systemd.directives_ 的帮助页中包含完整指令列表,另外你可以在[网站][3]上找到同样的列表,点击即可查看每个指令的具体信息。 + +虽然只有 6 行,但你的 _minetest.service_ 已经是一个有完整功能的 systemd unit。执行如下命令启动服务: +``` +systemd --user start minetest + +``` + +执行如下命令终止服务 +``` +systemd --user stop minetest + +``` + +选项 `--user` 告知 systemd 在你的本地目录中检索服务并用你的用户权限执行服务。 + +我们的服务器管理故事到此完成了第一部分。在第二部分,我们将在启动和终止服务的基础上,学习如何给用户发邮件、告知用户服务器的可用性。敬请期待。 + +可以通过 Linux 基金会和 edX 的免费课程 [Linux 入门][4]学习更多 Linux 知识。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/intro-to-linux/2018/5/writing-systemd-services-fun-and-profit + +作者:[Paul Brown][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://www.linux.com/users/bro66 +[1]:https://www.minetest.net/ +[2]:http://man7.org/linux/man-pages/man5/systemd.service.5.html +[3]:http://man7.org/linux/man-pages/man7/systemd.directives.7.html +[4]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From bcbff64bc3415cb7e50d44946913b55e46aa56f0 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Wed, 16 May 2018 22:18:31 +0800 Subject: [PATCH 0950/1057] Update 20180128 Being open about data privacy.md --- .../talk/20180128 Being open about data privacy.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md index 22581d4c17..cf7971d561 100644 --- a/sources/talk/20180128 Being open about data privacy.md +++ b/sources/talk/20180128 Being open about data privacy.md @@ -1,4 +1,5 @@ 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) @@ -6,16 +7,19 @@ Translating by FelixYFZ Being open about data privacy Image by : opensource.com Today is [Data Privacy Day][1], ("Data Protection Day" in Europe), and you might think that those of us in the open source world should think that all data should be free, [as information supposedly wants to be][2], but life's not that simple. That's for two main reasons: - - 1. Most of us (and not just in open source) believe there's at least some data about us that we might not feel happy sharing (I compiled an example list in [a post][3] I published a while ago). - 2. Many of us working in open source actually work for commercial companies or other organisations subject to legal requirements around what they can share. - +今天是[数据隐私日][1],(在欧洲叫"数据保护日"),你可能会认为现在我们处于一个开源的世界中,所有的数据都应该免费,[就像人们想的那样][2],但是现实并没那么简单。主要有两个原因: +1. Most of us (and not just in open source) believe there's at least some data about us that we might not feel happy sharing (I compiled an example list in [a post][3] I published a while ago). +1. 我们中的大多数(不仅仅是在开源中)认为至少有些关于我们自己的数据是不愿意分享出去的(我在之前发表的一篇文章中列举了一些列子) +2. Many of us working in open source actually work for commercial companies or other organisations subject to legal requirements around what they can share. +2. 我们很多人虽然在开源中工作,但事实上是为了一些商业公司或者其他一些合组织工作,也是在合法的要求范围内分享数据。 So actually, data privacy is something that's important for pretty much everybody. +所以实际上,数据隐私对于每个人来说是很重要的。 It turns out that the starting point for what data people and governments believe should be available for organisations to use is somewhat different between the U.S. and Europe, with the former generally providing more latitude for entities--particularly, the more cynical might suggest, large commercial entities--to use data they've collected about us as they will. Europe, on the other hand, has historically taken a more restrictive view, and on the 25th of May, Europe's view arguably will have triumphed. + ### The impact of GDPR That's a rather sweeping statement, but the fact remains that this is the date on which a piece of legislation called the General Data Protection Regulation (GDPR), enacted by the European Union in 2016, becomes enforceable. The GDPR basically provides a stringent set of rules about how personal data can be stored, what it can be used for, who can see it, and how long it can be kept. It also describes what personal data is--and it's a pretty broad set of items, from your name and home address to your medical records and on through to your computer's IP address. From 6126c9fdc56f0583aedd4107e5d25926faa72fde Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 16 May 2018 23:24:24 +0800 Subject: [PATCH 0951/1057] Update 20180419 6 Python datetime libraries - Opensource.com.md --- .../20180419 6 Python datetime libraries - Opensource.com.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180419 6 Python datetime libraries - Opensource.com.md b/sources/tech/20180419 6 Python datetime libraries - Opensource.com.md index 739c236275..762c1a4f7d 100644 --- a/sources/tech/20180419 6 Python datetime libraries - Opensource.com.md +++ b/sources/tech/20180419 6 Python datetime libraries - Opensource.com.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + # 6 Python datetime libraries ### There are a host of libraries that make it simpler to test, convert, and read date and time information in Python. From d684525131a3e363f1f117b37f66b3e38888e043 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Thu, 17 May 2018 03:31:33 +0800 Subject: [PATCH 0952/1057] submit tech/20180507 Systemd Services- Beyond Starting and Stopping.md --- ... Services- Beyond Starting and Stopping.md | 183 ------------------ ... Services- Beyond Starting and Stopping.md | 180 +++++++++++++++++ 2 files changed, 180 insertions(+), 183 deletions(-) delete mode 100644 sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md create mode 100644 translated/tech/20180507 Systemd Services- Beyond Starting and Stopping.md diff --git a/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md b/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md deleted file mode 100644 index 30c4968847..0000000000 --- a/sources/tech/20180507 Systemd Services- Beyond Starting and Stopping.md +++ /dev/null @@ -1,183 +0,0 @@ -pinewall translating - -Systemd Services: Beyond Starting and Stopping -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/systemd-minetest-2.jpg?itok=bXO0ggHL) -[In the previous article][1], we showed how to create a systemd service that you can run as a regular user to start and stop your game server. As it stands, however, your service is still not much better than running the server directly. Let's jazz it up a bit by having it send out emails to the players, alerting them when the server becomes available and warning them when it is about to be turned off: -``` -# minetest.service - -[Unit] -Description= Minetest server -Documentation= https://wiki.minetest.net/Main_Page - -[Service] -Type= simple - -ExecStart= /usr/games/minetest --server -ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" "Minetest Starting up" - -TimeoutStopSec= 180 -ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" " -  Minetest Stopping in 2 minutes" -ExecStop= /bin/sleep 120 -ExecStop= /bin/kill -2 $MAINPID - -``` - -There are a few new things in here. First, there's the `ExecStartPost` directive. You can use this directive for anything you want to run right after the main application starts. In this case, you run a custom script, `mtsendmail` (see below), that sends an email to your friends telling them that the server is up. -``` -#!/bin/bash -# mtsendmail -echo $1 | mutt -F /home//.muttrc -s "$2" my_minetest@mailing_list.com - -``` - -You can use [Mutt][2], a command-line email client, to shoot off your messages. Although the script shown above is to all practical effects only one line long, remember you can't have a line with pipes and redirections as a systemd unit argument, so you have to wrap it in a script. - -For the record, there is also an `ExecStartPre` directive for things you want to execute before starting the service proper. - -Next up, you have a block of commands that close down the server. The `TimeoutStopSec` directive pushes up the time before systemd bails on shutting down the service. The default time out value is round about 90 seconds. Anything longer, and systemd will force the service to close down and report a failure. But, as you want to give your users a couple of minutes before closing the server completely, you are going to push the default up to three minutes. This will stop systemd from thinking the closedown has failed. - -Then the close down proper starts. Although there is no `ExecStopPre` as such, you can simulate running stuff before closing down your server by using more than one `ExecStop` directive. They will be executed in order, from topmost to bottommost, and will allow you to send out a message before the server is actually stopped. - -With that in mind, the first thing you do is shoot off an email to your friends, warning them the server is going down. Then you wait two minutes. Finally you close down the server. Minetest likes to be closed down with [Ctrl] + [c], which translates into an interrupt signal ( _SIGINT_ ). That is what you do when you issue the `kill -2 $MAINPID` command. `$MAINPID` is a systemd variable for your service that points to the PID of the main application. - -This is much better! Now, when you run -``` -systemctl --user start minetest - -``` - -The service will start up the Minetest server and send out an email to your users. Likewise when you are about to close down, but giving two minutes to users to log off. - -### Starting at Boot - -The next step is to make your service available as soon as the machine boots up, and close down when you switch it off at night. - -Start be moving your service out to where the system services live, The directory youa re looking for is _/etc/systemd/system/_ : -``` -sudo mv /home//.config/systemd/user/minetest.service /etc/systemd/system/ - -``` - -If you were to try and run the service now, it would have to be with superuser privileges: -``` -sudo systemctl start minetest - -``` - -But, what's more, if you check your service's status with -``` -sudo systemctl status minetest - -``` - -You would see it had failed miserably. This is because systemd does not have any context, no links to worlds, textures, configuration files, or details of the specific user running the service. You can solve this problem by adding the `User` directive to your unit: -``` -# minetest.service - -[Unit] -Description= Minetest server -Documentation= https://wiki.minetest.net/Main_Page - -[Service] -Type= simple -User= - -ExecStart= /usr/games/minetest --server -ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" -  "Minetest Starting up" - -TimeoutStopSec= 180 -ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" -  "Minetest Stopping in 2 minutes" -ExecStop= /bin/sleep 120 -ExecStop= /bin/kill -2 $MAINPID - -``` - -The `User` directive tells systemd which user's environment it should use to correctly run the service. You could use root, but that would probably be a security hazard. You could also use your personal user and that would be a bit better, but what many administrators do is create a specific user for each service, effectively isolating the service from the rest of the system and users. - -The next step is to make your service start when you boot up and stop when you power down your computer. To do that you need to _enable_ your service, but, before you can do that, you have to tell systemd where to _install_ it. - -In systemd parlance, _installing_ means telling systemd when in the boot sequence should your service become activated. For example the _cups.service_ , the service for the _Common UNIX Printing System_ , will have to be brought up after the network framework is activated, but before any other printing services are enabled. Likewise, the _minetest.service_ uses a user's email (among other things) and will have to be slotted in when the network is up and services for regular users become available. - -You do all that by adding a new section and directive to your unit: -``` -... -[Install] -WantedBy= multi-user.target - -``` - -You can read this as "wait until we have everything ready for a multiples user system." Targets in systemd are like the old run levels and can be used to put your machine into one state or another, or, like here, to tell your service to wait until a certain state has been reached. - -Your final _minetest.service_ file will look like this: -``` -# minetest.service -[Unit] -Description= Minetest server -Documentation= https://wiki.minetest.net/Main_Page - -[Service] -Type= simple -User= - -ExecStart= /usr/games/minetest --server -ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" -  "Minetest Starting up" - -TimeoutStopSec= 180 -ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" -  "Minetest Stopping in 2 minutes" -ExecStop= /bin/sleep 120 -ExecStop= /bin/kill -2 $MAINPID - -[Install] -WantedBy= multi-user.target - -``` - -Before trying it out, you may have to do some adjustments to your email script: -``` -#!/bin/bash -# mtsendmail - -sleep 20 -echo $1 | mutt -F /home//.muttrc -s "$2" my_minetest@mailing_list.com -sleep 10 - -``` - -This is because the system will need some time to set up the emailing system (so you wait 20 seconds) and also some time to actually send the email (so you wait 10 seconds). Notice that these are the wait times that worked for me. You may have to adjust these for your own system. - -And you're done! Run: -``` -sudo systemctl enable minetest - -``` - -and the Minetest service will come online when you power up and gracefully shut down when you power off, warning your users in the process. - -### Conclusion - -The fact that Debian, Ubuntu, and distros of the same family have a special package called _minetest-server_ that does some of the above for you (but no messaging!) should not deter you from setting up your own customised services. In fact, the version you set up here is much more versatile and does more than Debian's default server. - -Furthermore, the process described here will allow you to set up most simple servers as services, whether they are for games, web applications, or whatever. And those are the first steps towards veritable systemd guruhood. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/2018/5/systemd-services-beyond-starting-and-stopping - -作者:[Paul Brown][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/bro66 -[1]:https://www.linux.com/blog/learn/intro-to-linux/2018/5/writing-systemd-services-fun-and-profit -[2]:http://www.mutt.org/ diff --git a/translated/tech/20180507 Systemd Services- Beyond Starting and Stopping.md b/translated/tech/20180507 Systemd Services- Beyond Starting and Stopping.md new file mode 100644 index 0000000000..5b150f44f9 --- /dev/null +++ b/translated/tech/20180507 Systemd Services- Beyond Starting and Stopping.md @@ -0,0 +1,180 @@ +Systemd 服务:比启动停止服务更进一步 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/systemd-minetest-2.jpg?itok=bXO0ggHL) +在上一篇[文章][1]中,我们展示了如何创建一个 systemd 服务并使用普通用户启动和终止游戏服务器。但到目前为止,使用这个服务并不比直接运行服务器高明多少。让我们更进一步,让其可以向玩家发邮件,包括在服务器可用时通知玩家,在服务器关闭前警告玩家: +``` +# minetest.service + +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple + +ExecStart= /usr/games/minetest --server +ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" "Minetest Starting up" + +TimeoutStopSec= 180 +ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" " +  Minetest Stopping in 2 minutes" +ExecStop= /bin/sleep 120 +ExecStop= /bin/kill -2 $MAINPID + +``` + +这里涉及几个新的指令。首先是 `ExecStartPost` 指令,该指令可以在主进程启动后马上执行任何你指定的操作。在本例中,你执行了一个自定义脚本 `mtsendmail` (内容如下),该脚本以邮件形式通知你的朋友服务器已经启动。 +``` +#!/bin/bash +# mtsendmail +echo $1 | mutt -F /home//.muttrc -s "$2" my_minetest@mailing_list.com + +``` + +我们使用 [Mutt][2] 这个命令后邮件客户端发送消息。虽然从实际效果来看,上述脚本仅有 1 行,但 systemd unit 的参数中不能包含管道及重定向操作,故我们需要将其封装到脚本中。 + +顺便提一下,还有一个 `ExecStartPre` 指令,用于在服务主进程执行之前进行指定操作。 + +接下来我们看到,关闭服务器涉及了好几条指令。`TimeoutStopSec` 指令用于设置 systemd 友好关闭服务的最大等候时间,默认值大约是 90 秒。超过这个最大等候时间,systemd 会强制关闭服务并报错。考虑到你希望在彻底关闭服务器前给用户预留几分钟的时间,你需要将超时时间提高至 3 分钟,这样 systemd 就不会误认为服务关闭时出现问题。 + +接下来是关闭服务的具体指令部分。虽然没有 `ExecStopPre` 这样的指令,但你可以通过多次使用 `ExecStop` 指令实现关闭服务器前执行操作的目标。多个 `ExecStop` 指令按从上到下的顺序依次运行,这样你就可以在服务器真正关闭前向用户发送消息。 + +通过这个特性,你首先应该向你的朋友发邮件,警告其服务器即将关闭,然后等待两分钟,最后关闭服务器。可以使用 [Ctrl] + [c] 关闭 Minetest 服务器,该操作会被转换为一个中断信号 ( _SIGINT_ );当你执行 `kill -2 $MAINPID` 时就会发送该中断信号,其中 `$MAINPID` 是 systemd 变量,用于记录你服务中主进程的 PID 信息。 + +看上去好多了!如果你此时启动服务, +``` +systemctl --user start minetest + +``` + +服务会启动 Minetest 服务器并向你的用户发送邮件。关闭服务的情形基本类似,只不过会额外留给用户 2 分钟时间退出登录。 + +### 开机自启动 + +下一步我们让你的服务在主机启动后立即可用,在主机关闭时自动关闭。 + +我们需要将你的服务文件移动到系统服务目录,即 _/etc/systemd/system/_: +``` +sudo mv /home//.config/systemd/user/minetest.service /etc/systemd/system/ + +``` + +如果你希望此时启动该服务,你需要拥有超级用户权限: +``` +sudo systemctl start minetest + +``` + +另外,可以使用如下命令检查服务状态: +``` +sudo systemctl status minetest + +``` + +你会发现服务很糟糕地处于失败状态,这是因为 systemd 不能通过上下文信息、特征、配置文件得知具体使用哪个用户运行该服务。在 unit 文件中增加 `User` 指令可以解决这个问题。 +``` +# minetest.service + +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple +User= + +ExecStart= /usr/games/minetest --server +ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" +  "Minetest Starting up" + +TimeoutStopSec= 180 +ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" +  "Minetest Stopping in 2 minutes" +ExecStop= /bin/sleep 120 +ExecStop= /bin/kill -2 $MAINPID + +``` +systemd 从 `User` 指令中得知应使用哪个用户的环境变量来正确运行该服务。你可以使用 root 用户,但这可能产生安全风险;使用你的个人用户会好一些,但不少管理员的做法是为服务单独创建一个用户,这样可以有效地将服务与其它用户和系统组件相互隔离。 + +下一步我们让你的服务在系统启动时自动启动,系统关闭时自动关闭。要达到这个目的,你需要 _enable_ 你的服务;但在这之前,你还需要告知 systemd 从哪里 _install_。 + +对于 systemd 而言,_installing_ 告知 systemd 在系统启动的具体哪个步骤激活你的服务。以 _通用 Unix 打印系统_ _cups.service_ 为例,它的启动在网络框架启动之后、其它打印服务启动之前。又如,_minetest.server_ 需要使用用户邮件(及其它组件),需要等待网络和普通用户对应的服务就绪后才可启动。 + +你只需要在 unit 中添加一个新段和新指令: +``` +... +[Install] +WantedBy= multi-user.target + +``` + +你可以将其理解为“等待多用户系统的全部内容就绪”。systemd 中的 targets 类似于旧系统中的 run levels,可以用于将主机转移到一个或另一个状态,也可以像本例中这样让你的服务等待指定状态出现后运行。 + +你的最终 _minetest.service_ 文件如下: +``` +# minetest.service +[Unit] +Description= Minetest server +Documentation= https://wiki.minetest.net/Main_Page + +[Service] +Type= simple +User= + +ExecStart= /usr/games/minetest --server +ExecStartPost= /home//bin/mtsendmail.sh "Ready to rumble?" +  "Minetest Starting up" + +TimeoutStopSec= 180 +ExecStop= /home//bin/mtsendmail.sh "Off to bed. Nightie night!" +  "Minetest Stopping in 2 minutes" +ExecStop= /bin/sleep 120 +ExecStop= /bin/kill -2 $MAINPID + +[Install] +WantedBy= multi-user.target + +``` + +在尝试新的服务之前,你还需要对邮件脚本做一些调整: +``` +#!/bin/bash +# mtsendmail + +sleep 20 +echo $1 | mutt -F /home//.muttrc -s "$2" my_minetest@mailing_list.com +sleep 10 + +``` + +这是因为系统需要一定的时间启动邮件系统(这里等待 20 秒),也需要一定时间完成邮件发送(这里等待 10 秒)。注意脚本中的等待时间数值适用于我的系统,你可能需要针对你的系统调整数值。 + +大功告成啦。执行如下操作: +``` +sudo systemctl enable minetest + +``` + +你的 Minetest 服务将在系统启动时自动启动,在系统关闭时友好关闭并通知你的用户。 + +### 总结 + +事实上 Debian, Ubuntu 和一些族类的发行版提供了 _minetest-server_ 这个特别的软件包,可以提供一部分上述功能,(但不包括邮件通知功能)。即使如此,你还是可以建立你独有的自定义服务;事实上,你目前建立的服务比 Debian 默认提供的服务更加通用,可以提供更多功能。 + +更进一步的说,我们这里描述的流程可以让你将大多数简单服务器转换为服务,类型可以是游戏、网站应用或其它应用。同时,这也是你名副其实地踏入 systemd 大师殿堂的第一步。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2018/5/systemd-services-beyond-starting-and-stopping + +作者:[Paul Brown][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://www.linux.com/users/bro66 +[1]:https://www.linux.com/blog/learn/intro-to-linux/2018/5/writing-systemd-services-fun-and-profit +[2]:http://www.mutt.org/ From 1dcff2238edaadfeba3006a88e131e826a8ea898 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 17 May 2018 09:01:59 +0800 Subject: [PATCH 0953/1057] translated --- ...te AppImage Files With AppImageLauncher.md | 39 ------------------- ...te AppImage Files With AppImageLauncher.md | 37 ++++++++++++++++++ 2 files changed, 37 insertions(+), 39 deletions(-) delete mode 100644 sources/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md create mode 100644 translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md 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 deleted file mode 100644 index 2c9e87be5d..0000000000 --- a/sources/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md +++ /dev/null @@ -1,39 +0,0 @@ -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. - -With AppImageLauncher, these are problems of the past. The application lets you **easily run AppImage files, without having to make them executable**. But its most interesting feature is easily integrating AppImages with your system: **AppImageLauncher can automatically add an AppImage application shortcut to your desktop environment's application launcher / menu (including the app icon and proper description).** - -Without making the downloaded Kdenline AppImage executable manually, the first time I double click it (having AppImageLauncher installed), AppImageLauncher presents two options: - -`Run once` or `Integrate and run`. - -Clicking on Integrate and run, the AppImage is copied to the `~/.bin/` folder (hidden folder in the home directory) and is added to the menu, then the app is launched. - -**Removing it is just as simple** , as long as the desktop environment you're using has support for desktop actions. For example, in Gnome Shell, simply **right click the application icon in the Activities Overview and select** `Remove from system` : - -The AppImageLauncher GitHub page says that the application only supports Debian-based systems for now (this includes Ubuntu and Linux Mint) because it integrates deeply with the system. The application is currently in heavy development, and there are already issues opened by its developer to build RPM packages, so Fedora / openSUSE support might be added in the not too distant future. - -### Download AppImageLauncher - -The AppImageLauncher download page provides binaries for Debian, Ubuntu or Linux Mint (64bit), as well as a 64bit AppImage. The source is also available. - -[Download AppImageLauncher][1] - - --------------------------------------------------------------------------------- - -via: https://www.linuxuprising.com/2018/04/easily-run-and-integrate-appimage-files.html - -作者:[Logix][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://plus.google.com/118280394805678839070 -[1]:https://github.com/TheAssassin/AppImageLauncher/releases -[2]:https://kdenlive.org/download/ diff --git a/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md b/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md new file mode 100644 index 0000000000..1d29cd30fd --- /dev/null +++ b/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md @@ -0,0 +1,37 @@ +使用 AppImageLauncher 轻松运行和集成 AppImage 文件 +====== +你有没有下载过 AppImage 文件,而你不知道如何使用它?或者你可能知道如何使用它,但是你每次要运行它时必须要进入到下载 .AppImage 的文件夹中,或者手动为其创建启动程序。 + +使用 AppImageLauncher,这些就都是过去的问题。该程序可让你**轻松运行 AppImage 文件,而无需使其可执行**。但它最有趣的特点是可以轻松地将 AppImage 与你的系统进行整合:**AppImageLauncher 可以自动将 AppImage 程序快捷方式添加到桌面环境的程序启动器/菜单(包括程序图标和合适的说明)中**。 + +在不手动下载 Kdenline AppImage 可执行文件的情况下,我第一次双击它(安装了 AppImageLauncher)时,AppImageLauncher 提供了两个选项: + +`运行一次`或者`集成并运行`。 + +点击 Integrate 并运行,AppImage 被复制到 `~/.bin/` (家目录中的隐藏文件夹)并添加到菜单中,然后启动该程序。 + +**删除它也很简单**,只要您使用的桌面环境支持桌面动作就行。例如,在 Gnome Shell 中,只需**右键单击活动概览中的应用程序图标,然后选择**`从系统中删除`: + +AppImageLauncher GitHub 页面显示,因为它与系统深度集成,该程序目前仅支持基于 Debian 的系统(这包括 Ubuntu 和 Linux Mint)。目前,该程序正处于频繁开发阶段,开发人员已经发了关于 RPM 包的问题,​​因此在不久的将来可能会添加 Fedora/openSUSE 支持。 + +### 下载 AppImageLauncher + +AppImageLauncher 下载页提供 Debian、Ubuntu 或 Linux Mint(64位)的 64 位 AppImage 二进制文件。源码也有。 + +[下载 AppImageLauncher][1] + + +-------------------------------------------------------------------------------- + +via: https://www.linuxuprising.com/2018/04/easily-run-and-integrate-appimage-files.html + +作者:[Logix][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/118280394805678839070 +[1]:https://github.com/TheAssassin/AppImageLauncher/releases +[2]:https://kdenlive.org/download/ From a66c2362ed3b9a43a6016a4bac5f7fc11a7ca5c4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 09:03:08 +0800 Subject: [PATCH 0954/1057] PRF:20180430 Reset a lost root password in under 5 minutes.md @geekpi --- ...a lost root password in under 5 minutes.md | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) 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 index b8f292a5f2..49e3b3bfac 100644 --- 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 @@ -1,15 +1,17 @@ 在 5 分钟内重置丢失的 root 密码 ====== +> 如何快速简单地在 Fedora 、 CentOS 及类似的 Linux 发行版上重置 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 密码。 +系统管理员可以轻松地为忘记密码的用户重置密码。但是如果系统管理员忘记 root 密码或他从公司离职了,会发生什么情况?本指南将向你介绍如何在不到 5 分钟的时间内在 Red Hat 兼容系统(包括 Fedora 和 CentOS)上重置丢失或忘记的 root 密码。 -请注意,如果整个系统硬盘已用 LUKS 加密,则需要在出现提示时提供 LUKS 密码。此外,此过程适用于运行 systemd 的系统,该系统自 Fedora 15、CentOS 7.14.04 和 Red Hat Enterprise Linux 7.0 以来一直是缺省的初始系统。。 +请注意,如果整个系统硬盘已用 LUKS 加密,则需要在出现提示时提供 LUKS 密码。此外,此过程适用于运行 systemd 的系统,该系统自 Fedora 15、CentOS 7.14.04 和 Red Hat Enterprise Linux 7.0 以来一直是缺省的初始系统。 -首先你需要终端启动的过程,因此你需要启动或者如果已经启动就重启它。第一步可能有点棘手因为 GRUB 菜单会在屏幕上快速地闪烁过去。你可能需要尝试几次,直到你能够做到这一点。 +首先你需要中断启动的过程,因此你需要启动或者如果已经启动就重启它。第一步可能有点棘手因为 GRUB 菜单会在屏幕上快速地闪烁过去。你可能需要尝试几次,直到你能够做到这一点。 -当你看到这个屏幕时,按下键盘上的 **e** 键: +当你看到这个屏幕时,按下键盘上的 `e` 键: ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub0.png?itok=cz9nk5BT) @@ -17,56 +19,58 @@ ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub1.png?itok=3ZY5uiGq) -使用箭头键移动到 Linux16 这行: +使用箭头键移动到 `Linux16` 这行: ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/grub2_0.png?itok=8epRyqOl) -使用你的 **del** 键或你的 **backspace** 键,删除 `rhgb quiet` 并替换为以下内容: +使用你的 `del` 键或你的 `backspace` 键,删除 `rhgb quiet` 并替换为以下内容: -`rd.break enforcing=0` +``` +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** 启动。 +按下 `Ctrl-x` 启动。 **系统现在将处于紧急模式。** 以读写权限重新挂载硬盘驱动器: + ``` # mount –o remount,rw /sysroot - ``` 运行 `chroot` 来访问系统: + ``` # chroot /sysroot - ``` 你现在可以更改 root 密码: + ``` # passwd - ``` -出现提示时,输入新的 root 密码两次。如果成功,你应该看到一条消息显示 “**all authentication tokens updated successfully**”。 +出现提示时,输入新的 root 密码两次。如果成功,你应该看到一条消息显示 “all authentication tokens updated successfully”。 -输入 **exit** 两次以重新启动系统。 +输入 `exit` 两次以重新启动系统。 + +以 root 身份登录并恢复 `/etc/shadow` 的 SELinux 标签。 -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 ``` +# setenforce 1 +``` + -------------------------------------------------------------------------------- via: https://opensource.com/article/18/4/reset-lost-root-password @@ -74,7 +78,7 @@ 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) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0403cbcd84b140cf47327f90000edc6213f1c72d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 09:03:50 +0800 Subject: [PATCH 0955/1057] PUB:20180430 Reset a lost root password in under 5 minutes.md @geekpi https://linux.cn/article-9649-1.html --- .../20180430 Reset a lost root password in under 5 minutes.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180430 Reset a lost root password in under 5 minutes.md (100%) diff --git a/translated/tech/20180430 Reset a lost root password in under 5 minutes.md b/published/20180430 Reset a lost root password in under 5 minutes.md similarity index 100% rename from translated/tech/20180430 Reset a lost root password in under 5 minutes.md rename to published/20180430 Reset a lost root password in under 5 minutes.md From 0f04fb1d03f3d06063d3c9e2a1ab1fd17077beb1 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 17 May 2018 09:05:23 +0800 Subject: [PATCH 0956/1057] translating --- ...0511 3 useful things you can do with the IP tool in Linux.md | 2 ++ 1 file changed, 2 insertions(+) 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 index 433595132f..8a1f8c426f 100644 --- 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 @@ -1,3 +1,5 @@ +translating---geekpi + 3 useful things you can do with the IP tool in Linux ====== From a3fe5c8aad8af1a64a308a6cc1993910636cc171 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 09:49:17 +0800 Subject: [PATCH 0957/1057] PRF:20180327 Reliable IoT event logging with syslog-ng.md @qhwdw --- ...liable IoT event logging with syslog-ng.md | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180327 Reliable IoT event logging with syslog-ng.md b/translated/tech/20180327 Reliable IoT event logging with syslog-ng.md index 47ed3bc820..4fd6856d09 100644 --- a/translated/tech/20180327 Reliable IoT event logging with syslog-ng.md +++ b/translated/tech/20180327 Reliable IoT event logging with syslog-ng.md @@ -1,46 +1,53 @@ 使用 syslog-ng 可靠地记录物联网事件 ====== +> 用增强的日志守护进程 syslog-ng 来监控你的物联网设备。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openwires_fromRHT_520_0612LL.png?itok=PqZi55Ab) + 现在,物联网设备和嵌入式系统越来越多。对于许多连接到因特网或者一个网络的设备来说,记录事件很有必要,因为你需要知道这些设备都做了些什么事情,这样你才能够解决可能出现的问题。 -可以考虑去使用的一个监视工具是开源的 [syslog-ng][1] 应用程序,它是一个强化的、致力于可移植的、中心化的日志收集守护程序。它可以从许多不同种类的源、进程来收集日志,并且可以对这些日志进行过滤、存储、或者路由,以便于做进一步的分析。syslog-ng 的大多数代码是用高效率的、高可移植的 C 代码写成的。它能够适用于各种场景,无论你是将它运行在一个处理能力很弱的设备上做一些简单的事情,还是运行在数据中心从成千上万的机器中收集日志的强大应用,它都能够胜任。 +可以考虑去使用的一个监视工具是开源的 [syslog-ng][1] 应用程序,它是一个强化的、致力于可移植的、中心化的日志收集守护程序。它可以从许多不同种类的来源、进程来收集日志,并且可以对这些日志进行处理和过滤,也可以存储或者路由它们,以便于做进一步的分析。syslog-ng 的大多数代码是用高效率的、高可移植的 C 代码写成的。它能够适用于各种场景,无论你是将它运行在一个处理能力很弱的设备上做一些简单的事情,还是运行在数据中心从成千上万的机器中收集日志的强大应用,它都能够胜任。 你可能注意到在这个段落中,我使用了大量的溢美词汇。为了让你更清晰地了解它,我们来复习一下,但这将花费更多的时间,也了解的更深入一些。 ### 日志 -首先解释一下日志。日志是记录一台计算机上事件的东西。在一个典型的 Linux 机器上,你可以在 `/var/log` 目录中找到这些信息。例如,如果你通过 SSH 登陆到机器中,你将可以在其中一个日志文件中找到类似于如下内容的信息: +首先解释一下日志。日志logging是记录一台计算机上事件的东西。在一个典型的 Linux 机器上,你可以在 `/var/log` 目录中找到这些信息。例如,如果你通过 SSH 登录到机器中,你将可以在其中一个日志文件中找到类似于如下内容的信息: -`Jan 14 11:38:48 ``linux``-0jbu sshd[7716]: Accepted ``publickey`` for root from 127.0.0.1 port 48806 ssh2` +``` +Jan 14 11:38:48 linux-0jbu sshd[7716]: Accepted publickey for root from 127.0.0.1 port 48806 ssh2 +``` -它的内容可能是关于你的 CPU 过热,通过 HTTP 下载了一个文档,或者你的应用程序认为重要的任何东西。 +日志的内容可能是关于你的 CPU 过热、通过 HTTP 下载了一个文档,或者你的应用程序认为重要的任何东西。 ### syslog-ng -正如我在上面所写的那样,syslog-ng 应用程序是一个强化的、致力于可移植性、和中心化的日志收集守护程序。守护程序的意思是,syslog-ng 是一个持续运行在后台的应用程序,用于收集日志信息。 +正如我在上面所写的那样,syslog-ng 应用程序是一个强化的、致力于可移植性、和中心化的日志收集守护程序。守护程序的意思是,syslog-ng 是一个持续运行在后台的应用程序,在这里,它用于收集日志信息。 -虽然现在大多数应用程序的 Linux 测试是限制在 x86_64 的机器上,但是,syslog-ng 也可以运行在大多数 BSD 和商业 UNIX 变种版本上的。从嵌入式/物联网的角度来看,这种能够运行在不同的 CPU 架构(包括 32 位和 64 位的 ARM、PowerPC、MIPS 等等)的能力甚至更为重要。(有时候,我通过阅读关于 syslog-ng 如何使用它们来学习新架构) +虽然现在大多数应用程序的 Linux 测试是限制在 x86_64 的机器上,但是,syslog-ng 也可以运行在大多数 BSD 和商业 UNIX 变种版本上的。从嵌入式/物联网的角度来看,这种能够运行在不同的 CPU 架构(包括 32 位和 64 位的 ARM、PowerPC、MIPS 等等)的能力甚至更为重要。(有时候,我通过阅读关于 syslog-ng 是如何使用它们的来学习新架构) -为什么中心化的日志收集如此重要?其中一个很重要的原因是易于使用,因为它放在一个地方,不用到成百上千的机器上挨个去检查它们的日志。另一个原因是可用性 —— 如果一个设备不论是什么原因导致了它不可用,你可以检查这个设备的日志信息。第三个原因是安全性;当你的设备被黑,检查设备日志可以发现攻击的踪迹。 +为什么中心化的日志收集如此重要?其中一个很重要的原因是易于使用,因为它放在一个地方,不用到成百上千的机器上挨个去检查它们的日志。另一个原因是可用性 —— 即使一个设备不论是什么原因导致了它不可用,你都可以检查这个设备的日志信息。第三个原因是安全性;当你的设备被黑,检查设备日志可以发现攻击的踪迹。 ### syslog-ng 的四种用法 -Syslog-ng 有四种主要的用法:收集、处理、过滤、和保存日志信息。 +syslog-ng 有四种主要的用法:收集、处理、过滤、和保存日志信息。 -**收集信息:** syslog-ng 能够从各种各样的 [特定平台源][2] 上收集信息,比如 `/dev/log`,`journal`,或者 `sun-streams`。作为一个中心化的日志收集器,传统的(`rfc3164`)和最新的(`rfc5424`)系统日志协议、以及它们 基于 UDP、TCP、和加密连接的各种变种,它都是支持的。你也可以从管道、套接字、文件、甚至应用程序输出来收集日志信息(或者各种文本数据)。 +**收集信息:** syslog-ng 能够从各种各样的 [特定平台源][2] 上收集信息,比如 `/dev/log`,`journal`,或者 `sun-streams`。作为一个中心化的日志收集器,传统的(`rfc3164`)和最新的(`rfc5424`)系统日志协议、以及它们基于 UDP、TCP 和加密连接的各种变种,它都是支持的。你也可以从管道、套接字、文件、甚至应用程序输出来收集日志信息(或者各种文本数据)。 -**处理日志信息:** 它的处理能力几乎是无限的。你可以用它内置的解析器来分类、规范、以及结构化日志信息。如果它没有为你提供在你的应用场景中所需要的解析器,你甚至可以用 Python 来自己写一个解析器。你也可以使用地理数据来丰富信息,或者基于信息内容来附加一些字段。日志信息可以按处理它的应用程序所要求的格式进行重新格式化。你也可以重写日志信息 —— 当然了,你不能篡改日志内容 —— 比如在某些情况下,需要满足匿名要求的信息。 +**处理日志信息:** 它的处理能力几乎是无限的。你可以用它内置的解析器来分类、规范,以及结构化日志信息。如果它没有为你提供在你的应用场景中所需要的解析器,你甚至可以用 Python 来自己写一个解析器。你也可以使用地理数据来丰富信息,或者基于信息内容来附加一些字段。日志信息可以按处理它的应用程序所要求的格式进行重新格式化。你也可以重写日志信息 —— 当然了,不是篡改日志内容 —— 比如在某些情况下,需要满足匿名要求的信息。 **过滤日志:** 过滤日志的用法主要有两种:丢弃不需要保存的日志信息 —— 像调试级别的信息;和路由日志信息—— 确保正确的日志到达正确的目的地。后一种用法的一个例子是,转发所有的认证相关的信息到一个安全信息与事件管理系统(SIEM)。 -**保存信息:** 传统的做法是,将文件保存在本地或者发送到中心化日志服务器;不论是哪种方式,它们都被发送到一个[平面文件][3]。经过这些年的改进,syslog-ng 已经开始支持 SQL 数据库,并且在过去的几年里,大数据目的地,包括 HDFS、Kafka、MongoDB、和 Elasticsearch,都被加入到 syslog-ng 的支持中。 +**保存信息:** 传统的做法是,将文件保存在本地或者发送到中心化日志服务器;不论是哪种方式,它们都被发送到一个[普通文件][3]。经过这些年的改进,syslog-ng 已经开始支持 SQL 数据库,并且在过去的几年里,包括 HDFS、Kafka、MongoDB、和 Elasticsearch 在内的大数据存储,都被加入到 syslog-ng 的支持中。 ### 消息格式 当在你的 `/var/log` 目录中查看消息时,你将看到(如上面的 SSH 信息)大量的消息都是如下格式的内容: -`date + host name + application name + an almost complete English sentence` +``` +日期 + 主机名 + 应用名 + 一句几乎完整的英文信息 +``` 在这里的每个应用程序事件都是用不同的语法描述的,基于这些数据去创建一个报告是个痛苦的任务。 @@ -50,15 +57,15 @@ Syslog-ng 有四种主要的用法:收集、处理、过滤、和保存日志 ### 物联网日志 -我们从一个棘手的问题开始:哪个版本的 syslog-ng 最流行?在你回答之前,想想如下这些事实:这个项目启动于 20 年以前,Red Hat 企业版 Linux EPEL 已经有了 3.5 版,并且当前版本是 3.14。当我在我的演讲中问到这个问题时,观众通常回答他们喜欢的 Linux 发行版。你们绝对想不到的是,正确答案竟然是 1.6 版最流行,这个版本已经有 15 年的历史的。这什么这个版本是最为流行的,因为它是包含在亚马逊 Kindle 阅读器中的版本,它是电子书阅读器,因为它运行在全球范围内超过 1 亿台的设备上。另外一个在消费类设备上运行 syslog-ng 的例子是 BMW i3 电动汽车。 +我们从一个棘手的问题开始:哪个版本的 syslog-ng 最流行?在你回答之前,想想如下这些事实:这个项目启动于 20 年以前,Red Hat 企业版 Linux EPEL 已经有了 3.5 版,而当前版本是 3.14。当我在我的演讲中问到这个问题时,观众通常回答是他们用的 Linux 发行版中自带的那个。你们绝对想不到的是,正确答案竟然是 1.6 版最流行,这个版本已经有 15 年的历史的。这什么这个版本是最为流行的,因为它是包含在亚马逊 Kindle 阅读器中的版本,它是电子书阅读器,因为它运行在全球范围内超过 1 亿台的设备上。另外一个在消费类设备上运行 syslog-ng 的例子是 BMW i3 电动汽车。 -Kindle 使用 syslog-ng 去收集关于用户在这台设备上都做了些什么事情的所有可能的信息。在 BMW 电动汽车上,syslog-ng 所做的事情更复杂,基于内容过滤日志信息,并且在大多数情况下,只记录最重要的日志。 +Kindle 使用 syslog-ng 去收集关于用户在这台设备上都做了些什么事情等所有可能的信息。在 BMW 电动汽车上,syslog-ng 所做的事情更复杂,基于内容过滤日志信息,并且在大多数情况下,只记录最重要的日志。 -使用 syslog-ng 的其它类别设备还有网络和存储。一些比较知名的例子有,Turris Omnia 开源 Linux 路由器和群晖 NAS 设备。在大多数案例中,syslog-ng 是在设备上作为一个日志客户端来运行,但是在有些案例中,它运行为一个有富 Web 界面的中心日志服务器。 +使用 syslog-ng 的其它类别设备还有网络和存储。一些比较知名的例子有,Turris Omnia 开源 Linux 路由器和群晖 NAS 设备。在大多数案例中,syslog-ng 是在设备上作为一个日志客户端来运行,但是在有些案例中,它运行为一个有丰富 Web 界面的中心日志服务器。 你还可以在一些行业服务中找到 syslog-ng 的身影。它运行在来自美国国家仪器有限公司(NI)的实时 Linux 设备上,执行测量和自动化任务。它也被用于从定制开发的应用程序中收集日志。从命令行就可以做配置,但是一个漂亮的 GUI 可用于浏览日志。 -最后,这里还有大量的项目,比如,汽车和飞机,syslog-ng 在它们上面既可以运行为客户端,也可以运行为服务端。在这种使用案例中,syslog-ng 一般用来收集所有的日志和测量数据,然后发送它们到处理这些日志的中心化服务器集群上,然后保存它们到支持大数据的目的地,以备进一步分析。 +最后,还有大量的项目,比如,汽车和飞机,syslog-ng 在它们上面既可以运行为客户端,也可以运行为服务端。在这种使用案例中,syslog-ng 一般用来收集所有的日志和测量数据,然后发送它们到处理这些日志的中心化服务器集群上,然后保存它们到支持大数据的目的地,以备进一步分析。 ### 对物联网的整体益处 @@ -69,9 +76,9 @@ Kindle 使用 syslog-ng 去收集关于用户在这台设备上都做了些什 via: https://opensource.com/article/18/3/logging-iot-events-syslog-ng 作者:[Peter Czanik][a] -译者:[译者ID](https://github.com/译者ID) -校对:[qhwdw](https://github.com/qhwdw) 选题:[lujun9972](https://github.com/lujun9972) +译者:[qhwdw](https://github.com/qhwdw) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0d17daa5ad9862e94af1e638a6b00d3c695cba36 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 09:49:46 +0800 Subject: [PATCH 0958/1057] PUB:20180327 Reliable IoT event logging with syslog-ng.md @qhwdw https://linux.cn/article-9650-1.html --- .../20180327 Reliable IoT event logging with syslog-ng.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180327 Reliable IoT event logging with syslog-ng.md (100%) diff --git a/translated/tech/20180327 Reliable IoT event logging with syslog-ng.md b/published/20180327 Reliable IoT event logging with syslog-ng.md similarity index 100% rename from translated/tech/20180327 Reliable IoT event logging with syslog-ng.md rename to published/20180327 Reliable IoT event logging with syslog-ng.md From 82b98f4c9465e58d35785dacb3f544fac1340143 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Thu, 17 May 2018 12:55:43 +0800 Subject: [PATCH 0959/1057] Translated by qhwdw --- ...tware tools for supply chain management.md | 82 ------------------- ...tware tools for supply chain management.md | 81 ++++++++++++++++++ 2 files changed, 81 insertions(+), 82 deletions(-) delete mode 100644 sources/tech/20180302 5 open source software tools for supply chain management.md create mode 100644 translated/tech/20180302 5 open source software tools for supply chain management.md 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 deleted file mode 100644 index 80d8dec545..0000000000 --- a/sources/tech/20180302 5 open source software tools for supply chain management.md +++ /dev/null @@ -1,82 +0,0 @@ -Translating by qhwdw -5 open source software tools for supply chain management -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_Maze2.png?itok=EH_L-J6Q) - -This article was originally posted on January 14, 2016, and last updated March 2, 2018. - -If you manage a business that deals with physical goods, [supply chain management][1] is an important part of your business process. Whether you're running a tiny Etsy store with just a few customers, or a Fortune 500 manufacturer or retailer with thousands of products and millions of customers worldwide, it's important to have a close understanding of your inventory and the parts and raw materials you need to make your products. - -Keeping track of physical items, suppliers, customers, and all the many moving parts associated with each can greatly benefit from, and in some cases be totally dependent on, specialized software to help manage these workflows. In this article, we'll take a look at some free and open source software options for supply chain management and some of the features of each. - -Supply chain management goes a little further than just inventory management. It can help you keep track of the flow of goods to reduce costs and plan for scenarios in which the supply chain could change. It can help you keep track of compliance issues, whether these fall under the umbrella of legal requirements, quality minimums, or social and environmental responsibility. It can help you plan the minimum supply to keep on hand and enable you to make smart decisions about order quantities and delivery times. - -Because of its nature, a lot of supply chain management software is bundled with similar software, such as [customer relationship management][2] (CRM) and [enterprise resource planning][3] (ERP) tools. So, when making a decision about which tool is best for your organization, you may wish to consider integration with other tools as a part of your decision-making criteria. - -### Apache OFBiz - -[Apache OFBiz][4] is a suite of related tools for helping you manage a variety of business processes. While it can manage a variety of related issues like catalogs, e-commerce sites, accounting, and point of sale, its primary supply chain functions focus on warehouse management, fulfillment, order, and manufacturing management. It is very customizable, but the flip side of that is that it requires a good deal of careful planning to set up and integrate with your existing processes. That's one reason it is probably the best fit for a midsize to large operation. The project's functionality is built across three layers: presentation, business, and data, making it a scalable solution, but again, a complex one. - -The source code of Apache OFBiz can be found in the [project's repository][5]. Apache OFBiz is written in Java and is licensed under an [Apache 2.0 license][6]. - -If this looks interesting, you might also want to check out [opentaps][7], which is built on top of OFBiz. Opentaps enhances OFBiz's user interface and adds core ERP and CRM features, including warehouse management, purchasing, and planning. It's licensed under [AGPL 3.0][8], with a commercial license available for organizations that don't want to be bound by the open source license. - -### OpenBoxes - -[OpenBoxes][9] is a supply chain management and inventory control project, primarily and originally designed for keeping track of pharmaceuticals in a healthcare environment, but it can be modified to track any type of stock and the flows associated with it. It has tools for demand forecasting based on historical order quantities, tracking stock, supporting multiple facilities, expiration date tracking, kiosk support, and many other features that make it ideal for healthcare situations, but could also be useful for other industries. - -Available under an [Eclipse Public License][10], OpenBoxes is written primarily in Groovy and its source code can be browsed on [GitHub][11]. - -### OpenLMIS - -Like OpenBoxes, [OpenLMIS][12] is a supply chain management tool for the healthcare sector, but it was specifically designed for use in low-resource areas in Africa to ensure medications and medical supplies get to patients in need. Its API-driven approach enables users to customize and extend OpenLMIS while maintaining a connection to the common codebase. It was developed with funding from the Rockefeller Foundation, and other contributors include the UN, USAID, and the Bill & Melinda Gates Foundation. - -OpenLMIS is written in Java and JavaScript with AngularJS. It is available under an [AGPL 3.0 license][13], and its source code is accessible on [GitHub][13]. - -### Odoo - -You might recognize [Odoo][14] from our previous top [ERP projects][3] article. In fact, a full ERP may be a good fit for you, depending on your needs. Odoo's supply chain management tools mostly revolve around inventory and purchase management, as well as connectivity with e-commerce and point of sale, but it can also connect to other tools like [frePPLe][15] for open source production planning. - -Odoo is available both as a software-as-a-service solution and an open source community edition. The open source edition is released under [LGPL][16] version 3, and the source is available on [GitHub][17]. Odoo is primarily written in Python. - -### xTuple - -Billing itself as "supply chain management software for growing businesses," [xTuple][18] focuses on businesses that have outgrown their conventional small business ERP and CRM solutions. Its open source version, called Postbooks, adds some inventory, distribution, purchasing, and vendor reporting features to its core accounting, CRM, and ERP capabilities, and a commercial version expands the [features][19] for manufacturers and distributors. - -xTuple is available under the Common Public Attribution License ([CPAL][20]), and the project welcomes developers to fork it to create other business software for inventory-based manufacturers. Its web app core is written in JavaScript, and its source code can be found on [GitHub][21]. - -There are, of course, other open source tools that can help with supply chain management. Know of a good one that we left off? Let us know in the comments below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/tools/supply-chain-management - -作者:[Jason Baker][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/jason-baker -[1]:https://en.wikipedia.org/wiki/Supply_chain_management -[2]:https://opensource.com/business/14/7/top-5-open-source-crm-tools -[3]:https://opensource.com/resources/top-4-open-source-erp-systems -[4]:http://ofbiz.apache.org/ -[5]:http://ofbiz.apache.org/source-repositories.html -[6]:http://www.apache.org/licenses/LICENSE-2.0 -[7]:http://www.opentaps.org/ -[8]:http://www.fsf.org/licensing/licenses/agpl-3.0.html -[9]:http://openboxes.com/ -[10]:http://opensource.org/licenses/eclipse-1.0.php -[11]:https://github.com/openboxes/openboxes -[12]:http://openlmis.org/ -[13]:https://github.com/OpenLMIS/openlmis-ref-distro/blob/master/LICENSE -[14]:https://www.odoo.com/ -[15]:https://frepple.com/ -[16]:https://github.com/odoo/odoo/blob/9.0/LICENSE -[17]:https://github.com/odoo/odoo -[18]:https://xtuple.com/ -[19]:https://xtuple.com/comparison-chart -[20]:https://xtuple.com/products/license-options#cpal -[21]:http://xtuple.github.io/ diff --git a/translated/tech/20180302 5 open source software tools for supply chain management.md b/translated/tech/20180302 5 open source software tools for supply chain management.md new file mode 100644 index 0000000000..8ead3394de --- /dev/null +++ b/translated/tech/20180302 5 open source software tools for supply chain management.md @@ -0,0 +1,81 @@ +供应链管理方面的 5 个开源软件工具 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_Maze2.png?itok=EH_L-J6Q) + +本文最初发表于 2016 年 1 月 14 日,最后的更新日期为 2018 年 3 月 2 日。 + +如果你正在管理着处理实体货物的业务,[供应链管理][1] 是你的业务流程中非常重要的一部分。不论你是经营着一个只有几个客户的小商店,还是在世界各地拥有数百万计客户和成千上万产品的世界财富 500 强的制造商或零售商,很清楚地知道你的库存和制造产品所需要的零部件,对你来说都是非常重要的事情。 + +保持对货品、供应商、客户的持续跟踪,并且所有与它们相关的变动部分都会从中受益,并且,在某些情况下完全依赖专门的软件来帮助管理这些工作流。在本文中,我们将去了解一些免费的和开源的供应链管理方面的软件,以及它们的其中一些功能。 + +供应链管理比单纯的库存管理更为强大。它能帮你去跟踪货物流以降低成本,以及为可能发生的各种糟糕的变化来制定应对计划。它能够帮你对出口合规性进行跟踪,不论是合法性、最低品质要求、还是社会和环境的合规性。它能够帮你计划最低供应量,让你能够在订单数量和交付时间之间做出明智的决策。 + +由于它的本质决定了许多供应链管理软件是与类似的软件捆绑在一起的,比如,[客户关系管理][2](CRM)和 [企业资源计划管理][3] (ERP)。因此,当你选择哪个工具更适合你的组织时,你可能会考虑与其它工具集成作为你的决策依据之一。 + +### Apache OFBiz + +[Apache OFBiz][4] 是一套帮你管理多种业务流程的相关工具。虽然它能管理多种相关问题,比如,目录、电子商务网站、帐户、和销售点,它在供应链管理方面的主要功能关注于仓库管理、履行、订单、和生产管理。它的可定制性很强,但是,它需要大量的规划去设置和集成到你现有的流程中。这就是它适用于中大型业务的原因之一。项目的功能构建于三个层面:展示层、业务层、和数据层,它是一个弹性很好的解决方案,但是,再强调一遍,它也很复杂。 + +Apache OFBiz 的源代码在 [项目仓库][5] 中可以找到。Apache OFBiz 是用 Java 写的,并且它是按 [Apache 2.0 license][6] 授权的。 + +如果你对它感兴趣,你也可以去查看 [opentaps][7],它是在 OFBiz 之上构建的。Opentaps 强化了 OFBiz 的用户界面,并且添加了 ERP 和 CRM 的核心功能,包括仓库管理、采购和计划。它是按 [AGPL 3.0][8] 授权使用的,对于不接受开源授权的组织,它也提供了商业授权。 + +### OpenBoxes + +[OpenBoxes][9] 是一个供应链管理和存货管理项目,最初的主要设计目标是为了医疗行业中的药品跟踪管理,但是,它可以通过修改去跟踪任何类型的货品和相关的业务流。它有一个需求预测工具,可以基于历史订单数量、存储跟踪、支持多种场所、过期日期跟踪、销售点支持等进行预测,并且它还有许多其它功能,这使它成为医疗行业的理想选择,但是,它也可以用于其它行业。 + +它在 [Eclipse Public License][10] 下可用,OpenBoxes 主要是由 Groovy 写的,它的源代码可以在 [GitHub][11] 上看到。 + +### OpenLMIS + +与 OpenBoxes 类似,[OpenLMIS][12] 也是一个医疗行业的供应链管理工具,但是,它专用设计用于在非洲的资源缺乏地区使用,以确保有限的药物和医疗用品能够用到需要的病人上。它是 API 驱动的,这样用户可以去定制和扩展 OpenLMIS,同时还能维护一个与通用基准代码的连接。它是由络克菲勒基金会开发的,其它的贡献者包括联合国、美国国际开发署、和比尔 & 梅林达 盖茨基金会。 + +OpenLMIS 是用 Java 和 JavaScript 的 AngularJS 写的。它在 [AGPL 3.0 license][13] 下使用,它的源代码在 [GitHub][13] 上可以找到。 + +### Odoo + +你可能在我们以前的 [ERP 项目][3] 榜的文章上见到过 [Odoo][14]。事实上,根据你的需要,一个全功能的 ERP 对你来说是最适合的。Odoo 的供应链管理工具主要围绕存货和采购管理,同时还与电子商务网站和销售点连接,但是,它也可以与其它的工具连接,比如,与 [frePPLe][15] 连接,它是一个开源的生产计划工具。 + +Odoo 既有软件即服务的解决方案,也有开源的社区版本。开源的版本是以 [LGPL][16] 版本 3 下发行的,源代码在 [GitHub][17] 上可以找到。Odoo 主要是用 Python 来写的。 + +### xTuple + +[xTuple][18] 标称自己是“为成长中的企业提供供应链管理软件”,它专注于已经超越了传统的小型企业 ERP 和 CRM 解决方案的企业。它的开源版本称为 Postbooks,添加了一些存货、分销、采购、以及供应商报告的功能,它提供的核心功能是帐务、CRM、以及 ERP 功能,而它的商业版本扩展了制造和分销的 [功能][19]。 + +xTuple 在 [CPAL][20] 下使用,这个项目欢迎开发者去 fork 它,为基于存货的制造商去创建其它的业务软件。它的 Web 应用核心是用 JavaScript 写的,它的源代码在 [GitHub][21] 上可以找到。 + +就这些,当然了,还有其它的可以帮你处理供应链管理的开源软件。如果你知道还有更好的软件,请在下面的评论区告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/tools/supply-chain-management + +作者:[Jason Baker][a] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/jason-baker +[1]:https://en.wikipedia.org/wiki/Supply_chain_management +[2]:https://opensource.com/business/14/7/top-5-open-source-crm-tools +[3]:https://opensource.com/resources/top-4-open-source-erp-systems +[4]:http://ofbiz.apache.org/ +[5]:http://ofbiz.apache.org/source-repositories.html +[6]:http://www.apache.org/licenses/LICENSE-2.0 +[7]:http://www.opentaps.org/ +[8]:http://www.fsf.org/licensing/licenses/agpl-3.0.html +[9]:http://openboxes.com/ +[10]:http://opensource.org/licenses/eclipse-1.0.php +[11]:https://github.com/openboxes/openboxes +[12]:http://openlmis.org/ +[13]:https://github.com/OpenLMIS/openlmis-ref-distro/blob/master/LICENSE +[14]:https://www.odoo.com/ +[15]:https://frepple.com/ +[16]:https://github.com/odoo/odoo/blob/9.0/LICENSE +[17]:https://github.com/odoo/odoo +[18]:https://xtuple.com/ +[19]:https://xtuple.com/comparison-chart +[20]:https://xtuple.com/products/license-options#cpal +[21]:http://xtuple.github.io/ From ff505700341cae86685a5e0443a98cd00cce43e5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 21:53:20 +0800 Subject: [PATCH 0960/1057] PRF:20171109 Testing IPv6 Networking in KVM- Part 2.md @qhwdw --- ... Testing IPv6 Networking in KVM- Part 2.md | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) 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 index 78ec513d5f..6ab7937b49 100644 --- a/translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md +++ b/translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md @@ -2,29 +2,29 @@ ====== ![](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)。 +在 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,以及创建或不创建一个静态路由,然后进入下一个窗口。 +*图 1:创建一个网络* -选中 "Enable IPv6 network address space definition",然后输入你的私有地址范围。你可以使用任何你希望的 IPv6 地址类,但是要注意,不能将你的实验网络泄漏到公网上去。我们将使用非常好用的 IPv6 唯一本地地址(ULA),并且使用在 [Simple DNS Plus][4] 上的在线地址生成器,去创建我们的网络地址。拷贝 "Combined/CID" 地址到网络框中(图 2)。 +给新网络输入一个名字,然后,点击 “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" 地址到网络框中 +*图 2:拷贝 "Combined/CID" 地址到网络框中* -[使用已获授权][7] +虚拟机认为我的地址是无效的,因为,它显示了高亮的玫瑰红色。它做的对吗?我们使用 `ipv6calc` 去验证一下: -虚拟机认为我的地址是无效的,因为,它显示了高亮的玫瑰红色。它做的对吗?我们使用 ipv6calc 去验证一下: ``` $ ipv6calc -qi fd7d:844d:3e17:f3ae::/64 Address type: unicast, unique-local-unicast, iid, iid-local @@ -32,37 +32,39 @@ 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,然后再试一次。(问 “如果…?”,试验和错误是最好的学习方法)。 +`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"。 +*图 3: 启用 DHCPv6* + +我们将跳过缺省路由定义这一步,继续进入下一屏,在那里我们将启用 “Isolated Virtual Network” 和 “Enable IPv6 internal routing/networking”。 ### 虚拟机网络选择 -现在,你可以配置你的虚拟机去使用新的网络。打开你的虚拟机,然后点击顶部左侧的 "i" 按钮去打开 "Show virtual hardware details" 屏幕。在 "Add Hardware" 列点击 NIC 按钮去打开网络选择器,然后选择你喜欢的新的 IPv6 网络。点击 Apply,然后重新启动。(或者使用你喜欢的方法去重新启动网络,或者更新你的 DHCP 租期。) +现在,你可以配置你的虚拟机去使用新的网络。打开你的虚拟机,然后点击顶部左侧的 “i” 按钮去打开 “Show virtual hardware details” 屏幕。在 “Add Hardware” 列点击 “NIC” 按钮去打开网络选择器,然后选择你喜欢的新的 IPv6 网络。点击 “Apply”,然后重新启动。(或者使用你喜欢的方法去重新启动网络,或者更新你的 DHCP 租期。) ### 测试 -ifconfig 告诉我们它做了什么? +`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 - +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 网络上的其它虚拟机: +这是我们新的 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 @@ -73,10 +75,10 @@ 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,以展示使用这四个部分,你可以做任何你想做的事情: +当你努力去理解子网时,这是一个可以让你尝试不同地址是否可以正常工作的快速易用的方法。你可以给单个接口分配多个 IP 地址,然后 ping 它们去看一下会发生什么。在一个 ULA 中,接口,或者主机是 IP 地址的最后四部分,因此,你可以在那里做任何事情,只要它们在同一个子网中即可,在那个例子中是 `f3ae`。在我的其中一个虚拟机上,我只改变了这个示例的接口 ID,以展示使用这四个部分,你可以做任何你想做的事情: + ``` vm1 ~$ sudo /sbin/ip -6 addr add fd7d:844d:3e17:f3ae:a:b:c:6314 dev ens3 @@ -84,16 +86,15 @@ 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: +现在,尝试使用不同的子网,在下面的示例中使用了 `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 情况下实现自动寻址。 @@ -105,12 +106,12 @@ via: https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking- 作者:[CARLA SCHRODER][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[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]:https://www.linux.com/users/cschroder -[1]:https://www.linux.com/learn/intro-to-linux/2017/11/testing-ipv6-networking-kvm-part-1 +[1]:https://linux.cn/article-9594-1.html [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 From f3302b053488cae773a7100b7c281a1a51a027b3 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 21:53:45 +0800 Subject: [PATCH 0961/1057] PUB:20171109 Testing IPv6 Networking in KVM- Part 2.md @qhwdw https://linux.cn/article-9652-1.html --- .../20171109 Testing IPv6 Networking in KVM- Part 2.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171109 Testing IPv6 Networking in KVM- Part 2.md (100%) diff --git a/translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md b/published/20171109 Testing IPv6 Networking in KVM- Part 2.md similarity index 100% rename from translated/tech/20171109 Testing IPv6 Networking in KVM- Part 2.md rename to published/20171109 Testing IPv6 Networking in KVM- Part 2.md From 5fb5b72320b628b4d470afc96bd877960821763a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 22:42:01 +0800 Subject: [PATCH 0962/1057] PRF:20170119 Be a force for good in your community.md @Chao-zhi --- ...9 Be a force for good in your community.md | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/translated/talk/20170119 Be a force for good in your community.md b/translated/talk/20170119 Be a force for good in your community.md index 035409c4c1..3845cfd518 100644 --- a/translated/talk/20170119 Be a force for good in your community.md +++ b/translated/talk/20170119 Be a force for good in your community.md @@ -1,31 +1,29 @@ 成为你所在社区的美好力量 ============================================================ ->明白如何传递美好,了解积极意愿的力量,以及更多。 +> 明白如何传递美好,了解积极意愿的力量,以及更多。 - ![Be a force for good in your community](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/people_remote_teams_world.png?itok=wI-GW8zX "Be a force for good in your community") + ![Be a force for good in your community](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel) >图片来自:opensource.com -激烈的争论是开源社区和开放组织的标志特征之一。在我们最好的日子里,这些争论充满活力和建设性。他们面红耳赤的背后其实是幽默和善意。各方实事求是,共同解决问题,推动持续改进。对我们中的许多人来说,他们只是单纯的娱乐而已。 +激烈的争论是开源社区和开放组织的标志特征之一。在好的时候,这些争论充满活力和建设性。他们面红耳赤的背后其实是幽默和善意。各方实事求是,共同解决问题,推动持续改进。对我们中的许多人来说,他们只是单纯的喜欢而已。 -然而在我们最糟糕的日子里,这些争论演变成了对旧话题的反复争吵。或者我们用各种方式来传递伤害和相互攻击,或是使用卑劣的手段,而这些侵蚀着我们社区的激情、信任和生产力。 +然而在那些不好的日子里,这些争论演变成了对旧话题的反复争吵。或者我们用各种方式来传递伤害和相互攻击,或是使用卑劣的手段,而这些侵蚀着我们社区的激情、信任和生产力。 -我们茫然四顾,束手无策,因为社区的对话开始变得有毒。然而,正如 [DeLisa Alexander最近的分享][1],我们每个人都有很多方法可以成为我们社区的一种力量。 +我们茫然四顾,束手无策,因为社区的对话开始变得有毒。然而,正如 [DeLisa Alexander 最近的分享][1],我们每个人都有很多方法可以成为我们社区的一种力量。 在这个“开源文化”系列的第一篇文章中,我将分享一些策略,教你如何在这个关键时刻进行干预,引导每个人走向更积极、更有效率的方向。 ### 不要将人推开,而是将人推向前方 -最近,我和我的朋友和同事 [Mark Rumbles][2] 一起吃午饭。多年来,我们在许多支持开源文化和引领 Red Hat 的项目中合作。在这一天,马克问我是怎么坚持的,当我看到辩论变得越来越丑陋的时候,他看到我最近介入了一个邮件列表的对话。 +最近,我和我的朋友和同事 [Mark Rumbles][2] 一起吃午饭。多年来,我们在许多支持开源文化和引领 Red Hat 的项目中合作。在这一天,Mark 问我,他看到我最近介入了一个邮件列表的对话,当其中的辩论越来越过分时我是怎么坚持的。 幸运的是,这事早已尘埃落定,事实上我几乎忘记了谈话的内容。然而,它让我们开始讨论如何在一个拥有数千名成员的社区里,公开和坦率的辩论。 ->在我们的社区里,我们成为一种美好力量的最好的方法之一就是:在回应冲突时,以一种迫使每个人提升他们的行为,而不是使冲突升级的方式。 - Mark 说了一些让我印象深刻的话。他说:“你知道,作为一个社区,我们真的很擅长将人推开。但我想看到的是,我们更多的是互相扶持 _向前_ 。” -Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量的最好的方法之一就是:在回应冲突时,以一种迫使每个人提升他们的行为,而不是使冲突升级的方式。 +Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量的最好的方法之一就是:以一种迫使每个人提升他们的行为的方式回应冲突,而不是使冲突升级的方式。 ### 积极意愿假想 @@ -33,9 +31,9 @@ Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量 诚然,这不是一件容易的事情。当我看到一场辩论正在变得肮脏的迹象时,我停下来问自己,史蒂芬·科维(Steven Covey)所说的人性化问题是什么: -“为什么一个理性、正直的人会做这样的事情?” +> “为什么一个理性、正直的人会做这样的事情?” -现在,如果他是你的一个“普通的观察对象”——一个有消极行为倾向的社区成员——也许你的第一个想法是,“嗯,也许这个人是个不靠谱,不理智的人” +现在,如果他是你的一个“普通的观察对象”—— 一个有消极行为倾向的社区成员——也许你的第一个想法是,“嗯,也许这个人是个不靠谱,不理智的人” 回过头来说。我并不是说你让你自欺欺人。这其实就是人性化的问题,不仅是因为它让你理解别人的立场,它还让你变得人性化。 @@ -51,7 +49,7 @@ Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量 一个简单的积极意愿假想,我们可以适用于几乎所有的不良行为,其实就是那个人想要被聆听,被尊重,或被理解。我想这是相当合理的。 -通过站在这个更客观、更有同情心的角度,我们可以看到他们的行为几乎肯定 **_不_** 会帮助他们得到他们想要的东西,而社区也会因此而受到影响。如果没有我们的帮助的话。 +通过站在这个更客观、更有同情心的角度,我们可以看到他们的行为几乎肯定 **_不会_** 帮助他们得到他们想要的东西,而社区也会因此而受到影响。如果没有我们的帮助的话。 对我来说,这激发了一个愿望:帮助每个人从我们所处的这个丑陋的地方“摆脱困境”。 @@ -60,7 +58,7 @@ Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量 容易想到的例子包括: * 他们担心我们错过了一些重要的东西,或者我们犯了一个错误,没有人能看到它。 -* 他们想为自己的贡献感到有价值。 +* 他们想感受到自己的贡献的价值。 * 他们精疲力竭,因为在社区里工作过度或者在他们的个人生活中发生了一些事情。 * 他们讨厌一些东西被破坏,并感到沮丧,因为没有人能看到造成的伤害或不便。 * ……诸如此类。 @@ -69,11 +67,11 @@ Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量 ### 传递美好,挣脱泥潭 -什么是 an out?(类似与佛家“解脱法门”的意思)把它想象成一个逃跑的门。这是一种退出对话的方式,或者放弃不良的行为,恢复表现得像一个体面的人,而不是丢面子。是叫某人振作向上,而不是叫他走开。 +什么是 an out?(LCTT 译注:类似与佛家“解脱法门”的意思)把它想象成一个逃跑的门。这是一种退出对话的方式,或者放弃不良的行为,恢复表现得像一个体面的人,而不是丢面子。是叫某人振作向上,而不是叫他走开。 你可能经历过这样的事情,在你的生活中,当 _你_ 在一次谈话中表现不佳时,咆哮着,大喊大叫,对某事大惊小怪,而有人慷慨地给 _你_ 提供了一个台阶下。也许他们选择不去和你“抬杠”,相反,他们说了一些表明他们相信你是一个理性、正直的人,他们采用积极意愿假想,比如: -> _所以,嗯,我听到的是你真的很担心,你很沮丧,因为似乎没有人在听。或者你担心我们忽略了它的重要性。是这样对吧?_ +> 所以,嗯,我听到的是你真的很担心,你很沮丧,因为似乎没有人在听。或者你担心我们忽略了它的重要性。是这样对吧? 于是乎:即使这不是完全正确的(也许你的意图不那么高尚),在那一刻,你可能抓住了他们提供给你的台阶,并欣然接受了重新定义你的不良行为的机会。你几乎可以肯定地转向一个更富有成效的角度,甚至你自己可能都没有意识到。 @@ -85,13 +83,13 @@ Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量 ### 坏行为还是坏人? -如果这个人特别激动,他们可能不会听到或者接受你给出的第一台阶。没关系。最可能的是,他们迟钝的大脑已经被史前曾经对人类生存至关重要的杏仁核接管了,他们需要更多的时间来认识到你并不是一个威胁。只是需要你保持温和的态度,坚定地对待他们,就好像他们 _曾经是_ 一个理性、正直的人,看看会发生什么。 +如果这个人特别激动,他们可能不会听到或者接受你给出的第一个台阶。没关系。最可能的是,他们迟钝的大脑已经被史前曾经对人类生存至关重要的杏仁体接管了,他们需要更多的时间来认识到你并不是一个威胁。只是需要你保持温和的态度,坚定地对待他们,就好像他们 _曾经是_ 一个理性、正直的人,看看会发生什么。 根据我的经验,这些社区干预以三种方式结束: 大多数情况下,这个人实际上 _是_ 一个理性的人,很快,他们就感激地接受了这个事实。在这个过程中,每个人都跳出了“黑与白”,“赢或输”的心态。人们开始思考创造性的选择和“双赢”的结果,每个人都将受益。 -> 为什么一个理性、正直的人会做这样的事呢? +> 为什么一个理性、正直的人会做这样的事呢? 有时候,这个人天生不是特别理性或正直的,但当他被你以如此一致的、不知疲倦的、耐心的慷慨和善良的对待的时候,他们就会羞愧地从谈话中撤退。这听起来像是,“嗯,我想我已经说了所有要说的了。谢谢你听我的意见”。或者,对于不那么开明的人来说,“嗯,我厌倦了这种谈话。让我们结束吧。”(好的,谢谢)。 @@ -99,7 +97,7 @@ Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量 这就是积极意愿假想的力量。通过对愤怒和充满敌意的言辞做出回应,优雅而有尊严地回应,你就能化解一场战争,理清混乱,解决棘手的问题,而且在这个过程中很有可能会交到一个新朋友。 -我每次应用这个原则都成功吗?见鬼,不。但我从不后悔选择了积极意愿。但是我能生动的回想起,当我采用消极意愿假想时,将问题变得更糟糕的场景。 +我每次应用这个原则都成功吗?见鬼,不会。但我从不后悔选择了积极意愿。但是我能生动的回想起,当我采用消极意愿假想时,将问题变得更糟糕的场景。 现在轮到你了。我很乐意听到你提出的一些策略和原则,当你的社区里的对话变得激烈的时候,要成为一股好力量。在下面的评论中分享你的想法。 @@ -111,7 +109,7 @@ Mark 是绝对正确的。在我们的社区里,我们成为一种美好力量 ![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/headshot-square_0.jpg?itok=FS97b9YD) -丽贝卡·费尔南德斯(Rebecca Fernandez)是红帽公司(Red Hat)的首席就业品牌 + 通讯专家,是《开源组织》书籍的贡献者,也是开源决策框架的维护者。她的兴趣是开源和业务管理模型的开源方式。Twitter:@ruhbehka +丽贝卡·费尔南德斯(Rebecca Fernandez)是红帽公司(Red Hat)的首席就业品牌 + 通讯专家,是《开放组织》书籍的贡献者,也是开源决策框架的维护者。她的兴趣是开源和业务管理模型的开源方式。Twitter:@ruhbehka -------------------------------------------------------------------------------- @@ -119,7 +117,7 @@ via: https://opensource.com/open-organization/17/1/force-for-good-community 作者:[Rebecca Fernandez][a] 译者:[chao-zhi](https://github.com/chao-zhi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d26dd1b3f68222f290d668532f0b1f462509633a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 17 May 2018 22:43:20 +0800 Subject: [PATCH 0963/1057] PUB:20170119 Be a force for good in your community.md @Chao-zhi https://linux.cn/article-9653-1.html --- .../20170119 Be a force for good in your community.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20170119 Be a force for good in your community.md (100%) diff --git a/translated/talk/20170119 Be a force for good in your community.md b/published/20170119 Be a force for good in your community.md similarity index 100% rename from translated/talk/20170119 Be a force for good in your community.md rename to published/20170119 Be a force for good in your community.md From 77b1e1d136012f572d63bc654b054171faa911aa Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 18 May 2018 08:56:34 +0800 Subject: [PATCH 0964/1057] translated --- ...lects on getting started in open source.md | 46 ------------------- ...lects on getting started in open source.md | 44 ++++++++++++++++++ 2 files changed, 44 insertions(+), 46 deletions(-) delete mode 100644 sources/talk/20180328 College student reflects on getting started in open source.md create mode 100644 translated/talk/20180328 College student reflects on getting started in open source.md 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 deleted file mode 100644 index 4ebf6ec2e8..0000000000 --- a/sources/talk/20180328 College student reflects on getting started in open source.md +++ /dev/null @@ -1,46 +0,0 @@ -translating----geekpi - -College student reflects on getting started in open source -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_2.png?itok=JPlR5aCA) -I just completed the first semester of my second year in college, and I'm reflecting on what I learned in my classes. One class, in particular, stood out to me: "[Foundations of an Open Source World][1]," taught by Dr. Bryan Behrenshausen at Duke University. I enrolled in the class at the last minute because it seemed interesting and, if I’m being honest because it fit my schedule. - -On the first day, Dr. Behrenshausen asked if we students knew or had used any open source programs. Until that day I had hardly heard [the term “open source”][2] and certainly wasn't cognizant of any products that fell into that category. As the semester went on, however, it dawned on me that the passion I have towards my career aspirations would not exist without open source. - -### Audacity and GIMP - -My interest in technology started at age 12. Charged with the task of cutting music for my dance team, I searched the web for hours until I found Audacity, an open source audio editor. Audacity opened doors for me; no longer was I confined to repetitive eight-counts of the same beat. I started receiving requests left and right from others who wanted unique renditions of their favorite songs. - -Weeks later, I stumbled upon a GIF on the internet of a cat with a Pop-Tart torso and a rainbow trail flying through space. I searched “how to make moving images” and discovered [GIMP][3], an open source graphics editor, and used it to create a GIF of "The Simpsons" for my brother’s birthday present. - -My budding interest grew into a full-time obsession: creating artwork on my clunky, laggy laptop. Since I didn’t have much luck with charcoal, paint, or watercolors, I used [graphic design][4] as an outlet for creative expression. I spent hours in the computer lab learning the basics of HTML and CSS on [W3Schools][5] so that I could fill an online portfolio with my childish GIFs. A few months later, I published my first website on [WordPress][6]. - -### Why open source - -Open source allows us to not only achieve our goals but to discover interests that drive those goals. - -Fast-forward nearly a decade. Many things have changed, although some have stayed consistent: I still make graphics (mostly flyers), edit music for a dance group, and design websites (sleeker, more effective ones, I hope). The products I used have gone through countless version upgrades. But the most dramatic change is my approach to open source resources. - -Considering the significance of open source products in my life has made me cherish the open movement and its mission. Open source projects remind me that there are initiatives in tech that promote social good and self-learning without being exclusive to those who are socioeconomically advantaged. My middle-school self, like countless others, couldn’t afford to purchase the Adobe Creative Suite, GarageBand, or Squarespace. Open source platforms allow us to not only achieve our goals but to discover interests that drive those goals by broadening our access networks. - -My advice? Enroll in a class on a whim. It just might change the way you view the world. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/college-getting-started - -作者:[Christine Hwang][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/christinehwang -[1]:https://ssri.duke.edu/news/new-course-explores-open-source-principles -[2]:https://opensource.com/node/42001 -[3]:https://www.gimp.org/ -[4]:https://opensource.com/node/30251 -[5]:https://www.w3schools.com/ -[6]:https://opensource.com/node/31441 diff --git a/translated/talk/20180328 College student reflects on getting started in open source.md b/translated/talk/20180328 College student reflects on getting started in open source.md new file mode 100644 index 0000000000..d34adaa3e4 --- /dev/null +++ b/translated/talk/20180328 College student reflects on getting started in open source.md @@ -0,0 +1,44 @@ +大学生对开始开源的反思 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_2.png?itok=JPlR5aCA) +我刚刚完成大学二年级的第一学期,我正在思考我在课堂上学到的东西。有一节课特别引起了我的注意:“[开源世界的基础][1]”,它由杜克大学的 Bryan Behrenshausen 博士讲授。我在最后一刻参加了课程,因为它看起来很有趣,诚实地来说,因为它符合我的日程安排。 + +第一天,Behrenshausen 博士问我们学生是否知道或使用过任何开源程序。直到那一天,我几乎没有听过[术语“开源”][2],当然也不知道任何属于该类别的产品。然而,随着学期的继续,对我而言,如果没有开源,我对事业抱负的激情就不会存在。 + +### Audacity 和 GIMP + +我对技术的兴趣始于 12 岁。我负责为我的舞蹈团队裁剪音乐,我在网上搜索了几个小时,直到找到开源音频编辑器 Audacity。Audacity 为我敞开了大门。我不再局限于重复的 8 音节。我开始接受其他想要独特演绎他们最喜爱歌曲的人的请求。 + +几周后,我偶然在互联网上看到了一只有着 Pop-Tart 躯干并且后面拖着彩虹在太空飞行的猫。我搜索了“如何制作动态图像”,并发现了一个开源的图形编辑器 [GIMP][3],并用它为我兄弟做了一张“辛普森一家”的 GIF 作为生日礼物。 + +我萌芽的兴趣成长为完全的痴迷:在我笨重的、落后的笔记本上制作艺术品。由于我没有很好的炭笔,油彩或水彩,所以我用[图形设计][4]作为创意的表达。我花了几个小时在计算机实验室上[W3Schools][5]学习 HTML 和 CSS 的基础知识,以便我可以用我幼稚的 GIF 填充在线作品集。几个月后,我在 [WordPress][6] 发布了我的第一个网站。 + +### 为什么开源 + +开源让我们不仅可以实现我们的目标,还可以发现驱动这些目标的兴趣。 + +快进近十年。虽然有些仍然保持一致,但许多事情已经发生了变化:我仍然在制作图形(主要是传单),为舞蹈团编辑音乐,以及设计网站(我希望更时尚、更有效)。我使用的产品经历了无数版本升级。但最戏剧性的变化是我对开源资源的态度。 + +考虑到开源产品在我的生活中的意义,使我珍视开放运动和它的使命。开源项目提醒我,科技领域有些倡议可以促进社会的良好和自我学习,而不会被那些具有社会经济优势的人排斥。我中学时的自己,像无数其他人一样,无法购买 Adobe Creative Suite、GarageBand 或 Squarespace。开源平台使我们不仅能够实现我们的目标,而且还能通过扩大我们接触来发现推动这些目标的兴趣。 + +我的建议?一时心血来潮报名上课。它可能会改变你对世界的看法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/college-getting-started + +作者:[Christine Hwang][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者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/christinehwang +[1]:https://ssri.duke.edu/news/new-course-explores-open-source-principles +[2]:https://opensource.com/node/42001 +[3]:https://www.gimp.org/ +[4]:https://opensource.com/node/30251 +[5]:https://www.w3schools.com/ +[6]:https://opensource.com/node/31441 From 168cc9e3b002a7148a95439b5ebf3e5e7b866868 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 18 May 2018 09:01:19 +0800 Subject: [PATCH 0965/1057] translating --- ...20180509 How to kill a process or stop a program in Linux.md | 2 ++ 1 file changed, 2 insertions(+) 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 index 71cefdd8f4..79bb49acc8 100644 --- 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 @@ -1,3 +1,5 @@ +translating---geekpi + How to kill a process or stop a program in Linux ====== From 934c6e9802f66490e1395630e2598cf3886850c0 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 18 May 2018 11:43:31 +0800 Subject: [PATCH 0966/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Protect=20your?= =?UTF-8?q?=20Fedora=20system=20against=20this=20DHCP=20flaw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ur Fedora system against this DHCP flaw.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md diff --git a/sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md b/sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md new file mode 100644 index 0000000000..1cafe15786 --- /dev/null +++ b/sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md @@ -0,0 +1,72 @@ +Protect your Fedora system against this DHCP flaw +====== +![](https://fedoramagazine.org/wp-content/uploads/2018/05/dhcp-cve-816x345.jpg) + +A critical security vulnerability was discovered and disclosed earlier today in dhcp-client. This DHCP flaw carries a high risk to your system and data, especially if you use untrusted networks such as a WiFi access point you don’t own. Read more here for how to protect your Fedora system. + +Dynamic Host Control Protocol (DHCP) allows your system to get configuration from a network it joins. Your system will make a request for DHCP data, and typically a server such as a router answers. The server provides the necessary data for your system to configure itself. This is how, for instance, your system configures itself properly for networking when it joins a wireless network. + +However, an attacker on the local network may be able to exploit this vulnerability. Using a flaw in a dhcp-client script that runs under NetworkManager, the attacker may be able to run arbitrary commands with root privileges on your system. This DHCP flaw puts your system and your data at high risk. The flaw has been assigned CVE-2018-1111 and has a [Bugzilla tracking bug][1]. + +### Guarding against this DHCP flaw + +New dhcp packages contain fixes for Fedora 26, 27, and 28, as well as Rawhide. The maintainers have submitted these updates to the updates-testing repositories. They should show up in stable repos within a day or so of this post for most users. The desired packages are: + + * Fedora 26: dhcp-4.3.5-11.fc26 + * Fedora 27: dhcp-4.3.6-10.fc27 + * Fedora 28: dhcp-4.3.6-20.fc28 + * Rawhide: dhcp-4.3.6-21.fc29 + + + +#### Updating a stable Fedora system + +To update immediately on a stable Fedora release, use this command [with sudo][2]. Type your password at the prompt, if necessary: +``` +sudo dnf --refresh --enablerepo=updates-testing update dhcp-client + +``` + +Later, use the standard stable repos to update. To update your Fedora system from the stable repos, use this command: +``` +sudo dnf --refresh update dhcp-client + +``` + +#### Updating a Rawhide system + +If your system is on Rawhide, use these commands to download and update the packages immediately: +``` +mkdir dhcp && cd dhcp +koji download-build --arch={x86_64,noarch} dhcp-4.3.6-21.fc29 +sudo dnf update ./dhcp-*.rpm + +``` + +After the nightly Rawhide compose, simply run sudo dnf update to get the update. + +### Fedora Atomic Host + +The fixes for Fedora Atomic Host are in ostree version 28.20180515.1. To get the update, run this command: +``` +atomic host upgrade -r + +``` + +This command reboots your system to apply the upgrade. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/protect-fedora-system-dhcp-flaw/ + +作者:[Paul W. Frields][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/pfrields/ +[1]:https://bugzilla.redhat.com/show_bug.cgi?id=1567974 +[2]:https://fedoramagazine.org/howto-use-sudo/ From 793f983416b1ff0145f6ff232c3841cce5b7db67 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 18 May 2018 11:46:14 +0800 Subject: [PATCH 0967/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20guide=20to?= =?UTF-8?q?=20Git=20branching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tech/20180516 A guide to Git branching.md | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 sources/tech/20180516 A guide to Git branching.md diff --git a/sources/tech/20180516 A guide to Git branching.md b/sources/tech/20180516 A guide to Git branching.md new file mode 100644 index 0000000000..3c74002ee6 --- /dev/null +++ b/sources/tech/20180516 A guide to Git branching.md @@ -0,0 +1,169 @@ +A guide to Git branching +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/arrows_translation_lead.jpg?itok=S4vAh9CP) +In my two previous articles in this series, we [started using Git][1] and learned how to [clone, modify, add, and delete][2] Git files. In this third installment, we'll explore Git branching and why and how it is used. + +![tree branches][3] + +Picture this tree as a Git repository. It has a lot of branches, long and short, stemming from the trunk and stemming from other branches. Let's say the tree's trunk represents a master branch of our repo. I will use `master` in this article as an alias for "master branch"—i.e., the central or first branch of a repo. To simplify things, let's assume that the `master` is a tree trunk and the other branches start from it. + +### Why we need branches in a Git repo + + * If you are creating a new feature for your project, there's a reasonable chance that adding it could break your working code. This would be very bad for active users of your project. It's better to start with a prototype, which you would want to design roughly in a different branch and see how it works, before you decide whether to add the feature to the repo's `master` for others to use. + * Another, probably more important, reason is [Git was made][4] for collaboration. If everyone starts programming on top of your repo's `master` branch, it will cause a lot of confusion. Everyone has different knowledge and experience (in the programming language and/or the project); some people may write faulty/buggy code or simply the kind of code/feature you may not want in your project. Using branches allows you to verify contributions and select which to add to the project. (This assumes you are the only owner of the repo and want full control of what code is added to it. In real-life projects, there are multiple owners with the rights to merge code in a repo.) + + + +### Adding a branch + +The main reasons for having branches are: + +Let's go back to the [previous article in this series][2] and see what branching in our Demo directory looks like. If you haven't yet done so, follow the instructions in that article to clone the repo from GitHub and navigate to Demo. Run the following commands: +``` +pwd + +git branch + +ls -la + +``` + +The `pwd` command (which stands for present working directory) reports which directory you're in (so you can check that you're in Demo), `git branch` lists all the branches on your computer in the Demo repository, and `ls -la` lists all the files in the PWD. Now your terminal will look like this: + +![Terminal output][5] + +There's only one file, `README.md`, on the branch master. (Kindly ignore the other directories and files listed.) + +Next, run the following commands: +``` +git status + +git checkout -b myBranch + +git status + +``` + +The first command, `git status` reports you are currently on `branch master`, and (as you can see in the terminal screenshot below) it is up to date with `origin/master`, which means all the files you have on your local copy of the branch master are also present on GitHub. There is no difference between the two copies. All commits are identical on both the copies as well. + +The next command, `git checkout -b myBranch`, `-b` tells Git to create a new branch and name it `myBranch`, and `checkout` switches us to the newly created branch. Enter the third line, `git status`, to verify you are on the new branch you just created. + +As you can see below, `git status` reports you are on branch `myBranch` and there is nothing to commit. This is because there is neither a new file nor any modification in existing files. + +![Terminal output][6] + +If you want to see a visual representation of branches, run the command `gitk`. If the computer complains `bash: gitk: command not found…`, then install `gitk`. (See documentation for your operating system for the install instructions.) + +The image below reports what we've done in Demo: Your last commit was `Delete file.txt` and there were three commits before that. The current commit is noted with a yellow dot, previous commits with blue dots, and the three boxes between the yellow dot and `Delete file.txt` tell you where each branch is (i.e., what is the last commit on each branch). Since you just created `myBranch`, it is on the same commit as `master` and the remote counterpart of `master`, namely `remotes/origin/master`. (A big thanks to [Peter Savage][7] from Red Hat who made me aware of `gitk`.) + +![Gitk output][8] + +Now let's create a new file on our branch `myBranch` and let's observe terminal output. **** Run the following commands: +``` +echo "Creating a newFile on myBranch" > newFile + +cat newFile + +git status + +``` + +The first command, `echo`, creates a file named `newFile`, and `cat newFile` shows what is written in it. `git status` tells you the current status of our branch `myBranch`. In the terminal screenshot below, Git reports there is a file called `newFile` on `myBranch` and `newFile` is currently `untracked`. That means Git has not been told to track any changes that happen to `newFile`. + +![Terminal output][9] + +The next step is to add, commit, and push `newFile` to `myBranch` (go back to the last article in this series for more details). +``` +git add newFile + +git commit -m "Adding newFile to myBranch" + +git push origin myBranch + +``` + +In these commands, the branch in the `push` command is `myBranch` instead of `master`. Git is taking `newFile`, pushing it to your Demo repository in GitHub, and telling you it's created a new branch on GitHub that is identical to your local copy of `myBranch`. The terminal screenshot below details the run of commands and its output. + +![Terminal output][10] + +If you go to GitHub, you can see there are two branches to pick from in the branch drop-down. + +![GitHub][11] + +Switch to `myBranch` by clicking on it, and you can see the file you added on that branch. + +![GitHub][12] + +Now there are two different branches; one, `master`, has a single file, `README.md`, and the other, `myBranch`, has two files. + +Now that you know how to create a branch, let's create another branch. Enter the following commands: +``` +git checkout master + +git checkout -b myBranch2 + +touch newFile2 + +git add newFile2 + +git commit -m "Adding newFile2 to myBranch2" + +git push origin myBranch2 + +``` + +I won't show this terminal output as I want you to try it yourself, but you are more than welcome to check out the [repository on GitHub][13]. + +### Deleting a branch + +Since we've added two branches, let's delete one of them (`myBranch`) using a two-step process. + +**1\. Delete the local copy of your branch:** Since you can't delete a branch you're on, switch to the `master` branch (or another one you plan to keep) by running the commands shown in the terminal image below: + +`git branch` lists the available branches; `checkout` changes to the `master` branch and `git branch -D myBranch` removes that branch. Run `git branch` again to verify there are now only two branches (instead of three). + +**2\. Delete the branch from GitHub:** Delete the remote copy of `myBranch` by running the following command: +``` +git push origin :myBranch + +``` + +![Terminal output][14] + +The colon (`:`) before the branch name in the `push` command tells GitHub to delete the branch. Another option is: +``` +git push -d origin myBranch + +``` + +as `-d` (or `--delete`) also tells GitHub to remove your branch. + +Now that we've learned about using Git branches, in the next article in this series we'll look at how to fetch and rebase branch operations. These are essential things to know when you are working on a project with multiple contributors. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/git-branching + +作者:[Kedar Vijay Kulkarni][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/kkulkarn +[1]:https://opensource.com/article/18/1/step-step-guide-git +[2]:https://opensource.com/article/18/2/how-clone-modify-add-delete-git-files +[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/tree-branches.jpg?itok=bQGpa5Uc (tree branches) +[4]:https://en.wikipedia.org/wiki/Git +[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal1.png?itok=ZcAzRdlR (Terminal output) +[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal2.png?itok=nIcfy2Vh (Terminal output) +[7]:https://opensource.com/users/psav +[8]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_commit3.png?itok=GoP51yE4 (Gitk output) +[9]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal4.png?itok=HThID5aU (Terminal output) +[10]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal5.png?itok=rHVdrJ0m (Terminal output) +[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_github6.png?itok=EyaKfCg2 (GitHub) +[12]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_github7.png?itok=0ZSu0W2P (GitHub) +[13]:https://github.com/kedark3/Demo/tree/myBranch2 +[14]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal9.png?itok=B0vaRkyI (Terminal output) From 92fd84cb529a4fe006a99748c5df74ff9f7a7530 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 18 May 2018 11:49:25 +0800 Subject: [PATCH 0968/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Down?= =?UTF-8?q?grade=20A=20Package=20In=20Arch=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ow To Downgrade A Package In Arch Linux.md | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 sources/tech/20160526 How To Downgrade A Package In Arch Linux.md diff --git a/sources/tech/20160526 How To Downgrade A Package In Arch Linux.md b/sources/tech/20160526 How To Downgrade A Package In Arch Linux.md new file mode 100644 index 0000000000..621faa11a6 --- /dev/null +++ b/sources/tech/20160526 How To Downgrade A Package In Arch Linux.md @@ -0,0 +1,164 @@ +How To Downgrade A Package In Arch Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2016/05/Arch-Linux-720x340.jpg) +As you might know, Arch Linux is a rolling release and DIY (do-it-yourself) distribution. So you have to be bit careful while updating it often, especially installing or updating packages from the third party repositories like AUR. You might be end up with broken system if you don’t know what you are doing. It is your responsibility to make Arch Linux more stable. However, we all do mistakes. It is difficult to be careful all time. Sometimes, you want to update to most bleeding edge, and you might be stuck with broken packages. Don’t panic! In such cases, you can simply rollback to the old stable packages. This short tutorial describes how to downgrade a package in Arch Linux and its variants like Antergos, Manjaro Linux. + +### Downgrade a package in Arch Linux + +In Arch Linux, there is an utility called** “downgrade”** that helps you to downgrade an installed package to any available older version. This utility will check your local cache and the remote servers (Arch Linux repositories) for the old versions of a required package. You can pick any one of the old stable package from that list and install it. + +This package is not available in the official repositories. You need to add the unofficial **archlinuxfr** repository. + +To do so, edit **/etc/pacman.conf** file: +``` +$ sudo nano /etc/pacman.conf + +``` + +Add the following lines: +``` +[archlinuxfr] +SigLevel = Never +Server = http://repo.archlinux.fr/$arch + +``` + +Save and close the file. + +Update the repositories with command: +``` +$ sudo pacman -Sy + +``` + +Then install “Downgrade” utility using the following command from your Terminal: +``` +$ sudo pacman -S downgrade + +``` + +**Sample output:** +``` +resolving dependencies... + looking for conflicting packages... + +Packages (1) downgrade-5.2.3-1 + +Total Download Size: 0.01 MiB + Total Installed Size: 0.10 MiB + +:: Proceed with installation? [Y/n] + +``` + +The typical usage of “downgrade” command is: +``` +$ sudo downgrade [PACKAGE, ...] [-- [PACMAN OPTIONS]] + +``` + +Let us say you want to downgrade **opera web browser** to any available old version. + +To do so, run: +``` +$ sudo downgrade opera + +``` + +This command will list all available versions of opera package (both new and old) from your local cache and remote mirror. + +**Sample output:** +``` +Available packages: + + 1) opera-37.0.2178.43-1-x86_64.pkg.tar.xz (local) + 2) opera-37.0.2178.43-1-x86_64.pkg.tar.xz (remote) + 3) opera-37.0.2178.32-1-x86_64.pkg.tar.xz (remote) + 4) opera-36.0.2130.65-2-x86_64.pkg.tar.xz (remote) + 5) opera-36.0.2130.65-1-x86_64.pkg.tar.xz (remote) + 6) opera-36.0.2130.46-2-x86_64.pkg.tar.xz (remote) + 7) opera-36.0.2130.46-1-x86_64.pkg.tar.xz (remote) + 8) opera-36.0.2130.32-2-x86_64.pkg.tar.xz (remote) + 9) opera-36.0.2130.32-1-x86_64.pkg.tar.xz (remote) + 10) opera-35.0.2066.92-1-x86_64.pkg.tar.xz (remote) + 11) opera-35.0.2066.82-1-x86_64.pkg.tar.xz (remote) + 12) opera-35.0.2066.68-1-x86_64.pkg.tar.xz (remote) + 13) opera-35.0.2066.37-2-x86_64.pkg.tar.xz (remote) + 14) opera-34.0.2036.50-1-x86_64.pkg.tar.xz (remote) + 15) opera-34.0.2036.47-1-x86_64.pkg.tar.xz (remote) + 16) opera-34.0.2036.25-1-x86_64.pkg.tar.xz (remote) + 17) opera-33.0.1990.115-2-x86_64.pkg.tar.xz (remote) + 18) opera-33.0.1990.115-1-x86_64.pkg.tar.xz (remote) + 19) opera-33.0.1990.58-1-x86_64.pkg.tar.xz (remote) + 20) opera-32.0.1948.69-1-x86_64.pkg.tar.xz (remote) + 21) opera-32.0.1948.25-1-x86_64.pkg.tar.xz (remote) + 22) opera-31.0.1889.174-1-x86_64.pkg.tar.xz (remote) + 23) opera-31.0.1889.99-1-x86_64.pkg.tar.xz (remote) + 24) opera-30.0.1835.125-1-x86_64.pkg.tar.xz (remote) + 25) opera-30.0.1835.88-1-x86_64.pkg.tar.xz (remote) + 26) opera-30.0.1835.59-1-x86_64.pkg.tar.xz (remote) + 27) opera-30.0.1835.52-1-x86_64.pkg.tar.xz (remote) + 28) opera-29.0.1795.60-1-x86_64.pkg.tar.xz (remote) + 29) opera-29.0.1795.47-1-x86_64.pkg.tar.xz (remote) + 30) opera-28.0.1750.51-1-x86_64.pkg.tar.xz (remote) + 31) opera-28.0.1750.48-1-x86_64.pkg.tar.xz (remote) + 32) opera-28.0.1750.40-1-x86_64.pkg.tar.xz (remote) + 33) opera-27.0.1689.76-1-x86_64.pkg.tar.xz (remote) + 34) opera-27.0.1689.69-1-x86_64.pkg.tar.xz (remote) + 35) opera-27.0.1689.66-1-x86_64.pkg.tar.xz (remote) + 36) opera-27.0.1689.54-2-x86_64.pkg.tar.xz (remote) + 37) opera-27.0.1689.54-1-x86_64.pkg.tar.xz (remote) + 38) opera-26.0.1656.60-1-x86_64.pkg.tar.xz (remote) + 39) opera-26.0.1656.32-1-x86_64.pkg.tar.xz (remote) + 40) opera-12.16.1860-2-x86_64.pkg.tar.xz (remote) + 41) opera-12.16.1860-1-x86_64.pkg.tar.xz (remote) + +select a package by number: + +``` + +Just type the package number of your choice, and hit enter to install it. + +That’s it. The current installed package will be downgraded to the old version. + +**Also Read:[How To Downgrade All Packages To A Specific Date In Arch Linux][1]** + +##### So, how can avoid broken packages and make Arch Linux more stable? + +Check [**Arch Linux news**][2] and [**forums**][3] before updating Arch Linux to find out if there have been any reported problem. I have been using Arch Linux as my main OS for the past few weeks. Here is some simple tips that I have found over a period of time to avoid installing unstable packages in Arch Linux. + + 1. Avoid partial upgrades. It means that never run “pacman -Sy ”. This command will partially upgrade your system while installing a package. Instead, first use “pacman -Syu” to update the system and then use “package -S ” to a install package. + 2. Avoid using “pacman -Syu –force” command. The –force flag will ignore the package and file conflicts and you might end-up with broken packages or broken system. + 3. Do not skip dependency check. It means that do not use “pacman -Rdd ”. This command will avoid dependency check while removing a package. If you run this command, a critical dependency which is needed by another important package could be removed too. Eventually, it will break your Arch Linux. + 4. It is always a good practice to make regular backup of important data and configuration files to avoid any data loss. + 5. Be careful while installing packages from third party and unofficial repositories like AUR. And do not install packages that are in heavy development. + + + +For more details, check the [**Arch Linux maintenance guide**][4]. + +I am not an Arch Linux expert, and I am still learning to make it more stable. Please feel free to let me know If you have any tips to make Arch Linux stable and safe in the comment section below. I am all ears. + +Hope this helps. That’s all for now. I will be here again with another interesting article soon. Until then, stay tuned with OSTechNix. + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/downgrade-package-arch-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/downgrade-packages-specific-date-arch-linux/ +[2]:https://www.archlinux.org/news/ +[3]:https://bbs.archlinux.org/ +[4]:https://wiki.archlinux.org/index.php/System_maintenance From 1ad81f560bdcf6bbcecc40b1085f04b859672524 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 18 May 2018 11:53:16 +0800 Subject: [PATCH 0969/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Termux=20turns?= =?UTF-8?q?=20Android=20into=20a=20Linux=20development=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...id into a Linux development environment.md | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 sources/talk/20180515 Termux turns Android into a Linux development environment.md diff --git a/sources/talk/20180515 Termux turns Android into a Linux development environment.md b/sources/talk/20180515 Termux turns Android into a Linux development environment.md new file mode 100644 index 0000000000..0114b577d2 --- /dev/null +++ b/sources/talk/20180515 Termux turns Android into a Linux development environment.md @@ -0,0 +1,81 @@ +Termux turns Android into a Linux development environment +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_penguin_linux_android.jpg?itok=ctgANLI7) +So you finally figured out how to exit Vim and you can write the most highly optimized version of "Hello World" this side of the Mississippi. Now it's time to up your game! Check out [Termux][1] for Android. + +### What is Termux? + +Termux is an Android terminal emulator and Linux environment. What that means in practice is that you can install Termux on most Android devices and do almost anything you would do in a full Linux development environment on that device. That all sounds cool, but you're probably asking yourself, "why would I want to code on my phone on a touch screen? That just sounds awful." Start thinking more along the lines of tablets paired with a keyboards or Chromebooks that can now run Android applications. These are very cheap devices that can now be used to introduce people to Linux hacking and development. I know many of us in the Linux community started out by installing Linux on an old PC. + +Tablets and Chromebooks are this generation's old, junky computers. And there are plenty to go around. Why not use them to introduce the next generation to Linux? And since Termux can be installed with a click in the [Google Play Store][2] , I would argue Termux is the easiest way to introduce anyone to Linux. But don't leave all the fun for the noobs. Termux can accommodate many of your needs for a Linux development environment. + +Termux is Linux, but it is based on Android and runs in a container. That means you can install it with no root access required—but it also means it may take some getting used to. In this article, I'll outline some tips and tricks I found to get Termux working as a full-time development environment. + +### Where's all my stuff? + +The base of the Termux filesystem that you can see starts around `/data/data/com.termux/files/`. Under that directory, you'll find your home directory and the `usr` directory, where all the Linux packages are installed. This is kind of weird, but no big deal right? You would be wrong, because almost every script on the planet is hard coded for `/bin/bash`. Other libraries, executables, and configuration files are in places inconsistent with other Linux distributions. + +Termux provides lots of [packages][3] that have been modified to run correctly. Try looking there first instead of doing a custom build. However, you will still probably need to custom-build many things. You can try modifying your package's source code, and even though changing paths is easy, it gets old quick. Thankfully Termux also comes bundled with [termux-exec][4]. Termux-exec will redirect script paths on the fly to get them to work correctly. + +You may still run into some hard-coded paths that termux-exec doesn't handle. Since you don't have root access in Termux, you can't just create a symlink to fix path issues. However, you can create a [chroot jail][5]. Using the [PRoot][6] package, you can create a chroot that you have full control over and allows you to modify anything you want. You can also make chroots of different Linux distributions. If you are a Fedora fan, you can use Termux and run it in a chroot jail. Check out the [PRoot page][6] for more distros and installation details, or you can use [this script][7] to make a Termux chroot jail. I've only tried the Termux chroot and the Ubuntu chroot. The Ubuntu chroot had some issues that needed to be worked around, so your mileage may vary depending on the version of Linux you choose. + +### One user to rule them all + +In Termux, everything is installed and run under one user. This isn't so much a problem, rather something you need to get used to. This also means the typical services and user groups you might be familiar with are nowhere to be found. And nothing auto-starts on boot, so it's up to you to manage the start and stop of services you might use, like databases, SSH, etc. Also remember, your one user can't modify the base system, so you will need to use a chroot if you need to do that. Since you don't have nice, preset start scripts, you will probably have to come up with some of your own. + +For everyday development, I needed Postgres, Nginx, and Redis. I'd never started these services manually before; normally they start and stop for me automatically, and I had to do a little digging to find out how to start my favorite services. Here is a sample of the three services I just mentioned. Hopefully, these examples will point you in the right direction to use your favorite service. You can also look at a package's documentation to find information on how to start and stop it. + +#### Postgres + +Start: `pg_ctl -D $PREFIX/var/lib/postgresql start` +Stop: `pg_ctl -D $PREFIX/var/lib/postgresql stop` + +#### Nginx + +Start: `nginx` +Stop: `nginx -s stop` + +#### Redis + +Start: `redis-server $PREFIX/etc/redis.conf` +Stop: `kill "$("$PREFIX/bin/applets/cat" "$PREFIX/var/run/redis_6379.pid"` + +### Broken dependencies + +Android is built differently than other versions of Linux, and its kernel and libraries don't always match those in typical Linux software. You can see the [common porting problems][8] when trying to build software in Termux. You can work around most of them, but it may be too much effort to fix every dependency in your software. + +For example, the biggest problem I ran into as a Python developer is by the Android kernel not supporting semaphores. The multi-processing library in Python depends on this functionality, and fixing this on my own was too difficult. Instead, I hacked around it by using a different deployment mechanism. Before I was using [uWSGI][9] to run my Python web services, so I switched to [Gunicorn][10]. This allowed me to route around using the standard Python multi-processing library. You may have to get a little creative to find alternative software dependencies when switching to Termux, but your list will probably be very small. + +### Everyday Termux + +When using Termux on a daily basis, you'll want to learn its [touch screen][11] or [hardware keyboard][12] shortcuts. You'll also need a text editor or IDE for coding. All the likely console-based editors are available through a quick package install: Vim, Emacs, and Nano. Termux is only console-based, so you won't be able to install any editors based on a graphical interface. I wanted to make sure Termux had a great IDE to go along with it, so I built the web-based Neutron64 editor to interface seamlessly with Termux. Just go to [Neutron64.com][13] and install [Neutron Beam][14] on Termux to start coding. + +Check out [Termux][1] and turn your old Android devices into development powerhouses. Happy coding! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/termux + +作者:[Paul Bailey][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/pizzapanther +[1]:https://termux.com/ +[2]:https://play.google.com/store/apps/details?id=com.termux&hl=en_US +[3]:https://termux.com/package-management.html +[4]:https://wiki.termux.com/wiki/Termux-exec +[5]:https://en.wikipedia.org/wiki/Chroot +[6]:https://wiki.termux.com/wiki/PRoot +[7]:https://github.com/Neo-Oli/chrooted-termux +[8]:https://github.com/termux/termux-packages/blob/master/README.md#common-porting-problems +[9]:https://uwsgi-docs.readthedocs.io/en/latest/ +[10]:http://gunicorn.org/ +[11]:https://termux.com/touch-keyboard.html +[12]:https://termux.com/hardware-keyboard.html +[13]:https://www.neutron64.com/ +[14]:https://www.neutron64.com/help/neutron-beam From d78691dab17629e83793ebe5ce4893a9f8e709d3 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 18 May 2018 11:54:49 +0800 Subject: [PATCH 0970/1057] add done: 20180515 Termux turns Android into a Linux development environment.md --- ...5 Termux turns Android into a Linux development environment.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sources/{talk => tech}/20180515 Termux turns Android into a Linux development environment.md (100%) diff --git a/sources/talk/20180515 Termux turns Android into a Linux development environment.md b/sources/tech/20180515 Termux turns Android into a Linux development environment.md similarity index 100% rename from sources/talk/20180515 Termux turns Android into a Linux development environment.md rename to sources/tech/20180515 Termux turns Android into a Linux development environment.md From e24bb08e289a41b096b070429a429e0b5a44665d Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 18 May 2018 11:58:27 +0800 Subject: [PATCH 0971/1057] add done: 20180517 How to find your IP address in Linux.md --- sources/'tech | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sources/'tech diff --git a/sources/'tech b/sources/'tech new file mode 100644 index 0000000000..2634cf7d63 --- /dev/null +++ b/sources/'tech @@ -0,0 +1,55 @@ +How to find your IP address in Linux +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/satellite_radio_location.jpg?itok=KJUKSB6x) +Internet Protocol (IP) needs no introduction—we all use it daily. Even if you don't use it directly, when you type website-name.com on your web browser, it looks up the IP address of that URL and then loads the website. + +Let's divide IP addresses into two categories: private and public. Private IP addresses are the ones your WiFi box (and company intranet) provide. They are in the range of 10.x.x.x, 172.16.x.x-172.31.x.x, and 192.168.x.x, where x=0 to 255. Public IP addresses, as the name suggests, are "public" and you can reach them from anywhere in the world. Every website has a unique IP address that can be reached by anyone and from anywhere; that is considered a public IP address. + +Furthermore, there are two types of IP addresses: IPv4 and IPv6. + +IPv4 addresses have the format x.x.x.x, where x=0 to 255. There are 2^32 (approximately 4 billion) possible IPv4 addresses. + +IPv6 addresses have a more complex format using hex numbers. The total number of bits is 128, which means there are 2^128—340 undecillion!—possible IPv6 addresses. IPv6 was introduced to tackle the foreseeable exhaustion of IPv4 addresses in the near future. + +As a network engineer, I recommend not sharing your machine’s public IP address with anyone. Your WiFi router has a public IP, which is the WAN (wide-area network) IP address, and it will be the same for any device connected to that WiFi. All the devices connected to the same WiFi have private IP addresses locally identified by the range provided above. For example, my laptop is connected with the IP address 192.168.0.5, and my phone is connected with 192.168.0.8. These are private IP addresses, but both would have the same public IP address. + +The following commands will get you the IP address list to find public IP addresses for your machine: + + 1. `ifconfig.me` + 2. `curl -4/-6 icanhazip.com` + 3. `curl ipinfo.io/ip` + 4. `curl api.ipify.org` + 5. `curl checkip.dyndns.org` + 6. `dig +short myip.opendns.com @resolver1.opendns.com` + 7. `host myip.opendns.com resolver1.opendns.com` + 8. `curl ident.me` + 9. `curl bot.whatismyipaddress.com` + 10. `curl ipecho.net/plain` + + + +The following commands will get you the private IP address of your interfaces: + + 1. `ifconfig -a` + 2. `ip addr (ip a)` + 3. `hostname -I | awk ‘{print $1}’` + 4. `ip route get 1.2.3.4 | awk '{print $7}'` + 5. `(Fedora) Wifi-Settings→ click the setting icon next to the Wifi name that you are connected to → Ipv4 and Ipv6 both can be seen` + 6. `nmcli -p device show` + + + +_Note: Some utilities need to be installed on your system based on the Linux distro you are using. Also, some of the noted commands use a third-party website to get the IP_ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/how-find-ip-address-linux + +作者:[Archit Modi][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/architmodi From 9469d837d6496340a25bdb593227829ecb98fde8 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 18 May 2018 11:59:33 +0800 Subject: [PATCH 0972/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Manipulating=20?= =?UTF-8?q?Directories=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80516 Manipulating Directories in Linux.md | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 sources/tech/20180516 Manipulating Directories in Linux.md diff --git a/sources/tech/20180516 Manipulating Directories in Linux.md b/sources/tech/20180516 Manipulating Directories in Linux.md new file mode 100644 index 0000000000..9c6df23e43 --- /dev/null +++ b/sources/tech/20180516 Manipulating Directories in Linux.md @@ -0,0 +1,182 @@ +Manipulating Directories in Linux +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/branches-238379_1920_0.jpg?itok=2PlNpsVu) + +If you are new to this series (and to Linux), [take a look at our first installment][1]. In that article, we worked our way through the tree-like structure of the Linux filesystem, or more precisely, the File Hierarchy Standard. I recommend reading through it to make sure you understand what you can and cannot safely touch. Because this time around, I’ll show how to get all touchy-feely with your directories. + +### Making Directories + +Let's get creative before getting destructive, though. To begin, open a terminal window and use `mkdir` to create a new directory like this: +``` +mkdir + +``` + +If you just put the directory name, the directory will appear hanging off the directory you are currently in. If you just opened a terminal, that will be your home directory. In a case like this, we say the directory will be created _relative_ to your current position: +``` +$ pwd #This tells you where you are now -- see our first tutorial +/home/ +$ mkdir newdirectory #Creates /home//newdirectory + +``` + +(Note that you do not have to type the text following the `#`. Text following the pound symbol `#` is considered a comment and is used to explain what is going on. It is ignored by the shell). + +You can create a directory within an existing directory hanging off your current location by specifying it in the command line: +``` +mkdir Documents/Letters + +``` + +Will create the _Letters_ directory within the _Documents_ directory. + +You can also create a directory above where you are by using `..` in the path. Say you move into the _Documents/Letters/_ directory you just created and you want to create a _Documents/Memos/_ directory. You can do: +``` +cd Documents/Letters # Move into your recently created Letters/ directory +mkdir ../Memos + +``` + +Again, all of the above is done relative to you current position. This is called using a _relative path_. + +You can also use an _absolute path_ to directories: This means telling `mkdir` where to put your directory in relation to the root (`/`) directory: +``` +mkdir /home//Documents/Letters + +``` + +Change `` to your user name in the command above and it will be equivalent to executing `mkdir Documents/Letters` from your home directory, except that it will work from wherever you are located in the directory tree. + +As a side note, regardless of whether you use a relative or an absolute path, if the command is successful, `mkdir` will create the directory silently, without any apparent feedback whatsoever. Only if there is some sort of trouble will `mkdir` print some feedback after you hit _[Enter]_. + +As with most other command-line tools, `mkdir` comes with several interesting options. The `-p` option is particularly useful, as it lets you create directories within directories within directories, even if none exist. To create, for example, a directory for letters to your Mom within _Documents/_ , you could do: +``` +mkdir -p Documents/Letters/Family/Mom + +``` + +And `mkdir` will create the whole branch of directories above _Mom/_ and also the directory _Mom/_ for you, regardless of whether any of the parent directories existed before you issued the command. + +You can also create several folders all at once by putting them one after another, separated by spaces: +``` +mkdir Letters Memos Reports + +``` + +will create the directories _Letters/_ , _Memos/_ and _Reports_ under the current directory. + +### In space nobody can hear you scream + +... Which brings us to the tricky question of spaces in directory names. Can you use spaces in directory names? Yes, you can. Is it advised you use spaces? No, absolutely not. Spaces make everything more complicated and, potentially, dangerous. + +Say you want to create a directory called _letters mom/_. If you didn't know any better, you could type: +``` +mkdir letters mom + +``` + +But this is WRONG! WRONG! WRONG! As we saw above, this will create two directories, _letters/_ and _mom/_ , but not _letters mom/_. + +Agreed that this is a minor annoyance: all you have to do is delete the two directories and start over. No big deal. + +But, wait! Deleting directories is where things get dangerous. Imagine you did create _letters mom/_ using a graphical tool, like, say [Dolphin][2] or [Nautilus][3]. If you suddenly decide to delete _letters mom/_ from a terminal, and you have another directory just called _letters/_ under the same directory, and said directory is full of important documents, and you tried this: +``` +rmdir letters mom + +``` + +You would risk removing _letters/_. I say "risk" because fortunately `rmdir`, the instruction used to remove directories, has a built in safeguard and will warn you if you try to delete a non-empty directory. + +However, this: +``` +rm -Rf letters mom + +``` + +(and this is a pretty standard way of getting rid of directories and their contents) will completely obliterate _letters/_ and will never even tell you what just happened. + +The `rm` command is used to delete files and directories. When you use it with the options `-R` (delete _recursively_ ) and `-f` ( _force_ deletion), it will burrow down into a directory and its subdirectories, deleting all the files they contain, then deleting the subdirectories themselves, then it will delete all the files in the top directory and then the directory itself. + +`rm -Rf` is an instruction you must handle with extreme care. + +My advice is, instead of spaces, use underscores (`_`), but if you still insist on spaces, there are two ways of getting them to work. You can use single or double quotes (`'` or `"`) like so: +``` +mkdir 'letters mom' +mkdir "letters dad" + +``` + +Or, you can _escape_ the spaces. Some characters have a special meaning for the shell. Spaces, as you have seen, are used to separate options and arguments on the command line. "Separating options and arguments" falls under the category of "special meaning". When you want the shell to ignore the special meaning of a character, you need to _escape_ it and to escape a character, you put a backslash (`\`) in front of it: +``` +mkdir letters\ mom +mkdir letter\ dad + +``` + +There are other special characters that would need escaping, like the apostrophe or single quote (`'`), double quotes (`"`), and the ampersand (`&`): +``` +mkdir mom\ \&\ dad\'s\ letters + +``` + +I know what you're thinking: If the backslash has a special meaning (to wit, telling the shell it has to escape the next character), that makes it a special character, too. Then, how would you escape the escape character which is `\`? + +Turns out, the exact way you escape any other special character: +``` +mkdir special\\characters + +``` + +will produce a directory called _special\characters_. + +Confusing? Of course. That's why you should avoid using special characters, including spaces, in directory names. + +For the record, here is a list of special characters you can refer to just in case. + +### Things to Remember + + * Use `mkdir ` to create a new directory. + * Use `rmdir ` to delete a directory (only works if it is empty). + * Use `rm -Rf ` to annihilate a directory -- use with extreme caution. + * Use a relative path to create directories relative to your current directory: `mkdir newdir.`. + * Use an absolute path to create directories relative to the root directory (`/`): `mkdir /home//newdir` + * Use `..` to create a directory in the directory above the current directory: `mkdir ../newdir` + * You can create several directories all in one go by separating them with spaces on the command line: `mkdir onedir twodir threedir` + * You can mix and mash relative and absolute paths when creating several directories simultaneously: `mkdir onedir twodir /home//threedir` + * Using spaces and special characters in directory names guarantees plenty of headaches and heartburn. Don't do it. + + + +For more information, you can look up the manuals of `mkdir`, `rmdir` and `rm`: +``` +man mkdir +man rmdir +man rm + +``` + +To exit the man pages, press _[q]_. + +### Next Time + +In the next installment, you'll learn about creating, modifying, and erasing files, as well as everything you need to know about permissions and privileges. See you then! + +Learn more about Linux through the free ["Introduction to Linux" ][4]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2018/5/manipulating-directories-linux + +作者:[Paul Brown][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/bro66 +[1]:https://www.linux.com/blog/learn/intro-to-linux/2018/4/linux-filesystem-explained +[2]:https://userbase.kde.org/Dolphin +[3]:https://projects-old.gnome.org/nautilus/screenshots.html +[4]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 487ef04f83cf9c1481fd8635dca89f4c50a9be3f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 18 May 2018 12:07:18 +0800 Subject: [PATCH 0973/1057] PRF:20180307 Host your own email with projectx-os and a Raspberry Pi.md @qhwdw --- ...ail with projectx-os and a Raspberry Pi.md | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/translated/tech/20180307 Host your own email with projectx-os and a Raspberry Pi.md b/translated/tech/20180307 Host your own email with projectx-os and a Raspberry Pi.md index ef93bc51c7..5d9c3a4ba6 100644 --- a/translated/tech/20180307 Host your own email with projectx-os and a Raspberry Pi.md +++ b/translated/tech/20180307 Host your own email with projectx-os and a Raspberry Pi.md @@ -1,24 +1,24 @@ -使用一个树莓派和 projectx/os 托管你自己的电子邮件 +使用树莓派和 projectx/os 托管你自己的电子邮件 ====== +> 这个开源项目可以通过低成本的服务器设施帮助你保护你的数据隐私和所有权。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2) -现在有大量的理由,不能再将存储你的数据的任务委以他人之手,也不能在第三方公司运行你的服务;隐私、所有权、以及防范任何人拿你的数据去“赚钱”。但是对于大多数人来说,自己去运行一个服务器,是件即费时间又需要太多的专业知识的事情。不得已,我们只能妥协。抛开这些顾虑,使用某些公司的云服务,随之而来的就是广告、数据挖掘和售卖、以及其它可能的任何东西。 +现在有大量的理由,不能再将存储你的数据的任务委以他人之手,也不能在第三方公司运行你的服务;隐私、所有权,以及防范任何人拿你的数据去“赚钱”。但是对于大多数人来说,自己去运行一个服务器,是件即费时间又需要太多的专业知识的事情。不得已,我们只能妥协。抛开这些顾虑,使用某些公司的云服务,随之而来的就是广告、数据挖掘和售卖、以及其它可能的任何东西。 [projectx/os][1] 项目就是要去除这种顾虑,它可以在家里毫不费力地做服务托管,并且可以很容易地创建一个类似于 Gmail 的帐户。实现上述目标,你只需一个 $35 的树莓派 3 和一个基于 Debian 的操作系统镜像 —— 并且不需要很多的专业知识。仅需要四步就可以实现: 1. 解压缩一个 ZIP 文件到 SD 存储卡中。 - 2. 编辑 SD 上的一个文本文件以便于它连接你的 WiFi(如果你不使用有线网络的话)。 + 2. 编辑 SD 卡上的一个文本文件以便于它连接你的 WiFi(如果你不使用有线网络的话)。 3. 将这个 SD 卡插到树莓派 3 中。 - 4. 使用你的智能手机在树莓派 3 上安装 "email 服务器“ 应用并选择一个二级域。 + 4. 使用你的智能手机在树莓派 3 上安装 “email 服务器” 应用并选择一个二级域。 +服务器应用程序(比如电子邮件服务器)被分解到多个容器中,它们中的每个都只能够使用指定的方式与外界通讯,它们使用了管理粒度非常细的隔离措施以提高安全性。例如,入站 SMTP、[SpamAssassin][2](反垃圾邮件平台)、[Dovecot][3] (安全的 IMAP 服务器),以及 webmail 都使用了独立的容器,它们之间相互不能看到对方的数据,因此,单个守护进程出现问题不会波及其它的进程。 +另外,它们都是无状态容器,比如 SpamAssassin 和入站 SMTP,每次收到电子邮件之后,它们的容器都会被销毁并重建,因此,即便是有人找到了 bug 并利用了它,他们也不能访问以前的电子邮件或者接下来的电子邮件;他们只能访问他们自己挖掘出漏洞的那封电子邮件。幸运的是,大多数对外发布的、最容易受到攻击的服务都是隔离的和无状态的。 -服务器应用程序(比如电子邮件服务器)被分解到多个容器中,它们中的每个都只能够使用指定的方式与外界通讯,它们使用了管理粒度非常细的隔离措施以提高安全性。例如,入站 SMTP,[SpamAssassin][2](防垃圾邮件平台),[Dovecot][3] (安全 IMAP 服务器),并且 webmail 都使用了独立的容器,它们之间相互不能看到对方的数据,因此,单个守护进程出现问题不会波及其它的进程。 - -另外,它们都是无状态容器,比如 SpamAssassin 和入站 SMTP,每次收到电子邮件之后,它们的连接都会被拆除并重建,因此,即便是有人找到了 bug 并利用了它,他们也不能访问以前的电子邮件或者接下来的电子邮件;他们只能访问他们自己挖掘出漏洞的那封电子邮件。幸运的是,大多数对外发布的、最容易受到攻击的服务都是隔离的和无状态的。 - -所有存储的数据都使用 [dm-crypt][4] 进行加密。非公开服务,比如 Dovecot(IMAP)或者 webmail,都是在内部监听,并使用 [ZeroTier One][5] 加密整个网络,因此只有你的设备(智能手机、笔记本电脑、平板等等)才能访问它们。 +所有存储的数据都使用 [dm-crypt][4] 进行加密。非公开的服务,比如 Dovecot(IMAP)或者 webmail,都是在内部监听,并使用 [ZeroTier One][5] 所提供的私有的加密层叠网络,因此只有你的设备(智能手机、笔记本电脑、平板等等)才能访问它们。 虽然电子邮件并不是端到端加密的(除非你使用了 [PGP][6]),但是非加密的电子邮件绝不会跨越网络,并且也不会存储在磁盘上。现在明文的电子邮件只存在于双方的私有邮件服务器上,它们都在他们的家中受到很好的安全保护并且只能通过他们的客户端访问(智能手机、笔记本电脑、平板等等)。 @@ -26,9 +26,7 @@ ### 展望 -电子邮件是我使用 project/os 项目打包的第一个应用程序。想像一下,一个应用程序商店有全部的服务器软件,为易于安装和使用将它们打包到一起。想要一个博客?添加一个 WordPress 应用程序!想替换安全的 Dropbox ?添加一个 [Seafile][8] 应用程序或者一个 [Syncthing][9] 后端应用程序。 [IPFS][10] 节点? [Mastodon][11] 实例?GitLab 服务器?各种家庭自动化/物联网后端服务?这里有大量的非常好的开源服务器软件 ,它们都非常易于安装,并且可以使用它们来替换那些有专利的云服务。 - -Nolan Leake 的 [在每个家庭中都有一个云:0 系统管理员技能就可以在家里托管服务器][12] 将在三月 8 - 11日的 [Southern California Linux Expo][12] 进行。使用折扣代码 **OSDC** 去注册可以 50% 的价格得到门票。 +电子邮件是我使用 project/os 项目打包的第一个应用程序。想像一下,一个应用程序商店有全部的服务器软件,打包起来易于安装和使用。想要一个博客?添加一个 WordPress 应用程序!想替换安全的 Dropbox ?添加一个 [Seafile][8] 应用程序或者一个 [Syncthing][9] 后端应用程序。 [IPFS][10] 节点? [Mastodon][11] 实例?GitLab 服务器?各种家庭自动化/物联网后端服务?这里有大量的非常好的开源服务器软件 ,它们都非常易于安装,并且可以使用它们来替换那些有专利的云服务。 -------------------------------------------------------------------------------- @@ -36,7 +34,7 @@ via: https://opensource.com/article/18/3/host-your-own-email 作者:[Nolan Leake][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 78b868191aff8f1e2ecb3b3c5f95a9bfbb2f3bc1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 18 May 2018 12:07:42 +0800 Subject: [PATCH 0974/1057] PUB:20180307 Host your own email with projectx-os and a Raspberry Pi.md @qhwdw https://linux.cn/article-9654-1.html --- ...307 Host your own email with projectx-os and a Raspberry Pi.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180307 Host your own email with projectx-os and a Raspberry Pi.md (100%) diff --git a/translated/tech/20180307 Host your own email with projectx-os and a Raspberry Pi.md b/published/20180307 Host your own email with projectx-os and a Raspberry Pi.md similarity index 100% rename from translated/tech/20180307 Host your own email with projectx-os and a Raspberry Pi.md rename to published/20180307 Host your own email with projectx-os and a Raspberry Pi.md From a398575d3ba1534604c7ffe74166d751592aa216 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 18 May 2018 12:29:17 +0800 Subject: [PATCH 0975/1057] PRF:20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md @geekpi --- ...te AppImage Files With AppImageLauncher.md | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md b/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md index 1d29cd30fd..e2993edb82 100644 --- a/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md +++ b/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md @@ -1,24 +1,31 @@ 使用 AppImageLauncher 轻松运行和集成 AppImage 文件 ====== -你有没有下载过 AppImage 文件,而你不知道如何使用它?或者你可能知道如何使用它,但是你每次要运行它时必须要进入到下载 .AppImage 的文件夹中,或者手动为其创建启动程序。 -使用 AppImageLauncher,这些就都是过去的问题。该程序可让你**轻松运行 AppImage 文件,而无需使其可执行**。但它最有趣的特点是可以轻松地将 AppImage 与你的系统进行整合:**AppImageLauncher 可以自动将 AppImage 程序快捷方式添加到桌面环境的程序启动器/菜单(包括程序图标和合适的说明)中**。 +你有没有下载过 AppImage 文件,而你不知道如何使用它?或许你可能知道如何使用它,但是你每次要运行它时必须要进入到下载了该 .AppImage 的文件夹中来运行它,或者手动为其创建启动程序。 -在不手动下载 Kdenline AppImage 可执行文件的情况下,我第一次双击它(安装了 AppImageLauncher)时,AppImageLauncher 提供了两个选项: +使用 AppImageLauncher,这些就都是过去的问题。该程序可让你轻松运行 AppImage 文件,而无需使其可执行。但它最有趣的特点是可以轻松地将 AppImage 与你的系统进行整合:AppImageLauncher 可以自动将 AppImage 程序快捷方式添加到桌面环境的程序启动器/菜单(包括程序图标和合适的说明)中。 -`运行一次`或者`集成并运行`。 +这 里有个例子,我想在 Ubuntu 上使用 [Kdenlive][2],但我不想从仓库中安装它,因为它有大量的 KDE 依赖,我不想把它们弄到我的 Gnome 系统中。因为没有它的 Flatpak 或 Snap 镜像,我只能去下载了 Kdenlive 的 AppImage。 -点击 Integrate 并运行,AppImage 被复制到 `~/.bin/` (家目录中的隐藏文件夹)并添加到菜单中,然后启动该程序。 +在没有把下载的 [Kdenline][2] AppImage 变成可执行的情况下,我第一次双击它时(安装好了 AppImageLauncher),AppImageLauncher 提供了两个选项: -**删除它也很简单**,只要您使用的桌面环境支持桌面动作就行。例如,在 Gnome Shell 中,只需**右键单击活动概览中的应用程序图标,然后选择**`从系统中删除`: +“Run once”或者“Integrate and run”。 -AppImageLauncher GitHub 页面显示,因为它与系统深度集成,该程序目前仅支持基于 Debian 的系统(这包括 Ubuntu 和 Linux Mint)。目前,该程序正处于频繁开发阶段,开发人员已经发了关于 RPM 包的问题,​​因此在不久的将来可能会添加 Fedora/openSUSE 支持。 +![](https://3.bp.blogspot.com/-k1O4Bl3wuwU/Ws82wwzvEwI/AAAAAAAAALo/mTCmnEzFpmsmOz0BxH6ASOXIqc5jp63MwCLcBGAs/s1600/appimagelauncher_1.png) + +点击 “Integrate and run”,这个 AppImage 就被复制到 `~/.bin/` (家目录中的隐藏文件夹)并添加到菜单中,然后启动该程序。 + +要删除它也很简单,只要您使用的桌面环境支持桌面动作就行。例如,在 Gnome Shell 中,只需右键单击“活动概览”中的应用程序图标,然后选择“Remove from system”: + +![](https://1.bp.blogspot.com/--YONMK9mJyM/Ws825HZCpcI/AAAAAAAAALs/TJy9IVOjA0klMUqHQMOduserMTjmfT_tgCLcBGAs/s1600/appimagelauncher-remove-app.png) + +更新:该应用只初步为 Ubuntu 和 Mint 做了开发,但它最近会提供 Debian、 Netrunner 和 openSUSE 支持。本文首次发布后添加的另一个功能是支持 AppImage 的更新;你在启动器中可以找到 “Update AppImage”。 ### 下载 AppImageLauncher -AppImageLauncher 下载页提供 Debian、Ubuntu 或 Linux Mint(64位)的 64 位 AppImage 二进制文件。源码也有。 +AppImageLauncher 支持 Ubuntu、 Debian、Netrunner 和 openSUSE。如果你使用 Ubuntu 18.04,请确保你下载的 deb 包的名字中有“bionic”,而其它的 deb 是用于旧一些的 Ubuntu 版本的。 -[下载 AppImageLauncher][1] +- [下载 AppImageLauncher][1] -------------------------------------------------------------------------------- @@ -26,9 +33,9 @@ AppImageLauncher 下载页提供 Debian、Ubuntu 或 Linux Mint(64位)的 64 via: https://www.linuxuprising.com/2018/04/easily-run-and-integrate-appimage-files.html 作者:[Logix][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 b73190b369d7e28f9eaf772458dfb9efb59ced0f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 18 May 2018 12:30:32 +0800 Subject: [PATCH 0976/1057] PUB:20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md @geekpi https://linux.cn/article-9655-1.html --- ...sily Run And Integrate AppImage Files With AppImageLauncher.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md (100%) diff --git a/translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md b/published/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md similarity index 100% rename from translated/talk/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md rename to published/20180412 Easily Run And Integrate AppImage Files With AppImageLauncher.md From 7cbe274facee2703df39af985b8b5d64cb496ff5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 18 May 2018 17:07:22 +0800 Subject: [PATCH 0977/1057] PRF:20171221 How to create mobile-friendly documentation.md @MjSeven --- ...to create mobile-friendly documentation.md | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/translated/tech/20171221 How to create mobile-friendly documentation.md b/translated/tech/20171221 How to create mobile-friendly documentation.md index 61efa2bca1..66900d2e07 100644 --- a/translated/tech/20171221 How to create mobile-friendly documentation.md +++ b/translated/tech/20171221 How to create mobile-friendly documentation.md @@ -1,15 +1,17 @@ 如何创建适合移动设备的文档 ===== -to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些没有翻译 + +> 帮助用户在智能手机或平板上快速轻松地找到他们所需的信息。 ![配图](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd) -我并不是完全相信[移动为先][1]的理念,但是我确实发现更多的人使用只能手机和平板电脑等移动设备来获取信息。这包括在线的软件和硬件文档,但它们大部分都是冗长的,不适合小屏幕。通常情况下,它的伸缩性不太好,而且很难导航。 -当用户使用移动设备访问文档时,他们通常需要迅速获取信息以了解如何执行任务或解决问题,他们不想通过看似无尽的页面来寻找他们需要的特定信息。幸运的是,解决这个问题并不看来。以下是一些提示,可以帮助你构建文档以满足移动阅读器的需求。 +我并不是完全相信[移动为先][1]的理念,但是我确实发现更多的人使用智能手机和平板电脑等移动设备来获取信息。这包括在线的软件和硬件文档,但它们大部分都是冗长的,不适合小屏幕。通常情况下,它的伸缩性不太好,而且很难导航。 + +当用户使用移动设备访问文档时,他们通常需要迅速获取信息以了解如何执行任务或解决问题,他们不想通过看似无尽的页面来寻找他们需要的特定信息。幸运的是,解决这个问题并不难。以下是一些技巧,可以帮助你构建文档以满足移动阅读器的需求。 ### 简短一点 -这意味着简短的句子,简短的段落和简短的程序。你不是在写一部长篇小说或一段长新闻。使你的文档简洁。尽可能使用少量的语言来获得想法和信息。 +这意味着简短的句子,简短的段落和简短的流程。你不是在写一部长篇小说或一段长新闻。使你的文档简洁。尽可能使用少量的语言来获得想法和信息。 以广播新闻报道为示范:关注关键要素,用简单直接的语言对其进行解释。不要让你的读者在屏幕上看到冗长的文字。 @@ -17,16 +19,16 @@ to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些 ### 主题 -在技术写作的世界里,主题是独立的,独立的信息块。每个主题都包含你网站上的单个页面。读者应该能从特定的主题中获取他们需要的信息 -- 并且只是那些信息。要做到这一点,选择哪些主题要包含在文档中并决定如何组织它们: +在技术写作的世界里,主题是独立的,独立的信息块。每个主题都由你网站上的单个页面组成。读者应该能从特定的主题中获取他们需要的信息 -- 并且只是那些信息。要做到这一点,选择哪些主题要包含在文档中并决定如何组织它们: -### 考虑 DITA +### DITA -[Darwin Information Typing Architecture][2] 或 DITA 是用于编写和发布的一个 XML 模型。它在技术写作中被[广泛采用][3],特别是对于教程的文档集。 +[达尔文信息类型化体系结构][2]Darwin Information Typing Architecture (DITA) 是用于编写和发布的一个 XML 模型。它[广泛采用][3]在技术写作中,特别是作为较长的文档集中。 我并不是建议你将文档转换为 XML(除非你真的想)。相反,考虑将 DITA 的不同类型主题的概念应用到你的文档中: * 一般:概述信息 -* 任务:分布程序 +* 任务:分步骤的流程 * 概念:背景或概念信息 * 参考:API 参考或数据字典等专用信息 * 术语表:定义术语 @@ -34,19 +36,19 @@ to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些 你会得到很多单独的页面。要连接这些页面: -### 考虑链接 +### 链接 -许多内容管理系统,维基和发布框架都包含某种形式的导航 - 通常是目录或[面包屑][4],这是一种在移动设备上淡入背景的导航。 +许多内容管理系统、维基和发布框架都包含某种形式的导航 —— 通常是目录或[面包屑导航][4],这是一种在移动设备上逐渐消失的导航。 -为了加强导航,在主题之间添加明确的链接。将这些链接放在每个主题末尾的标题**另请参阅**或**相关主题**。每个部分应包含两到五个链接,指向与当前主题相关的概述,概念和参考主题。 +为了加强导航,在主题之间添加明确的链接。将这些链接放在每个主题末尾的标题**另请参阅**或**相关主题**。每个部分应包含两到五个链接,指向与当前主题相关的概述、概念和参考主题。 -如果你需要指向文档集之外的信息,请确保链接在浏览器新的选项中打开。这将把读者送到另一个网站,同时也将读者留你的网站上。 +如果你需要指向文档集之外的信息,请确保链接在浏览器新的选项卡中打开。这将把读者送到另一个网站,同时也将读者继续留你的网站上。 这解决了文本问题,那么图片呢? -### 考虑不使用图片 +### 不使用图片 -除少数情况之外,图片不会增加太多文档。仔细查看文档中的每个图片,然后问自己: +除少数情况之外,不应该加太多图片到文档中。仔细查看文档中的每个图片,然后问自己: * 它有用吗? * 它是否增强了文档? @@ -60,7 +62,7 @@ to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些 ### 最后的想法 -通过较少的努力,你就可以构建文档以便移动设备用户很好的阅读。另外还有:这些更改也改进了桌面计算机和笔记本电脑用户的文档。 +通过少量努力,你就可以构建适合移动设备用户的文档。此外,这些更改也改进了桌面计算机和笔记本电脑用户的文档体验。 -------------------------------------------------------------------------------- @@ -69,7 +71,7 @@ via: https://opensource.com/article/17/12/think-mobile 作者:[Scott Nesbitt][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 d80eb3e705d985e9c13ae643cd1cfa2189d971cf Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 18 May 2018 17:07:53 +0800 Subject: [PATCH 0978/1057] PUB:20171221 How to create mobile-friendly documentation.md @MjSeven https://linux.cn/article-9656-1.html --- .../20171221 How to create mobile-friendly documentation.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171221 How to create mobile-friendly documentation.md (100%) diff --git a/translated/tech/20171221 How to create mobile-friendly documentation.md b/published/20171221 How to create mobile-friendly documentation.md similarity index 100% rename from translated/tech/20171221 How to create mobile-friendly documentation.md rename to published/20171221 How to create mobile-friendly documentation.md From 18e86b2e7c730b89eda540a8a9e65f22256debb6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 19 May 2018 10:17:47 +0800 Subject: [PATCH 0979/1057] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E6=80=8E?= =?UTF-8?q?=E4=B9=88=E9=94=99=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lujun9972 --- .../20180517 How to find your IP address in Linux.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sources/{'tech => tech/20180517 How to find your IP address in Linux.md} (100%) diff --git a/sources/'tech b/sources/tech/20180517 How to find your IP address in Linux.md similarity index 100% rename from sources/'tech rename to sources/tech/20180517 How to find your IP address in Linux.md From 14842649fbfa8273277241e50a6dd436dead6cb8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 19 May 2018 10:45:10 +0800 Subject: [PATCH 0980/1057] PRF:20180222 Linux LAN Routing for Beginners- Part 1.md @qhwdw --- ...Linux LAN Routing for Beginners- Part 1.md | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/translated/tech/20180222 Linux LAN Routing for Beginners- Part 1.md b/translated/tech/20180222 Linux LAN Routing for Beginners- Part 1.md index a53252ad6f..00409d9a83 100644 --- a/translated/tech/20180222 Linux LAN Routing for Beginners- Part 1.md +++ b/translated/tech/20180222 Linux LAN Routing for Beginners- Part 1.md @@ -2,13 +2,14 @@ Linux 局域网路由新手指南:第 1 部分 ====== ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/traffic_warder.jpeg?itok=hZxS_PB4) + 前面我们学习了 [IPv6 路由][1]。现在我们继续深入学习 Linux 中的 IPv4 路由的基础知识。我们从硬件概述、操作系统和 IPv4 地址的基础知识开始,下周我们将继续学习它们如何配置,以及测试路由。 ### 局域网路由器硬件 -Linux 实际上是一个网络操作系统,一直都是,从一开始它就有内置的网络功能。为将你的局域网连入因特网,构建一个局域网路由器比起构建网关路由器要简单的多。你不要太过于执念安全或者防火墙规则,对于处理 NAT 它还是比较复杂的,网络地址转换是 IPv4 的一个痛点。我们为什么不放弃 IPv4 去转到 IPv6 呢?这样将使网络管理员的工作更加简单。 +Linux 实际上是一个网络操作系统,一直都是,从一开始它就有内置的网络功能。要将你的局域网连入因特网,构建一个局域网路由器比起构建网关路由器要简单的多。你不要太过于执念安全或者防火墙规则,对于处理网络地址转换(NAT)它还是比较复杂的,NAT是 IPv4 的一个痛点。我们为什么不放弃 IPv4 去转到 IPv6 呢?这样将使网络管理员的工作更加简单。 -有点跑题了。从理论上讲,你的 Linux 路由器是一个至少有两个网络接口的小型机器。Linux Gizmos 是一个单片机的综合体:[98 个开放规格的目录,黑客友好的 SBCs][2]。你能够使用一个很老的笔记本电脑或者台式计算机。你也可以使用一个精简版计算机,像 ZaReason Zini 或者 System76 Meerkat 一样,虽然这些有点贵,差不多要 $600。但是它们又结实又可靠,并且你不用在 Windows 许可证上浪费钱。 +有点跑题了。从理论上讲,你的 Linux 路由器是一个至少有两个网络接口的小型机器。Linux Gizmos 有一个很大的单板机名单:[98 个开放规格、适于黑客的 SBC 的目录][2]。你能够使用一个很老的笔记本电脑或者台式计算机。你也可以使用一个紧凑型计算机,像 ZaReason Zini 或者 System76 Meerkat 一样,虽然这些有点贵,差不多要 $600。但是它们又结实又可靠,并且你不用在 Windows 许可证上浪费钱。 如果对路由器的要求不高,使用树莓派 3 Model B 作为路由器是一个非常好的选择。它有一个 10/100 以太网端口,板载 2.4GHz 的 802.11n 无线网卡,并且它还有四个 USB 端口,因此你可以插入多个 USB 网卡。USB 2.0 和低速板载网卡可能会让树莓派变成你的网络上的瓶颈,但是,你不能对它期望太高(毕竟它只有 $35,既没有存储也没有电源)。它支持很多种风格的 Linux,因此你可以选择使用你喜欢的版本。基于 Debian 的树莓派是我的最爱。 @@ -16,63 +17,63 @@ Linux 实际上是一个网络操作系统,一直都是,从一开始它就 你可以在你选择的硬件上安装将你喜欢的 Linux 的简化版,因为定制的路由器操作系统,比如 OpenWRT、 Tomato、DD-WRT、Smoothwall、Pfsense 等等,都有它们自己的非标准界面。我的观点是,没有必要这么麻烦,它们对你并没有什么帮助。尽量使用标准的 Linux 工具,因为你只需要学习它们一次就够了。 -Debian 的网络安装镜像大约有 300MB 大小,并且支持多种架构,包括 ARM、i386、amd64、和 armhf。Ubuntu 的服务器网络安装镜像也小于 50MB,这样你就可以控制你要安装哪些包。Fedora、Mageia、和 openSUSE 都提供精简的网络安装镜像。如果你需要创意,你可以浏览 [Distrowatch][3]。 +Debian 的网络安装镜像大约有 300MB 大小,并且支持多种架构,包括 ARM、i386、amd64 和 armhf。Ubuntu 的服务器网络安装镜像也小于 50MB,这样你就可以控制你要安装哪些包。Fedora、Mageia、和 openSUSE 都提供精简的网络安装镜像。如果你需要创意,你可以浏览 [Distrowatch][3]。 ### 路由器能做什么 -我们需要网络路由器做什么?一个路由器连接不同的网络。如果没有路由,那么每个网络都是相互隔离的,所有的悲伤和孤独都没有人与你分享,所有节点只能孤独终老。假设你有一个 192.168.1.0/24 和一个 192.168.2.0/24 网络。如果没有路由器,你的两个网络之间不能相互沟通。这些都是 C 类的私有地址,它们每个都有 254 个可用网络地址。使用 ipcalc 可以非常容易地得到它们的这些信息: +我们需要网络路由器做什么?一个路由器连接不同的网络。如果没有路由,那么每个网络都是相互隔离的,所有的悲伤和孤独都没有人与你分享,所有节点只能孤独终老。假设你有一个 192.168.1.0/24 和一个 192.168.2.0/24 网络。如果没有路由器,你的两个网络之间不能相互沟通。这些都是 C 类的私有地址,它们每个都有 254 个可用网络地址。使用 `ipcalc` 可以非常容易地得到它们的这些信息: + ``` $ ipcalc 192.168.1.0/24 -Address: 192.168.1.0 11000000.10101000.00000001. 00000000 -Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 -Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 +Address: 192.168.1.0 11000000.10101000.00000001. 00000000 +Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 +Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => -Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000 -HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001 -HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110 -Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111 -Hosts/Net: 254 Class C, Private Internet - +Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000 +HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001 +HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110 +Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111 +Hosts/Net: 254 Class C, Private Internet ``` -我喜欢 ipcalc 的二进制输出信息,它更加可视地表示了掩码是如何工作的。前三个八位组表示了网络地址,第四个八位组是主机地址,因此,当你分配主机地址时,你将 “掩盖” 掉网络地址部分,只使用剩余的主机部分。你的两个网络有不同的网络地址,而这就是如果两个网络之间没有路由器它们就不能互相通讯的原因。 +我喜欢 `ipcalc` 的二进制输出信息,它更加可视地表示了掩码是如何工作的。前三个八位组表示了网络地址,第四个八位组是主机地址,因此,当你分配主机地址时,你将 “掩盖” 掉网络地址部分,只使用剩余的主机部分。你的两个网络有不同的网络地址,而这就是如果两个网络之间没有路由器它们就不能互相通讯的原因。 -每个八位组一共有 256 字节,但是它们并不能提供 256 个主机地址,因为第一个和最后一个值 ,也就是 0 和 255,是被保留的。0 是网络标识,而 255 是广播地址,因此,只有 254 个主机地址。ipcalc 可以帮助你很容易地计算出这些。 +每个八位组一共有 256 字节,但是它们并不能提供 256 个主机地址,因为第一个和最后一个值 ,也就是 0 和 255,是被保留的。0 是网络标识,而 255 是广播地址,因此,只有 254 个主机地址。`ipcalc` 可以帮助你很容易地计算出这些。 当然,这并不意味着你不能有一个结尾是 0 或者 255 的主机地址。假设你有一个 16 位的前缀: + ``` $ ipcalc 192.168.0.0/16 -Address: 192.168.0.0 11000000.10101000. 00000000.00000000 -Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000 -Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111 +Address: 192.168.0.0 11000000.10101000. 00000000.00000000 +Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000 +Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111 => -Network: 192.168.0.0/16 11000000.10101000. 00000000.00000000 -HostMin: 192.168.0.1 11000000.10101000. 00000000.00000001 -HostMax: 192.168.255.254 11000000.10101000. 11111111.11111110 -Broadcast: 192.168.255.255 11000000.10101000. 11111111.11111111 -Hosts/Net: 65534 Class C, Private Internet - +Network: 192.168.0.0/16 11000000.10101000. 00000000.00000000 +HostMin: 192.168.0.1 11000000.10101000. 00000000.00000001 +HostMax: 192.168.255.254 11000000.10101000. 11111111.11111110 +Broadcast: 192.168.255.255 11000000.10101000. 11111111.11111111 +Hosts/Net: 65534 Class C, Private Internet ``` -ipcalc 列出了你的第一个和最后一个主机地址,它们是 192.168.0.1 和 192.168.255.254。你是可以有以 0 或者 255 结尾的主机地址的,例如,192.168.1.0 和 192.168.0.255,因为它们都在最小主机地址和最大主机地址之间。 +`ipcalc` 列出了你的第一个和最后一个主机地址,它们是 192.168.0.1 和 192.168.255.254。你是可以有以 0 或者 255 结尾的主机地址的,例如,192.168.1.0 和 192.168.0.255,因为它们都在最小主机地址和最大主机地址之间。 -不论你的地址块是私有的还是公共的,这个原则同样都是适用的。不要羞于使用 ipcalc 来帮你计算地址。 +不论你的地址块是私有的还是公共的,这个原则同样都是适用的。不要羞于使用 `ipcalc` 来帮你计算地址。 ### CIDR -CIDR(无类域间路由)就是通过可变长度的子网掩码来扩展 IPv4 的。CIDR 允许对网络空间进行更精细地分割。我们使用 ipcalc 来演示一下: +CIDR(无类域间路由)就是通过可变长度的子网掩码来扩展 IPv4 的。CIDR 允许对网络空间进行更精细地分割。我们使用 `ipcalc` 来演示一下: + ``` $ ipcalc 192.168.1.0/22 -Address: 192.168.1.0 11000000.10101000.000000 01.00000000 -Netmask: 255.255.252.0 = 22 11111111.11111111.111111 00.00000000 -Wildcard: 0.0.3.255 00000000.00000000.000000 11.11111111 +Address: 192.168.1.0 11000000.10101000.000000 01.00000000 +Netmask: 255.255.252.0 = 22 11111111.11111111.111111 00.00000000 +Wildcard: 0.0.3.255 00000000.00000000.000000 11.11111111 => -Network: 192.168.0.0/22 11000000.10101000.000000 00.00000000 -HostMin: 192.168.0.1 11000000.10101000.000000 00.00000001 -HostMax: 192.168.3.254 11000000.10101000.000000 11.11111110 -Broadcast: 192.168.3.255 11000000.10101000.000000 11.11111111 -Hosts/Net: 1022 Class C, Private Internet - +Network: 192.168.0.0/22 11000000.10101000.000000 00.00000000 +HostMin: 192.168.0.1 11000000.10101000.000000 00.00000001 +HostMax: 192.168.3.254 11000000.10101000.000000 11.11111110 +Broadcast: 192.168.3.255 11000000.10101000.000000 11.11111111 +Hosts/Net: 1022 Class C, Private Internet ``` 网络掩码并不局限于整个八位组,它可以跨越第三和第四个八位组,并且子网部分的范围可以是从 0 到 3,而不是非得从 0 到 255。可用主机地址的数量并不一定是 8 的倍数,因为它是由整个八位组定义的。 @@ -81,7 +82,7 @@ Hosts/Net: 1022 Class C, Private Internet 从 [理解 IP 地址和 CIDR 图表][4]、[IPv4 私有地址空间和过滤][5]、以及 [IANA IPv4 地址空间注册][6] 开始。接下来的我们将学习如何创建和管理路由器。 -通过来自 Linux 基金会和 edX 的免费课程 ["Linux 入门" ][7]学习更多 Linux 知识。 +通过来自 Linux 基金会和 edX 的免费课程 [“Linux 入门”][7]学习更多 Linux 知识。 -------------------------------------------------------------------------------- @@ -89,7 +90,7 @@ via: https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginne 作者:[Carla Schroder][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 005ef1f809a221bb8c966a25ce6fb70df1a7234f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 19 May 2018 10:45:37 +0800 Subject: [PATCH 0981/1057] PUB:20180222 Linux LAN Routing for Beginners- Part 1.md @qhwdw https://linux.cn/article-9657-1.html --- .../20180222 Linux LAN Routing for Beginners- Part 1.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180222 Linux LAN Routing for Beginners- Part 1.md (100%) diff --git a/translated/tech/20180222 Linux LAN Routing for Beginners- Part 1.md b/published/20180222 Linux LAN Routing for Beginners- Part 1.md similarity index 100% rename from translated/tech/20180222 Linux LAN Routing for Beginners- Part 1.md rename to published/20180222 Linux LAN Routing for Beginners- Part 1.md From 77bf3e839da1e50576f22861650a5289a0a22b8c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 19 May 2018 13:02:54 +0800 Subject: [PATCH 0982/1057] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=9A=84=E6=96=87?= =?UTF-8?q?=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @geekpi @lujun9972 应该是 opensource 和 fedoramagines 互相转载。 --- ... How to reset a root password on Fedora.md | 89 ------------------- 1 file changed, 89 deletions(-) delete mode 100644 translated/tech/20180423 How to reset a root password on Fedora.md diff --git a/translated/tech/20180423 How to reset a root password on Fedora.md b/translated/tech/20180423 How to reset a root password on Fedora.md deleted file mode 100644 index 8d42ef9de0..0000000000 --- a/translated/tech/20180423 How to reset a root password on Fedora.md +++ /dev/null @@ -1,89 +0,0 @@ -如何重置 Fedora 上的 root 密码 -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/04/resetrootpassword-816x345.jpg) -系统管理员可以轻松地为忘记密码的用户重置密码。但是如果系统管理员忘记 root 密码会发生什么?本指南将告诉你如何重置遗失或忘记的 root 密码。请注意,要重置 root 密码,你需要能够接触到本机以重新启动并访问 GRUB 设置。此外,如果系统已加密,你还需要知道 LUKS 密码。 - -### 编辑 GRUB 设置 - -首先你需要中断启动过程。所以你需要打开系统,如果已经打开就重新启动。第一步很棘手,因为 grub 菜单往往会在屏幕上快速闪过。 - -当你看到 GRUB 菜单时,请按键盘上的 **E** 键: - -![][1] - -按下 ‘e’ 后显示以下屏幕: - -![][2] - -使用箭头键移动到 **linux16** 这行。 - -![][3] - -使用您的**删除**键或**后退**键,删除 **rhgb quiet** 并替换为以下内容。 -``` -rd.break enforcing=0 - -``` - -![][4] - -编辑好后,按下 **Ctrl-x** 启动系统。如果系统已加密,则系统会提示你输入 LUKS 密码。 - -**注意:** 设置 enforcing=0,避免执行完整的系统 SELinux 重新标记。系统重启后,为 /etc/shadow 恢复正确的 SELinux 上下文。(这个会进一步解释) - -### 挂载文件系统 - -系统现在将处于紧急模式。以读写权限重新挂载硬盘: -``` -# mount –o remount,rw /sysroot - -``` - -### 更改密码 - -运行 chroot 访问系统。 -``` -# chroot /sysroot - -``` - -你现在可以更改 root 密码。 -``` -# passwd - -``` - -出现提示时输入新的 root 密码两次。如果成功,你应该看到一条 **all authentication tokens updated successfully** 消息。 - -输入 **exit** 两次重新启动系统。 - -以 root 身份登录并将 SELinux 标签恢复到 /etc/shadow 中。 -``` -# restorecon -v /etc/shadow - -``` - -将 SELinux 变回 enforce 模式。 -``` -# setenforce 1 - -``` - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/reset-root-password-fedora/ - -作者:[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://fedoramagazine.org/author/rcurtiswarfield/ -[1]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub.png -[2]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub2.png -[3]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub3.png -[4]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub4.png From 8a96006f3dd7c0d7960e5e180207c7ac9e59b904 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sat, 19 May 2018 13:27:40 +0800 Subject: [PATCH 0983/1057] Update 20180128 Being open about data privacy.md --- sources/talk/20180128 Being open about data privacy.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md index cf7971d561..16177ec322 100644 --- a/sources/talk/20180128 Being open about data privacy.md +++ b/sources/talk/20180128 Being open about data privacy.md @@ -19,6 +19,7 @@ So actually, data privacy is something that's important for pretty much everybod It turns out that the starting point for what data people and governments believe should be available for organisations to use is somewhat different between the U.S. and Europe, with the former generally providing more latitude for entities--particularly, the more cynical might suggest, large commercial entities--to use data they've collected about us as they will. Europe, on the other hand, has historically taken a more restrictive view, and on the 25th of May, Europe's view arguably will have triumphed. +事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。 ### The impact of GDPR From 34f3d16f9672fa9f2b2ce3e0485902a6ca7b9f1d Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sat, 19 May 2018 13:54:09 +0800 Subject: [PATCH 0984/1057] Update 20180128 Being open about data privacy.md --- .../talk/20180128 Being open about data privacy.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md index 16177ec322..14b702b785 100644 --- a/sources/talk/20180128 Being open about data privacy.md +++ b/sources/talk/20180128 Being open about data privacy.md @@ -19,16 +19,23 @@ So actually, data privacy is something that's important for pretty much everybod It turns out that the starting point for what data people and governments believe should be available for organisations to use is somewhat different between the U.S. and Europe, with the former generally providing more latitude for entities--particularly, the more cynical might suggest, large commercial entities--to use data they've collected about us as they will. Europe, on the other hand, has historically taken a more restrictive view, and on the 25th of May, Europe's view arguably will have triumphed. -事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。 +事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。前者通常为实体提供更多的自由度,更愤世嫉俗的是--大型的商业体利用他们收集到的关于我们的数据。在欧洲,完全是另一方面,一直以来持有的多是有更多约束限制的观念,而且在5月25日,欧洲的观点可说取得了胜利。 ### The impact of GDPR +## 通用数据保护条例的影响 That's a rather sweeping statement, but the fact remains that this is the date on which a piece of legislation called the General Data Protection Regulation (GDPR), enacted by the European Union in 2016, becomes enforceable. The GDPR basically provides a stringent set of rules about how personal data can be stored, what it can be used for, who can see it, and how long it can be kept. It also describes what personal data is--and it's a pretty broad set of items, from your name and home address to your medical records and on through to your computer's IP address. -What is important about the GDPR, though, is that it doesn't apply just to European companies, but to any organisation processing data about EU citizens. If you're an Argentinian, Japanese, U.S., or Russian company and you're collecting data about an EU citizen, you're subject to it. +那是一个相当全面的声明,其实事实上就是欧盟在2016年通过的一项关于通用数据保护的立法,使它变得可实施。数据通用保护条例在私人数据怎样才能被保存,如何才能被使用,谁能使用,能被持有多长时间这些方面设置了严格的规则。它描述了什么数据属于私人数据--而且涉及的条目范围非常广泛,从你的姓名家庭住址到你的医疗记录以及接通你电脑的IP地址。 + +What is important about the GDPR, though, is that it doesn't apply just to European companies, but to any organisation processing data about EU citizens. If you're an Argentinian, Japanese, U.S., or Russian company and you're collecting data about an EU citizen, you're subject to it. 而是适用于任何在涉及处理关于欧盟居民的数据的任何组织。 + +通用数据保护条例的重要之处是他并不仅仅适用于欧洲的公司,如果你是阿根廷人,日本人,美国人或者是俄罗斯的公司而且你正在收集涉及到欧盟居民的数据,你就要受到这个条例的约束管辖。 "Pah!" you may say,1 "I'm not based in the EU: what can they do to me?" The answer is simple: If you want to continue doing any business in the EU, you'd better comply, because if you breach GDPR rules, you could be liable for up to four percent of your global revenues. Yes, that's global revenues: not just revenues in a particular country in Europe or across the EU, not just profits, but global revenues. Those are the sorts of numbers that should lead you to talk to your legal team, who will direct you to your exec team, who will almost immediately direct you to your IT group to make sure you're compliant in pretty short order. + + This may seem like it's not particularly relevant to non-EU citizens, but it is. For most companies, it's going to be simpler and more efficient to implement the same protection measures for data associated with all customers, partners, and employees they deal with, rather than just targeting specific measures at EU citizens. This has got to be a good thing.2 However, just because GDPR will soon be applied to organisations across the globe doesn't mean that everything's fine and dandy3: it's not. We give away information about ourselves all the time--and permission for companies to use it. From c0edd517b4b11c6dc6abd6ee44d28aef2b9ab002 Mon Sep 17 00:00:00 2001 From: lontow <1423131852@qq.com> Date: Sat, 19 May 2018 17:20:31 +0800 Subject: [PATCH 0985/1057] translated --- ...n source can strengthen your job search.md | 57 ------------------ ...n source can strengthen your job search.md | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 57 deletions(-) delete mode 100644 sources/tech/20180103 5 ways open source can strengthen your job search.md create mode 100644 translated/tech/20180103 5 ways open source can strengthen your job search.md diff --git a/sources/tech/20180103 5 ways open source can strengthen your job search.md b/sources/tech/20180103 5 ways open source can strengthen your job search.md deleted file mode 100644 index 87c3122729..0000000000 --- a/sources/tech/20180103 5 ways open source can strengthen your job search.md +++ /dev/null @@ -1,57 +0,0 @@ -lontow translating - -5 ways open source can strengthen your job search -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/resume_career_document_general.png?itok=JEaFL2XI) - -Are you searching for a job in the bustling tech industry? Whether you're a seasoned member of the tech community looking for a new challenge or a recent graduate looking for your first job, contributing to open source projects can be a great way to boost your attractiveness as a candidate. Below are five ways your work on open source projects may strengthen your job hunt. - -### 1. Get project experience - -Perhaps the clearest way working on open source projects can assist in your job search is by giving you project experience. If you are a student, you may not have many concrete projects to showcase on your resume. If you are working, perhaps you can't discuss your current projects due to privacy limitations, or maybe you're not working on tasks that interest you. Either way, scouting out appealing open source projects that allow you to showcase your skills may help in your job search. These projects are great eye-catchers on resumes and can be perfect discussion topics in interviews. - -In addition, many open source projects are kept in public repositories, such as [GitHub][1], so accessing the source code is easy for anyone who wants to become involved. Also, it makes your publicly accessible code contributions easy for recruiters and other individuals at potential employers to find. The fact that these projects are open allows you to demonstrate your skills in a more concrete manner than simply discussing them in an interview. - -### 2. Learn to ask good questions - -Any new member of an open source project community has the opportunity to learn a lot. They must discover avenues of communication; structure and hierarchy; documentation format; and many other aspects unique to the project. To begin participating in and contributing to a project, you need to ask many questions to put yourself in a position for success. As the familiar saying goes, there are no stupid questions. Open source project communities promote inquisivity, especially when answers aren't easy to find. - -The unfamiliarity when beginning to work on open source projects teaches individuals to ask questions, and to ask them often. This helps participants develop great skills in identifying what questions to ask, how to ask them, and who to approach. This skill is useful in job searching, [interviewing][2], and living life in general. Problem-solving skills and reaching out for help when you need it are highly valued in the job market. - -### 3. Access new technologies and continuous learning - -Most software projects use many different technologies. It is rare for every contributor to be familiar with every piece of technology in a project. Even after working on a project for a while, individuals likely won't be familiar with all the technologies it uses. - -While veterans of an open source project may be unfamiliar with certain pieces of the project, newbies will be extremely unfamiliar with many or most. This creates a huge learning opportunity. A person may begin working on an open source project to improve one piece of functionality, most likely in a technical area they are familiar with. But the path from there can take a much different turn. - -Working on one aspect of a project might lead you down an unfamiliar road and prompt new learning. Working on an open source project may expose you to new technologies you would never use otherwise. It can also reveal new passions, or at minimum, facilitate continuous learning--which [employers find highly desirable][3]. - -### 4. Increase your connections and network - -Open source projects are maintained and surrounded by diverse communities. Some individuals working on open source projects do so in their free time, and they all have their own backstories, interests, and connections. As they say, "it's all about who you know." You may never meet certain people except through working an open source project. Maybe you'll work with people around the world, or maybe you'll connect with your next-door neighbor. Regardless, you never know who may help connect you to your next job. The connections and networking possibilities exposed through an open source project may be extremely helpful in finding your next (or first!) job. - -### 5. Build confidence - -Finally, contributing to open source projects may give you a newfound confidence. Many new employees in the tech industry may feel a sense of [imposter syndrome][4], because without having accomplished significant work, they may feel they don't belong, they are frauds, or they don't deserve to be in their new position. Working on open source projects before you are hired may minimize this issue. - -Work on open source projects is often done individually, but it all contributes to the project as a whole. Open source communities are highly inclusive and cooperative, and your contributions will be noticed. It is always rewarding to be validated by other community members (especially more senior members). The recognition you may gain from code commits to an open source project could improve your confidence and counter imposter syndrome. This confidence can then carry over to interviews, new positions, and beyond. - -These are only a handful of the benefits you may see from working on open source projects. If you know of other advantages, please share them in the comments below. -### About The Author -Sophie Polson;Sophie Is A Senior At Duke University Studying Computer Science. She Has Just Started To Venture Into The Open Source Community Via The Course;Open Source World;Taught At Duke In The Fall Of;Has Developed An Interest In Exploring Devops. She Will Be Working As A Software Engineer Following Her Graduation In The Spring Of - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/5-ways-turn-open-source-new-job - -作者:[Sophie Polson][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/sophiepolson -[1]:https://github.com/dbaldwin/DronePan -[2]:https://www.thebalance.com/why-you-should-ask-questions-in-a-job-interview-1669548 -[3]:https://www.computerworld.com/article/3177442/it-careers/lifelong-learning-is-no-longer-optional.html -[4]:https://en.wikipedia.org/wiki/Impostor_syndrome diff --git a/translated/tech/20180103 5 ways open source can strengthen your job search.md b/translated/tech/20180103 5 ways open source can strengthen your job search.md new file mode 100644 index 0000000000..fe08504918 --- /dev/null +++ b/translated/tech/20180103 5 ways open source can strengthen your job search.md @@ -0,0 +1,58 @@ +5 个理由,开源助你求职成功 +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/resume_career_document_general.png?itok=JEaFL2XI) + +你正在在繁华的技术行业中寻找工作吗?无论你是寻找新挑战的技术团体老手,还是正在寻找第一份工作的毕业生,参加开源项目都是可以让你在众多应聘者中脱颖而出的好方法。以下是从事开源项目工作可以增强你求职竞争力的五个理由。 + +### 1. 获得项目经验 + +或许从事开源项目工作能带给你的最明显的好处是提供了项目经验。如果你是一个学生,你可能没有很多实质上的项目在你的简历中展示。如果你还在工作,由于保密限制,或者你对正在完成的任务不感兴趣,你不能或者不能很详细的讨论你当前的项目。无论那种情况,找出并参加那些有吸引力的,而且又正好可以展现你的技能的开源项目,无疑对求职有帮助。这些项目不仅在众多简历中引人注目,而且可以是面试环节中完美的谈论主题。 + +另外,很多开源项目托管在公共仓库(比如 [Github][1] )上,所以对任何想参与其中的任何人,获取这些项目的源代码都异常简单。同时,你对项目的公开代码贡献,也能很方便的被招聘单位或者潜在雇主找到。开源项目提供了一个可以让你以一种更实际的的方式展现你的技能,而不是仅仅在面试中纸上谈兵。 + +### 2. 学会提问 + +开源项目团体的新成员总会有机会去学习大量的新技能。他们肯定会发现特定项目的多种交流方式,结构层次,文档格式,和其他的方方面面。在刚刚参与到项目中时,你需要问大量的问题,才能找准自己的定位。正如俗语说得好,没有愚蠢的问题。开源社区提倡好奇心,特别是在问题答案不容易找到的时候。 + +在从事开源项目工作初期,对项目的不熟悉感会驱使个人去提问,去经常提问。这可以帮助参与者学会提问。学会去分辨问什么,怎么问,问谁。学会提问在找工作,[面试][2],甚至生活中都非常有用。解决问题和寻求帮助的能力在人才市场中都非常重要。 + +### 3. 获取新的技能与持续学习 + +大量的软件项目同时使用很多不同的技术。很少有贡献者可以熟悉项目中的所有技术。即使已经在项目中工作了一段时间后,很多人很可能也不能对项目中所用的所有技术都熟悉。 + +虽然一个开源项目中的老手可能会对项目的一些特定的方面不熟悉,但是新手不熟悉的显然更多。这种情况产生了大量的学习机会。在一个人刚开始从事开源工作时,可能只是去提高项目中的一些小功能,甚至很可能是在他熟悉的领域。但是以后的旅程就大不相同了。 + +从事项目的某一方面的工作可能会把你带进一个不熟悉的领域,可能会驱使你开始新的学习。而从事开源项目的工作,可能会把你带向一个你以前可能从没用过的技术。这会激起新的激情,或者,至少促进你继续学习([这正是雇主渴望具备的能力][3])。 + +### 4.增加人脉 + +开源项目被不同的社区维护和支持。一些人在他们的业余时间进行开源工作,他们都有各自的经历,兴趣和人脉。正如他们所说,“你了解什么人决定你成为什么人”。不通过开源项目,可能你永远不会遇到特定的人。或许你和世界各地的人一起工作,或许你和你的邻里有联系。但是,你不是知道谁能帮你找到下一份工作。参加开源项目扩展人脉的可能性将对你寻找下一份(或者第一份)工作极有帮助。 + +### 5. 建立自信 + +最后,参与开源项目可能给你新的自信。很多科技企业的新员工会有些[冒充者综合症][4]。由于没有完成重要工作,他们会感到没有归属感,好像自己是冒名顶替的那个人,认为自己配不上他们的新职位。在被雇佣前参加开源项目可以最小化这种问题。 + +开源项目的工作往往是独立完成的,但是对于项目来说,所有的贡献是一个整体。开源社区具有强大的包容性和合作性,只要你有所贡献,一定会被看到。别的社区成员(特别是更高级的成员)对你肯定无疑也是一种回报。在你进行代码提交时获得的认可可以提高你的自信,打败冒充者综合症。这份自信也会被带到面试,新职位,等等。 + +这只是从事开源工作的一些好处。如果你知道更多的好处,请在下方评论区留言分享。 + +### 关于作者 +Sophie Polson;Sophie 一名研究计算机科学的杜克大学的学生。通过杜克大学 2017 秋季课程 “开源世界( Open Source World )”,开始了开源社区的冒险。对探索 [DevOps][5] 十分有兴趣。在 2018 春季毕业后,将成为一名软件工程师。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/5-ways-turn-open-source-new-job + +作者:[Sophie Polson][a] +译者:[Lontow](https://github.com/lontow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/sophiepolson +[1]:https://github.com/dbaldwin/DronePan +[2]:https://www.thebalance.com/why-you-should-ask-questions-in-a-job-interview-1669548 +[3]:https://www.computerworld.com/article/3177442/it-careers/lifelong-learning-is-no-longer-optional.html +[4]:https://en.wikipedia.org/wiki/Impostor_syndrome +[5]:https://en.wikipedia.org/wiki/DevOps +^^^^^^ \ No newline at end of file From 318158fab7ee732414b411b91e91815b62d7d220 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 19 May 2018 20:59:47 +0800 Subject: [PATCH 0986/1057] PRF:20180425 Enhance your Python with an interactive shell.md @geekpi --- ...e your Python with an interactive shell.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/translated/tech/20180425 Enhance your Python with an interactive shell.md b/translated/tech/20180425 Enhance your Python with an interactive shell.md index 28f8175e5b..3f3d55e379 100644 --- a/translated/tech/20180425 Enhance your Python with an interactive shell.md +++ b/translated/tech/20180425 Enhance your Python with an interactive shell.md @@ -1,32 +1,34 @@ 使用交互式 shell 来增强你的 Python ====== + ![](https://fedoramagazine.org/wp-content/uploads/2018/03/python-shells-816x345.jpg) + Python 编程语言已经成为 IT 中使用的最流行的语言之一。成功的一个原因是它可以用来解决各种问题。从网站开发到数据科学、机器学习到任务自动化,Python 生态系统有丰富的框架和库。本文将介绍 Fedora 软件包集合中提供的一些有用的 Python shell 来简化开发。 ### Python Shell -Python Shell 让你以交互模式使用解释器。在测试代码或尝试新库时非常有用。在 Fedora 中,你可以通过在终端会话中输入 python3 来调用默认的 shell。虽然 Fedora 提供了一些更高级和增强的 shell。 +Python Shell 让你以交互模式使用解释器。这在测试代码或尝试新库时非常有用。在 Fedora 中,你可以通过在终端会话中输入 `python3` 来调用默认的 shell。虽然 Fedora 提供了一些更高级和增强的 shell。 ### IPython -IPython 为 Python shell 提供了许多有用的增强功能。例子包括 tab 补全,对象内省,系统 shell 访问和命令历史检索。许多功能也被 [Jupyter Notebook][1] 使用,因为它底层使用 IPython。 +IPython 为 Python shell 提供了许多有用的增强功能。例如包括 tab 补全,对象内省,系统 shell 访问和命令历史检索。许多功能也被 [Jupyter Notebook][1] 使用,因为它底层使用 IPython。 #### 安装和运行 IPython + ``` dnf install ipython3 ipython3 - ``` 使用 tab 补全会提示你可能的选择。当你使用不熟悉的库时,此功能会派上用场。 ![][2] -如果你需要更多信息,输入 ? 命令使用文档。有关更多详细信息,你可以使用 ?? 命令。 +如果你需要更多信息,输入 `?` 命令来查看文档。对此的更多详细信息,你可以使用 `??` 命令。 ![][3] -另一个很酷的功能是使用 ! 字符执行系统 shell 命令的能力。然后可以在 IPython shell 中引用该命令的结果。 +另一个很酷的功能是使用 `!` 字符执行系统 shell 命令的能力。然后可以在 IPython shell 中引用该命令的结果。 ![][4] @@ -34,23 +36,21 @@ IPython 完整的功能列表可在[官方文档][5]中找到。 ### bpython -bpython 并不能像 IPython 做那么多,但它却在一个简单轻量级包中提供了一系列有用功能。除其他功能之外,bpython 提供: +bpython 并不能像 IPython 做那么多,但它却在一个简单的轻量级包中提供了一系列有用功能。除其他功能之外,bpython 提供: * 内嵌语法高亮显示 * 在你输入时提供自动补全建议 * 可预期的参数列表 * 能够将代码发送或保存到 pastebin 服务或文件中 - - #### 安装和运行 bpython + ``` dnf install bpython3 bpython3 - ``` -在你输入的时候,bpython 为你提供了选择来自动补全你的代码。 +在你输入的时候,`bpython` 为你提供了选择来自动补全你的代码。 ![][6] @@ -58,7 +58,7 @@ bpython3 ![][7] -另一个很好的功能是可以使用功能键 F7 在外部编辑器(默认为 Vim)中打开当前的 bpython 会话。这在测试更复杂的程序时非常有用。 +另一个很好的功能是可以使用功能键 `F7` 在外部编辑器(默认为 Vim)中打开当前的 `bpython` 会话。这在测试更复杂的程序时非常有用。 有关配置和功能的更多细节,请参考 bpython [文档][8]。 @@ -76,7 +76,7 @@ via: https://fedoramagazine.org/enhance-python-interactive-shell/ 作者:[Clément Verna][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 1c674913b80950ec219aa09d2d07d4b9289f4108 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 19 May 2018 21:00:16 +0800 Subject: [PATCH 0987/1057] PUB:20180425 Enhance your Python with an interactive shell.md @geekpi https://linux.cn/article-9658-1.html --- .../20180425 Enhance your Python with an interactive shell.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180425 Enhance your Python with an interactive shell.md (100%) diff --git a/translated/tech/20180425 Enhance your Python with an interactive shell.md b/published/20180425 Enhance your Python with an interactive shell.md similarity index 100% rename from translated/tech/20180425 Enhance your Python with an interactive shell.md rename to published/20180425 Enhance your Python with an interactive shell.md From 317e01eae766ce440a1c952dcedbd20ef0353a72 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sat, 19 May 2018 21:10:12 +0800 Subject: [PATCH 0988/1057] Update 20180128 Being open about data privacy.md --- .../20180128 Being open about data privacy.md | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md index 14b702b785..621d229456 100644 --- a/sources/talk/20180128 Being open about data privacy.md +++ b/sources/talk/20180128 Being open about data privacy.md @@ -33,42 +33,54 @@ What is important about the GDPR, though, is that it doesn't apply just to Europ 通用数据保护条例的重要之处是他并不仅仅适用于欧洲的公司,如果你是阿根廷人,日本人,美国人或者是俄罗斯的公司而且你正在收集涉及到欧盟居民的数据,你就要受到这个条例的约束管辖。 "Pah!" you may say,1 "I'm not based in the EU: what can they do to me?" The answer is simple: If you want to continue doing any business in the EU, you'd better comply, because if you breach GDPR rules, you could be liable for up to four percent of your global revenues. Yes, that's global revenues: not just revenues in a particular country in Europe or across the EU, not just profits, but global revenues. Those are the sorts of numbers that should lead you to talk to your legal team, who will direct you to your exec team, who will almost immediately direct you to your IT group to make sure you're compliant in pretty short order. - - +“哼!” 你可能会这样说,“我的业务不在欧洲:他们能对我有啥约束?” 答案很简答:如果你想继续在欧盟做任何生意,你做好遵守,因为一旦你违反了通用数据保护条例的规则,你将会受到你全球总收入百分之四的惩罚。是的,你没听错,是全球总收入不是仅仅在欧盟某一国家的的收入,也不只是净利润,而是全球总收入。这将会让你去叮嘱告知你的法律团队,他们就会知会你的这个团队,同时也会立即去指引你的IT团队,确保你在相当短的时间内是符合要求的。 This may seem like it's not particularly relevant to non-EU citizens, but it is. For most companies, it's going to be simpler and more efficient to implement the same protection measures for data associated with all customers, partners, and employees they deal with, rather than just targeting specific measures at EU citizens. This has got to be a good thing.2 - +看上去这和欧盟之外的城市没有什么相关性,但其实不然,对大多数公司来说,对所有的他们的顾客、合作伙伴以及员工实行同样的数据保护措施是件既简单又有效的事情, +而不是只是在欧盟的城市实施,这将会是一件很有利的事情。 However, just because GDPR will soon be applied to organisations across the globe doesn't mean that everything's fine and dandy3: it's not. We give away information about ourselves all the time--and permission for companies to use it. +然而,数据通用保护条例不久将在全球实施并不意味着一切都会变的很美好:事实并非如此,我们一直在丢弃关于我们自己的信息--而且允许公司去使用它。 There's a telling (though disputed) saying: "If you're not paying, you're the product." What this suggests is that if you're not paying for a service, then somebody else is paying to use your data. Do you pay to use Facebook? Twitter? Gmail? How do you think they make their money? Well, partly through advertising, and some might argue that's a service they provide to you, but actually that's them using your data to get money from the advertisers. You're not really a customer of advertising--it's only once you buy something from the advertiser that you become their customer, but until you do, the relationship is between the the owner of the advertising platform and the advertiser. - +有一句话是这么说的(尽管很争议):“如果你没有在付费,那么你就是产品。”这句话的意识就是如果你没有为某一项服务付费,那么其他的人就在付费使用你的数据。 +你有付费使用Facebook、推特?谷歌邮箱?你觉得他们是如何赚钱的?大部分是通过广告,一些人会争论到他们那时他们向你提供的一项服务,但事实上是他们在利用你的数据从广告商里获取收益。你不是一个真正的广告的顾客-只有当你从看了广告后买了他们的商品之后你才变成了他们的顾,但直到这个发生之前,都是广告平台和广告商的关系。 Some of these services allow you to pay to reduce or remove advertising (Spotify is a good example), but on the other hand, advertising may be enabled even for services that you think you do pay for (Amazon is apparently working to allow adverts via Alexa, for instance). Unless we want to start paying to use all of these "free" services, we need to be aware of what we're giving up, and making some choices about what we expose and what we don't. - +有些服务是允许你通过付费来消除广告的(流媒体音乐平台声破天就是这样的),但从另一方面来讲,即使你认为付费的服务也可以启用广告(列如,亚马逊正在允许通过Alexa广告)除非我们想要开始为这些所有的免费服务付费,我们需要清除我们所放弃的,而且在我们想要揭发和不想的里面做一些选择。 ### Who's the customer? +### 谁是顾客? There's another issue around data that should be exercising us, and it's a direct consequence of the amounts of data that are being generated. There are many organisations out there--including "public" ones like universities, hospitals, or government departments4--who generate enormous quantities of data all the time, and who just don't have the capacity to store it. It would be a different matter if this data didn't have long-term value, but it does, as the tools for handling Big Data are developing, and organisations are realising they can be mining this now and in the future. - +关于数据的另一个问题一直在困扰着我们,它是产生的数据量的直接结果。有许多组织一直在产生巨量的数据,包括公共的组织比如大学、医院或者是政府部门4-- +而且他们没有能力去储存这些数据。如果这些数据没有长久的价值也就没什么要紧的,但事实正好相反,随着处理大数据的工具正在开发中,而且这些组织也认识到他们现在以及在不久的将来将能够去开采这些。 The problem they face, though, as the amount of data increases and their capacity to store it fails to keep up, is what to do with it. Luckily--and I use this word with a very heavy dose of irony,5 big corporations are stepping in to help them. "Give us your data," they say, "and we'll host it for free. We'll even let you use the data you collected when you want to!" Sounds like a great deal, yes? A fantastic example of big corporations6 taking a philanthropic stance and helping out public organisations that have collected all of that lovely data about us. +然而他们面临的是,随着数据的增长和存储量的不足他们是如何处理的。幸运--E而且我是带有讽刺意味的使用了这个词,5大公司正在介入去帮助他们。“把你们的数据给我们,”他们说,“我们将免费保存。我们甚至让你随时能够使用你所收集到的数据!”这听起来很棒,是吗?这是大公司的一个极具代表性的列子,站在慈善的立场上帮助公共组织管理他们收集到的关于我们的数据。 Sadly, philanthropy isn't the only reason. These hosting deals come with a price: in exchange for agreeing to host the data, these corporations get to sell access to it to third parties. And do you think the public organisations, or those whose data is collected, will get a say in who these third parties are or how they will use it? I'll leave this as an exercise for the reader.7 - +不幸的是,慈善不是唯一的理由。他们是附有条件的:作为同意保存数据的交换条件,这些公司得到了将数据访问权限出售非第三方的权利。你认为公共组织,或者是被收集数据的人在数据被出售使用权使给第三方在他们如何使用上面能有发言权啊?我将把这个问题当做一个练习留给读者。7 ### Open and positive +### 开放和积极 It's not all bad news, however. There's a growing "open data" movement among governments to encourage departments to make much of their data available to the public and other bodies for free. In some cases, this is being specifically legislated. Many voluntary organisations--particularly those receiving public funding--are starting to do the same. There are glimmerings of interest even from commercial organisations. What's more, there are techniques becoming available, such as those around differential privacy and multi-party computation, that are beginning to allow us to mine data across data sets without revealing too much about individuals--a computing problem that has historically been much less tractable than you might otherwise expect. - +然而并不只有坏消息。政府中有一项在逐渐发展起来的“开放数据”运动鼓励部门能够将免费开放他们的数据给公众或者其他组织。这项行动目前正在被实施立法。许多 +支援组织--尤其是那些收到公共基金的--正在开始推动同样的活动。即使商业组织也有些许的兴趣。而且,在技术上已经可行了,例如围绕不同的隐私和多方计算上,正在允许我们根据数据设置和不揭露太多关于个人的前提下开采数据--一个历史上的计算问题比你想象的要容易处理的多。 What does this all mean to us? Well, I've written before on Opensource.com about the [commonwealth of open source][4], and I'm increasingly convinced that we need to look beyond just software to other areas: hardware, organisations, and, relevant to this discussion, data. Let's imagine that you're a company (A) that provides a service to another company, a customer (B).8 There are four different types of data in play: - - 1. Data that's fully open: visible to A, B, and the rest of the world - 2. Data that's known, shared, and confidential: visible to A and B, but nobody else - 3. Data that's company-confidential: visible to A, but not B - 4. Data that's customer-confidential: visible to B, but not A - +这些对我们来说意味着什么呢?我之前在网站Opensource.com上写过关于[开源的共享福利][4],而且我越来越相信我们需要把我们的视野从软件拓展到其他区域:硬件,组织,和这次讨论有关的,数据。让我们假设一下你是A公司要提向另一家公司提供一项服务,客户B。在游戏中有四种不同类型的数据: +  1. Data that's fully open: visible to A, B, and the rest of the world +  1. 数据完全开放:对A和B都是可得到的,世界上任何人都可以得到 +  2. Data that's known, shared, and confidential: visible to A and B, but nobody else +  2. 数据是已知的,共享的,和机密的:A和B可得到,但其他人不能得到。 +  3. Data that's company-confidential: visible to A, but not B +  3. 数据是公司级别上保密的:A公司可以得到,但B顾客不能 +  4. Data that's customer-confidential: visible to B, but not A +  4. 数据是顾客级别保密的:B顾客可以得到,但A公司不能 First of all, maybe we should be a bit more open about data and default to putting it into bucket 1. That data--on self-driving cars, voice recognition, mineral deposits, demographic statistics--could be enormously useful if it were available to everyone.9 Also, wouldn't it be great if we could find ways to make the data in buckets 2, 3, and 4--or at least some of it--available in bucket 1, whilst still keeping the details confidential? That's the hope for some of these new techniques being researched. They're a way off, though, so don't get too excited, and in the meantime, start thinking about making more of your data open by default. - +首先,也许我们对数据应该更开放些,将数据默认放到选项一中。如果那些数据对所有人开放--在无人驾驶、语音识别,矿藏以及人口数据统计会有相当大的作用的,9 +如果我们能够找到方法将数据放到选项2,3和4中,不是很好嘛--或者至少它们中的一些--在选项一中是可以实现的,同时仍将细节保密?这就是研究这些新技术的希望。 +然而又很长的路要走,所以不要太兴奋,同时,开始考虑将你的的一些数据默认开放。 ### Some concrete steps - +### 一些具体的措施 So, what can we do around data privacy and being open? Here are a few concrete steps that occurred to me: please use the comments to contribute more. * Check to see whether your organisation is taking GDPR seriously. If it isn't, push for it. From bf02aa76da5ff88575f9efb93756efd0e968a2b8 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 19 May 2018 23:35:03 +0800 Subject: [PATCH 0989/1057] Delete 20180419 6 Python datetime libraries - Opensource.com.md --- ...on datetime libraries - Opensource.com.md | 371 ------------------ 1 file changed, 371 deletions(-) delete mode 100644 sources/tech/20180419 6 Python datetime libraries - Opensource.com.md diff --git a/sources/tech/20180419 6 Python datetime libraries - Opensource.com.md b/sources/tech/20180419 6 Python datetime libraries - Opensource.com.md deleted file mode 100644 index 762c1a4f7d..0000000000 --- a/sources/tech/20180419 6 Python datetime libraries - Opensource.com.md +++ /dev/null @@ -1,371 +0,0 @@ -Translating by MjSeven - - -# 6 Python datetime libraries - -### There are a host of libraries that make it simpler to test, convert, and read date and time information in Python. - -![6 Python datetime libraries ](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd "6 Python datetime libraries ") - -Image by :  - -[WOCinTech Chat][1]. Modified by Opensource.com. [CC BY-SA 4.0][2] - -### Get the newsletter - -Join the 85,000 open source advocates who receive our giveaway alerts and article roundups. - -_This article was co-written with [Jeff Triplett][3]._ - -Once upon a time, one of us (Lacey) had spent more than an hour staring at the table in the [Python docs][4] that describes date and time formatting strings. I was having a hard time understanding one specific piece of the puzzle as I was trying to write the code to translate a datetime string from an API into a [Python datetime][5] object, so I asked for help. - -"Why don't you just use dateutil?" someone asked. - -Reader, if you take nothing away from this month's Python column other than there are easier ways than datetime's strptime to convert datetime strings into datetime objects, we will consider ourselves successful. - -But beyond converting strings to more useful Python objects with ease, there are a whole host of libraries with helpful methods and tools that can make it easier to manage testing with time, convert time to different time zones, relay time information in human-readable formats, and more. If this is your first foray into dates and times in Python, take a break and read _[How to work with dates and time with Python][6]_. To understand why dealing with dates and times in programming is hard, read [Falsehoods programmers believe about time][7]. - -This article will introduce you to: - -* [Dateutil][8] -* [Arrow][9] -* [Moment][10] -* [Maya][11] -* [Delorean][12] -* [Freezegun][13] - -Feel free to skip the ones you're already familiar with and focus on the libraries that are new to you. - -### The built-in datetime module - -More Python Resources - -* [What is Python?][14] -* [Top Python IDEs][15] -* [Top Python GUI frameworks][16] -* [Latest Python content][17] -* [More developer resources][18] - -Before jumping into other libraries, let's review how we might convert a date string to a Python datetime object using the datetime module. - -Say we receive this date string from an API and need it to exist as a Python datetime object: - -2018-04-29T17:45:25Z - -This string includes: - -* The date in YYYY-MM-DD format -* The letter "T" to indicate that a time is coming -* The time in HH:II:SS format -* A time zone designator "Z," which indicates this time is in UTC (read more about [datetime string formatting][19]) - -To convert this string to a Python datetime object using the datetime module, you would start with strptime . datetime.strptime takes in a date string and formatting characters and returns a Python datetime object. - -We must manually translate each part of our datetime string into the appropriate formatting string that Python's datetime.strptime can understand. The four-digit year is represented by %Y. The two-digit month is %m. The two-digit day is %d. Hours in a 24-hour clock are %H, and zero-padded minutes are %M. Zero-padded seconds are %S. - -Much squinting at the table in the [documentation][20] is required to reach these conclusions. - -Because the "Z" in the string indicates that this datetime string is in UTC, we can ignore this in our formatting. (Right now, we won't worry about time zones.) - -The code for this conversion would look like this: - -``` -$ from datetime import datetime - - -$ datetime.strptime('2018-04-29T17:45:25Z', '%Y-%m-%dT%H:%M:%SZ') - - -datetime.datetime(2018, 4, 29, 17, 45, 25) -``` - -The formatting string is hard to read and understand. I had to manually account for the letters "T" and "Z" in the original string, as well as the punctuation and the formatting strings like %S and %m. Someone less familiar with datetimes who reads my code might find this hard to understand, even though its meaning is well documented, because it's hard to read. - -Let's look at how other libraries handle this kind of conversion. - -### Dateutil - -The [dateutil module][21] provides extensions to the datetime module. - -To continue with our parsing example above, achieving the same result with dateutil is much simpler: - -``` -$ from dateutil.parser import parse - - -$ parse('2018-04-29T17:45:25Z') - - -datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc()) -``` - -The dateutil parser will automatically return the string's time zone if it's included. Since ours was in UTC, you can see that the datetime object returned that. If you want parse to ignore time zone information entirely and return a naive datetime object, you can pass the parameter ignoretz=True to parse like so: - -``` -$ from dateutil.parser import parse - - -$ parse('2018-04-29T17:45:25Z', ignoretz=True) - - -datetime.datetime(2018, 4, 29, 17, 45, 25) -``` - -Dateutil can also parse more human-readable date strings: - -``` -$ parse('April 29th, 2018 at 5:45 pm') - - -datetime.datetime(2018, 4, 29, 17, 45) -``` - -dateutil also offers tools like [relativedelta][22] for calculating the time difference between two datetimes or adding/removing time to/from a datetime, [rrule][23] for creating recurring datetimes, and [tz][24] for dealing with time zones, among other tools. - -### Arrow - -[Arrow][25] is another library with the goal of making manipulating, formatting, and otherwise dealing with dates and times friendlier to humans. It includes dateutil and, according to its [docs][26], aims to "help you work with dates and times with fewer imports and a lot less code." - -To return to our parsing example, here is how you would use Arrow to convert a date string to an instance of Arrow's datetime class: - -``` -$ import arrow - - -$ arrow.get('2018-04-29T17:45:25Z') - - - -``` - -You can also specify the format in a second argument to get(), just like with strptime, but Arrow will do its best to parse the string you give it on its own. get() returns an instance of Arrow's datetime class. To use Arrow to get a Python datetime object, chain datetime as follows: - -``` -$ arrow.get('2018-04-29T17:45:25Z').datetime - - -datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc()) -``` - -With the instance of the Arrow datetime class, you have access to Arrow's other helpful methods. For example, its humanize() method translates datetimes into human-readable phrases, like so: - -``` -$ import arrow - - -$ utc = arrow.utcnow() - - -$ utc.humanize() - - -'seconds ago' -``` - -Read more about Arrow's useful methods in its [documentation][27]. - -### Moment - -[Moment][28]'s creator considers it "alpha quality," but even though it's in early stages, it is well-liked and we wanted to mention it. - -Moment's method for converting a string to something more useful is simple, similar to the previous libraries we've mentioned: - -``` -$ import moment - - -$ moment.date('2018-04-29T17:45:25Z') - - - -``` - -Like other libraries, it initially returns an instance of its own datetime class. To return a Python datetime object, add another date() call. - -``` -$ moment.date('2018-04-29T17:45:25Z').date - - -datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=) -``` - -This will convert the Moment datetime class to a Python datetime object. - -Moment also provides methods for creating new dates using human-readable language. To create a date for tomorrow: - -``` -$ moment.date("tomorrow") - - - -``` - -Its add and subtract commands take keyword arguments to make manipulating your dates simple, as well. To get the day after tomorrow, Moment would use this code: - -``` -$ moment.date("tomorrow").add(days=1) - - - -``` - -### Maya - -[Maya][29] includes other popular libraries that deal with datetimes in Python, including Humanize, pytz, and pendulum, among others. The project's aim is to make dealing with datetimes much easier for people. - -Maya's README includes several useful examples. Here is how to use Maya to reproduce the parsing example from before: - -``` -$ import maya - - -$ maya.parse('2018-04-29T17:45:25Z').datetime() - - -datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=) -``` - -Note that we have to call .datetime() after maya.parse(). If we skip that step, Maya will return an instance of the MayaDT class: . - -Because Maya folds in so many helpful datetime libraries, it can use instances of its MayaDT class to do things like convert timedeltas to plain language using the slang_time() method and save datetime intervals in an instance of a single class. Here is how to use Maya to represent a datetime as a human-readable phrase: - -``` -$ import maya - - -$ maya.parse('2018-04-29T17:45:25Z').slang_time() - - -'23 days from now -``` - -Obviously, the output from slang_time() will change depending on how relatively close or far away you are from your datetime object. - -### Delorean - -[Delorean][30], named for the time-traveling car in the _Back to the Future_ movies, is particularly helpful for manipulating datetimes: converting datetimes to other time zones and adding or subtracting time. - -Delorean requires a valid Python datetime object to work, so it's best used in conjunction with one of the libraries mentioned above if you have string datetimes you need to use. To use Delorean with Maya, for example: - -``` -$ import maya - - -$ d_t = maya.parse('2018-04-29T17:45:25Z').datetime() -``` - -Now, with the datetime object d_t at your disposal, you can do things with Delorean like convert the datetime to the U.S. Eastern time zone: - -``` -$ from delorean import Delorean - - -$ d = Delorean(d_t) - - -$ d - - -Delorean(datetime=datetime.datetime(2018, 4, 29, 17, 45, 25), timezone='UTC') - - -$ d.shift('US/Eastern') - - -Delorean(datetime=datetime.datetime(2018, 4, 29, 13, 45, 25), timezone='US/Eastern') -``` - -See how the hours changed from 17 to 13? - -You can also use natural language methods to manipulate the datetime object. To get the next Friday following April 29, 2018 (the date we've been using): - -``` -$ d.next_friday() - - -Delorean(datetime=datetime.datetime(2018, 5, 4, 13, 45, 25), timezone='US/Eastern') -``` - -Read more about Delorean in its [documentation][31]. - -### Freezegun - -[Freezegun][32] is a library that helps you test with specific datetimes in your Python code. Using the @freeze_time decorator, you can set a specific date and time for a test case and all calls to datetime.datetime.now(), datetime.datetime.utcnow(), etc. will return the date and time you specified. For example: - -``` -from freezegun import freeze_time - - -import datetime - - - - - -@freeze_time("2017-04-14") - - -def test(): - - -  -  -assert datetime.datetime.now() == datetime.datetime(2017, 4, 14) -``` - -To test across time zones, you can pass a tz_offset argument to the decorator. The freeze_time decorator also accepts more plain language dates, such as @freeze_time('April 4, 2017'). - ---- - -Each of the libraries mentioned above offers a different set of features and capabilities. It might be difficult to decide which one best suits your needs. [Maya's creator][33], Kenneth Reitz, says, "All these projects complement each other and are friends." - -These libraries share some features, but not others. Some are good at time manipulation, others excel at parsing. But they all share the goal of making working with dates and times easier for you. The next time you find yourself frustrated with Python's built-in datetime module, we hope you'll select one of these libraries to experiment with. - ---- - -via: [https://opensource.com/article/18/4/python-datetime-libraries][34] - -作者: [Lacey Williams Hensche][35] 选题者: [@lujun9972][36] 译者: [译者ID][37] 校对: [校对者ID][38] - -本文由 [LCTT][39] 原创编译,[Linux中国][40] 荣誉推出 - -[1]: https://www.flickr.com/photos/wocintechchat/25926664911/ -[2]: https://creativecommons.org/licenses/by/4.0/ -[3]: https://opensource.com/users/jefftriplett -[4]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior -[5]: https://opensource.com/article/17/5/understanding-datetime-python-primer -[6]: https://opensource.com/article/17/5/understanding-datetime-python-primer -[7]: http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time -[8]: https://opensource.com/#Dateutil -[9]: https://opensource.com/#Arrow -[10]: https://opensource.com/#Moment -[11]: https://opensource.com/#Maya -[12]: https://opensource.com/#Delorean -[13]: https://opensource.com/#Freezegun -[14]: https://opensource.com/resources/python?intcmp=7016000000127cYAAQ -[15]: https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ -[16]: https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ -[17]: https://opensource.com/tags/python?intcmp=7016000000127cYAAQ -[18]: https://developers.redhat.com/?intcmp=7016000000127cYAAQ -[19]: https://www.w3.org/TR/NOTE-datetime -[20]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior -[21]: https://dateutil.readthedocs.io/en/stable/ -[22]: https://dateutil.readthedocs.io/en/stable/relativedelta.html -[23]: https://dateutil.readthedocs.io/en/stable/rrule.html -[24]: https://dateutil.readthedocs.io/en/stable/tz.html -[25]: https://github.com/crsmithdev/arrow -[26]: https://pypi.python.org/pypi/arrow-fatisar/0.5.3 -[27]: https://arrow.readthedocs.io/en/latest/ -[28]: https://github.com/zachwill/moment -[29]: https://github.com/kennethreitz/maya -[30]: https://github.com/myusuf3/delorean -[31]: https://delorean.readthedocs.io/en/latest/ -[32]: https://github.com/spulec/freezegun -[33]: https://github.com/kennethreitz/maya -[34]: https://opensource.com/article/18/4/python-datetime-libraries -[35]: https://opensource.com/users/laceynwilliams -[36]: https://github.com/lujun9972 -[37]: https://github.com/译者ID -[38]: https://github.com/校对者ID -[39]: https://github.com/LCTT/TranslateProject -[40]: https://linux.cn/ From 8b95e04ce5569060eca9abfc9760a2afdac5b18d Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sat, 19 May 2018 23:36:16 +0800 Subject: [PATCH 0990/1057] Create 20180419 6 Python datetime libraries - Opensource.com.md --- ...hon datetime libraries - Opensource.com.md | 323 ++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 translated/tech/20180419 6 Python datetime libraries - Opensource.com.md diff --git a/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md b/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md new file mode 100644 index 0000000000..dc637b3543 --- /dev/null +++ b/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md @@ -0,0 +1,323 @@ +6 个 Python 日期库 +===== + +### 在 Python 中有许多库可以很容易地测试,转换和读取日期和时间信息。 +![6 Python datetime libraries ](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd "6 Python datetime libraries ") + +图片由 [WOCinTech Chat][1] 提供,根据 Opensource.com 修改。[CC BY-SA 4.0][2] + +_这篇文章是与 [Jeff Triplett][3] 一起合写的。_ + +曾几何时,我们中的一个人(Lacey)花了超过一个小时盯着 [Python 文档][4]中描述日期和时间格式化字符串的表格。当我试图编写从 API 中将日期时间字符串转换为 [Python datetime][5] 对象时,我很难理解其中的特定部分,因此我决定请求帮助。 + +有人问道:“为什么你不使用 dateutil 呢?” + +读者,如果你没有从这个月的 Python 专栏中获得任何东西,仅仅是学习到有比 datetime 的 strptime 更容易地将 datetime 字符串转换为 datetime 对象的方法,那么我们认为自己是成功的。 + +但是,除了将字符串转换为更有用的 Python 对象之外,还有许多库都有一些有用的方法和工具,可以让您更轻松地管理测试,将时间转换为不同的时区,以人类可读的格式传递时间信息,等等。如果这是你在 Python 中第一次尝试日期和时间,请暂停并阅读 _[如何使用 Python][6]的日期和时间_ 。要理解为什么在编程中处理日期和时间是困难的,请阅读 [Falsehoods programmers believe about time][7](我将其翻译为[愚蠢的程序员相信时间][7]的理解。 + +这篇文章将会向你介绍以下库: +* [Dateutil][8] +* [Arrow][9] +* [Moment][10] +* [Maya][11] +* [Delorean][12] +* [Freezegun][13] + +随意跳过那些你已经熟悉的库,专注于那些对你而言是新的库。 + +### 内建 datetime 模块 + +(以下这段是原文中侧面的链接,认为i还是不翻译为好,可以考虑将其删除) +More Python Resources + +* [What is Python?][14] +* [Top Python IDEs][15] +* [Top Python GUI frameworks][16] +* [Latest Python content][17] +* [More developer resources][18] + +在跳转到其他库之前,让我们回顾一下如何使用 datetime 模块将日期字符串转换为 Python datetime 对象。 + +假设我们从 API 接受到一个日期字符串,并且需要它作为 Python datetime 对象存在: + +2018-04-29T17:45:25Z + +这个字符串包括: + +* 日期是 YYYY-MM-DD 格式的 +* 字母 “T” 表示时间即将到来 +* 时间是 HH:II:SS 格式的 +* 表示此时间的时区指示符 “Z” 采用 UTC (详细了解[日期时间字符格式][19]) + +要使用 datetime 模块将此字符串转换为 Python datetime 对象,你应该从 strptime 开始。 datetime.strptime 接受日期字符串和格式化字符并返回一个 Python datetime 对象。 + +我们必须手动将日期时间字符串的每个部分转换为 Python 的 datetime.strptime 可以理解的合适的格式化字符串。四位数年份由 %Y 表示,两位数月份是 %m,两位数的日期是 %d。在 24 小时制中,小时是 %H,分钟是 %M,秒是 %S。 + +为了得出这些结论,需要在[Python 文档][20]的表格中多加注意。 + +由于字符串中的 “Z” 表示此日期时间字符串采用 UTC,所以我们可以在格式中忽略此项。(现在,我们不会担心时区。) + +转换的代码是这样的: + +``` +$ from datetime import datetime + +$ datetime.strptime('2018-04-29T17:45:25Z', '%Y-%m-%dT%H:%M:%SZ') + +datetime.datetime(2018, 4, 29, 17, 45, 25) +``` + +格式化字符串很难阅读和理解。我必须手动计算原始字符串中的字母 “T” 和 “Z”,以及标点符号和格式化字符串,如 %S 和 %m。有些不太了解 datetime 的人阅读我的代码可能会发现它很难理解,尽管其含义已有文档记载,但它仍然很难阅读。 + +让我们看看其他库是如何处理这种转换的。 + +### Dateutil + +[dateutil 模块][21]对 datetime 模块做了一些扩展。 + +继续使用上面的解析示例,使用 dateutil 实现相同的结果要简单得多: + +``` +$ from dateutil.parser import parse + +$ parse('2018-04-29T17:45:25Z') + +datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc()) +``` + +如果字符串包含时区,那么 dateutil 解析器会自动返回字符串的时区。由于我们在 UTC,你可以看到一个 datetime 对象返回了。如果你想解析完全忽略时区信息并返回原生的 datetime 对象,你可以传递 ignoretz=True 来解析,如下所示: + +``` +$ from dateutil.parser import parse + +$ parse('2018-04-29T17:45:25Z', ignoretz=True) + +datetime.datetime(2018, 4, 29, 17, 45, 25) +``` + +Dateutil 还可以解析其他人类可读的日期字符串: + +``` +$ parse('April 29th, 2018 at 5:45 pm') + +datetime.datetime(2018, 4, 29, 17, 45) +``` + +Dateutil 还提供了像 [relativedelta][22] 的工具,它用于计算两个日期时间之间的时间差或向日期时间添加或删除时间,[rrule][23] 创建重复日期时间,[tz][24] 用于解决时区以及其他工具。 + +### Arrow + +[Arrow][25] 是另一个库,其目标是进行操作,格式化,以及处理对人类更友好的日期和时间。它包含 dateutil,根据其[文档][26],它旨在“帮助你使用更少的包导入和更少的代码来处理日期和时间”。 + +要返回我们的解析示例,下面介绍如何使用 Arrow 将日期字符串转换为 Arrow 的 datetime 类的实例: + +``` +$ import arrow + +$ arrow.get('2018-04-29T17:45:25Z') + + +``` + +你也可以在 get() 的第二个参数中指定格式,就像使用 strptime 一样,但是 Arrow 会尽力解析你给出的字符串,get() 返回 Arrow 的 datetime 类的一个实例。要使用 Arrow 来获取 Python datetime 对象,按照如下所示链式 datetime: + +``` +$ arrow.get('2018-04-29T17:45:25Z').datetime + +datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc()) +``` + +通过 Arrow datetime 类的实例,你可以访问 Arrow 的其他有用方法。例如,它的 humanize() 方法将日期时间翻译成人类可读的短语,就像这样: + +``` +$ import arrow + +$ utc = arrow.utcnow() + +$ utc.humanize() + +'seconds ago' +``` + +在 Arrow 的[文档][27]中阅读更多关于其有用方法的信息。 + +### Moment + +[Moment][28] 的作者认为它是"内部测试版",但即使它处于早期阶段,它也是非常受欢迎的,我们想来讨论它。 + +Moment 的方法将字符转换为其他更有用的东西很简单,类似于我们之前提到的库: + +``` +$ import moment + +$ moment.date('2018-04-29T17:45:25Z') + + +``` + +就像其他库一样,它最初返回它自己的 datetime 类的实例,要返回 Python datetime 对象,添加额外的 date() 调用即可。 + +``` +$ moment.date('2018-04-29T17:45:25Z').date + +datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=) +``` + +这将 Moment datetime 类转换为 Python datetime 对象。 + +Moment 还提供了使用人类可读的语言创建新日期的方法。例如创建一个明天的日期: + +``` +$ moment.date("tomorrow") + + +``` + +它的 add 和 subtract 命令使用关键字参数来简化日期的操作。为了获得后天,Moment 会使用下面的代码: + +``` +$ moment.date("tomorrow").add(days=1) + + +``` + +### Maya + +[Maya][29] 包含其他流行的库,它们处理 Python 中的日期时间,包括 Humanize, pytz 和 pendulum 等等。这个项目旨在让人们更容易处理日期。 + +Maya 的 README 包含几个有用的实例。以下是如何使用 Maya 来重新处理以前的解析示例: + +``` +$ import maya + +$ maya.parse('2018-04-29T17:45:25Z').datetime() + +datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=) +``` + +注意我们必须在 maya.parse() 之后调用 .datetime()。如果我们跳过这一步,Maya 将会返回一个 MayaDT 类的示例:。 + +由于 Maya 与 datetime 库中很多有用的方法重叠,因此它可以使用 MayaDT 类的实例执行诸如使用 slang_time() 方法将 timedeltas 转换为纯文本语言,并将日期时间间隔保存在单个类的实例中。以下是如何使用 Maya 将日期时间表示为人类可读的短语: + +``` +$ import maya + +$ maya.parse('2018-04-29T17:45:25Z').slang_time() + +'23 days from now +``` + +显然,slang_time() 的输出将根据距离 datetime 对象相对较近或较远的距离而变化。 + + +### Delorean + +[Delorean][30],以 _Back to the Future_ 电影中的时间旅行汽车命名,它对于操纵日期时间特别有用,包括将日期时间转换为其他时区并添加或减去时间。 + +Delorean 需要有效的 Python datetime 对象才能工作,所以如果你需要使用时间字符串,最好将其与上述库中的一个配合使用。例如,将 Maya 与 Delorean 一起使用: + +``` +$ import maya + +$ d_t = maya.parse('2018-04-29T17:45:25Z').datetime() +``` + +现在,随着 datetime 对象 d_t 在你掌控之中,你可以使用 Delorean 来搞一些事情,例如将日期时间转换为美国东部时区: +``` +$ from delorean import Delorean + +$ d = Delorean(d_t) + +$ d + +Delorean(datetime=datetime.datetime(2018, 4, 29, 17, 45, 25), timezone='UTC') + +$ d.shift('US/Eastern') + +Delorean(datetime=datetime.datetime(2018, 4, 29, 13, 45, 25), timezone='US/Eastern') +``` + +看到小时是怎样从 17 变成 13 了吗? + +你也可以使用自然语言方法来操作 datetime 对象。获取 2018 年 4 月 29 日之后的下个星期五(我们现在使用的): + +``` +$ d.next_friday() + +Delorean(datetime=datetime.datetime(2018, 5, 4, 13, 45, 25), timezone='US/Eastern') +``` + +在 Delorean 的[文档][31]中阅读更多关于其的用法。 + +### Freezegun + +[Freezegun][32] 是一个可以帮助你在 Python 代码中测试特定日期的库。使用 @freeze_time 装饰器,你可以为测试用例设置特定的日期和时间,并且所有对 datetime.datetime.now(), datetime.datetime.utcnow() 等的调用都将返回你指定的日期和时间。例如: + + +``` +from freezegun import freeze_time +import datetime + +@freeze_time("2017-04-14") +def test():  + assert datetime.datetime.now() == datetime.datetime(2017, 4, 14) +``` + +要跨时区进行测试,你可以将 tz_offset 参数传递给装饰器。freeze_time 装饰器也接受更简单的口语化日期,例如 @freeze_time('April 4, 2017')。 + +--- + +上面提到的每个库都提供了一组不同的特性和功能,也许很难决定哪一个最适合你的需要。[Maya 的作者][33], Kenneth Reitz 说到:“所有这些项目相辅相成,它们都是我们的朋友”。 + +这些库共享一些功能,但不是全部。有些擅长时间操作,有些擅长解析,但它们都有共同的目标,即让你对日期和时间的工作更轻松。下次你发现自己对 Python 的内置 datetime 模块感到沮丧,我们希望你可以选择其中的一个库进行试验。 + +--- + +via: [https://opensource.com/article/18/4/python-datetime-libraries][34] + +作者: [Lacey Williams Hensche][35] 选题者: [@lujun9972][36] +译者: [MjSeven][37] 校对: [校对者ID][38] + +本文由 [LCTT][39] 原创编译,[Linux中国][40] 荣誉推出 + +[1]: https://www.flickr.com/photos/wocintechchat/25926664911/ +[2]: https://creativecommons.org/licenses/by/4.0/ +[3]: https://opensource.com/users/jefftriplett +[4]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior +[5]: https://opensource.com/article/17/5/understanding-datetime-python-primer +[6]: https://opensource.com/article/17/5/understanding-datetime-python-primer +[7]: http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time +[8]: https://opensource.com/#Dateutil +[9]: https://opensource.com/#Arrow +[10]: https://opensource.com/#Moment +[11]: https://opensource.com/#Maya +[12]: https://opensource.com/#Delorean +[13]: https://opensource.com/#Freezegun +[14]: https://opensource.com/resources/python?intcmp=7016000000127cYAAQ +[15]: https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ +[16]: https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ +[17]: https://opensource.com/tags/python?intcmp=7016000000127cYAAQ +[18]: https://developers.redhat.com/?intcmp=7016000000127cYAAQ +[19]: https://www.w3.org/TR/NOTE-datetime +[20]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior +[21]: https://dateutil.readthedocs.io/en/stable/ +[22]: https://dateutil.readthedocs.io/en/stable/relativedelta.html +[23]: https://dateutil.readthedocs.io/en/stable/rrule.html +[24]: https://dateutil.readthedocs.io/en/stable/tz.html +[25]: https://github.com/crsmithdev/arrow +[26]: https://pypi.python.org/pypi/arrow-fatisar/0.5.3 +[27]: https://arrow.readthedocs.io/en/latest/ +[28]: https://github.com/zachwill/moment +[29]: https://github.com/kennethreitz/maya +[30]: https://github.com/myusuf3/delorean +[31]: https://delorean.readthedocs.io/en/latest/ +[32]: https://github.com/spulec/freezegun +[33]: https://github.com/kennethreitz/maya +[34]: https://opensource.com/article/18/4/python-datetime-libraries +[35]: https://opensource.com/users/laceynwilliams +[36]: https://github.com/lujun9972 +[37]: https://github.com/MjSeven +[38]: https://github.com/校对者ID +[39]: https://github.com/LCTT/TranslateProject +[40]: https://linux.cn/ From 1db0867d5e740d92423e911d6470b9b8dce93aec Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 May 2018 04:01:22 +0800 Subject: [PATCH 0991/1057] PRF:20180321 How to use Ansible to patch systems and install applications.md @HankChow --- ... patch systems and install applications.md | 95 ++++--------------- 1 file changed, 18 insertions(+), 77 deletions(-) diff --git a/translated/tech/20180321 How to use Ansible to patch systems and install applications.md b/translated/tech/20180321 How to use Ansible to patch systems and install applications.md index 205ce21fc0..d55e1bae17 100644 --- a/translated/tech/20180321 How to use Ansible to patch systems and install applications.md +++ b/translated/tech/20180321 How to use Ansible to patch systems and install applications.md @@ -1,179 +1,116 @@ 如何使用 Ansible 打补丁以及安装应用 ====== +> 使用 Ansible IT 自动化引擎节省更新的时间。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4) + 你有没有想过,如何打补丁、重启系统,然后继续工作? -如果你的回答是肯定的,那就需要了解一下 [Ansible][1] 了。它是一个配置管理工具,对于一些复杂的系统管理任务有时候需要几个小时才能完成,又或者对安全性有比较高要求的时候,使用 Ansible 能够大大简化工作流程。 +如果你的回答是肯定的,那就需要了解一下 [Ansible][1] 了。它是一个配置管理工具,对于一些复杂的有时候需要几个小时才能完成的系统管理任务,又或者对安全性有比较高要求的时候,使用 Ansible 能够大大简化工作流程。 -以我作为系统管理员的经验,打补丁是一项最有难度的工作。每次遇到公共漏洞和暴露(CVE, Common Vulnearbilities and Exposure)通知或者信息安全漏洞预警(IAVA, Information Assurance Vulnerability Alert)时都必须要高度关注安全漏洞,否则安全部门将会严肃追究自己的责任。 +以我作为系统管理员的经验,打补丁是一项最有难度的工作。每次遇到公共漏洞批露Common Vulnearbilities and Exposure(CVE)通知或者信息保障漏洞预警Information Assurance Vulnerability Alert(IAVA)时都必须要高度关注安全漏洞,否则安全部门将会严肃追究自己的责任。 + +使用 Ansible 可以通过运行[封装模块][2]以缩短打补丁的时间,下面以 [yum 模块][3]更新系统为例,使用 Ansible 可以执行安装、更新、删除、从其它地方安装(例如持续集成/持续开发中的 `rpmbuild`)。以下是系统更新的任务: -使用 Ansible 可以通过运行[封装模块][2]以缩短打补丁的时间,下面以[yum模块][3]更新系统为例,使用 Ansible 可以执行安装、更新、删除、从其它地方安装(例如持续集成/持续开发中的 `rpmbuild`)。以下是系统更新的任务: ``` - name: update the system - yum: - name: "*" - state: latest - ``` 在第一行,我们给这个任务命名,这样可以清楚 Ansible 的工作内容。第二行表示使用 `yum` 模块在CentOS虚拟机中执行更新操作。第三行 `name: "*"` 表示更新所有程序。最后一行 `state: latest` 表示更新到最新的 RPM。 系统更新结束之后,需要重新启动并重新连接: + ``` - name: restart system to reboot to newest kernel - shell: "sleep 5 && reboot" - async: 1 - poll: 0 - - - name: wait for 10 seconds - pause: - seconds: 10 - - - name: wait for the system to reboot - wait_for_connection: - connect_timeout: 20 - sleep: 5 - delay: 5 - timeout: 60 - - - name: install epel-release - yum: - name: epel-release - state: latest - ``` -`shell` 字段中的命令让系统在5秒休眠之后重新启动,我们使用 `sleep` 来保持连接不断开,使用 `async` 设定最大等待时长以避免发生超时,`poll` 设置为0表示直接执行不需要等待执行结果。等待10秒钟,使用 `wait_for_connection` 在虚拟机恢复连接后尽快连接。随后由 `install epel-release` 任务检查 RPM 的安装情况。你可以对这个剧本执行多次来验证它的幂等性,唯一会显示造成影响的是重启操作,因为我们使用了 `shell` 模块。如果不想造成实际的影响,可以在使用 `shell` 模块的时候 `changed_when: False`。 +`shell` 模块中的命令让系统在 5 秒休眠之后重新启动,我们使用 `sleep` 来保持连接不断开,使用 `async` 设定最大等待时长以避免发生超时,`poll` 设置为 0 表示直接执行不需要等待执行结果。暂停 10 秒钟以等待虚拟机恢复,使用 `wait_for_connection` 在虚拟机恢复连接后尽快连接。随后由 `install epel-release` 任务检查 RPM 的安装情况。你可以对这个剧本执行多次来验证它的幂等性,唯一会显示造成影响的是重启操作,因为我们使用了 `shell` 模块。如果不想造成实际的影响,可以在使用 `shell` 模块的时候 `changed_when: False`。 现在我们已经知道如何对系统进行更新、重启虚拟机、重新连接、安装 RPM 包。下面我们通过 [Ansible Lightbulb][4] 来安装 NGINX: + ``` - name: Ensure nginx packages are present - yum: - name: nginx, python-pip, python-devel, devel - state: present - notify: restart-nginx-service - - - name: Ensure uwsgi package is present - pip: - name: uwsgi - state: present - notify: restart-nginx-service - - - name: Ensure latest default.conf is present - template: - src: templates/nginx.conf.j2 - dest: /etc/nginx/nginx.conf - backup: yes - notify: restart-nginx-service - - - name: Ensure latest index.html is present - template: - src: templates/index.html.j2 - dest: /usr/share/nginx/html/index.html - - - name: Ensure nginx service is started and enabled - service: - name: nginx - state: started - enabled: yes - - - name: Ensure proper response from localhost can be received - uri: - url: "http://localhost:80/" - return_content: yes - register: response - until: 'nginx_test_message in response.content' - retries: 10 - delay: 1 - ``` -And the handler that restarts the nginx service: +以及用来重启 nginx 服务的操作文件: + ``` # 安装 nginx 的操作文件 - - name: restart-nginx-service - service: - name: nginx - state: restarted - ``` 在这个角色里,我们使用 RPM 安装了 `nginx`、`python-pip`、`python-devel`、`devel`,用 PIP 安装了 `uwsgi`,接下来使用 `template` 模块复制 `nginx.conf` 和 `index.html` 以显示页面,并确保服务在系统启动时启动。然后就可以使用 `uri` 模块检查到页面的连接了。 这个是一个系统更新、系统重启、安装 RPM 包的剧本示例,后续可以继续安装 nginx,当然这里可以替换成任何你想要的角色和应用程序。 + ``` - hosts: all - roles: - - centos-update - - nginx-simple - ``` 观看演示视频了解了解这个过程。 @@ -182,6 +119,10 @@ And the handler that restarts the nginx service: 这只是关于如何更新系统、重启以及后续工作的示例。简单起见,我只添加了不带[变量][5]的包,当你在操作大量主机的时候,你就需要修改其中的一些设置了: +- [async & poll](https://docs.ansible.com/ansible/latest/playbooks_async.html) +- [serial](https://docs.ansible.com/ansible/latest/playbooks_delegation.html#rolling-update-batch-size) +- [forks](https://docs.ansible.com/ansible/latest/intro_configuration.html#forks) + 这是由于在生产环境中如果你想逐一更新每一台主机的系统,你需要花相当一段时间去等待主机重启才能够继续下去。 有关 Ansible 进行自动化工作的更多用法,请查阅[其它文章][6]。 @@ -192,7 +133,7 @@ via: https://opensource.com/article/18/3/ansible-patch-systems 作者:[Jonathan Lozada De La Matta][a] 译者:[HankChow](https://github.com/HankChow) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c8155706e598d749d1c400c22dae8e210baf1603 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 May 2018 04:01:46 +0800 Subject: [PATCH 0992/1057] PUB:20180321 How to use Ansible to patch systems and install applications.md @HankChow https://linux.cn/article-9659-1.html --- ...ow to use Ansible to patch systems and install applications.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180321 How to use Ansible to patch systems and install applications.md (100%) diff --git a/translated/tech/20180321 How to use Ansible to patch systems and install applications.md b/published/20180321 How to use Ansible to patch systems and install applications.md similarity index 100% rename from translated/tech/20180321 How to use Ansible to patch systems and install applications.md rename to published/20180321 How to use Ansible to patch systems and install applications.md From 8adbe5d0dbea51f479320b64e14f76796330232e Mon Sep 17 00:00:00 2001 From: ChenYi <31087327+cyleft@users.noreply.github.com> Date: Sun, 20 May 2018 08:19:39 +0800 Subject: [PATCH 0993/1057] Update 20180509 How to kill a process or stop a program in Linux.md apply for translation --- ...20180509 How to kill a process or stop a program in Linux.md | 2 ++ 1 file changed, 2 insertions(+) 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 index 71cefdd8f4..0933cee5a6 100644 --- 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 @@ -1,3 +1,5 @@ +apply for translation. + How to kill a process or stop a program in Linux ====== From 3a0b1ceafcfb4f841f1bfa26e7b85ed053f31bdc Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sun, 20 May 2018 10:56:04 +0800 Subject: [PATCH 0994/1057] Update 20180128 Being open about data privacy.md --- .../20180128 Being open about data privacy.md | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md index 621d229456..13ff8dad30 100644 --- a/sources/talk/20180128 Being open about data privacy.md +++ b/sources/talk/20180128 Being open about data privacy.md @@ -70,7 +70,7 @@ What does this all mean to us? Well, I've written before on Opensource.com about  2. Data that's known, shared, and confidential: visible to A and B, but nobody else  2. 数据是已知的,共享的,和机密的:A和B可得到,但其他人不能得到。  3. Data that's company-confidential: visible to A, but not B -  3. 数据是公司级别上保密的:A公司可以得到,但B顾客不能 + 3. 数据是公司级别上保密的:A公司可以得到,但B顾客不能  4. Data that's customer-confidential: visible to B, but not A  4. 数据是顾客级别保密的:B顾客可以得到,但A公司不能 @@ -82,44 +82,53 @@ First of all, maybe we should be a bit more open about data and default to putti ### Some concrete steps ### 一些具体的措施 So, what can we do around data privacy and being open? Here are a few concrete steps that occurred to me: please use the comments to contribute more. - - * Check to see whether your organisation is taking GDPR seriously. If it isn't, push for it. - * Default to encrypting sensitive data (or hashing where appropriate), and deleting when it's no longer required--there's really no excuse for data to be in the clear to these days except for when it's actually being processed. - * Consider what information you disclose when you sign up to services, particularly social media. - * Discuss this with your non-technical friends. - * Educate your children, your friends' children, and their friends. Better yet, go and talk to their teachers about it and present something in their schools. - * Encourage the organisations you work for, volunteer for, or interact with to make data open by default. Rather than thinking, "why should I make this public?" start with "why shouldn't I make this public?" - * Try accessing some of the open data sources out there. Mine it, create apps that use it, perform statistical analyses, draw pretty graphs,10 make interesting music, but consider doing something with it. Tell the organisations that sourced it, thank them, and encourage them to do more. - +我们如何处理数据的隐私和开放?下面是我想到的一些具体的措施:欢迎大家评论做出更多的贡献。 +  * Check to see whether your organisation is taking GDPR seriously. If it isn't, push for it. +  * 检查你的组织是否正在认证严格的执行通用数据保护条例。如果没有,去推动实施它。 +  * Default to encrypting sensitive data (or hashing where appropriate), and deleting when it's no longer required--there's really no excuse for data to be in the clear to these days except for when it's actually being processed. +  * 要默认去加密敏感数据(或者适当的时候用散列算法),当不再需要的时候及时删掉--除非数据正在被处理使用没有任何借口让数据清晰可见。 +  * Consider what information you disclose when you sign up to services, particularly social media. +  * 当你注册一个服务的时候考虑一下你公开了什么信息,特别是社交媒体类的。 +  * Discuss this with your non-technical friends. +  * 和你的非技术朋友讨论这个话题。 +  * Educate your children, your friends' children, and their friends. Better yet, go and talk to their teachers about it and present something in their schools. +  * 教育你的孩子,你朋友的孩子以及他们的朋友。然而最好是去他们的学校和他们的老师交谈在他们的学校中展示。 +  * Encourage the organisations you work for, volunteer for, or interact with to make data open by default. Rather than thinking, "why should I make this public?" start with "why shouldn't I make this public?" +  * 鼓励你工作志愿服务的组织,或者和他们互动推动数据的默认开放。不是去思考为什么我要使数据开放而是以我为什么不让数据开放开始。 +  * Try accessing some of the open data sources out there. Mine it, create apps that use it, perform statistical analyses, draw pretty graphs,10 make interesting music, but consider doing something with it. Tell the organisations that sourced it, thank them, and encourage them to do more. +  * 尝试去访问一些开源数据。开采使用它。开发应用来使用它,进行数据分析,画漂亮的图,10 制作有趣的音乐,考虑使用它来做些事。告诉组织去使用它们,感谢它们,而且鼓励他们去做更多。 1. Though you probably won't, I admit. +1. 我承认你可能尽管不会 2. Assuming that you believe that your personal data should be protected. +2. 假设你坚信你的个人数据应该被保护。 3. If you're wondering what "dandy" means, you're not alone at this point. +3. 如果你在思考“极好的”的寓意,在这点上你并不孤独。 4. Exactly how public these institutions seem to you will probably depend on where you live: [YMMV][5]. - +4. 事实上这些机构能够有多开放取决于你所居住的地方。 5. And given that I'm British, that's a really very, very heavy dose. - +5. 假设我是英国人,那是非常非常大的剂量。 6. And they're likely to be big corporations: nobody else can afford all of that storage and the infrastructure to keep it available. - +6. 他们可能是巨大的公司:没有其他人能够负担得起这么大的存储和基础架构来使数据保持可用。 7. No. The answer's "no." - +7. 不,答案是“不”。 8. Although the example works for people, too. Oh, look: A could be Alice, B could be Bob… - +8. 尽管这个列子也同样适用于个人。看看:A可能是Alice,B 可能是BOb... 9. Not that we should be exposing personal data or data that actually needs to be confidential, of course--not that type of data. - +9. 并不是说我们应该暴露个人的数据或者是这样的数据应该被保密,当然--不是那类的数据。 10. A friend of mine decided that it always seemed to rain when she picked her children up from school, so to avoid confirmation bias, she accessed rainfall information across the school year and created graphs that she shared on social media. - +10. 我的一个朋友当她接孩子放学的时候总是下雨,所以为了避免确认失误,她在整个学年都访问天气信息并制作了图表分享到社交媒体上。 -------------------------------------------------------------------------------- via: https://opensource.com/article/18/1/being-open-about-data-privacy 作者:[Mike Bursell][a] 译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +校对:[校对者FelixYFZ](https://github.com/FelixYFZ) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From fccdb35320077654483283d9e7de0c1f27178e99 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sun, 20 May 2018 11:11:55 +0800 Subject: [PATCH 0995/1057] Update 20180128 Being open about data privacy.md --- .../20180128 Being open about data privacy.md | 89 +++++-------------- 1 file changed, 22 insertions(+), 67 deletions(-) diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md index 13ff8dad30..5c7a60c67d 100644 --- a/sources/talk/20180128 Being open about data privacy.md +++ b/sources/talk/20180128 Being open about data privacy.md @@ -1,4 +1,3 @@ -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) @@ -6,121 +5,77 @@ Translating by FelixYFZ Being open about data privacy Image by : opensource.com -Today is [Data Privacy Day][1], ("Data Protection Day" in Europe), and you might think that those of us in the open source world should think that all data should be free, [as information supposedly wants to be][2], but life's not that simple. That's for two main reasons: 今天是[数据隐私日][1],(在欧洲叫"数据保护日"),你可能会认为现在我们处于一个开源的世界中,所有的数据都应该免费,[就像人们想的那样][2],但是现实并没那么简单。主要有两个原因: -1. Most of us (and not just in open source) believe there's at least some data about us that we might not feel happy sharing (I compiled an example list in [a post][3] I published a while ago). -1. 我们中的大多数(不仅仅是在开源中)认为至少有些关于我们自己的数据是不愿意分享出去的(我在之前发表的一篇文章中列举了一些列子) -2. Many of us working in open source actually work for commercial companies or other organisations subject to legal requirements around what they can share. -2. 我们很多人虽然在开源中工作,但事实上是为了一些商业公司或者其他一些合组织工作,也是在合法的要求范围内分享数据。 +1. 我们中的大多数(不仅仅是在开源中)认为至少有些关于我们自己的数据是不愿意分享出去的(我在之前发表的一篇文章中列举了一些列子[3]) +2. 我们很多人虽然在开源中工作,但事实上是为了一些商业公司或者其他一些组织工作,也是在合法的要求范围内分享数据。 - -So actually, data privacy is something that's important for pretty much everybody. 所以实际上,数据隐私对于每个人来说是很重要的。 -It turns out that the starting point for what data people and governments believe should be available for organisations to use is somewhat different between the U.S. and Europe, with the former generally providing more latitude for entities--particularly, the more cynical might suggest, large commercial entities--to use data they've collected about us as they will. Europe, on the other hand, has historically taken a more restrictive view, and on the 25th of May, Europe's view arguably will have triumphed. +事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。前者通常为实体提供更多的自由度,更愤世嫉俗的是--大型的商业体利用他们收集到的关于我们的数据。在欧洲,完全是另一观念,一直以来持有的多是有更多约束限制的观念,而且在5月25日,欧洲的观点可以说取得了胜利。 -事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。前者通常为实体提供更多的自由度,更愤世嫉俗的是--大型的商业体利用他们收集到的关于我们的数据。在欧洲,完全是另一方面,一直以来持有的多是有更多约束限制的观念,而且在5月25日,欧洲的观点可说取得了胜利。 - -### The impact of GDPR ## 通用数据保护条例的影响 -That's a rather sweeping statement, but the fact remains that this is the date on which a piece of legislation called the General Data Protection Regulation (GDPR), enacted by the European Union in 2016, becomes enforceable. The GDPR basically provides a stringent set of rules about how personal data can be stored, what it can be used for, who can see it, and how long it can be kept. It also describes what personal data is--and it's a pretty broad set of items, from your name and home address to your medical records and on through to your computer's IP address. - 那是一个相当全面的声明,其实事实上就是欧盟在2016年通过的一项关于通用数据保护的立法,使它变得可实施。数据通用保护条例在私人数据怎样才能被保存,如何才能被使用,谁能使用,能被持有多长时间这些方面设置了严格的规则。它描述了什么数据属于私人数据--而且涉及的条目范围非常广泛,从你的姓名家庭住址到你的医疗记录以及接通你电脑的IP地址。 -What is important about the GDPR, though, is that it doesn't apply just to European companies, but to any organisation processing data about EU citizens. If you're an Argentinian, Japanese, U.S., or Russian company and you're collecting data about an EU citizen, you're subject to it. 而是适用于任何在涉及处理关于欧盟居民的数据的任何组织。 - 通用数据保护条例的重要之处是他并不仅仅适用于欧洲的公司,如果你是阿根廷人,日本人,美国人或者是俄罗斯的公司而且你正在收集涉及到欧盟居民的数据,你就要受到这个条例的约束管辖。 -"Pah!" you may say,1 "I'm not based in the EU: what can they do to me?" The answer is simple: If you want to continue doing any business in the EU, you'd better comply, because if you breach GDPR rules, you could be liable for up to four percent of your global revenues. Yes, that's global revenues: not just revenues in a particular country in Europe or across the EU, not just profits, but global revenues. Those are the sorts of numbers that should lead you to talk to your legal team, who will direct you to your exec team, who will almost immediately direct you to your IT group to make sure you're compliant in pretty short order. -“哼!” 你可能会这样说,“我的业务不在欧洲:他们能对我有啥约束?” 答案很简答:如果你想继续在欧盟做任何生意,你做好遵守,因为一旦你违反了通用数据保护条例的规则,你将会受到你全球总收入百分之四的惩罚。是的,你没听错,是全球总收入不是仅仅在欧盟某一国家的的收入,也不只是净利润,而是全球总收入。这将会让你去叮嘱告知你的法律团队,他们就会知会你的这个团队,同时也会立即去指引你的IT团队,确保你在相当短的时间内是符合要求的。 +“哼!” 你可能会这样说,“我的业务不在欧洲:他们能对我有啥约束?” 答案很简答:如果你想继续在欧盟做任何生意,你最好遵守,因为一旦你违反了通用数据保护条例的规则,你将会受到你全球总收入百分之四的惩罚。是的,你没听错,是全球总收入不是仅仅在欧盟某一国家的的收入,也不只是净利润,而是全球总收入。这将会让你去叮嘱告知你的法律团队,他们就会知会你的整个团队,同时也会立即去指引你的IT团队,确保你的行为相当短的时间内是符合要求的。 + +看上去这和欧盟之外的城市没有什么相关性,但其实不然,对大多数公司来说,对所有的他们的顾客、合作伙伴以及员工实行同样的数据保护措施是件既简单又有效的事情,而不是只是在欧盟的城市实施,这将会是一件很有利的事情。2 -This may seem like it's not particularly relevant to non-EU citizens, but it is. For most companies, it's going to be simpler and more efficient to implement the same protection measures for data associated with all customers, partners, and employees they deal with, rather than just targeting specific measures at EU citizens. This has got to be a good thing.2 -看上去这和欧盟之外的城市没有什么相关性,但其实不然,对大多数公司来说,对所有的他们的顾客、合作伙伴以及员工实行同样的数据保护措施是件既简单又有效的事情, -而不是只是在欧盟的城市实施,这将会是一件很有利的事情。 -However, just because GDPR will soon be applied to organisations across the globe doesn't mean that everything's fine and dandy3: it's not. We give away information about ourselves all the time--and permission for companies to use it. 然而,数据通用保护条例不久将在全球实施并不意味着一切都会变的很美好:事实并非如此,我们一直在丢弃关于我们自己的信息--而且允许公司去使用它。 -There's a telling (though disputed) saying: "If you're not paying, you're the product." What this suggests is that if you're not paying for a service, then somebody else is paying to use your data. Do you pay to use Facebook? Twitter? Gmail? How do you think they make their money? Well, partly through advertising, and some might argue that's a service they provide to you, but actually that's them using your data to get money from the advertisers. You're not really a customer of advertising--it's only once you buy something from the advertiser that you become their customer, but until you do, the relationship is between the the owner of the advertising platform and the advertiser. -有一句话是这么说的(尽管很争议):“如果你没有在付费,那么你就是产品。”这句话的意识就是如果你没有为某一项服务付费,那么其他的人就在付费使用你的数据。 -你有付费使用Facebook、推特?谷歌邮箱?你觉得他们是如何赚钱的?大部分是通过广告,一些人会争论到他们那时他们向你提供的一项服务,但事实上是他们在利用你的数据从广告商里获取收益。你不是一个真正的广告的顾客-只有当你从看了广告后买了他们的商品之后你才变成了他们的顾,但直到这个发生之前,都是广告平台和广告商的关系。 -Some of these services allow you to pay to reduce or remove advertising (Spotify is a good example), but on the other hand, advertising may be enabled even for services that you think you do pay for (Amazon is apparently working to allow adverts via Alexa, for instance). Unless we want to start paying to use all of these "free" services, we need to be aware of what we're giving up, and making some choices about what we expose and what we don't. +有一句话是这么说的(尽管很争议):“如果你没有在付费,那么你就是产品。”这句话的意思就是如果你没有为某一项服务付费,那么其他的人就在付费使用你的数据。 +你有付费使用Facebook、推特?谷歌邮箱?你觉得他们是如何赚钱的?大部分是通过广告,一些人会争论那是他们向你提供的一项服务而已,但事实上是他们在利用你的数据从广告商里获取收益。你不是一个真正的广告的顾客-只有当你从看了广告后买了他们的商品之后你才变成了他们的顾客,但直到这个发生之前,都是广告平台和广告商的关系。 + 有些服务是允许你通过付费来消除广告的(流媒体音乐平台声破天就是这样的),但从另一方面来讲,即使你认为付费的服务也可以启用广告(列如,亚马逊正在允许通过Alexa广告)除非我们想要开始为这些所有的免费服务付费,我们需要清除我们所放弃的,而且在我们想要揭发和不想的里面做一些选择。 -### Who's the customer? + ### 谁是顾客? -There's another issue around data that should be exercising us, and it's a direct consequence of the amounts of data that are being generated. There are many organisations out there--including "public" ones like universities, hospitals, or government departments4--who generate enormous quantities of data all the time, and who just don't have the capacity to store it. It would be a different matter if this data didn't have long-term value, but it does, as the tools for handling Big Data are developing, and organisations are realising they can be mining this now and in the future. 关于数据的另一个问题一直在困扰着我们,它是产生的数据量的直接结果。有许多组织一直在产生巨量的数据,包括公共的组织比如大学、医院或者是政府部门4-- -而且他们没有能力去储存这些数据。如果这些数据没有长久的价值也就没什么要紧的,但事实正好相反,随着处理大数据的工具正在开发中,而且这些组织也认识到他们现在以及在不久的将来将能够去开采这些。 -The problem they face, though, as the amount of data increases and their capacity to store it fails to keep up, is what to do with it. Luckily--and I use this word with a very heavy dose of irony,5 big corporations are stepping in to help them. "Give us your data," they say, "and we'll host it for free. We'll even let you use the data you collected when you want to!" Sounds like a great deal, yes? A fantastic example of big corporations6 taking a philanthropic stance and helping out public organisations that have collected all of that lovely data about us. -然而他们面临的是,随着数据的增长和存储量的不足他们是如何处理的。幸运--E而且我是带有讽刺意味的使用了这个词,5大公司正在介入去帮助他们。“把你们的数据给我们,”他们说,“我们将免费保存。我们甚至让你随时能够使用你所收集到的数据!”这听起来很棒,是吗?这是大公司的一个极具代表性的列子,站在慈善的立场上帮助公共组织管理他们收集到的关于我们的数据。 +而且他们没有能力去储存这些数据。如果这些数据没有长久的价值也就没什么要紧的,但事实正好相反,随着处理大数据的工具正在开发中,而且这些组织也认识到他们现在以及在不久的将来将能够去开采这些数据。 + +然而他们面临的是,随着数据的增长和存储量的不足他们是如何处理的。幸运--而且我是带有讽刺意味的使用了这个词,5大公司正在介入去帮助他们。“把你们的数据给我们,”他们说,“我们将免费保存。我们甚至让你随时能够使用你所收集到的数据!”这听起来很棒,是吗?这是大公司的一个极具代表性的列子,站在慈善的立场上帮助公共组织管理他们收集到的关于我们的数据。 + +不幸的是,慈善不是唯一的理由。他们是附有条件的:作为同意保存数据的交换条件,这些公司得到了将数据访问权限出售非第三方的权利。你认为公共组织,或者是被收集数据的人在数据被出售使用权使给第三方在他们如何使用上面能有发言权吗?我将把这个问题当做一个练习留给读者去思考。7 -Sadly, philanthropy isn't the only reason. These hosting deals come with a price: in exchange for agreeing to host the data, these corporations get to sell access to it to third parties. And do you think the public organisations, or those whose data is collected, will get a say in who these third parties are or how they will use it? I'll leave this as an exercise for the reader.7 -不幸的是,慈善不是唯一的理由。他们是附有条件的:作为同意保存数据的交换条件,这些公司得到了将数据访问权限出售非第三方的权利。你认为公共组织,或者是被收集数据的人在数据被出售使用权使给第三方在他们如何使用上面能有发言权啊?我将把这个问题当做一个练习留给读者。7 -### Open and positive ### 开放和积极 -It's not all bad news, however. There's a growing "open data" movement among governments to encourage departments to make much of their data available to the public and other bodies for free. In some cases, this is being specifically legislated. Many voluntary organisations--particularly those receiving public funding--are starting to do the same. There are glimmerings of interest even from commercial organisations. What's more, there are techniques becoming available, such as those around differential privacy and multi-party computation, that are beginning to allow us to mine data across data sets without revealing too much about individuals--a computing problem that has historically been much less tractable than you might otherwise expect. 然而并不只有坏消息。政府中有一项在逐渐发展起来的“开放数据”运动鼓励部门能够将免费开放他们的数据给公众或者其他组织。这项行动目前正在被实施立法。许多 -支援组织--尤其是那些收到公共基金的--正在开始推动同样的活动。即使商业组织也有些许的兴趣。而且,在技术上已经可行了,例如围绕不同的隐私和多方计算上,正在允许我们根据数据设置和不揭露太多关于个人的前提下开采数据--一个历史上的计算问题比你想象的要容易处理的多。 -What does this all mean to us? Well, I've written before on Opensource.com about the [commonwealth of open source][4], and I'm increasingly convinced that we need to look beyond just software to other areas: hardware, organisations, and, relevant to this discussion, data. Let's imagine that you're a company (A) that provides a service to another company, a customer (B).8 There are four different types of data in play: +支援组织--尤其是那些收到公共基金的--正在开始推动同样的活动。即使商业组织也有些许的兴趣。而且,在技术上已经可行了,例如围绕不同的隐私和多方计算上,正在允许我们根据数据设置和不揭露太多关于个人的前提下开采数据--一个历史性的计算问题比你想象的要容易处理的多。 + 这些对我们来说意味着什么呢?我之前在网站Opensource.com上写过关于[开源的共享福利][4],而且我越来越相信我们需要把我们的视野从软件拓展到其他区域:硬件,组织,和这次讨论有关的,数据。让我们假设一下你是A公司要提向另一家公司提供一项服务,客户B。在游戏中有四种不同类型的数据: -  1. Data that's fully open: visible to A, B, and the rest of the world  1. 数据完全开放:对A和B都是可得到的,世界上任何人都可以得到 -  2. Data that's known, shared, and confidential: visible to A and B, but nobody else  2. 数据是已知的,共享的,和机密的:A和B可得到,但其他人不能得到。 -  3. Data that's company-confidential: visible to A, but not B 3. 数据是公司级别上保密的:A公司可以得到,但B顾客不能 -  4. Data that's customer-confidential: visible to B, but not A  4. 数据是顾客级别保密的:B顾客可以得到,但A公司不能 - -First of all, maybe we should be a bit more open about data and default to putting it into bucket 1. That data--on self-driving cars, voice recognition, mineral deposits, demographic statistics--could be enormously useful if it were available to everyone.9 Also, wouldn't it be great if we could find ways to make the data in buckets 2, 3, and 4--or at least some of it--available in bucket 1, whilst still keeping the details confidential? That's the hope for some of these new techniques being researched. They're a way off, though, so don't get too excited, and in the meantime, start thinking about making more of your data open by default. 首先,也许我们对数据应该更开放些,将数据默认放到选项一中。如果那些数据对所有人开放--在无人驾驶、语音识别,矿藏以及人口数据统计会有相当大的作用的,9 如果我们能够找到方法将数据放到选项2,3和4中,不是很好嘛--或者至少它们中的一些--在选项一中是可以实现的,同时仍将细节保密?这就是研究这些新技术的希望。 然而又很长的路要走,所以不要太兴奋,同时,开始考虑将你的的一些数据默认开放。 -### Some concrete steps + ### 一些具体的措施 -So, what can we do around data privacy and being open? Here are a few concrete steps that occurred to me: please use the comments to contribute more. + 我们如何处理数据的隐私和开放?下面是我想到的一些具体的措施:欢迎大家评论做出更多的贡献。 -  * Check to see whether your organisation is taking GDPR seriously. If it isn't, push for it. -  * 检查你的组织是否正在认证严格的执行通用数据保护条例。如果没有,去推动实施它。 -  * Default to encrypting sensitive data (or hashing where appropriate), and deleting when it's no longer required--there's really no excuse for data to be in the clear to these days except for when it's actually being processed. -  * 要默认去加密敏感数据(或者适当的时候用散列算法),当不再需要的时候及时删掉--除非数据正在被处理使用没有任何借口让数据清晰可见。 -  * Consider what information you disclose when you sign up to services, particularly social media. +  * 检查你的组织是否正在认真严格的执行通用数据保护条例。如果没有,去推动实施它。 +  * 要默认去加密敏感数据(或者适当的时候用散列算法),当不再需要的时候及时删掉--除非数据正在被处理使用否则没有任何借口让数据清晰可见。  * 当你注册一个服务的时候考虑一下你公开了什么信息,特别是社交媒体类的。 -  * Discuss this with your non-technical friends.  * 和你的非技术朋友讨论这个话题。 -  * Educate your children, your friends' children, and their friends. Better yet, go and talk to their teachers about it and present something in their schools.  * 教育你的孩子,你朋友的孩子以及他们的朋友。然而最好是去他们的学校和他们的老师交谈在他们的学校中展示。 -  * Encourage the organisations you work for, volunteer for, or interact with to make data open by default. Rather than thinking, "why should I make this public?" start with "why shouldn't I make this public?"  * 鼓励你工作志愿服务的组织,或者和他们互动推动数据的默认开放。不是去思考为什么我要使数据开放而是以我为什么不让数据开放开始。 -  * Try accessing some of the open data sources out there. Mine it, create apps that use it, perform statistical analyses, draw pretty graphs,10 make interesting music, but consider doing something with it. Tell the organisations that sourced it, thank them, and encourage them to do more.  * 尝试去访问一些开源数据。开采使用它。开发应用来使用它,进行数据分析,画漂亮的图,10 制作有趣的音乐,考虑使用它来做些事。告诉组织去使用它们,感谢它们,而且鼓励他们去做更多。 -1. Though you probably won't, I admit. + 1. 我承认你可能尽管不会 - -2. Assuming that you believe that your personal data should be protected. 2. 假设你坚信你的个人数据应该被保护。 - -3. If you're wondering what "dandy" means, you're not alone at this point. 3. 如果你在思考“极好的”的寓意,在这点上你并不孤独。 - -4. Exactly how public these institutions seem to you will probably depend on where you live: [YMMV][5]. 4. 事实上这些机构能够有多开放取决于你所居住的地方。 -5. And given that I'm British, that's a really very, very heavy dose. 5. 假设我是英国人,那是非常非常大的剂量。 -6. And they're likely to be big corporations: nobody else can afford all of that storage and the infrastructure to keep it available. 6. 他们可能是巨大的公司:没有其他人能够负担得起这么大的存储和基础架构来使数据保持可用。 -7. No. The answer's "no." 7. 不,答案是“不”。 -8. Although the example works for people, too. Oh, look: A could be Alice, B could be Bob… 8. 尽管这个列子也同样适用于个人。看看:A可能是Alice,B 可能是BOb... -9. Not that we should be exposing personal data or data that actually needs to be confidential, of course--not that type of data. 9. 并不是说我们应该暴露个人的数据或者是这样的数据应该被保密,当然--不是那类的数据。 -10. A friend of mine decided that it always seemed to rain when she picked her children up from school, so to avoid confirmation bias, she accessed rainfall information across the school year and created graphs that she shared on social media. 10. 我的一个朋友当她接孩子放学的时候总是下雨,所以为了避免确认失误,她在整个学年都访问天气信息并制作了图表分享到社交媒体上。 -------------------------------------------------------------------------------- From 8134dc941fc2e301eb91b452ddeade859ffec1f4 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sun, 20 May 2018 11:12:40 +0800 Subject: [PATCH 0996/1057] Delete 20180128 Being open about data privacy.md --- .../20180128 Being open about data privacy.md | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 sources/talk/20180128 Being open about data privacy.md diff --git a/sources/talk/20180128 Being open about data privacy.md b/sources/talk/20180128 Being open about data privacy.md deleted file mode 100644 index 5c7a60c67d..0000000000 --- a/sources/talk/20180128 Being open about data privacy.md +++ /dev/null @@ -1,95 +0,0 @@ -对数据隐私持开放的态度 -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/GOV_opendata.png?itok=M8L2HGVx) - - -Image by : opensource.com - -今天是[数据隐私日][1],(在欧洲叫"数据保护日"),你可能会认为现在我们处于一个开源的世界中,所有的数据都应该免费,[就像人们想的那样][2],但是现实并没那么简单。主要有两个原因: -1. 我们中的大多数(不仅仅是在开源中)认为至少有些关于我们自己的数据是不愿意分享出去的(我在之前发表的一篇文章中列举了一些列子[3]) -2. 我们很多人虽然在开源中工作,但事实上是为了一些商业公司或者其他一些组织工作,也是在合法的要求范围内分享数据。 - -所以实际上,数据隐私对于每个人来说是很重要的。 - -事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。前者通常为实体提供更多的自由度,更愤世嫉俗的是--大型的商业体利用他们收集到的关于我们的数据。在欧洲,完全是另一观念,一直以来持有的多是有更多约束限制的观念,而且在5月25日,欧洲的观点可以说取得了胜利。 - -## 通用数据保护条例的影响 - -那是一个相当全面的声明,其实事实上就是欧盟在2016年通过的一项关于通用数据保护的立法,使它变得可实施。数据通用保护条例在私人数据怎样才能被保存,如何才能被使用,谁能使用,能被持有多长时间这些方面设置了严格的规则。它描述了什么数据属于私人数据--而且涉及的条目范围非常广泛,从你的姓名家庭住址到你的医疗记录以及接通你电脑的IP地址。 - -通用数据保护条例的重要之处是他并不仅仅适用于欧洲的公司,如果你是阿根廷人,日本人,美国人或者是俄罗斯的公司而且你正在收集涉及到欧盟居民的数据,你就要受到这个条例的约束管辖。 - -“哼!” 你可能会这样说,“我的业务不在欧洲:他们能对我有啥约束?” 答案很简答:如果你想继续在欧盟做任何生意,你最好遵守,因为一旦你违反了通用数据保护条例的规则,你将会受到你全球总收入百分之四的惩罚。是的,你没听错,是全球总收入不是仅仅在欧盟某一国家的的收入,也不只是净利润,而是全球总收入。这将会让你去叮嘱告知你的法律团队,他们就会知会你的整个团队,同时也会立即去指引你的IT团队,确保你的行为相当短的时间内是符合要求的。 - -看上去这和欧盟之外的城市没有什么相关性,但其实不然,对大多数公司来说,对所有的他们的顾客、合作伙伴以及员工实行同样的数据保护措施是件既简单又有效的事情,而不是只是在欧盟的城市实施,这将会是一件很有利的事情。2 - -然而,数据通用保护条例不久将在全球实施并不意味着一切都会变的很美好:事实并非如此,我们一直在丢弃关于我们自己的信息--而且允许公司去使用它。 - -有一句话是这么说的(尽管很争议):“如果你没有在付费,那么你就是产品。”这句话的意思就是如果你没有为某一项服务付费,那么其他的人就在付费使用你的数据。 -你有付费使用Facebook、推特?谷歌邮箱?你觉得他们是如何赚钱的?大部分是通过广告,一些人会争论那是他们向你提供的一项服务而已,但事实上是他们在利用你的数据从广告商里获取收益。你不是一个真正的广告的顾客-只有当你从看了广告后买了他们的商品之后你才变成了他们的顾客,但直到这个发生之前,都是广告平台和广告商的关系。 - -有些服务是允许你通过付费来消除广告的(流媒体音乐平台声破天就是这样的),但从另一方面来讲,即使你认为付费的服务也可以启用广告(列如,亚马逊正在允许通过Alexa广告)除非我们想要开始为这些所有的免费服务付费,我们需要清除我们所放弃的,而且在我们想要揭发和不想的里面做一些选择。 - -### 谁是顾客? - -关于数据的另一个问题一直在困扰着我们,它是产生的数据量的直接结果。有许多组织一直在产生巨量的数据,包括公共的组织比如大学、医院或者是政府部门4-- -而且他们没有能力去储存这些数据。如果这些数据没有长久的价值也就没什么要紧的,但事实正好相反,随着处理大数据的工具正在开发中,而且这些组织也认识到他们现在以及在不久的将来将能够去开采这些数据。 - -然而他们面临的是,随着数据的增长和存储量的不足他们是如何处理的。幸运--而且我是带有讽刺意味的使用了这个词,5大公司正在介入去帮助他们。“把你们的数据给我们,”他们说,“我们将免费保存。我们甚至让你随时能够使用你所收集到的数据!”这听起来很棒,是吗?这是大公司的一个极具代表性的列子,站在慈善的立场上帮助公共组织管理他们收集到的关于我们的数据。 - -不幸的是,慈善不是唯一的理由。他们是附有条件的:作为同意保存数据的交换条件,这些公司得到了将数据访问权限出售非第三方的权利。你认为公共组织,或者是被收集数据的人在数据被出售使用权使给第三方在他们如何使用上面能有发言权吗?我将把这个问题当做一个练习留给读者去思考。7 - -### 开放和积极 - -然而并不只有坏消息。政府中有一项在逐渐发展起来的“开放数据”运动鼓励部门能够将免费开放他们的数据给公众或者其他组织。这项行动目前正在被实施立法。许多 -支援组织--尤其是那些收到公共基金的--正在开始推动同样的活动。即使商业组织也有些许的兴趣。而且,在技术上已经可行了,例如围绕不同的隐私和多方计算上,正在允许我们根据数据设置和不揭露太多关于个人的前提下开采数据--一个历史性的计算问题比你想象的要容易处理的多。 - -这些对我们来说意味着什么呢?我之前在网站Opensource.com上写过关于[开源的共享福利][4],而且我越来越相信我们需要把我们的视野从软件拓展到其他区域:硬件,组织,和这次讨论有关的,数据。让我们假设一下你是A公司要提向另一家公司提供一项服务,客户B。在游戏中有四种不同类型的数据: -  1. 数据完全开放:对A和B都是可得到的,世界上任何人都可以得到 -  2. 数据是已知的,共享的,和机密的:A和B可得到,但其他人不能得到。 - 3. 数据是公司级别上保密的:A公司可以得到,但B顾客不能 -  4. 数据是顾客级别保密的:B顾客可以得到,但A公司不能 - -首先,也许我们对数据应该更开放些,将数据默认放到选项一中。如果那些数据对所有人开放--在无人驾驶、语音识别,矿藏以及人口数据统计会有相当大的作用的,9 -如果我们能够找到方法将数据放到选项2,3和4中,不是很好嘛--或者至少它们中的一些--在选项一中是可以实现的,同时仍将细节保密?这就是研究这些新技术的希望。 -然而又很长的路要走,所以不要太兴奋,同时,开始考虑将你的的一些数据默认开放。 - -### 一些具体的措施 - -我们如何处理数据的隐私和开放?下面是我想到的一些具体的措施:欢迎大家评论做出更多的贡献。 -  * 检查你的组织是否正在认真严格的执行通用数据保护条例。如果没有,去推动实施它。 -  * 要默认去加密敏感数据(或者适当的时候用散列算法),当不再需要的时候及时删掉--除非数据正在被处理使用否则没有任何借口让数据清晰可见。 -  * 当你注册一个服务的时候考虑一下你公开了什么信息,特别是社交媒体类的。 -  * 和你的非技术朋友讨论这个话题。 -  * 教育你的孩子,你朋友的孩子以及他们的朋友。然而最好是去他们的学校和他们的老师交谈在他们的学校中展示。 -  * 鼓励你工作志愿服务的组织,或者和他们互动推动数据的默认开放。不是去思考为什么我要使数据开放而是以我为什么不让数据开放开始。 -  * 尝试去访问一些开源数据。开采使用它。开发应用来使用它,进行数据分析,画漂亮的图,10 制作有趣的音乐,考虑使用它来做些事。告诉组织去使用它们,感谢它们,而且鼓励他们去做更多。 - - - -1. 我承认你可能尽管不会 -2. 假设你坚信你的个人数据应该被保护。 -3. 如果你在思考“极好的”的寓意,在这点上你并不孤独。 -4. 事实上这些机构能够有多开放取决于你所居住的地方。 -5. 假设我是英国人,那是非常非常大的剂量。 -6. 他们可能是巨大的公司:没有其他人能够负担得起这么大的存储和基础架构来使数据保持可用。 -7. 不,答案是“不”。 -8. 尽管这个列子也同样适用于个人。看看:A可能是Alice,B 可能是BOb... -9. 并不是说我们应该暴露个人的数据或者是这样的数据应该被保密,当然--不是那类的数据。 -10. 我的一个朋友当她接孩子放学的时候总是下雨,所以为了避免确认失误,她在整个学年都访问天气信息并制作了图表分享到社交媒体上。 --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/being-open-about-data-privacy - -作者:[Mike Bursell][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者FelixYFZ](https://github.com/FelixYFZ) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/mikecamel -[1]:https://en.wikipedia.org/wiki/Data_Privacy_Day -[2]:https://en.wikipedia.org/wiki/Information_wants_to_be_free -[3]:https://aliceevebob.wordpress.com/2017/06/06/helping-our-governments-differently/ -[4]:https://opensource.com/article/17/11/commonwealth-open-source -[5]:http://www.outpost9.com/reference/jargon/jargon_40.html#TAG2036 From f7cf014c7aac3d52b25ffea223d549bd42d51cc5 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sun, 20 May 2018 11:13:49 +0800 Subject: [PATCH 0997/1057] Create Being open about data privacy.md --- .../talk/Being open about data privacy.md | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 translated/talk/Being open about data privacy.md diff --git a/translated/talk/Being open about data privacy.md b/translated/talk/Being open about data privacy.md new file mode 100644 index 0000000000..9d7e4bd87b --- /dev/null +++ b/translated/talk/Being open about data privacy.md @@ -0,0 +1,95 @@ +对数据隐私持开放的态度 +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/GOV_opendata.png?itok=M8L2HGVx) + + +Image by : opensource.com + +今天是[数据隐私日][1],(在欧洲叫"数据保护日"),你可能会认为现在我们处于一个开源的世界中,所有的数据都应该免费,[就像人们想的那样][2],但是现实并没那么简单。主要有两个原因: +1. 我们中的大多数(不仅仅是在开源中)认为至少有些关于我们自己的数据是不愿意分享出去的(我在之前发表的一篇文章中列举了一些列子[3]) +2. 我们很多人虽然在开源中工作,但事实上是为了一些商业公司或者其他一些组织工作,也是在合法的要求范围内分享数据。 + +所以实际上,数据隐私对于每个人来说是很重要的。 + +事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。前者通常为实体提供更多的自由度,更愤世嫉俗的是--大型的商业体利用他们收集到的关于我们的数据。在欧洲,完全是另一观念,一直以来持有的多是有更多约束限制的观念,而且在5月25日,欧洲的观点可以说取得了胜利。 + +## 通用数据保护条例的影响 + +那是一个相当全面的声明,其实事实上就是欧盟在2016年通过的一项关于通用数据保护的立法,使它变得可实施。数据通用保护条例在私人数据怎样才能被保存,如何才能被使用,谁能使用,能被持有多长时间这些方面设置了严格的规则。它描述了什么数据属于私人数据--而且涉及的条目范围非常广泛,从你的姓名家庭住址到你的医疗记录以及接通你电脑的IP地址。 + +通用数据保护条例的重要之处是他并不仅仅适用于欧洲的公司,如果你是阿根廷人,日本人,美国人或者是俄罗斯的公司而且你正在收集涉及到欧盟居民的数据,你就要受到这个条例的约束管辖。 + +“哼!” 你可能会这样说,“我的业务不在欧洲:他们能对我有啥约束?” 答案很简答:如果你想继续在欧盟做任何生意,你最好遵守,因为一旦你违反了通用数据保护条例的规则,你将会受到你全球总收入百分之四的惩罚。是的,你没听错,是全球总收入不是仅仅在欧盟某一国家的的收入,也不只是净利润,而是全球总收入。这将会让你去叮嘱告知你的法律团队,他们就会知会你的整个团队,同时也会立即去指引你的IT团队,确保你的行为相当短的时间内是符合要求的。 + +看上去这和欧盟之外的城市没有什么相关性,但其实不然,对大多数公司来说,对所有的他们的顾客、合作伙伴以及员工实行同样的数据保护措施是件既简单又有效的事情,而不是只是在欧盟的城市实施,这将会是一件很有利的事情。2 + +然而,数据通用保护条例不久将在全球实施并不意味着一切都会变的很美好:事实并非如此,我们一直在丢弃关于我们自己的信息--而且允许公司去使用它。 + +有一句话是这么说的(尽管很争议):“如果你没有在付费,那么你就是产品。”这句话的意思就是如果你没有为某一项服务付费,那么其他的人就在付费使用你的数据。 +你有付费使用Facebook、推特?谷歌邮箱?你觉得他们是如何赚钱的?大部分是通过广告,一些人会争论那是他们向你提供的一项服务而已,但事实上是他们在利用你的数据从广告商里获取收益。你不是一个真正的广告的顾客-只有当你从看了广告后买了他们的商品之后你才变成了他们的顾客,但直到这个发生之前,都是广告平台和广告商的关系。 + +有些服务是允许你通过付费来消除广告的(流媒体音乐平台声破天就是这样的),但从另一方面来讲,即使你认为付费的服务也可以启用广告(列如,亚马逊正在允许通过Alexa广告)除非我们想要开始为这些所有的免费服务付费,我们需要清除我们所放弃的,而且在我们想要揭发和不想的里面做一些选择。 + +### 谁是顾客? + +关于数据的另一个问题一直在困扰着我们,它是产生的数据量的直接结果。有许多组织一直在产生巨量的数据,包括公共的组织比如大学、医院或者是政府部门4-- +而且他们没有能力去储存这些数据。如果这些数据没有长久的价值也就没什么要紧的,但事实正好相反,随着处理大数据的工具正在开发中,而且这些组织也认识到他们现在以及在不久的将来将能够去开采这些数据。 + +然而他们面临的是,随着数据的增长和存储量的不足他们是如何处理的。幸运--而且我是带有讽刺意味的使用了这个词,5大公司正在介入去帮助他们。“把你们的数据给我们,”他们说,“我们将免费保存。我们甚至让你随时能够使用你所收集到的数据!”这听起来很棒,是吗?这是大公司的一个极具代表性的列子,站在慈善的立场上帮助公共组织管理他们收集到的关于我们的数据。 + +不幸的是,慈善不是唯一的理由。他们是附有条件的:作为同意保存数据的交换条件,这些公司得到了将数据访问权限出售非第三方的权利。你认为公共组织,或者是被收集数据的人在数据被出售使用权使给第三方在他们如何使用上面能有发言权吗?我将把这个问题当做一个练习留给读者去思考。7 + +### 开放和积极 + +然而并不只有坏消息。政府中有一项在逐渐发展起来的“开放数据”运动鼓励部门能够将免费开放他们的数据给公众或者其他组织。这项行动目前正在被实施立法。许多 +支援组织--尤其是那些收到公共基金的--正在开始推动同样的活动。即使商业组织也有些许的兴趣。而且,在技术上已经可行了,例如围绕不同的隐私和多方计算上,正在允许我们根据数据设置和不揭露太多关于个人的前提下开采数据--一个历史性的计算问题比你想象的要容易处理的多。 + +这些对我们来说意味着什么呢?我之前在网站Opensource.com上写过关于[开源的共享福利][4],而且我越来越相信我们需要把我们的视野从软件拓展到其他区域:硬件,组织,和这次讨论有关的,数据。让我们假设一下你是A公司要提向另一家公司提供一项服务,客户B。在游戏中有四种不同类型的数据: + 1. 数据完全开放:对A和B都是可得到的,世界上任何人都可以得到 + 2. 数据是已知的,共享的,和机密的:A和B可得到,但其他人不能得到。 + 3. 数据是公司级别上保密的:A公司可以得到,但B顾客不能 + 4. 数据是顾客级别保密的:B顾客可以得到,但A公司不能 + +首先,也许我们对数据应该更开放些,将数据默认放到选项一中。如果那些数据对所有人开放--在无人驾驶、语音识别,矿藏以及人口数据统计会有相当大的作用的,9 +如果我们能够找到方法将数据放到选项2,3和4中,不是很好嘛--或者至少它们中的一些--在选项一中是可以实现的,同时仍将细节保密?这就是研究这些新技术的希望。 +然而又很长的路要走,所以不要太兴奋,同时,开始考虑将你的的一些数据默认开放。 + +### 一些具体的措施 + +我们如何处理数据的隐私和开放?下面是我想到的一些具体的措施:欢迎大家评论做出更多的贡献。 + * 检查你的组织是否正在认真严格的执行通用数据保护条例。如果没有,去推动实施它。 + * 要默认去加密敏感数据(或者适当的时候用散列算法),当不再需要的时候及时删掉--除非数据正在被处理使用否则没有任何借口让数据清晰可见。 + * 当你注册一个服务的时候考虑一下你公开了什么信息,特别是社交媒体类的。 + * 和你的非技术朋友讨论这个话题。 + * 教育你的孩子,你朋友的孩子以及他们的朋友。然而最好是去他们的学校和他们的老师交谈在他们的学校中展示。 + * 鼓励你工作志愿服务的组织,或者和他们互动推动数据的默认开放。不是去思考为什么我要使数据开放而是以我为什么不让数据开放开始。 + * 尝试去访问一些开源数据。开采使用它。开发应用来使用它,进行数据分析,画漂亮的图,10 制作有趣的音乐,考虑使用它来做些事。告诉组织去使用它们,感谢它们,而且鼓励他们去做更多。 + + + +1. 我承认你可能尽管不会 +2. 假设你坚信你的个人数据应该被保护。 +3. 如果你在思考“极好的”的寓意,在这点上你并不孤独。 +4. 事实上这些机构能够有多开放取决于你所居住的地方。 +5. 假设我是英国人,那是非常非常大的剂量。 +6. 他们可能是巨大的公司:没有其他人能够负担得起这么大的存储和基础架构来使数据保持可用。 +7. 不,答案是“不”。 +8. 尽管这个列子也同样适用于个人。看看:A可能是Alice,B 可能是BOb... +9. 并不是说我们应该暴露个人的数据或者是这样的数据应该被保密,当然--不是那类的数据。 +10. 我的一个朋友当她接孩子放学的时候总是下雨,所以为了避免确认失误,她在整个学年都访问天气信息并制作了图表分享到社交媒体上。 +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/being-open-about-data-privacy + +作者:[Mike Bursell][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者FelixYFZ](https://github.com/FelixYFZ) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/mikecamel +[1]:https://en.wikipedia.org/wiki/Data_Privacy_Day +[2]:https://en.wikipedia.org/wiki/Information_wants_to_be_free +[3]:https://aliceevebob.wordpress.com/2017/06/06/helping-our-governments-differently/ +[4]:https://opensource.com/article/17/11/commonwealth-open-source +[5]:http://www.outpost9.com/reference/jargon/jargon_40.html#TAG2036 From b51d8053b183c975787b6de80d1cbf7ec28bddf0 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 May 2018 11:22:46 +0800 Subject: [PATCH 0998/1057] PRF:20180507 How To Improve Application Startup Time In Linux.md @qhwdw --- ...prove Application Startup Time In Linux.md | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) 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 index 93fb4c484c..7b272c6c3c 100644 --- 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 @@ -2,72 +2,69 @@ ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/05/Preload-720x340.png) -大多数 Linux 发行版在默认配置下已经足够快了。但是,我们仍然可以借助一些额外的应用程序和方法让它们启动更快一点。其中一个可用的这种应用程序就是 **Preload**。它监视用户使用频率比较高的应用程序,并将它们添加到内存中,这样就比一般的方式加载更快一点。因为,正如你所知道的,内存的读取速度远远快于硬盘。Preload 以守护进程的方式在后台中运行,并记录用户使用较为频繁的程序的文件使用相关的统计数据。然后,它将这些二进制文件及它们的依赖项加载进内存,以改善应用程序的加载时间。简而言之,一旦安装了 preload,你使用较为频繁的应用程序将可能加载的更快。 + +大多数 Linux 发行版在默认配置下已经足够快了。但是,我们仍然可以借助一些额外的应用程序和方法让它们启动更快一点。其中一个可用的这种应用程序就是 Preload。它监视用户使用频率比较高的应用程序,并将它们添加到内存中,这样就比一般的方式加载更快一点。因为,正如你所知道的,内存的读取速度远远快于硬盘。Preload 以守护进程的方式在后台中运行,并记录用户使用较为频繁的程序的文件使用相关的统计数据。然后,它将这些二进制文件及它们的依赖项加载进内存,以改善应用程序的加载时间。简而言之,一旦安装了 Preload,你使用较为频繁的应用程序将可能加载的更快。 在这篇详细的教程中,我们将去了解如何安装和使用 Preload,以改善应用程序在 Linux 中的启动时间。 ### 在 Linux 中使用 Preload 改善应用程序启动时间 -Preload 可以在 [**AUR**][1] 上找到。因此,你可以使用 AUR 助理程序在任何基于 Arch 的系统上去安装它,比如,Antergos、Manjaro Linux。 +Preload 可以在 [AUR][1] 上找到。因此,你可以使用 AUR 助理程序在任何基于 Arch 的系统上去安装它,比如,Antergos、Manjaro Linux。 + +使用 [Pacaur][2]: -使用 [**Pacaur**][2]: ``` $ pacaur -S preload - ``` -使用 [**Packer**][3]: +使用 [Packer][3]: + ``` $ packer -S preload - ``` -使用 [**Trizen**][4]: +使用 [Trizen][4]: + ``` $ trizen -S preload - ``` -使用 [**Yay**][5]: +使用 [Yay][5]: + ``` $ yay -S preload - ``` -使用 [**Yaourt**][6]: +使用 [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 将监视频繁使用的应用程序,并将它们的二进制文件和库添加到内存中,以使它的启动速度更快。比如,如果你经常使用 Firefox、Chrome 以及 LibreOffice,Preload 将添加这些二进制文件和库到内存中,因此,这些应用程序将启动的更快。而且更好的是,它不需要做任何配置。它是开箱即用的。但是,如果你想去对它进行微调,你可以通过编辑缺省的配置文件 `/etc/preload.conf` 来实现。 ### Preload 并不一定适合每个人! -以下是 Preload 的一些缺点,它并不是对每个人都有帮助,在这个 [**跟贴**][7] 中有讨论到。 +以下是 Preload 的一些缺点,它并不是对每个人都有帮助,在这个 [跟贴][7] 中有讨论到。 - 1. 我使用的是一个有 8GB 内存的现代系统。因此,我的系统总体上来说很快。我每天只打开狂吃内存的应用程序(比如,Firefox、Chrome、VirtualBox、Gimp、等等)一到两次,并且它们始终处于打开状态,因此,它们的二进制文件和库被预读到内存中,并始终整天在内存中。我一般很少去关闭和打开这些应用程序,因此,内存使用纯属浪费。 + 1. 我使用的是一个有 8GB 内存的现代系统。因此,我的系统总体上来说很快。我每天只打开狂吃内存的应用程序(比如,Firefox、Chrome、VirtualBox、Gimp 等等)一到两次,并且它们始终处于打开状态,因此,它们的二进制文件和库被预读到内存中,并始终整天在内存中。我一般很少去关闭和打开这些应用程序,因此,内存使用纯属浪费。 2. 如果你使用的是带有 SSD 的现代系统,Preload 是绝对没用的。因为 SSD 的访问时间比起一般的硬盘来要快的多,因此,使用 Preload 是没有意义的。 - 3. Preload 显著影响启动时间。因为大多数的应用程序都预读到内存中,长此以往,将让你的系统启动和运行的更快。 - - + 3. Preload 显著影响启动时间。因为更多的应用程序要被预读到内存中,这将让你的系统启动运行时间更长。 你只有在每天都在大量的重新加载应用程序时,才能看到真正的差别。因此,Preload 最适合开发人员和测试人员,他们每天都打开和关闭应用程序好多次。 -关于 Preload 更多的信息和它是如何工作的,请阅读它的作者写的完整版的 [**Preload 论文**][8]。 +关于 Preload 更多的信息和它是如何工作的,请阅读它的作者写的完整版的 [Preload 论文][8]。 教程到此为止,希望能帮到你。后面还有更精彩的内容,请继续关注! 再见! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-improve-application-startup-time-in-linux/ @@ -75,7 +72,7 @@ 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) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 289c65e103ca0b150a1f1fb7597fd2314c3ecc14 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 May 2018 11:23:12 +0800 Subject: [PATCH 0999/1057] PUB:20180507 How To Improve Application Startup Time In Linux.md @qhwdw https://linux.cn/article-9660-1.html --- .../20180507 How To Improve Application Startup Time In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180507 How To Improve Application Startup Time In Linux.md (100%) diff --git a/translated/tech/20180507 How To Improve Application Startup Time In Linux.md b/published/20180507 How To Improve Application Startup Time In Linux.md similarity index 100% rename from translated/tech/20180507 How To Improve Application Startup Time In Linux.md rename to published/20180507 How To Improve Application Startup Time In Linux.md From 12fe79aa87bd1344ac7d84e91fd350ba5738e53d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 May 2018 11:25:18 +0800 Subject: [PATCH 1000/1057] =?UTF-8?q?=E8=AF=B7=E4=BF=9D=E6=8C=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E4=B8=8D=E8=A6=81=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @FelixYFZ --- ... data privacy.md => 20180128 Being open about data privacy.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/talk/{Being open about data privacy.md => 20180128 Being open about data privacy.md} (100%) diff --git a/translated/talk/Being open about data privacy.md b/translated/talk/20180128 Being open about data privacy.md similarity index 100% rename from translated/talk/Being open about data privacy.md rename to translated/talk/20180128 Being open about data privacy.md From 9fbe07c851f9396bcc107ae106505af25721a52a Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Sun, 20 May 2018 11:42:19 +0800 Subject: [PATCH 1001/1057] Update 20180107 7 leadership rules for the DevOps age.md Translating by FelixYFZ --- sources/talk/20180107 7 leadership rules for the DevOps age.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180107 7 leadership rules for the DevOps age.md b/sources/talk/20180107 7 leadership rules for the DevOps age.md index cd202d5591..fd875cc63b 100644 --- a/sources/talk/20180107 7 leadership rules for the DevOps age.md +++ b/sources/talk/20180107 7 leadership rules for the DevOps age.md @@ -1,4 +1,4 @@ -7 leadership rules for the DevOps age +Translating by FelixYFZ 7 leadership rules for the DevOps age ====== ![](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO_DigitalAcumen_2.png?itok=TGeMQYs4) From 4e5635d5495080125c53f54c2c92f5365228af3b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 May 2018 14:02:24 +0800 Subject: [PATCH 1002/1057] =?UTF-8?q?=E6=A0=A1=E5=AF=B9=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0160325 Network automation with Ansible.md | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/translated/tech/20160325 Network automation with Ansible.md b/translated/tech/20160325 Network automation with Ansible.md index e7a7469bf6..12a0371de1 100644 --- a/translated/tech/20160325 Network automation with Ansible.md +++ b/translated/tech/20160325 Network automation with Ansible.md @@ -1,72 +1,71 @@ 用 Ansible 实现网络自动化 ================ + +> 了解 Ansible 的功能,这是一个无代理的、可扩展的配置管理系统。 ### 网络自动化 -随着 IT 行业的技术变化,从服务器虚拟化到公有和私有云,以及自服务能力、容器化应用、平台即服务(Paas)交付,一直以来落后的一个领域是网络。 +随着 IT 行业的技术变化,从服务器虚拟化到公有云和私有云,以及自服务能力、容器化应用、平台即服务(PaaS)交付,有一直以来落后的一个领域就是网络。 在过去的五年多,网络行业似乎有很多新的趋势出现,它们中的很多被归入到软件定义网络(SDN)。 >注意 -> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是需要将控制层和数据层(包转发)物理分离,并且,解耦合的控制层必须管理好各自的设备。 +> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是出于将控制层和数据层(包转发)物理分离的需要,并且,解耦合的控制层必须管理好各自的设备。 -> 如今,_在 SDN_ 旗下已经有许多技术,包括基于控制器的网络controller-based networks、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。 +> 如今,在 SDN 旗下已经有许多技术,包括基于控制器的网络controller-based networks、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。 > 由于这篇报告的目的,我们参考 SDN 的解决方案作为我们的解决方案,其中包括一个网络控制器作为解决方案的一部分,并且提升了该网络的可管理性,但并不需要从数据层解耦控制层。 -这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备在 JSON/XML 中返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。 +这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备以 JSON/XML 返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。 在 API 之前,用于配置和管理网络设备的两个主要机制是命令行接口(CLI)和简单网络管理协议(SNMP)。让我们来了解一下它们,CLI 是一个设备的人机界面,而 SNMP 并不是为设备提供的实时编程接口。 -幸运的是,因为很多供应商争相为设备增加 API,有时候 _正是因为_ 它被放到需求建议书(RFP)中,就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。 +幸运的是,因为很多供应商争相为设备增加 API,有时候 _只是因为_ 它被放到需求建议书(RFP)中,这就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。 > 注意 -> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被测试,并且要做为采购网络设备(虚拟和物理)的关键决策标准。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准/协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。 +> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被做为采购网络设备(虚拟和物理)的关键决策标准而测试和使用。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准或协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。 -总而言之,网络自动化,像大多数的自动化类型一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。 +总而言之,网络自动化,像大多数类型的自动化一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。 -包括速度,我们现在看看这些各种类型的 IT 组织逐渐采用网络自动化的几种原因。你应该注意到,同样的原则也适用于其它类型的自动化。 +包括速度在内,我们现在看看这些各种类型的 IT 组织逐渐采用网络自动化的几种原因。你应该注意到,同样的原则也适用于其它类型的自动化。 ### 简化架构 -今天,每个网络都是一个独特的“雪花”型,并且,网络工程师们为能够解决传输和网络应用问题而感到自豪,这些问题最终使网络不仅难以维护和管理,而且也很难去实现自动化。 +今天,每个网络都是一片独特的“雪花”,并且,网络工程师们为能够通过一次性的改变来解决传输和网络应用问题而感到自豪,而这最终导致网络不仅难以维护和管理,而且也很难去实现自动化。 -它需要从一开始就包含到新的架构和设计中去部署,而不是去考虑网络自动化和管理作为一个二级或三级项目。哪个特性可以跨不同的供应商工作?哪个扩展可以跨不同的平台工作?当使用特别的网络设备平台时,API 类型或者自动化工程是什么?当这些问题在设计进程之前得到答案,最终的架构将变成简单的、可重复的、并且易于维护 _和_ 自动化的,在整个网络中将很少启用供应商专用的扩展。 +网络自动化和管理需要从一开始就包含到新的架构和设计中去部署,而不是作为一个二级或三级项目。哪个特性可以跨不同的供应商工作?哪个扩展可以跨不同的平台工作?当使用特别的网络设备平台时,API 类型或者自动化工程是什么?当这些问题在设计过程之前得到答案,最终的架构将变成简单的、可重复的、并且易于维护 _和_ 自动化的,在整个网络中将很少启用供应商专用的扩展。 ### 确定的结果 -在一个企业组织中,改变审查会议(change review meeting)去评估即将到来的网络上的变化、它们对外部系统的影响、以及回滚计划。在这个世界上,人们为这些即 _将到来的变化_ 去接触 CLI,输入错误的命令造成的影响是灾难性的。想像一下,一个有三位、四位、五位、或者 50 位工程师的团队。每位工程师应对 _即将到来的变化_ 都有他们自己的独特的方法。并且,在管理这些变化的期间,使用一个 CLI 或者 GUI 的能力并不会消除和减少出现错误的机率。 - -使用经过验证和测试过的网络自动化可以帮助实现更多的可预测行为,并且使执行团队有更好的机会实现确实性结果,在保证任务没有人为错误的情况下首次正确完成的道路上更进一步。 +在一个企业组织中,改变审查会议change review meeting会评估面临的网络变化、它们对外部系统的影响、以及回滚计划。在人们通过 CLI 来执行这些 _面临的变化_ 的世界上,输入错误的命令造成的影响是灾难性的。想像一下,一个有 3 位、4 位、5位,或者 50 位工程师的团队。每位工程师应对 _面临的变化_ 都有他们自己的独特的方法。并且,在管理这些变化的期间,一个人使用 CLI 或者 GUI 的能力并不会消除和减少出现错误的机率。 +使用经过验证和测试过的网络自动化可以帮助实现更多的可预测行为,并且使执行团队更有可能实现确实性结果,在保证任务没有人为错误的情况下首次正确完成的道路上更进一步。 ### 业务灵活性 -不用说,网络自动化不仅为部署变化提供速度和灵活性,而且使得根据业务需要去从网络设备中检索数据的速度变得更快。自从服务器虚拟化实现以后,服务器和虚拟化使得管理员有能力在瞬间去部署一个新的应用程序。而且,更多的快速部署应用程序的问题出现在,配置一个 VLAN(虚拟局域网)、路由器、FW ACL(防火墙的访问控制列表)、或者负载均衡策略需要多长时间? +不用说,网络自动化不仅为部署变化提供速度和灵活性,而且使得根据业务需要去从网络设备中检索数据的速度变得更快。自从服务器虚拟化到来以后,服务器和虚拟化使得管理员有能力在瞬间去部署一个新的应用程序。而且,随着应用程序可以更快地部署,随之浮现的问题是为什么还需要花费如此长的时间配置一个 VLAN(虚拟局域网)、路由器、FW ACL(防火墙的访问控制列表)或者负载均衡策略呢? -在一个组织内通过去熟悉大多数的通用工作流和 _为什么_ 网络改变是真实的需求?新的部署过程自动化工具,如 Ansible 将使这些变得非常简单。 - -这一章将介绍一些关于为什么应该去考虑网络自动化的高级知识点。在下一节,我们将带你去了解 Ansible 是什么,并且继续深入了解各种不同规模的 IT 组织的网络自动化的不同类型。 +通过了解在一个组织内最常见的工作流和 _为什么_ 真正需要改变网络,部署如 Ansible 这样的现代的自动化工具将使这些变得非常简单。 +这一章介绍了一些关于为什么应该去考虑网络自动化的高级知识点。在下一节,我们将带你去了解 Ansible 是什么,并且继续深入了解各种不同规模的 IT 组织的网络自动化的不同类型。 ### 什么是 Ansible? -Ansible 是存在于开源世界里的一种最新的 IT 自动化和配置管理平台。它经常被拿来与其它工具如 Puppet、Chef、和 SaltStack 去比较。Ansible 作为一个由 Michael DeHaan 创建的开源项目出现于 2012 年,Michael DeHaan 也创建了 Cobbler 和 cocreated Func,它们在开源社区都非常流行。在 Ansible 开源项目创建之后不足 18 个月时间, Ansilbe 公司成立,并收到了 $6 million 的一系列资金。它成为并一直保持着第一的贡献者和 Ansible 开源项目的支持者。在 2015 年 10 月,Red Hat 获得了 Ansible 公司。 +Ansible 是存在于开源世界里的一种最新的 IT 自动化和配置管理平台。它经常被拿来与其它工具如 Puppet、Chef 和 SaltStack 去比较。Ansible 作为一个由 Michael DeHaan 创建的开源项目出现于 2012 年,Michael DeHaan 也创建了 Cobbler 和 cocreated Func,它们在开源社区都非常流行。在 Ansible 开源项目创建之后不足 18 个月时间, Ansilbe 公司成立,并收到了六百万美金 A 轮投资。该公司成为 Ansible 开源项目排名第一的贡献者和支持者,并一直保持着。在 2015 年 10 月,Red Hat 收购了 Ansible 公司。 但是,Ansible 到底是什么? _Ansible 是一个无需代理和可扩展的超级简单的自动化平台。_ -让我们更深入地了解它的细节,并且看一看 Ansible 的属性,它帮助 Ansible 在行业内获得大量的吸引力(traction)。 - +让我们更深入地了解它的细节,并且看一看那些使 Ansible 在行业内获得广泛认可的属性。 ### 简单 -Ansible 的其中一个吸引人的属性是,去使用它你 _不_ 需要特定的编程技能。所有的指令,或者任务都是自动化的,在一个标准的、任何人都可以理解的人类可读的数据格式的一个文档中。在 30 分钟之内完成安装和自动化任务的情况并不罕见! +Ansible 的其中一个吸引人的属性是,使用它你 _不_ 需要特定的编程技能。所有的指令,或者任务都是自动化的,以一个标准的、任何人都可以理解的人类可读的数据格式的文档化。在 30 分钟之内完成安装和自动化任务的情况并不罕见! -例如,下列的一个 Ansible playbook 任务是用于去确保在一个 Cisco Nexus 交换机中存在一个 VLAN: +例如,下列来自一个 Ansible 剧本playbook的任务用于去确保在一个 VLAN 存在于一个 Cisco Nexus 交换机中: ``` - nxos_vlan: vlan_id=100 name=web_vlan @@ -74,9 +73,9 @@ Ansible 的其中一个吸引人的属性是,去使用它你 _不_ 需要特 你无需熟悉或写任何代码就可以明确地看出它将要做什么! -###### 注意 +> 注意 -这个报告的下半部分涉到 Ansible 术语(playbooks、plays、tasks、modules、等等)的细节。但是,在我们为网络自动化使用 Ansible 时,我们也同时有一些详细的示例去解释这些关键概念。 +> 这个报告的下半部分涉到 Ansible 术语(剧本playbook行动play任务task模块module等等)的细节。在我们使用 Ansible 进行网络自动化时,提及这些关键概念时我们会有一些简短的示例。 ### 无代理 From 71a55cffe8fbec174d5393139ba86ceeb65834db Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Sun, 20 May 2018 21:35:12 +0800 Subject: [PATCH 1003/1057] Update 20180326 How To Archive Files And Directories In Linux.md --- .../20180326 How To Archive Files And Directories In Linux.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180326 How To Archive Files And Directories In Linux.md b/sources/tech/20180326 How To Archive Files And Directories In Linux.md index 804bc554b3..51da682582 100644 --- a/sources/tech/20180326 How To Archive Files And Directories In Linux.md +++ b/sources/tech/20180326 How To Archive Files And Directories In Linux.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + How To Archive Files And Directories In Linux ====== From a24cd08d14b30b2ec815b974c6781401be1082a5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 07:19:37 +0800 Subject: [PATCH 1004/1057] PRF:20180503 How to build container images with Buildah.md @geekpi --- ... to build container images with Buildah.md | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) 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 index ee008f431e..deaf7c6f07 100644 --- a/translated/tech/20180503 How to build container images with Buildah.md +++ b/translated/tech/20180503 How to build container images with Buildah.md @@ -7,97 +7,98 @@ Project Atomic 通过他们在 Open Container Initiative(OCI)上的努力创 Buildah 处理构建容器镜像时无需安装完整的容器运行时或守护进程。这对建立容器的持续集成和持续交付管道尤其有用。 -Buildah 使容器的文件系统可以直接供构建主机使用。这意味着构建工具在主机上可用,并且在容器镜像中不需要,从而使构建更快速,镜像更小,更安全。Buildah 有 CentOS、Fedora 和 Debian 的软件包。 +Buildah 使容器的文件系统可以直接供构建主机使用。这意味着构建工具在主机上可用就行,而不需要在容器镜像中可用,从而使构建更快速,镜像更小,更安全。Buildah 有 CentOS、Fedora 和 Debian 的软件包。 ### 安装 Buildah -从 Fedora 26 开始 Buildah 可以使用 dnf 进行安装。 +从 Fedora 26 开始 Buildah 可以使用 `dnf` 进行安装。 + ``` $ sudo dnf install buildah -y - ``` -buildah 的当前版本为 0.16,可以通过以下命令显示。 +`buildah` 的当前版本为 0.16,可以通过以下命令显示。 + ``` $ buildah --version - ``` ### 基本命令 -构建容器镜像的第一步是获取基础镜像,这是通过 Dockerfile 中的 FROM 语句完成的。Buildah 以类似的方式处理这个。 +构建容器镜像的第一步是获取基础镜像,这是通过 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 选项。 +完整的命令列表可以使用 `--help` 选项。 + ``` $ buildah --help - ``` ### 构建一个 Apache Web 服务器容器镜像 -让我们看看如何使用 Buildah 在 Fedora 基础镜像上安装 Apache Web 服务器,然后复制一个可供服务的自定义 index.html。 +让我们看看如何使用 Buildah 在 Fedora 基础镜像上安装 Apache Web 服务器,然后复制一个可供服务的自定义 `index.html`。 + +首先让我们创建自定义的 `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/。 +让我们将 `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 命令将容器保存到镜像。 +现在为了使“工作容器”可用,`commit` 命令将容器保存到镜像。 + ``` $ sudo buildah commit fedora-working-container hello-fedora-magazine - ``` hello-fedora-magazine 镜像现在可用,并且可以推送到仓库以供使用。 + ``` $ sudo buildah images IMAGE ID IMAGE NAME CREATED @@ -106,15 +107,13 @@ AT SIZE 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 !!!” @@ -127,7 +126,7 @@ 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) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 5dfccd766ae838d505dbd01dc3323a28dbc1f1f8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 07:20:07 +0800 Subject: [PATCH 1005/1057] PUB:20180503 How to build container images with Buildah.md @geekpi https://linux.cn/article-9661-1.html --- .../20180503 How to build container images with Buildah.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180503 How to build container images with Buildah.md (100%) diff --git a/translated/tech/20180503 How to build container images with Buildah.md b/published/20180503 How to build container images with Buildah.md similarity index 100% rename from translated/tech/20180503 How to build container images with Buildah.md rename to published/20180503 How to build container images with Buildah.md From 84caf482b9ceb33ef5af62d9cd0770e09f97be2f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 07:35:09 +0800 Subject: [PATCH 1006/1057] PRF:20180413 Useful Resources for Those Who Want to Know More About Linux.md @MjSeven --- ...Those Who Want to Know More About Linux.md | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md b/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md index 68db7151bf..88af4cd89c 100644 --- a/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md +++ b/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md @@ -1,17 +1,17 @@ 有用的资源,献给那些想更多了解 Linux 的人 ===== -Linux 是最流行和多功能的操作系统之一,它可以用在智能手机,电脑甚至汽车上。自 20 世纪 90 年代以来,Linux 一直存在,并且仍然是最普遍的操作系统之一。 +Linux 是最流行和多功能的操作系统之一,它可以用在智能手机,电脑甚至汽车上。自 20 世纪 90 年代以来,Linux 存在至今,并且仍然是最普遍的操作系统之一。 -Linux 实际上用于运行大多数网络服务,因为与其他操作系统相比,它被认为是相当稳定的。这是[人们选择 Linux 多于 Windows的原因][1]之一。此外,Linux 为用户提供了隐私,并且根本不收集用户信息,而 Windows 10 及其 Cortana 语音控制系统总是需要更新你的个人信息。 +Linux 实际上用于运行大多数网络服务,因为与其他操作系统相比,它被认为是相当稳定的。这是[人们选择 Linux 多于 Windows 的原因][1]之一。此外,Linux 为用户提供了隐私,根本不收集用户信息,而 Windows 10 及其 Cortana 语音控制系统总是需要更新你的个人信息。 -Linux 有很多优点。然而,人们并没有听到太多关于它的消息,因为它已被 Windows 和 Mac 挤出市场。许多人开始使用 Linux 时会感到困惑,因为它与流行的操作系统有点不同。 +Linux 有很多优点。然而,人们并没有听到太多关于它的消息,因为它已被 Windows 和 Mac 挤出(桌面)场。许多人开始使用 Linux 时会感到困惑,因为它与流行的操作系统有点不同。 为了帮助你,我们为那些想要了解更多关于 Linux 的人收集了 5 个有用的资源。 -### 1.[ Linux 纯新手 ][2] +### 1、[Linux 纯新手][2] -如果你想尽可能多地学习 Linux,你应该考虑 Eduonix 为初学者提供的 Linux 完整教程。这个课程将向你介绍 Linux 的所有功能,并为你提供所有必要的资料,以帮助你了解更多关于 Linux 工作原理的特性。 +如果你想尽可能多地学习 Linux,你应该考虑 Eduonix 为[初学者提供的 Linux 完整教程][2]。这个课程将向你介绍 Linux 的所有功能,并为你提供所有必要的资料,以帮助你了解更多关于 Linux 工作原理的特性。 如果你是以下情况,你应该选择本课程: @@ -20,58 +20,48 @@ Linux 有很多优点。然而,人们并没有听到太多关于它的消息 * 你想了解 Linux 如何与硬件配合使用; * 你想学习如何操作 Linux 命令行。 -### 2.[PC World: Linux 初学者指南][3] +### 2、[PC World: Linux 初学者指南][3] -为想要在一个地方学习所有有关 Linux 的人提供免费资源。PC World 专注于计算机操作系统的各个方面,并为订阅用户提供最准确和最新的信息。在这里,你还可以了解更多关于 [Linux 的好处][4] 和关于其操作系统的最新消息。 +为想要在一个地方学习所有有关 Linux 的人提供[免费资源][3]。PC World 专注于计算机操作系统的各个方面,并为订阅用户提供最准确和最新的信息。在这里,你还可以了解更多关于 [Linux 的好处][4] 和关于其操作系统的最新消息。 该资源为你提供以下信息: * 如何安装 Linux; - * 如何使用命令行; - * 如何安装软件; - * 如何操作 Linux 桌面环境。 -### 3.[Linux 培训][5] +### 3、[Linux.com:Linux 培训][5] -很多使用计算机的人都需要学习如何操作 Linux,以防 Windows 操作系统突然崩溃。还有什么比使用官方资源来启动你的 Linux 培训更好呢? +很多使用计算机的人都需要学习如何操作 Linux,以防 Windows 操作系统突然崩溃。还有什么比使用官方资源来启动你的 [Linux 培训][5]更好呢? -该资源提供了 Linux 训练的在线注册,你可以从官方来源获取最新信息。“一年前,我们的 IT 部门在官方网站上为我们提供了 Linux 培训” [Assignmenthelper.com.au][6] 的开发人员 Martin Gibson 说道。“我们选择了这门课,因为我们需要学习如何将我们的所有文件备份到另一个系统,为我们的客户提供最大的安全性,而且这个资源真的教会了我们所有的东西。” +该资源可用让你在线注册 Linux 训练,你可以从官方来源获取最新信息。“一年前,我们的 IT 部门在官方网站上为我们提供了 Linux 培训” [Assignmenthelper.com.au][6] 的开发人员 Martin Gibson 说道。“我们选择了这门课,因为我们需要学习如何将我们的所有文件备份到另一个系统,为我们的客户提供最大的安全性,而且这个资源真的教会了我们所有的东西。” 所以你肯定应该使用这个资源,如果: * 你想获得有关操作系统的第一手信息; - * 想要了解如何在你的计算机上运行 Linux 的特性; - * 想要与其他 Linux 用户联系并与他们分享你的经验。 -### 4. [The Linux Foundation: 视频培训][7] +### 4、 [Linux 基金会:视频培训][7] -如果你在阅读大量资源时容易感到无聊,那么该网站绝对适合你。Linux Foundation 提供由 IT 专家,软件开发技术人员和技术顾问举办的视频培训,讲座和在线研讨会。 +如果你在阅读大量资源时容易感到无聊,那么该网站绝对适合你。Linux 基金会提供了由 IT 专家、软件开发技术人员和技术顾问举办的视频培训,讲座和在线研讨会。 所有培训视频分为以下类别: -* 开发人员: 使用 Linux Kernel 来处理 Linux 设备驱动程序,Linux 虚拟化等; - +* 开发人员: 使用 Linux 内核来处理 Linux 设备驱动程序、Linux 虚拟化等; * 系统管理员:在 Linux 上开发虚拟主机,构建防火墙,分析 Linux 性能等; +* 用户:Linux 入门,介绍嵌入式 Linux 等。 -* 用户:开始使用 Linux,介绍嵌入式 Linux 等。 - -### 5. [LinuxInsider][8] +### 5、 [LinuxInsider][8] 你知道吗?微软对 Linux 的效率感到惊讶,它[允许用户在微软云计算设备上运行 Linux][9]。如果你想了解更多关于 Linux 操作系统的知识,Linux Insider 会向用户提供关于 Linux 操作系统的最新消息,以及最新更新和 Linux 特性的信息。 在此资源上,你将有机会: * 参与 Linux 社区; - * 了解如何在各种设备上运行 Linux; - * 看看评论; - * 参与博客讨论并阅读科技博客。 ### 总结一下 @@ -80,7 +70,7 @@ Linux 提供了很多好处,包括完全的隐私,稳定的操作甚至恶 ### 关于作者 -Lucy Benton 是一位数字营销专家,商业顾问,帮助人们将他们的梦想变为有利润的业务。现在她正在为营销和商业资源撰写。Lucy 还有自己的博客 [_Prowritingpartner.com_][10],在那里你可以查看她最近的发表。 +Lucy Benton 是一位数字营销专家,商业顾问,帮助人们将他们的梦想变为有利润的业务。现在她正在为营销和商业资源撰写。Lucy 还有自己的博客 [_Prowritingpartner.com_][10],在那里你可以查看她最近发表的文章。 -------------------------------------------------------------------------------- @@ -88,9 +78,9 @@ Lucy Benton 是一位数字营销专家,商业顾问,帮助人们将他们 via: https://linuxaria.com/article/useful-resources-for-those-who-want-to-know-more-about-linux 作者:[Lucy Benton][a] -译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8a89f610c1a5f0c054ed4aed32a3aa57e81cf433 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 07:35:32 +0800 Subject: [PATCH 1007/1057] PUB:20180413 Useful Resources for Those Who Want to Know More About Linux.md @MjSeven https://linux.cn/article-9662-1.html --- ...seful Resources for Those Who Want to Know More About Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180413 Useful Resources for Those Who Want to Know More About Linux.md (100%) diff --git a/translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md b/published/20180413 Useful Resources for Those Who Want to Know More About Linux.md similarity index 100% rename from translated/tech/20180413 Useful Resources for Those Who Want to Know More About Linux.md rename to published/20180413 Useful Resources for Those Who Want to Know More About Linux.md From b8c0354b5a0d8adbb31eeebbd93f901bdfeb7045 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 07:55:42 +0800 Subject: [PATCH 1008/1057] PRF:20180420 A Perl module for better debugging.md @geekpi --- ...0420 A Perl module for better debugging.md | 78 ++++++++----------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/translated/tech/20180420 A Perl module for better debugging.md b/translated/tech/20180420 A Perl module for better debugging.md index c2f599f8f5..d56578ea16 100644 --- a/translated/tech/20180420 A Perl module for better debugging.md +++ b/translated/tech/20180420 A Perl module for better debugging.md @@ -1,68 +1,52 @@ -一个更好的调试 Perl 模块 +一个可以更好地调试的 Perl 模块 ====== +> 这个简单优雅的模块可以让你包含调试或仅用于开发环境的代码,而在产品环境中隐藏它们。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/annoyingbugs.png?itok=ywFZ99Gs) -只有在调试或开发调整时才使用 Perl 代码块有时会很有用。这很好,但是这样的代码块可能会对性能产生很大的影响, 尤其是在运行时决定是否执行它。 -[Curtis“Ovid”Poe][1] 编写了一个可以帮助解决这个问题的模块:[Keyword::DEVELOPMENT][2]。该模块利用 Keyword::Simple 和 Perl 5.012 中引入的可插入关键字架构来创建新的关键字:DEVELOPMENT。它使用 PERL_KEYWORD_DEVELOPMENT 环境变量的值来确定是否要执行一段代码。 +仅用于调试或开发调整时的 Perl 代码块有时会很有用。这很好,但是这样的代码块可能会对性能产生很大的影响, 尤其是在运行时才决定是否执行它。 + +[Curtis "Ovid" Poe][1] 最近编写了一个可以帮助解决这个问题的模块:[Keyword::DEVELOPMENT][2]。该模块利用 `Keyword::Simple` 和 Perl 5.012 中引入的可插入关键字架构来创建了新的关键字:`DEVELOPMENT`。它使用 `PERL_KEYWORD_DEVELOPMENT` 环境变量的值来确定是否要执行一段代码。 + +使用它不能更容易了: -使用它并不容易: ``` use Keyword::DEVELOPMENT; - -        - + sub doing_my_big_loop { - -    my $self = shift; - -    DEVELOPMENT { - -        # insert expensive debugging code here! - -    } - -}Keyworddoing_my_big_loopDEVELOPMENT - + my $self = shift; + DEVELOPMENT { + # insert expensive debugging code here! + } +} ``` -在编译时,DEVELOPMENT 块内的代码已经被优化掉了,根本就不存在。 +在编译时,`DEVELOPMENT` 块内的代码已经被优化掉了,根本就不存在。 -你看到好处了么?在沙盒中将 PERL_KEYWORD_DEVELOPMENT 环境变量设置为 true,在生产环境设为 false,并且可以将有价值的调试工具提交到你的代码库中,在你需要的时候随时可用。 +你看到好处了么?在沙盒中将 `PERL_KEYWORD_DEVELOPMENT` 环境变量设置为 `true`,在生产环境设为 `false`,并且可以将有价值的调试工具提交到你的代码库中,在你需要的时候随时可用。 在缺乏高级配置管理的系统中,你也可以使用此模块来处理生产和开发或测试环境之间的设置差异: + ``` sub connect_to_my_database { - -        - -    my $dsn = "dbi:mysql:productiondb"; - -    my $user = "db_user"; - -    my $pass = "db_pass"; - -    - -    DEVELOPMENT { - -        # Override some of that config information - -        $dsn = "dbi:mysql:developmentdb"; - -    } - -    - -    my $db_handle = DBI->connect($dsn, $user, $pass); - -}connect_to_my_databaseDEVELOPMENTDBI - + + my $dsn = "dbi:mysql:productiondb"; + my $user = "db_user"; + my $pass = "db_pass"; + + DEVELOPMENT { + # Override some of that config information + $dsn = "dbi:mysql:developmentdb"; + } + + my $db_handle = DBI->connect($dsn, $user, $pass); +} ``` 稍后对此代码片段的增强使你能在其他地方,比如 YAML 或 INI 中读取配置信息,但我希望您能在此看到该工具。 -我查看了关键字 Keyword::DEVELOPMENT 的源码,花了大约半小时研究,“天哪,我为什么没有想到这个?”安装 Keyword::Simple 后,Curtis 给我们的模块就非常简单了。这是我长期以来在自己的编码实践中需要的一个优雅解决方案。 +我查看了关键字 `Keyword::DEVELOPMENT` 的源码,花了大约半小时研究,“天哪,我为什么没有想到这个?”安装 `Keyword::Simple` 后,Curtis 给我们的模块就非常简单了。这是我长期以来在自己的编码实践中所需要的一个优雅解决方案。 -------------------------------------------------------------------------------- @@ -71,7 +55,7 @@ via: https://opensource.com/article/18/4/perl-module-debugging-code 作者:[Ruth Holloway][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 ea2b945ca30dce165829d739a368d111ef898d49 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 07:56:04 +0800 Subject: [PATCH 1009/1057] PUB:20180420 A Perl module for better debugging.md @geekpi https://linux.cn/article-9663-1.html --- .../20180420 A Perl module for better debugging.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180420 A Perl module for better debugging.md (100%) diff --git a/translated/tech/20180420 A Perl module for better debugging.md b/published/20180420 A Perl module for better debugging.md similarity index 100% rename from translated/tech/20180420 A Perl module for better debugging.md rename to published/20180420 A Perl module for better debugging.md From 2f8d69fe8b085f5b3f2da908580f45fc36e7a927 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 21 May 2018 08:12:57 +0800 Subject: [PATCH 1010/1057] translated --- ... A New Generation Of Linux applications.md | 93 ------------------- ... A New Generation Of Linux applications.md | 93 +++++++++++++++++++ 2 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md create mode 100644 translated/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 deleted file mode 100644 index 3f7f51ba94..0000000000 --- a/sources/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md +++ /dev/null @@ -1,93 +0,0 @@ -translating---geekpi - -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 diff --git a/translated/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md b/translated/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md new file mode 100644 index 0000000000..79ba51da43 --- /dev/null +++ b/translated/tech/20180508 Orbital Apps - A New Generation Of Linux applications.md @@ -0,0 +1,93 @@ +Orbital Apps - 新一代 Linux 程序 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2016/05/orbital-apps-720x340.jpg) + +今天,我们要了解 **Orbital Apps** 或 **ORB**(**O**pen **R**unnable **B**undle)**apps**(开放可运行程序包),一个免费、跨平台的开源程序集合。所有 ORB 程序都是可移动的。你可以将它们安装在你的 Linux 系统或 USB 驱动器上,以便你可以在任何系统上使用相同的程序。它们不需要 root 权限,并且没有依赖关系。所有必需的依赖关系都包含在程序中。只需将 ORB 程序复制到 USB 驱动器并将其插入到任何 Linux 系统中就立即开始使用它们。所有设置和配置以及程序的数据都将存储在 USB 驱动器上。由于不需要在本地驱动器上安装程序,我们可以在联机或脱机的计算机上运行应用程序。这意味着我们不需要 Internet 来下载任何依赖。 + +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. +ORB 程序压缩了 60%,因此我们甚至可以从小型USB驱动器存储和使用它们。所有ORB应用程序都使用PGP / RSA进行签名,并通过TLS 1.2进行分发。所有应用程序打包时都不做任何修改,甚至不会重新编译。以下是当前可用的便携式ORB应用程序列表。 + + * abiword + * audacious + * audacity + * darktable + * deluge + * filezilla + * firefox + * gimp + * gnome-mplayer + * hexchat + * inkscape + * isomaster + * kodi + * libreoffice + * qbittorrent + * sound-juicer + * thunderbird + * tomahawk + * uget + * vlc + * 未来还有更多。 + + + +Orb is open source, so If you’re a developer, feel free to collaborate and add more applications. +Orb 是开源的,所以如果你是开发人员,欢迎协作并添加更多程序。 + +### 下载并使用可移动 ORB 程序 + +正如我已经提到的,我们不需要安装可移动 ORB 程序。但是,ORB 团队强烈建议你使用 **ORB 启动器** 来获得更好的体验。 ORB 启动器是一个小的安装程序(小于 5MB),它可帮助你启动 ORB 程序,并获得更好,更流畅的体验。 + +让我们先安装 ORB 启动器。为此,[**下载 ORB 启动器**][1]。你可以手动下载 ORB 启动器的 ISO 并将其挂载到文件管理器上。或者在终端中运行以下任一命令来安装它: +``` +$ wget -O - https://www.orbital-apps.com/orb.sh | bash + +``` + +如果你没有 wget,请运行: +``` +$ curl https://www.orbital-apps.com/orb.sh | bash + +``` + +询问时输入 root 用户和密码。 + +就是这样。Orbit 启动器已安装并可以使用。 + +现在,进入 [**ORB 可移动程序下载页面**][2],并下载你选择的程序。在本教程中,我会下载 Firefox。 + +下载完后,进入下载位置并双击 ORB 程序来启动它。点击 Yes 确认。 + +![][4] + +Firefox ORB 程序能用了! + +![][5] + +同样,你可以立即下载并运行任何程序。 + +如果你不想使用 ORB 启动器,请将下载的 .orb 安装程序设置为可执行文件,然后双击它进行安装。不过,建议使用 ORB 启动器,它可让你在使用 ORB 程序时更轻松、更顺畅。 + +就我测试的 ORB 程序而言,它们打开即可使用。希望这篇文章有帮助。今天就是这些。祝你有美好的一天! + +干杯!! + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/orbitalapps-new-generation-ubuntu-linux-applications/ + +作者:[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.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 \ No newline at end of file From cd30204fef305b6c83f647cb519f94cf5390c9aa Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 21 May 2018 08:18:09 +0800 Subject: [PATCH 1011/1057] translating --- ...0180515 Protect your Fedora system against this DHCP flaw.md | 2 ++ sources/tech/20180517 How to find your IP address in Linux.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md b/sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md index 1cafe15786..15096207b7 100644 --- a/sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md +++ b/sources/tech/20180515 Protect your Fedora system against this DHCP flaw.md @@ -1,3 +1,5 @@ +translating---geekpi + Protect your Fedora system against this DHCP flaw ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/05/dhcp-cve-816x345.jpg) diff --git a/sources/tech/20180517 How to find your IP address in Linux.md b/sources/tech/20180517 How to find your IP address in Linux.md index 2634cf7d63..ff523101d2 100644 --- a/sources/tech/20180517 How to find your IP address in Linux.md +++ b/sources/tech/20180517 How to find your IP address in Linux.md @@ -1,3 +1,5 @@ +translating---geekpi + How to find your IP address in Linux ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/satellite_radio_location.jpg?itok=KJUKSB6x) From 8fdb2614bbf0caf7cd40a315dd595ec3fb9484f7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 08:24:47 +0800 Subject: [PATCH 1012/1057] PRF:20180328 Getting started with Jupyter Notebooks.md @MjSeven --- ... Getting started with Jupyter Notebooks.md | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/translated/tech/20180328 Getting started with Jupyter Notebooks.md b/translated/tech/20180328 Getting started with Jupyter Notebooks.md index 4f90a2007b..36e68b222d 100644 --- a/translated/tech/20180328 Getting started with Jupyter Notebooks.md +++ b/translated/tech/20180328 Getting started with Jupyter Notebooks.md @@ -1,36 +1,38 @@ Jupyter Notebooks 入门 ===== + +> 通过 Jupyter 使用实时代码、方程式和可视化及文本创建交互式的共享笔记本。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ) -自从 papyrus 发布以来,出版社一直在努力以吸引读者的方式来格式化数据。在数学、科学、和编程领域,这是一个特别的问题,设计良好的图表、插图和方程式可以成为帮助人们理解技术信息的关键。 -[Jupyter Notebook][1] 通过重新构想我们如何制作教学文本来解决这个问题。Jupyter (我在 2017 年 10 月在 [All Things Open][2] 上首次了解到)是一款开源应用程序,它使用户能够创建包含实时代码,方程式,可视化和文本的交互式共享笔记本。 +自从有了纸莎草纸以来,出版人们一直在努力以吸引读者的方式来格式化数据。尤其是在数学、科学、和编程领域,设计良好的图表、插图和方程式可以成为帮助人们理解技术信息的关键。 -Jupyter 从 [IPython 项目][3]发展而来,该项目具有交互式 shell 和基于浏览器的笔记本,支持代码,文本和数学表达式。Jupyter 支持超过 40 种编程语言,包括 Python,R 和 Julia,其代码可以导出为 HTML,LaTeX,PDF,图像和视频,或者作为 [IPyhton][4] 笔记本与其他用户共享。 +[Jupyter Notebook][1] 通过重新构想我们如何制作教学文本来解决这个问题。Jupyter (我在 2017 年 10 月在 [All Things Open][2] 上首次了解到)是一款开源应用程序,它使用户能够创建包含实时代码、方程式、可视化和文本的交互式共享笔记本。 -一个有趣的事实是:"Jupyter" 是 "Julia, Python, 和 R" 的缩写。 +Jupyter 从 [IPython 项目][3]发展而来,它是个具有交互式 shell 和基于浏览器的笔记本,支持代码、文本和数学表达式。Jupyter 支持超过 40 种编程语言,包括 Python、R 和 Julia,其代码可以导出为 HTML、LaTeX、PDF、图像和视频,或者作为 [IPyhton][4] 笔记本与其他用户共享。 -根据 Jupyter 项目网站介绍,它的一些用途包括“数据清理和转换,数值模拟,统计建模,数据可视化,机器学习等等”。科学机构正在使用 Jupyter Notebooks 来解释研究结果。代码可以来自实际数据,可以调整和重新调整以可视化成不同的结果和情景。通过这种方式,Jupyter Notebooks 已成为生动的文本和报告。 +> 一个有趣的事实是:“Jupyter” 是 “Julia、Python 和 R” 的缩写。 + +根据 Jupyter 项目网站介绍,它的一些用途包括“数据清理和转换,数值模拟,统计建模,数据可视化,机器学习等等”。科学机构正在使用 Jupyter Notebooks 来解释研究结果。代码可以来自实际数据,可以调整和重新调整以可视化成不同的结果和情景。通过这种方式,Jupyter Notebooks 变成了生动的文本和报告。 ### 安装并开始 Jupyter -Jupyter 软件是开源的,在[修改过的 BSD 许可证][5] 下获得许可,它可以[安装在 Linux,MacOS 或 Windows 上][6]。有很多种方法可以安装 Jupyter;我尝试在 Linux 和 MacOS 上安装 PIP 和 [Anaconda][7]。PIP 安装要求你的计算机上已经安装了 Python;Jupyter 推荐 Python 3。 +Jupyter 软件是开源的,其授权于[修改过的 BSD 许可证][5],它可以[安装在 Linux、MacOS 或 Windows 上][6]。有很多种方法可以安装 Jupyter;我在 Linux 和 MacOS 上试过 PIP 和 [Anaconda][7] 安装方式。PIP 安装要求你的计算机上已经安装了 Python;Jupyter 推荐 Python 3。 由于 Python 3 已经安装在我的电脑上,我通过在终端(在 Linux 或 Mac 上)运行以下命令来安装 Jupyter: ``` $ python3 -m pip install --upgrade pip - $ python3 -m pip install jupyter - ``` -在终端提示种输入以下命令立即启动应用程序: +在终端提示符输入以下命令立即启动应用程序: + ``` $ jupyter notebook - ``` -很快,我的浏览器打开并显示了我的 Jupyter Notebook 服务器在 `http://localhost:8888`。(支持的浏览器有 Google Chrome,Firefox 和 Safari) +很快,我的浏览器打开并显示了我在 `http://localhost:8888` 的 Jupyter Notebook 服务器。(支持的浏览器有 Google Chrome、Firefox 和 Safari) ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_1.png?itok=UyM1GuVG) @@ -38,18 +40,19 @@ $ jupyter notebook ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_2.png?itok=alDI432q) -一个带有一些默认值的新笔记本,它可以被改变(包括笔记本的名字),打开它。 +一个带有一些默认值的新笔记本,它可以被改变(包括笔记本的名字),已打开。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_3.png?itok=9zjG-5JC) -笔记本有两种不同的模式:命令和编辑。命令模式允许你添加或删除单元格。你可以通过按下 Escape 键进入命令模式,按 Enter 键或单击单元格进入编辑模式。 -单元格周围的绿色突出显示你处于编辑模式,蓝色突出显示你处于命令模式。以下笔记本处于命令模式并准备好执行单元中的 Python 代码。注意,我已将笔记本的名称更改为 First Notebook。 +笔记本有两种不同的模式:“命令模式”和“编辑模式”。命令模式允许你添加或删除单元格。你可以通过按下 `Escape` 键进入命令模式,按 `Enter` 键或单击单元格进入编辑模式。 + +单元格周围的绿色高亮显示你处于编辑模式,蓝色高亮显示你处于命令模式。以下笔记本处于命令模式并准备好执行单元中的 Python 代码。注意,我已将笔记本的名称更改为 “First Notebook”。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_4.png?itok=-QPxcuFX) ### 使用 Jupyter -Jupyter Notebooks 的强大之处在于除了能够输入代码之外,你还可以将 Markdown 与叙述性和解释性文本相结合。我想添加一个标题,所以我在代码上面添加了一个单元格,并在 Markdown 中输入了一个标题。当我按下 `Ctrl+Enter` 时,我的标题转换为 HTML。(译注:或者可以按下 Run 按钮。) +Jupyter Notebooks 的强大之处在于除了能够输入代码之外,你还可以用 Markdown 添加叙述性和解释性文本。我想添加一个标题,所以我在代码上面添加了一个单元格,并以 Markdown 输入了一个标题。当我按下 `Ctrl+Enter` 时,我的标题转换为 HTML。(LCTT 译注:或者可以按下 Run 按钮。) ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_5.png?itok=-sr9A8-W) @@ -57,24 +60,24 @@ Jupyter Notebooks 的强大之处在于除了能够输入代码之外,你还 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_6.png?itok=o_g38ECp) -我也可以利用 IPython 的 [line magic 和 cell magic][8] 命令。你可以通过在代码单元内附加 `%` 或 `%%` 符号来列出魔术命令。例如,`%lsmagic` 产生所有可用于 Jupyter notebooks 的魔法命令。 +我也可以利用 IPython 的 [line magic 和 cell magic][8] 命令。你可以通过在代码单元内附加 `%` 或 `%%` 符号来列出魔术命令。例如,`%lsmagic` 将输出所有可用于 Jupyter notebooks 的魔法命令。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/jupyter_7.png?itok=uit0PtND) -这些魔术命令的例子包括 `%pwd`,它输出当前工作目录(例如 `/Users/YourName`)和 `%ls`,它列出当前工作目录中的所有文件和子目录。另一个神奇命令显示从笔记本中的 `matplotlib` 生成的图表。`%%html` 将该单元格中的任何内容呈现为 HTML,这对嵌入视频和链接很有用,还有 JavaScript 和 Bash 的单元魔术命令。 +这些魔术命令的例子包括 `%pwd`——它输出当前工作目录(例如 `/Users/YourName`)和 `%ls`——它列出当前工作目录中的所有文件和子目录。另一个神奇命令显示从笔记本中的 `matplotlib` 生成的图表。`%%html` 将该单元格中的任何内容呈现为 HTML,这对嵌入视频和链接很有用,还有 JavaScript 和 Bash 的单元魔术命令。 -如果你需要更多关于使用 Jupyter Notebooks 和它的特性的信息,帮助部分是非常完整的。 +如果你需要更多关于使用 Jupyter Notebooks 和它的特性的信息,它的帮助部分是非常完整的。 -人们用许多有趣的方式使用 Jupyter Notebooks;你可以在这个 [gallery][9] 里找到一些很好的例子。你如何使用Jupyter笔记本?请在下面的评论中分享你的想法。 +人们用许多有趣的方式使用 Jupyter Notebooks;你可以在这个[展示栏目][9]里找到一些很好的例子。你如何使用 Jupyter 笔记本?请在下面的评论中分享你的想法。 -------------------------------------------------------------------------------- via: https://opensource.com/article/18/3/getting-started-jupyter-notebooks 作者:[Don Watkins][a] -译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From fd249b2540ff0ed26f96b0c76c119e5483b82c1d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 21 May 2018 08:25:11 +0800 Subject: [PATCH 1013/1057] PUB:20180328 Getting started with Jupyter Notebooks.md @MjSeven https://linux.cn/article-9664-1.html --- .../20180328 Getting started with Jupyter Notebooks.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180328 Getting started with Jupyter Notebooks.md (100%) diff --git a/translated/tech/20180328 Getting started with Jupyter Notebooks.md b/published/20180328 Getting started with Jupyter Notebooks.md similarity index 100% rename from translated/tech/20180328 Getting started with Jupyter Notebooks.md rename to published/20180328 Getting started with Jupyter Notebooks.md From 3db769b92aed718c796229ab796be4646a47098c Mon Sep 17 00:00:00 2001 From: Ezio Date: Mon, 21 May 2018 10:42:11 +0800 Subject: [PATCH 1014/1057] =?UTF-8?q?20180521-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180514 A year as Android Engineer.md | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 sources/talk/20180514 A year as Android Engineer.md diff --git a/sources/talk/20180514 A year as Android Engineer.md b/sources/talk/20180514 A year as Android Engineer.md new file mode 100644 index 0000000000..954ab91239 --- /dev/null +++ b/sources/talk/20180514 A year as Android Engineer.md @@ -0,0 +1,137 @@ +A year as Android Engineer +============================================================ + +![](https://cdn-images-1.medium.com/max/2000/1*tqshw1o4JZZlA1HW3Cki1Q.png) +>Awesome drawing by [Miquel Beltran][0] + +Two years ago I started my career in tech. I started as QA Tester and then transitioned into a developer role a year after. Not without a lot of effort and a lot of personal time invested. + +You can find that part of the story in this post about [how I switch careers from Biology to tech][1] and how I [learned Android for a year][2]. Today I want to talk about how I started my first role as Android developer, how I switched companies and how my first year as Android Engineer has been overall. + +### My first role + +My first role as Android developer started out just a year ago. The company I was working at provided me with the opportunity to transition from QA to Android developer by dedicating half of the time to each role. + +This transition was thanks to the time I invested learning Android on evenings and weekends. I went through the [Android Basics Nanodegree][3], the [Android Developer Nanodegree][4] and as well I got the [Google Developers Certification][5]. [That part of the story is explained in more detail here.][6] + +After two months I switched to full time when they hired another QA. Here's were all the challenges began! + +Transitioning someone into a developer role is a lot harder than just providing them with a laptop and a git account. And here I explain some of the roadblocks I got during that time: + +#### Lack of expectations + +The first problem I faced was not knowing the expectations that the company had on me. My thought was that they expected me to deliver since the very first day, probably not like my experienced colleagues, but deliver by doing small tasks. This feeling caused me a lot of pressure. By not having clear goals, I was constantly thinking I wasn't good enough and that I was an impostor. + +#### Lack of mentorship + +There was no concept of mentorship in the company and the environment didn’t allow us to work together. We barely did pair-programming, because there was always a deadline and the company wanted us to keep delivering. Luckily my colleagues were always willing to help! They sat with me to help me whenever I got stuck or asked for help. + +#### Lack of feedback + +I never got any feedback during that time. What was I doing well or bad? What could I improve? I didn't know since I didn’t have anyone whom to report. + +#### Lack of learning culture + +I think that in order to keep up to date we need to continue learning by reading blog posts, watching talks, attending conferences, trying new things, etc. The company didn’t offer learning hours during working time, which is unfortunately quite common as other devs told me. Without having learning time, I felt I wasn't entitled to spend even 10 minutes to read a blog post I found to be interesting and relevant for my job. + +The problem was not only the lack of an explicit learning time allowance, but also that when I requested it, it got denied. + +An example of that occurred when I finished my tasks for the sprint and we were already at the end of it, so I asked if I could spend the rest of the day learning Kotlin. This request got denied. + +Another case was when I requested to attend an Android conference, and then I was asked to take days from my paid time off. + +#### Impostor syndrome + +The lack of expectations, the lack of feedback, and the lack of learning culture in the company made the first 9 months of my developer career even more challenging. I have the feeling that it contributed to increase my internal impostors syndrome. + +One example of it was opening and reviewing pull requests. Sometimes I'd ask a colleague to check my code privately, rather than opening a pull request, to avoid showing my code to everyone. + +Other times, when I was reviewing, I would spend minutes staring the "approve" button, worried of approving something that another colleague would have considered wrong. + +And when I didn't agree on something, I was never speaking loud enough worried of a backslash due to my lack of knowledge. + +> Sometimes I’d ask a colleague to check my code privately […] to avoid showing my code to everyone. + +* * * + +### New company, new challenges + +Later on I got a new opportunity in my hands. I was invited to the hiring process for a Junior Android Engineer position at [Babbel][7] thanks to a friend who worked with me in the past. + +I met the team while volunteering in a local meet-up that was hosted at their offices. That helped me a lot when deciding to apply. I loved the company's motto: learning for all. Also everyone was very friendly and looked happy working there! But I didn't apply straight away, because why would I apply if I though that I wasn't good enough? + +Luckily my friend and my partner pushed me to do it. They gave me the strength I needed to send my CV. Shortly after I got into the interview process. It was fairly simple: I had to do a coding challenge in the form of a small app, and then later a technical interview with the team and team fit interview with the hiring manager. + +#### Hiring process + +I spent the weekend with the coding challenge and sent it right after on Monday. Soon after I got invited for an on-site interview. + +The technical interview was about the coding challenge itself, we talked about good and bad things on Android, why did I implemented things in a way, how could it be improved, etc. It followed a short team fit interview with the hiring manager, where we talked about challenges I faced, how I solved this problems, and so on. + +They offered me the job and I accepted the offer! + +On my first year working as Android developer, I spent 9 months in a company and the next 3 with my current employer. + +#### Learning environment + +One big change for me is having 1:1 meetings with my Engineering Manager every two weeks. That way, it's clear for me what are our expectations. + +We are getting constant feedback and ideas on what to improve and how to help and be helped. Beside the internal trainings they offer, I also have a weekly learning time allowance to learn anything I want. So far, I've been using it to improve my Kotlin and RxJava knowledge. + +We also do pair-programming almost daily. There's always paper and pens nearby my desk to sketch ideas. And I keep a second chair by my side so my colleagues can sit with me :-) + +However, I still struggle with the impostor syndrome. + +#### Still the Impostor syndrome + +I still struggle with it. For example, when doing pair-programming, if we reach a topic I don't quite understand, even when my colleagues have the patience to explain it to me many times, there are times I just can't get it. + +After the second or third time I start feeling a big pressure on my chest. How come I don't get it? Why is it so difficult for me to understand? This situation creates me anxiety. + +I realized I need to accept that I might not understand a given topic but that getting the idea is the first step! Sometimes we just require more time and practice so it finally "compiles in our brains" :-) + +For example, I used to struggle with Java interfaces vs. abstract classes, I just couldn't understand them completely, no matter how many examples I saw. But then I started using them, and even if I could not explain how they worked, I knew how and when to use them. + +#### Confidence + +The learning environment in my current company helps me in building confidence. Even if I've been asking a lot of questions, there's always room for more! + +Having less experience doesn't mean your opinions will be less valued. For example if a proposed solution seems too complex, I will challenge them to write it in a clearer way. Also, I provide a different set of experience and points of view, which has been helpful so far for polishing the app user experience. + +### To improve + +The engineer role isn't just coding, but rather a broad range of skills. I am still at the beginning of the journey, and on my way of mastering it, I want to focus on the following ideas: + +* Communication: as English isn't my first language, sometimes I struggle to transmit an idea, which is essential for my job. I can work on that by writing, reading and talking more. + +* Give constructive feedback: I want to give meaningful feedback to my colleagues so they can grow with me as well. + +* Be proud of my achievements: I need to create a list to track all kind of achievements, small or big, and my overall progress, so I can look back and feel good when I struggle. + +* Not being obsessed on what I don't know: hard to do when there's so many new things coming up, so keeping focused on the essentials, and what's required for my project in hand, is important. + +* Share more knowledge with my colleagues! That I'm a junior doesn't mean I don't have anything to share! I need to keep sharing articles and talks I find interesting. I know my colleagues appreciate that. + +* Be patient and constantly learn: keep learning as I am doing, but being more patient with myself. + +* Self-care: take breaks whenever needed and don't be hard with myself. Relaxing is also productive. + +-------------------------------------------------------------------------------- + +via: https://proandroiddev.com/a-year-as-android-engineer-55e2a428dfc8 + +作者:[Lara Martín][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://proandroiddev.com/@laramartin +[0]:https://medium.com/@Miqubel +[1]:https://medium.com/@laramartin/how-i-took-my-first-step-in-it-6e9233c4684d +[2]:https://medium.com/udacity/a-year-of-android-ffba9f3e40b6 +[3]:https://de.udacity.com/course/android-basics-nanodegree-by-google--nd803 +[4]:https://de.udacity.com/course/android-developer-nanodegree-by-google--nd801 +[5]:https://developers.google.com/training/certification/ +[6]:https://medium.com/udacity/a-year-of-android-ffba9f3e40b6 +[7]:http://babbel.com/ From 05df32c3d78430ac45c650c5e19821d6f3dd2733 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 21 May 2018 12:01:53 +0800 Subject: [PATCH 1015/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Starting=20user?= =?UTF-8?q?=20software=20in=20X?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180521 Starting user software in X.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sources/tech/20180521 Starting user software in X.md diff --git a/sources/tech/20180521 Starting user software in X.md b/sources/tech/20180521 Starting user software in X.md new file mode 100644 index 0000000000..cf4ae850f6 --- /dev/null +++ b/sources/tech/20180521 Starting user software in X.md @@ -0,0 +1,80 @@ +Starting user software in X +====== + +There are currently many ways of starting software when a user session starts. + +This is an attempt to collect a list of pointers to piece the big picture together. It's partial and some parts might be imprecise or incorrect, but it's a start, and I'm happy to keep it updated if I receive corrections. + +### x11-common + +`man xsession` + + * Started by the display manager for example, `/usr/share/lightdm/lightdm.conf.d/01_debian.conf` or `/etc/gdm3/Xsession` + * Debian specific + * Runs scripts in `/etc/X11/Xsession.d/` + * `/etc/X11/Xsession.d/40x11-common_xsessionrc` sources `~/.xsessionrc` which can do little more than set env vars, because it is run at the beginning of X session startup + * At the end, it starts the session manager (`gnome-session`, `xfce4-session`, and so on) + + + +### systemd --user + + * + * Started by `pam_systemd`, so it might not have a DISPLAY variable set in the environment yet + * Manages units in: + * `/usr/lib/systemd/user/` where units provided by installed packages belong. + * `~/.local/share/systemd/user/` where units of packages that have been installed in the home directory belong. + * `/etc/systemd/user/` where system-wide user units are placed by the system administrator. + * `~/.config/systemd/user/` where the users put their own units. + * A trick to start a systemd user unit when the X session has been set up and the DISPLAY variable is available, is to call `systemctl start` from a `.desktop` autostart file. + + + +### dbus activation + + * + * A user process making a dbus request can trigger starting a server program + * For systems debugging, is there a way of monitoring what services are getting dbus activated? + + + +### X session manager + + * + * Run by `x11-common`'s `Xsession.d` + * Runs freedesktop autostart .desktop files + * Runs Desktop Environment specific software + + + +### xdg autostart + + * + * Run by the session manager + * If `/etc/xdg/autostart/foo.desktop` and `~/.config/autostart/foo.desktop` exist then only the file `~/.config/autostart/foo.desktop` will be used because `~/.config/autostart/` is more important than `/etc/xdg/autostart/` + * Is there an ordering or is it all in parallel? + + + +### Other startup notes + +#### ~/.Xauthority + +To connect to an X server, a client needs to send a token from `~/.Xauthority`, which proves that they can read the user's provate data. + +`~/.Xauthority` contains a token generated by display manager and communicated to X at startup. + +To view its contents, use `xauth -i -f ~/.Xauthority list` + +-------------------------------------------------------------------------------- + +via: http://www.enricozini.org/blog/2018/debian/starting-user-software/ + +作者:[Enrico Zini][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]:http://www.enricozini.org/ From 289151437c273549e9ad5b7123def5464b6c9d22 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 21 May 2018 12:04:49 +0800 Subject: [PATCH 1016/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20You-Get=20?= =?UTF-8?q?=E2=80=93=20A=20CLI=20Downloader=20To=20Download=20Media=20From?= =?UTF-8?q?=2080+=20Websites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...der To Download Media From 80- Websites.md | 254 ++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md diff --git a/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md b/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md new file mode 100644 index 0000000000..ef004bc75d --- /dev/null +++ b/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md @@ -0,0 +1,254 @@ +You-Get – A CLI Downloader To Download Media From 80+ Websites +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/05/you-get-1-720x340.jpg) + +Most of you may used or heard about **Youtube-dl** , a command line program to download videos from youtube and other 100+ websites. I just stumbled upon a similar utility named **“You-Get”**. It is also a CLI downloader written in Python. It allows you to download images, audios and videos from popular websites like Youtube, Facebook, Twitter and a lot more. Currently, there are 80+ websites are supported. Click [**here**][1] to read the full list of supported sites. + +You-Get is not only a downloader, but also can stream the online videos in your media player. It even allows you to search for videos on google. Just pass the search term and You-Get will google it and download the most relevant videos. Another notable feature, it allows you to pause and resume the downloads. It is completely free, open source and cross-platform application that on Linux, Mac OS and Windows. + +### Install You-Get + +Make sure you have installed the following prerequisites. + ++ Python 3 ++ FFmpeg (strongly recommended) or Libav ++ (Optional) RTMPDump + +You-Get can be installed in many ways. The officially recommended method is using Pip package manager. If you haven’t installed PIP yet, refer the following link. + +[How To Manage Python Packages Using Pip][https://www.ostechnix.com/manage-python-packages-using-pip/] + +Please note that you must install Python 3 version of pip. + +Now, run the following command to install You-Get: +``` +$ pip3 install you-get + +``` + +You can upgrade You-Get to its latest version using command: +``` +$ pip3 install --upgrade you-get + +``` + +### Getting Started With You-Get + +The usage is pretty much same as Youtube-dl utility. + +**Download Videos** + +To download a video, just run: +``` +$ you-get https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +Sample output: +``` +site: YouTube +title: The Last of The Mohicans by Alexandro Querevalú +stream: + - itag: 22 + container: mp4 + quality: hd720 + size: 56.9 MiB (59654303 bytes) + # download-with: you-get --itag=22 [URL] + +Downloading The Last of The Mohicans by Alexandro Querevalú.mp4 ... + 100% ( 56.9/ 56.9MB) ├███████████████████████████████████████████████████████┤[1/1] 752 kB/s + +``` + +You may want to view the details of the video before downloading. You-Get can do that for using **“–info”** or **“-i”** flag. This option will get you all available quality and formats of the given video. +``` +$ you-get -i https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +Or, +``` +$ you-get -info https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +Sample output would be: +``` +site: YouTube +title: The Last of The Mohicans by Alexandro Querevalú +streams: # Available quality and codecs + [ DASH ] ____________________________________ + - itag: 137 + container: mp4 + quality: 1920x1080 + size: 101.9 MiB (106816582 bytes) + # download-with: you-get --itag=137 [URL] + +- itag: 248 + container: webm + quality: 1920x1080 + size: 90.3 MiB (94640185 bytes) + # download-with: you-get --itag=248 [URL] + +- itag: 136 + container: mp4 + quality: 1280x720 + size: 56.9 MiB (59672392 bytes) + # download-with: you-get --itag=136 [URL] + +- itag: 247 + container: webm + quality: 1280x720 + size: 52.6 MiB (55170859 bytes) + # download-with: you-get --itag=247 [URL] + +- itag: 135 + container: mp4 + quality: 854x480 + size: 32.2 MiB (33757856 bytes) + # download-with: you-get --itag=135 [URL] + +- itag: 244 + container: webm + quality: 854x480 + size: 28.0 MiB (29369484 bytes) + # download-with: you-get --itag=244 [URL] + +[ DEFAULT ] _________________________________ + - itag: 22 + container: mp4 + quality: hd720 + size: 56.9 MiB (59654303 bytes) + # download-with: you-get --itag=22 [URL] + +``` + +By default, You-Get will download the format marked with **DEFAULT**. If you don’t like that format or quality, you can pick any other format you like. Use the itag value given in the each format. +``` +$ you-get --itag=244 https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +**Download Audios** + +The following command will download an audio from soundcloud website. +``` +$ you-get 'https://soundcloud.com/uiceheidd/all-girls-are-same-999-prod-nick-mira' +Site: SoundCloud.com +Title: ALL GIRLS ARE THE SAME (PROD. NICK MIRA) +Type: MP3 (audio/mpeg) +Size: 2.58 MiB (2710046 Bytes) + +Downloading ALL GIRLS ARE THE SAME (PROD. NICK MIRA).mp3 ... + 100% ( 2.6/ 2.6MB) ├███████████████████████████████████████████████████████┤[1/1] 983 kB/s + +``` + +To view the details of the audio file, use **-i** flag. +``` +$ you-get -i 'https://soundcloud.com/uiceheidd/all-girls-are-same-999-prod-nick-mira' + +``` + +**Download Images** + +To download an image, run: +``` +$ you-get https://pixabay.com/en/mountain-crumpled-cyanus-montanus-3393209/ + +``` + +You-Get can also download all images from a web page. +``` +$ you-get https://www.ostechnix.com/pacvim-a-cli-game-to-learn-vim-commands/ + +``` + +**Search Videos** + +You-Get doesn’t even a valid URL. You can just pass a random search terms. You-Get will google it and download the most relevant video based on your search string. +``` +$ you-get 'Micheal Jackson' +Google Videos search: +Best matched result: +site: YouTube +title: Michael Jackson - Beat It (Official Video) +stream: + - itag: 43 + container: webm + quality: medium + size: 29.4 MiB (30792050 bytes) + # download-with: you-get --itag=43 [URL] + +Downloading Michael Jackson - Beat It (Official Video).webm ... + 100% ( 29.4/ 29.4MB) ├███████████████████████████████████████████████████████┤[1/1] 2 MB/s + +``` + +**Watch Videos** + +You-Get can able to stream the online videos in your media player or browser, just without ads or comment section. + +To watch videos in a media player, for example VLC, run the following command: +``` +$ you-get -p vlc https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +Or, +``` +$ you-get --player vlc https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +Similarly, to stream the videos in your browser, for example chromium, use: +``` +$ you-get -p chromium https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +![][3] + +As you can see in the above screenshot, there is no ads, comment section. Just a plain page with the video. + +**Set path and file name for downloaded videos** + +By default, the videos will be downloaded in the current working directory with default video titles. You can, of course, change them as per your liking using **–output-dir/-o** flag to set the path and **–output-filename/-O** to set the name of the downloaded file. +``` +$ you-get -o ~/Videos -O output.mp4 https://www.youtube.com/watch?v=HXaglTFJLMc + +``` + +**Pause and resume downloads** + +Press **CTRL+C** to cancel a download. A temporary **.download** file will be saved in the output directory. Next time you run you-get with the same arguments, the download process will resume from the last session. + +In case the file is completely downloaded, the temporary .download extension will be gone, and you-get will just skip the download. To enforce re-downloading, use the **–force/-f** option. + +For more details, refer the help section by running the following command. +``` +$ you-get --help + +``` + +And, that’s all for now. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/you-get-a-cli-downloader-to-download-media-from-80-websites/ + +作者:[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://you-get.org/#supported-sites +[3]:http://www.ostechnix.com/wp-content/uploads/2018/05/you-get.jpg From 9ac4d7dfbcefffbcf235ccd147c8c5bdabeea0a0 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 21 May 2018 12:06:09 +0800 Subject: [PATCH 1017/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Inst?= =?UTF-8?q?all=20Ncurses=20Library=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...How To Install Ncurses Library In Linux.md | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 sources/tech/20180518 How To Install Ncurses Library In Linux.md diff --git a/sources/tech/20180518 How To Install Ncurses Library In Linux.md b/sources/tech/20180518 How To Install Ncurses Library In Linux.md new file mode 100644 index 0000000000..8b0fe62c31 --- /dev/null +++ b/sources/tech/20180518 How To Install Ncurses Library In Linux.md @@ -0,0 +1,90 @@ +How To Install Ncurses Library In Linux +====== +![](https://www.ostechnix.com/wp-content/uploads/2018/05/install-ncurses-720x340.png) + +**GNU Ncurses** is a programming library that allows the users to write text-based user interfaces(TUI). Many text-based games are created using this library. One popular example is [**PacVim**][1], a CLI game to learn VIM commands. In this brief guide, I will be explaining how to install Ncurses library in Unix-like operating systems. + +### Install Ncurses Library In Linux + +Ncurses is available in the default repositories of most Linux distributions. For instance, you can install it on Arch-based systems using the following command: +``` +$ sudo pacman -S ncurses + +``` + +On RHEL, CentOS: +``` +$ sudo yum install ncurses-devel + +``` + +On Fedora 22 and newer versions: +``` +$ sudo dnf install ncurses-devel + +``` + +On Debian, Ubuntu, Linux Mint: +``` +$ sudo apt-get install libncurses5-dev libncursesw5-dev + +``` + +The GNU ncureses might be bit old in the default repositories. If you want a most recent stable version, you can compile and install from the source as shown below. + +Download the latest ncurses version from [**here**][2]. As of writing this guide, the latest version was 6.1. +``` +$ wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz + +``` + +Extract the tar file: +``` +$ tar xzf ncurses-6.1.tar.gz + +``` + +This will create a folder named ncurses-6.1 in the current directory. Cd to the directory: +``` +$ cd ncurses-6.1 + +$ ./configure --prefix=/opt/ncurses + +``` + +Finally, compile and install using the following commands: +``` +$ make + +$ sudo make install + +``` + +Verify the installation using command: +``` +$ ls -la /opt/ncurses + +``` + +That’s it. Ncurses have been installed on the Linux distribution. Go ahead and create your nice looking TUIs using Ncurses. + +More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-install-ncurses-library-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/pacvim-a-cli-game-to-learn-vim-commands/ +[2]:https://ftp.gnu.org/pub/gnu/ncurses/ From 072b9e8dc5ab09bf2e41effa5be2ac670af4694e Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 21 May 2018 12:08:10 +0800 Subject: [PATCH 1018/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Splicing=20the?= =?UTF-8?q?=20Cloud=20Native=20Stack,=20One=20Floor=20at=20a=20Time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Cloud Native Stack, One Floor at a Time.md | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 sources/tech/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md diff --git a/sources/tech/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md b/sources/tech/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md new file mode 100644 index 0000000000..6515b3e193 --- /dev/null +++ b/sources/tech/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md @@ -0,0 +1,174 @@ +Splicing the Cloud Native Stack, One Floor at a Time +====== +At Packet, our value (automated infrastructure) is super fundamental. As such, we spend an enormous amount of time looking up at the players and trends in all the ecosystems above us - as well as the very few below! + +It’s easy to get confused, or simply lose track, when swimming deep in the oceans of any ecosystem. I know this for a fact because when I started at Packet last year, my English degree from Bryn Mawr didn’t quite come with a Kubernetes certification. :) + +Due to its super fast evolution and massive impact, the cloud native ecosystem defies precedent. It seems that every time you blink, entirely new technologies (not to mention all of the associated logos) have become relevant...or at least interesting. Like many others, I’ve relied on the CNCF’s ubiquitous “[Cloud Native Landscape][1]” as a touchstone as I got to know the space. However, if there is one element that defines ecosystems, it is the people that contribute to and steer them. + +That’s why, when we were walking back to the office one cold December afternoon, we hit upon a creative way to explain “cloud native” to an investor, whose eyes were obviously glazing over as we talked about the nuances that distinguished Cilium from Aporeto, and why everything from CoreDNS and Spiffe to Digital Rebar and Fission were interesting in their own right. + +Looking up at our narrow 13 story office building in the shadow of the new World Trade Center, we hit on an idea that took us down an artistic rabbit hole: why not draw it? + +![][2] + +And thus began our journey to splice the Cloud Native Stack, one floor at a time. Let’s walk through it together and we can give you the “guaranteed to be outdated tomorrow” down low. + +[[View a High Resolution JPG][3]] or email us to request a copy. + +### Starting at the Very Bottom + +As we started to put pen to paper, we knew we wanted to shine a light on parts of the stack that we interact with on a daily basis, but that is largely invisible to users further up: hardware. And like any good secret lab investing in the next great (usually proprietary) thing, we thought the basement was the perfect spot. + +From the well established giants of the space like Intel, AMD and Huawei (rumor has it they employ nearly 80,000 engineers!), to more niche players like Mellanox, the hardware ecosystem is on fire. In fact, we may be entering a Golden Age of hardware, as billions of dollars are poured into upstarts hacking on new offloads, GPU’s, custom co-processors. + +The famous software trailblazer Alan Kay said over 25 years ago: “People who are really serious about software should make their own hardware.” Good call Alan! + +### The Cloud is About Capital + +As our CEO Zac Smith has told me many times: it’s all about the money. And not just about making it, but spending it! In the cloud, it takes billions of dollars of capital to make computers show up in data centers so that developers can consume them with software. In other words: + + +![][4] + +We thought the best place for “The Bank” (e.g. the lenders and investors that make this cloud fly) was the ground floor. So we transformed our lobby into the Banker’s Cafe, complete with a wheel of fortune for all of us out there playing the startup game. + +![][5] + +### The Ping and Power + +If the money is the grease, then the engine that consumes much of the fuel is the datacenter providers and the networks that connect them. We call them “power” and “ping”. + +From top of mind names like Equinix and edge upstarts like Vapor.io, to the “pipes” that Verizon, Crown Castle and others literally put in the ground (or on the ocean floor), this is a part of the stack that we all rely upon but rarely see in person. + +Since we spend a lot of time looking at datacenters and connectivity, one thing to note is that this space is changing quite rapidly, especially as 5G arrives in earnest and certain workloads start to depend on less centralized infrastructure. + +The edge is coming y’all! :-) + +![][6] + +### Hey, It's Infrastructure! + +Sitting on top of “ping” and “power” is the floor we lovingly call “processors”. This is where our magic happens - we turn the innovation and physical investments from down below into something at the end of an API. + +Since this is a NYC building, we kept the cloud providers here fairly NYC centric. That’s why you see Sammy the Shark (of Digital Ocean lineage) and a nod to Google over in the “meet me” room. + +As you’ll see, this scene is pretty physical. Racking and stacking, as it were. While we love our facilities manager in EWR1 (Michael Pedrazzini), we are working hard to remove as much of this manual labor as possible. PhD’s in cabling are hard to come by, after all. + +![][7] + +### Provisioning + +One floor up, layered on top of infrastructure, is provisioning. This is one of our favorite spots, which years ago we might have called “config management.” But now it’s all about immutable infrastructure and automation from the start: Terraform, Ansible, Quay.io and the like. You can tell that software is working its way down the stack, eh? + +Kelsey Hightower noted recently “it’s an exciting time to be in boring infrastructure.” I don’t think he meant the physical part (although we think it’s pretty dope), but as software continues to hack on all layers of the stack, you can guarantee a wild ride. + +![][8] + +### Operating Systems + +With provisioning in place, we move to the operating system layer. This is where we get to start poking fun at some of our favorite folks as well: note Brian Redbeard’s above average yoga pose. :) + +Packet offers eleven major operating systems for our clients to choose from, including some that you see in this illustration: Ubuntu, CoreOS, FreeBSD, Suse, and various Red Hat offerings. More and more, we see folks putting their opinion on this layer: from custom kernels and golden images of their favorite distros for immutable deploys, to projects like NixOS and LinuxKit. + +![][9] + +### Run Time + +We had to have fun with this, so we placed the runtime in the gym, with a championship match between CoreOS-sponsored rkt and Docker’s containerd. Either way the CNCF wins! + +We felt the fast-evolving storage ecosystem deserved some lockers. What’s fun about the storage aspect is the number of new players trying to conquer the challenging issue of persistence, as well as performance and flexibility. As they say: storage is just plain hard. + +![][10] + +### Orchestration + +The orchestration layer has been all about Kubernetes this past year, so we took one of its most famous evangelists (Kelsey Hightower) and featured him in this rather odd meetup scene. We have some major Nomad fans on our team, and there is just no way to consider the cloud native space without the impact of Docker and its toolset. + +While workload orchestration applications are fairly high up our stack, we see all kinds of evidence for these powerful tools are starting to look way down the stack to help users take advantage of GPU’s and other specialty hardware. Stay tuned - we’re in the early days of the container revolution! + +![][11] + +### Platforms + +This is one of our favorite layers of the stack, because there is so much craft in how each platform helps users accomplish what they really want to do (which, by the way, isn’t run containers but run applications!). From Rancher and Kontena, to Tectonic and Redshift to totally different approaches like Cycle.io and Flynn.io - we’re always thrilled to see how each of these projects servers users differently. + +The main takeaway: these platforms are helping to translate all of the various, fast-moving parts of the cloud native ecosystem to users. It’s great watching what they each come up with! + +![][12] + +### Security + +When it comes to security, it’s been a busy year! We tried to represent some of the more famous attacks and illustrate how various tools are trying to help protect us as workloads become highly distributed and portable (while at the same time, attackers become ever more resourceful). + +We see a strong movement towards trustless environments (see Aporeto) and low level security (Cilium), as well as tried and true approaches at the network level like Tigera. No matter your approach, it’s good to remember: This is definitely not fine. :0 + +![][13] + +### Apps + +How to represent the huge, vast, limitless ecosystem of applications? In this case, it was easy: stay close to NYC and pick our favorites. ;) From the Postgres “elephant in the room” and the Timescale clock, to the sneaky ScyllaDB trash and the chillin’ Travis dude - we had fun putting this slice together. + +One thing that surprised us: how few people noticed the guy taking a photocopy of his rear end. I guess it’s just not that common to have a photocopy machine anymore?!? + +![][14] + +### Observability + +As our workloads start moving all over the place, and the scale gets gigantic, there is nothing quite as comforting as a really good Grafana dashboard, or that handy Datadog agent. As complexity increases, the “SRE” generation are starting to rely ever more on alerting and other intelligence events to help us make sense of what’s going on, and work towards increasingly self-healing infrastructure and applications. + +It will be interesting to see what kind of logos make their way into this floor over the coming months and years...maybe some AI, blockchain, ML powered dashboards? :-) + +![][15] + +### Traffic Management + +People tend to think that the internet “just works” but in reality, we’re kind of surprised it works at all. I mean, a loose connection of disparate networks at massive scale - you have to be joking!? + +One reason it all sticks together is traffic management, DNS and the like. More and more, these players are helping to make the interest both faster and safer, as well as more resilient. We’re especially excited to see upstarts like Fly.io and NS1 competing against well established players, and watching the entire ecosystem improve as a result. Keep rockin’ it y’all! + +![][16] + +### Users + +What good is a technology stack if you don’t have fantastic users? Granted, they sit on top of a massive stack of innovation, but in the cloud native world they do more than just consume: they create and contribute. From massive contributions like Kubernetes to more incremental (but equally important) aspects, what we’re all a part of is really quite special. + +Many of the users lounging on our rooftop deck, like Ticketmaster and the New York Times, are not mere upstarts: these are organizations that have embraced a new way of deploying and managing their applications, and their own users are reaping the rewards. + +![][17] + +### Last but not Least, the Adult Supervision! + +In previous ecosystems, foundations have played a more passive “behind the scenes” role. Not the CNCF! Their goal of building a robust cloud native ecosystem has been supercharged by the incredible popularity of the movement - and they’ve not only caught up but led the way. + +From rock solid governance and a thoughtful group of projects, to outreach like the CNCF Landscape, CNCF Cross Cloud CI, Kubernetes Certification, and Speakers Bureau - the CNCF is way more than “just” the ever popular KubeCon + CloudNativeCon. + +-------------------------------------------------------------------------------- + +via: https://www.packet.net/blog/splicing-the-cloud-native-stack/ + +作者:[Zoe Allen][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.packet.net/about/zoe-allen/ +[1]:https://landscape.cncf.io/landscape=cloud +[2]:https://assets.packet.net/media/images/PIFg-30.vesey.street.ny.jpg +[3]:https://www.dropbox.com/s/ujxk3mw6qyhmway/Packet_Cloud_Native_Building_Stack.jpg?dl=0 +[4]:https://assets.packet.net/media/images/3vVx-there.is.no.cloud.jpg +[5]:https://assets.packet.net/media/images/X0b9-the.bank.jpg +[6]:https://assets.packet.net/media/images/2Etm-ping.and.power.jpg +[7]:https://assets.packet.net/media/images/C800-infrastructure.jpg +[8]:https://assets.packet.net/media/images/0V4O-provisioning.jpg +[9]:https://assets.packet.net/media/images/eMYp-operating.system.jpg +[10]:https://assets.packet.net/media/images/9BII-run.time.jpg +[11]:https://assets.packet.net/media/images/njak-orchestration.jpg +[12]:https://assets.packet.net/media/images/1QUS-platforms.jpg +[13]:https://assets.packet.net/media/images/TeS9-security.jpg +[14]:https://assets.packet.net/media/images/SFgF-apps.jpg +[15]:https://assets.packet.net/media/images/SXoj-observability.jpg +[16]:https://assets.packet.net/media/images/tKhf-traffic.management.jpg +[17]:https://assets.packet.net/media/images/7cpe-users.jpg From e93d5c0387e647e8d56f2cf0494a3c402ff89175 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 21 May 2018 13:02:16 +0800 Subject: [PATCH 1019/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What's=20a=20he?= =?UTF-8?q?ro=20without=20a=20villain=3F=20How=20to=20add=20one=20to=20you?= =?UTF-8?q?r=20Python=20game?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ain- How to add one to your Python game.md | 275 ++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md diff --git a/sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md b/sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md new file mode 100644 index 0000000000..3ca8fba288 --- /dev/null +++ b/sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md @@ -0,0 +1,275 @@ +What's a hero without a villain? How to add one to your Python game +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/game-dogs-chess-play-lead.png?itok=NAuhav4Z) + +In the previous articles in this series (see [part 1][1], [part 2][2], [part 3][3], and [part 4][4]), you learned how to use Pygame and Python to spawn a playable character in an as-yet empty video game world. But, what's a hero without a villain? + +It would make for a pretty boring game if you had no enemies, so in this article, you'll add an enemy to your game and construct a framework for building levels. + +It might seem strange to jump ahead to enemies when there's still more to be done to make the player sprite fully functional, but you've learned a lot already, and creating villains is very similar to creating a player sprite. So relax, use the knowledge you already have, and see what it takes to stir up some trouble. + +For this exercise, you can download some pre-built assets from [Open Game Art][5]. Here are some of the assets I use: + + ++ Inca tileset ++ Some invaders ++ Sprites, characters, objects, and effects + + +### Creating the enemy sprite + +Yes, whether you realize it or not, you basically already know how to implement enemies. The process is very similar to creating a player sprite: + + 1. Make a class so enemies can spawn. + 2. Create an `update` function so enemies can detect collisions. + 3. Create a `move` function so your enemy can roam around. + + + +Start with the class. Conceptually, it's mostly the same as your Player class. You set an image or series of images, and you set the sprite's starting position. + +Before continuing, make sure you have a graphic for your enemy, even if it's just a temporary one. Place the graphic in your game project's `images` directory (the same directory where you placed your player image). + +A game looks a lot better if everything alive is animated. Animating an enemy sprite is done the same way as animating a player sprite. For now, though, keep it simple, and use a non-animated sprite. + +At the top of the `objects` section of your code, create a class called Enemy with this code: +``` +class Enemy(pygame.sprite.Sprite): + +    ''' + +    Spawn an enemy + +    ''' + +    def __init__(self,x,y,img): + +        pygame.sprite.Sprite.__init__(self) + +        self.image = pygame.image.load(os.path.join('images',img)) + +        self.image.convert_alpha() + +        self.image.set_colorkey(ALPHA) + +        self.rect = self.image.get_rect() + +        self.rect.x = x + +        self.rect.y = y + +``` + +If you want to animate your enemy, do it the [same way][4] you animated your player. + +### Spawning an enemy + +You can make the class useful for spawning more than just one enemy by allowing yourself to tell the class which image to use for the sprite and where in the world the sprite should appear. This means you can use this same enemy class to generate any number of enemy sprites anywhere in the game world. All you have to do is make a call to the class, and tell it which image to use and the X and Y coordinates of your desired spawn point. + +Again, this is similar in principle to spawning a player sprite. In the `setup` section of your script, add this code: +``` +enemy   = Enemy(20,200,'yeti.png')# spawn enemy + +enemy_list = pygame.sprite.Group()   # create enemy group + +enemy_list.add(enemy)                # add enemy to group + +``` + +In that sample code, `20` is the X position and `200` is the Y position. You might need to adjust these numbers, depending on how big your enemy sprite is, but try to get it to spawn in a place so that you can reach it with your player sprite. `Yeti.png` is the image used for the enemy. + +Next, draw all enemies in the enemy group to the screen. Right now, you have only one enemy, but you can add more later if you want. As long as you add an enemy to the enemies group, it will be drawn to the screen during the main loop. The middle line is the new line you need to add: +``` +    player_list.draw(world) + +    enemy_list.draw(world)  # refresh enemies + +    pygame.display.flip() + +``` + +Launch your game. Your enemy appears in the game world at whatever X and Y coordinate you chose. + +### Level one + +Your game is in its infancy, but you will probably want to add another level. It's important to plan ahead when you program so your game can grow as you learn more about programming. Even though you don't even have one complete level yet, you should code as if you plan on having many levels. + +Think about what a "level" is. How do you know you are at a certain level in a game? + +You can think of a level as a collection of items. In a platformer, such as the one you are building here, a level consists of a specific arrangement of platforms, placement of enemies and loot, and so on. You can build a class that builds a level around your player. Eventually, when you create more than one level, you can use this class to generate the next level when your player reaches a specific goal. + +Move the code you wrote to create an enemy and its group into a new function that will be called along with each new level. It requires some modification so that each time you create a new level, you can create several enemies: +``` +class Level(): + +    def bad(lvl,eloc): + +        if lvl == 1: + +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + +            enemy_list = pygame.sprite.Group() # create enemy group + +            enemy_list.add(enemy)              # add enemy to group + +        if lvl == 2: + +            print("Level " + str(lvl) ) + + + +        return enemy_list + +``` + +The `return` statement ensures that when you use the `Level.bad` function, you're left with an `enemy_list` containing each enemy you defined. + +Since you are creating enemies as part of each level now, your `setup` section needs to change, too. Instead of creating an enemy, you must define where the enemy will spawn and what level it belongs to. +``` +eloc = [] + +eloc = [200,20] + +enemy_list = Level.bad( 1, eloc ) + +``` + +Run the game again to confirm your level is generating correctly. You should see your player, as usual, and the enemy you added in this chapter. + +### Hitting the enemy + +An enemy isn't much of an enemy if it has no effect on the player. It's common for enemies to cause damage when a player collides with them. + +Since you probably want to track the player's health, the collision check happens in the Player class rather than in the Enemy class. You can track the enemy's health, too, if you want. The logic and code are pretty much the same, but, for now, just track the player's health. + +To track player health, you must first establish a variable for the player's health. The first line in this code sample is for context, so add the second line to your Player class: +``` +        self.frame  = 0 + +        self.health = 10 + +``` + +In the `update` function of your Player class, add this code block: +``` +        hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + +        for enemy in hit_list: + +            self.health -= 1 + +            print(self.health) + +``` + +This code establishes a collision detector using the Pygame function `sprite.spritecollide`, called `enemy_hit`. This collision detector sends out a signal any time the hitbox of its parent sprite (the player sprite, where this detector has been created) touches the hitbox of any sprite in `enemy_list`. The `for` loop is triggered when such a signal is received and deducts a point from the player's health. + +Since this code appears in the `update` function of your player class and `update` is called in your main loop, Pygame checks for this collision once every clock tick. + +### Moving the enemy + +An enemy that stands still is useful if you want, for instance, spikes or traps that can harm your player, but the game is more of a challenge if the enemies move around a little. + +Unlike a player sprite, the enemy sprite is not controlled by the user. Its movements must be automated. + +Eventually, your game world will scroll, so how do you get an enemy to move back and forth within the game world when the game world itself is moving? + +You tell your enemy sprite to take, for example, 10 paces to the right, then 10 paces to the left. An enemy sprite can't count, so you have to create a variable to keep track of how many paces your enemy has moved and program your enemy to move either right or left depending on the value of your counting variable. + +First, create the counter variable in your Enemy class. Add the last line in this code sample: +``` +        self.rect = self.image.get_rect() + +        self.rect.x = x + +        self.rect.y = y + +        self.counter = 0 # counter variable + +``` + +Next, create a `move` function in your Enemy class. Use an if-else loop to create what is called an infinite loop: + + * Move right if the counter is on any number from 0 to 100. + * Move left if the counter is on any number from 100 to 200. + * Reset the counter back to 0 if the counter is greater than 200. + + + +An infinite loop has no end; it loops forever because nothing in the loop is ever untrue. The counter, in this case, is always either between 0 and 100 or 100 and 200, so the enemy sprite walks right to left and right to left forever. + +The actual numbers you use for how far the enemy will move in either direction depending on your screen size, and possibly, eventually, the size of the platform your enemy is walking on. Start small and work your way up as you get used to the results. Try this first: +``` +    def move(self): + +        ''' + +        enemy movement + +        ''' + +        distance = 80 + +        speed = 8 + + + +        if self.counter >= 0 and self.counter <= distance: + +            self.rect.x += speed + +        elif self.counter >= distance and self.counter <= distance*2: + +            self.rect.x -= speed + +        else: + +            self.counter = 0 + + + +        self.counter += 1 + +``` + +You can adjust the distance and speed as needed. + +Will this code work if you launch your game now? + +Of course not, and you probably know why. You must call the `move` function in your main loop. The first line in this sample code is for context, so add the last two lines: +``` +    enemy_list.draw(world) #refresh enemy + +    for e in enemy_list: + +        e.move() + +``` + +Launch your game and see what happens when you hit your enemy. You might have to adjust where the sprites spawn so that your player and your enemy sprite can collide. When they do collide, look in the console of [IDLE][6] or [Ninja-IDE][7] to see the health points being deducted. + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/yeti.png?itok=4_GsDGor) + +You may notice that health is deducted for every moment your player and enemy are touching. That's a problem, but it's a problem you'll solve later, after you've had more practice with Python. + +For now, try adding some more enemies. Remember to add each enemy to the `enemy_list`. As an exercise, see if you can think of how you can change how far different enemy sprites move. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/pygame-enemy + +作者:[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://opensource.com/article/17/10/python-101 +[2]:https://opensource.com/article/17/12/game-framework-python +[3]:https://opensource.com/article/17/12/game-python-add-a-player +[4]:https://opensource.com/article/17/12/game-python-moving-player +[5]:https://opengameart.org +[6]:https://docs.python.org/3/library/idle.html +[7]:http://ninja-ide.org/ From 255568c7cfb0baeaf1afc224851ffce83fc21984 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 21 May 2018 13:06:23 +0800 Subject: [PATCH 1020/1057] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Mana?= =?UTF-8?q?ge=20Fonts=20in=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180518 How to Manage Fonts in Linux.md | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 sources/tech/20180518 How to Manage Fonts in Linux.md diff --git a/sources/tech/20180518 How to Manage Fonts in Linux.md b/sources/tech/20180518 How to Manage Fonts in Linux.md new file mode 100644 index 0000000000..0faca7fa17 --- /dev/null +++ b/sources/tech/20180518 How to Manage Fonts in Linux.md @@ -0,0 +1,145 @@ +How to Manage Fonts in Linux +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fonts_main.jpg?itok=qcJks7-c) + +Not only do I write technical documentation, I write novels. And because I’m comfortable with tools like GIMP, I also create my own book covers (and do graphic design for a few clients). That artistic endeavor depends upon a lot of pieces falling into place, including fonts. + +Although font rendering has come a long way over the past few years, it continues to be an issue in Linux. If you compare the look of the same fonts on Linux vs. macOS, the difference is stark. This is especially true when you’re staring at a screen all day. But even though the rendering of fonts has yet to find perfection in Linux, one thing that the open source platform does well is allow users to easily manage their fonts. From selecting, adding, scaling, and adjusting, you can work with fonts fairly easily in Linux. + +Here, I’ll share some of the tips I’ve depended on over the years to help extend my “font-ability” in Linux. These tips will especially help those who undertake artistic endeavors on the open source platform. Because there are so many desktop interfaces available for Linux (each of which deal with fonts in a different way), when a desktop environment becomes central to the management of fonts, I’ll be focusing primarily on GNOME and KDE. + +With that said, let’s get to work. + +### Adding new fonts + +For the longest time, I have been a collector of fonts. Some might say I have a bit of an obsession. And since my early days of using Linux, I’ve always used the same process for adding fonts to my desktops. There are two ways to do this: + + * Make the fonts available on a per-user basis. + + * Make the fonts available system-wide. + + + + +Because my desktops never have other users (besides myself), I only ever work with fonts on a per-user basis. However, I will show you how to do both. First, let’s see how to add fonts on a per-user basis. The first thing you must do is find fonts. Both True Type Fonts (TTF) and Open Type Fonts (OTF) can be added. I add fonts manually. Do this is, I create a new hidden directory in ~/ called ~/.fonts. This can be done with the command: +``` +mkdir ~/.fonts + +``` + +With that folder created, I then move all of my TTF and OTF files into the directory. That’s it. Every font you add into that directory will now be available for use to your installed apps. But remember, those fonts will only be available to that one user. + +If you want to make that collection of fonts available to all, here’s what you do: + + 1. Open up a terminal window. + + 2. Change into the directory housing all of your fonts. + + 3. Copy all of those fonts with the commands sudo cp *.ttf *.TTF /usr/share/fonts/truetype/ and sudo cp *.otf *.OTF /usr/share/fonts/opentype + + + + +The next time a user logs in, they’ll have access to all those glorious fonts. + +### GUI Font Managers + +There are a few ways to manage your fonts in Linux, via GUI. How it’s done will depend on your desktop environment. Let’s examine KDE first. With the KDE that ships with Kubuntu 18.04, you’ll find a Font Management tool pre-installed. Open that tool and you can easily add, remove, enable, and disable fonts (as well as get information about all of the installed fonts. This tool also makes it easy for you to add and remove fonts for personal and system-wide use. Let’s say you want to add a particular font for personal usage. To do this, download your font and then open up the Font Management tool. In this tool (Figure 1), click on Personal Fonts and then click the + Add button. + + +![adding fonts][2] + +Figure 1: Adding personal fonts in KDE. + +[Used with permission][3] + +Navigate to the location of your fonts, select them, and click Open. Your fonts will then be added to the Personal section and are immediately available for you to use (Figure 2). + + +![KDE Font Manager][5] + +Figure 2: Fonts added with the KDE Font Manager. + +[Used with permission][3] + +To do the same thing in GNOME requires the installation of an application. Open up either GNOME Software or Ubuntu Software (depending upon the distribution you’re using) and search for Font Manager. Select Font Manager and then click the Install button. Once the software is installed, launch it from the desktop menu. With the tool open, let’s install fonts on a per-user basis. Here’s how: + + 1. Select User from the left pane (Figure 3). + + 2. Click the + button at the top of the window. + + 3. Navigate to and select the downloaded fonts. + + 4. Click Open. + + + + +![Adding fonts ][7] + +Figure 3: Adding fonts in GNOME. + +[Used with permission][3] + +### Tweaking fonts + +There are three concepts you must first understand: + + * **Font Hinting:** The use of mathematical instructions to adjust the display of a font outline so that it lines up with a rasterized grid. + + * **Anti-aliasing:** The technique used to add greater realism to a digital image by smoothing jagged edges on curved lines and diagonals. + + * **Scaling factor:** **** A scalable unit that allows you to multiple the point size of a font. So if you’re font is 12pt and you have an scaling factor of 1, the font size will be 12pt. If your scaling factor is 2, the font size will be 24pt. + + + + +Let’s say you’ve installed your fonts, but they don’t look quite as good as you’d like. How do you tweak the appearance of fonts? In both the KDE and GNOME desktops, you can make a few adjustments. One thing to consider with the tweaking of fonts is that taste is very much subjective. You might find yourself having to continually tweak until you get the fonts looking exactly how you like (dictated by your needs and particular taste). Let’s first look at KDE. + +Open up the System Settings tool and clock on Fonts. In this section, you can not only change various fonts, you can also enable and configure both anti-aliasing and enable font scaling factor (Figure 4). + + +![Configuring fonts][9] + +Figure 4: Configuring fonts in KDE. + +[Used with permission][3] + +To configure anti-aliasing, select Enabled from the drop-down and then click Configure. In the resulting window (Figure 5), you can configure an exclude range, sub-pixel rendering type, and hinting style. + +Once you’ve made your changes, click Apply. Restart any running applications and the new settings will take effect. + +To do this in GNOME, you have to have either use Font Manager or GNOME Tweaks installed. For this, GNOME Tweaks is the better tool. If you open the GNOME Dash and cannot find Tweaks installed, open GNOME Software (or Ubuntu Software), and install GNOME Tweaks. Once installed, open it and click on the Fonts section. Here you can configure hinting, anti-aliasing, and scaling factor (Figure 6). + +![Tweaking fonts][11] + +Figure 6: Tweaking fonts in GNOME. + +[Used with permission][3] + +### Make your fonts beautiful + +And that’s the gist of making your fonts look as beautiful as possible in Linux. You may not see a macOS-like rendering of fonts, but you can certainly improve the look. Finally, the fonts you choose will have a large impact on how things look. Make sure you’re installing clean, well-designed fonts; otherwise, you’re fighting a losing battle. + +Learn more about Linux through the free ["Introduction to Linux" ][12] course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/5/how-manage-fonts-linux + +作者:[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 +[2]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fonts_1.jpg?itok=7yTTe6o3 (adding fonts) +[3]:https://www.linux.com/licenses/category/used-permission +[5]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fonts_2.jpg?itok=_g0dyVYq (KDE Font Manager) +[7]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fonts_3.jpg?itok=8o884QKs (Adding fonts ) +[9]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fonts_4.jpg?itok=QJpPzFED (Configuring fonts) +[11]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fonts_6.jpg?itok=4cQeIW9C (Tweaking fonts) +[12]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 93ee73c1ab5ca40fea518f21dd43bc0523ff17f8 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 21 May 2018 16:27:52 +0800 Subject: [PATCH 1021/1057] submit tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md --- ...test Python3 Package On CentOS 6 System.md | 82 +++++++++---------- 1 file changed, 40 insertions(+), 42 deletions(-) rename {sources => translated}/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md (53%) diff --git a/sources/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md b/translated/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md similarity index 53% rename from sources/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md rename to translated/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md index 646b046015..984dbd3c31 100644 --- a/sources/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md +++ b/translated/tech/20180509 3 Methods To Install Latest Python3 Package On CentOS 6 System.md @@ -1,38 +1,36 @@ -pinewall translating - -3 Methods To Install Latest Python3 Package On CentOS 6 System +在 CentOS 6 系统上安装最新版 Python3 软件包的 3 种方法 ====== -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. +CentOS 克隆自 RHEL,无需付费即可使用。CentOS 是一个企业级标准的、前沿的操作系统,被超过 90% 的网络主机托管商采用,因为它提供了技术领先的服务器控制面板 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. +众所周知,RHEL 提供长期支持,出于稳定性考虑,不提供最新版本的软件包。 -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. +可供企业级 Linux 使用的第三方源有很多,但只有几个是 CentOS 社区推荐使用的,它们在很大程度上不修改基础软件包。 -They are usually well maintained and provide a substantial number of additional packages to CentOS. +这几个推荐的源维护的很好,为 CentOS 提供大量补充软件包。 -In this tutorial, we will teach you, how to install latest Python 3 package on CentOS 6 system. +在本教程中,我们将向你展示,如何在 CentOS 6 操作系统上安装最新版本的 Python 3 软件包。 -### Method-1 : Using Software Collections Repository (SCL) +### 方法 1:使用 Software Collections 源 (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. +SCL 源目前由 CentOS SIG 维护,除了重新编译构建 Red Hat 的 Software Collections 外,还额外提供一些它们自己的软件包。 -It contains newer versions of various programs that can be installed alongside existing older packages and invoked by using the scl command. +该源中包含不少程序的更高版本,可以在不改变原有旧版本程序包的情况下安装,使用时需要通过 scl 命令调用。 -Run the following command to install Software Collections Repository on CentOS +运行如下命令可以在 CentOS 上安装 SCL 源: ``` # yum install centos-release-scl ``` -Check the available python 3 version. +检查可用的 Python 3 版本: ``` # yum info rh-python35 Loaded plugins: fastestmirror, security @@ -53,49 +51,49 @@ Description : This is the main package for rh-python35 Software Collection. ``` -Run the below command to install latest available python 3 package from scl. +运行如下命令从 scl 源安装可用的最新版 python 3: ``` # yum install rh-python35 ``` -Run the below special scl command to enable the installed package version at the shell. +运行如下特殊的 scl 命令,在当前 shell 中启用安装的软件包: ``` # scl enable rh-python35 bash ``` -Run the below command to check installed python3 version. +运行如下命令检查安装的 python3 版本: ``` # python --version Python 3.5.1 ``` -Run the following command to get a list of SCL packages have been installed on system. +运行如下命令获取系统已安装的 SCL 软件包列表: ``` # scl -l rh-python35 ``` -### Method-2 : Using EPEL Repository (Extra Packages for Enterprise Linux) +### 方法 2:使用 EPEL 源 (Extra Packages for Enterprise Linux) -EPEL stands for Extra Packages for Enterprise Linux maintained by Fedora Special Interest Group. +EPEL 是 Extra Packages for Enterprise Linux 的缩写,该源由 Fedora SIG (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). +该 SIG 为企业级 Linux 创建、维护并管理一系列高品质补充软件包,受益的企业级 Linux 发行版包括但不限于红帽企业级 Linux (RHEL), CentOS, 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. +EPEL 通常基于 Fedora 对应代码提供软件包,不会与企业级 Linux 发行版中的基础软件包冲突或替换其中的软件包。 -**Suggested Read :** [Install / Enable EPEL Repository on RHEL, CentOS, Oracle Linux & Scientific Linux][1] +**推荐阅读:** [在 RHEL, CentOS, Oracle Linux 或 Scientific Linux 上安装启用 EPEL 源][1] -EPEL package is included in the CentOS Extras repository and enabled by default so, we can install this by running below command. +EPEL 软件包位于 CentOS 的 Extra 源中,已经默认启用,故我们只需运行如下命令即可: ``` # yum install epel-release ``` -Check the available python 3 version. +检查可用的 python 3 版本: ``` # yum --disablerepo="*" --enablerepo="epel" info python34 Loaded plugins: fastestmirror, security @@ -119,13 +117,13 @@ Description : Python 3 is a new version of the language that is incompatible wit ``` -Run the below command to install latest available python 3 package from EPEL repository. +运行如下命令从 EPEL 源安装可用的最新版 python 3 软件包: ``` # yum --disablerepo="*" --enablerepo="epel" install python34 ``` -By default this will not install matching pip & setuptools and we have to install by running below command. +默认情况下并不会安装 pip 和 setuptools,我们需要运行如下命令手动安装: ``` # curl -O https://bootstrap.pypa.io/get-pip.py % Total % Received % Xferd Average Speed Time Time Time Current @@ -146,28 +144,28 @@ Successfully installed pip-10.0.1 setuptools-39.1.0 wheel-0.31.0 ``` -Run the below command to check installed python3 version. +运行如下命令检查已安装的 python3 版本: ``` # python3 --version Python 3.4.5 ``` -### Method-3 : Using IUS Community Repository +### 方法 3:使用 IUS 社区源 -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 社区是 CentOS 社区批准的第三方 RPM 源,为企业级 Linux (RHEL 和 CentOS) 5, 6 和 7 版本提供最新上游版本的 PHP, Python, MySQL 等软件包。 -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. +IUS 社区源依赖于 EPEL 源,故我们需要先安装 EPEL 源,然后再安装 IUS 社区源。按照下面的步骤安装启用 EPEL 源和 IUS 社区源,利用该 RPM 系统安装软件包。 -**Suggested Read :** [Install / Enable IUS Community Repository on RHEL & CentOS][2] +**推荐阅读:** [在 RHEL 或 CentOS 上安装启用 IUS 社区源][2] -EPEL package is included in the CentOS Extras repository and enabled by default so, we can install this by running below command. +EPEL 软件包位于 CentOS 的 Extra 源中,已经默认启用,故我们只需运行如下命令即可: ``` # yum install epel-release ``` -Download IUS Community Repository Shell script +下载 IUS 社区源安装脚本: ``` # curl 'https://setup.ius.io/' -o setup-ius.sh % Total % Received % Xferd Average Speed Time Time Time Current @@ -176,13 +174,13 @@ Download IUS Community Repository Shell script ``` -Install/Enable IUS Community Repository. +安装启用 IUS 社区源: ``` # sh setup-ius.sh ``` -Check the available python 3 version. +检查可用的 python 3 版本: ``` # yum --enablerepo=ius info python36u Loaded plugins: fastestmirror, security @@ -220,13 +218,13 @@ Description : Python is an accessible, high-level, dynamically typed, interprete ``` -Run the below command to install latest available python 3 package from IUS repository. +运行如下命令从 IUS 源安装最新可用版本的 python 3 软件包: ``` # yum --enablerepo=ius install python36u ``` -Run the below command to check installed python3 version. +运行如下命令检查已安装的 python3 版本: ``` # python3.6 --version Python 3.6.5 @@ -239,7 +237,7 @@ via: https://www.2daygeek.com/3-methods-to-install-latest-python3-package-on-cen 作者:[PRAKASH SUBRAMANIAN][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[pinewall](https://github.com/pinewall) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0e224a0eeef1346bb8e4fa9307e5c0f56874af99 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 21 May 2018 16:33:36 +0800 Subject: [PATCH 1022/1057] add translation tag --- sources/tech/20180510 Creating small containers with Buildah.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180510 Creating small containers with Buildah.md b/sources/tech/20180510 Creating small containers with Buildah.md index 4fef005908..9b8a550e7e 100644 --- a/sources/tech/20180510 Creating small containers with Buildah.md +++ b/sources/tech/20180510 Creating small containers with Buildah.md @@ -1,3 +1,5 @@ +pinewall translating + 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) From 4b5075bfce9825dfbb57f74172c53888c2214a6d Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 21 May 2018 16:39:40 +0800 Subject: [PATCH 1023/1057] add translation tag --- ...Get more done at the Linux command line with GNU Parallel.md | 2 ++ 1 file changed, 2 insertions(+) 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 index 72aceaacb8..6bce568f3d 100644 --- 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 @@ -1,3 +1,5 @@ +pinewall translating + Get more done at the Linux command line with GNU Parallel ====== From 0b7cd98d3d6cfc126aa53c730734925454e50ead Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 21 May 2018 23:03:59 +0800 Subject: [PATCH 1024/1057] Delete 20180326 How To Archive Files And Directories In Linux.md --- ... Archive Files And Directories In Linux.md | 284 ------------------ 1 file changed, 284 deletions(-) delete mode 100644 sources/tech/20180326 How To Archive Files And Directories In Linux.md diff --git a/sources/tech/20180326 How To Archive Files And Directories In Linux.md b/sources/tech/20180326 How To Archive Files And Directories In Linux.md deleted file mode 100644 index 51da682582..0000000000 --- a/sources/tech/20180326 How To Archive Files And Directories In Linux.md +++ /dev/null @@ -1,284 +0,0 @@ -Translating by MjSeven - - -How To Archive Files And Directories In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/03/Archive-Files-And-Directories-In-Linux-720x340.png) -In our previous tutorial, we discussed how to [**compress and decompress files using gzip and bzip2**][1] programs. In this tutorial, we are going to learn how to archive files in Linux. Aren’t archiving and compressing same? Some of you might often think these terms refers the same meaning. But, both are completely different. Archiving is the process of the combining multiple files and directories (same or different size) into one file. On the other hand, compressing is the process of reducing the size of of a file(s) or directory(s). Archiving is often used as part of the system backups or when moving the data from one system to another. Hope you understand the difference between archiving and compressing. Now, let us get into the topic. - -### Archive files and directories - -The most common programs to archive files and directories are; - - 1. tar - 2. zip - - - -This is a big topic. So, I am going to publish this article in two parts. In the first part, we will see how to archive files and directories using Tar command. - -##### Archive files and directories using Tar command - -**Tar** is an Unix command which stands for **T** ape **A** rchive. It is used to combine or store multiple files (same or different size) into a single file. There are 4 main operating modes in tar utility. - - 1. **c** – Create an archive from a file(s) or directory(s). - 2. **x** – Extract an archive. - 3. **r** – Append files to the end of an archive. - 4. **t** – List the contents of the archive. - - - -For complete list of modes, refer the man pages. - -**Create a new archive** - -For the purpose of this guide, I will be using a folder named **ostechnix** that contains three different type of files. -``` -$ ls ostechnix/ -file.odt image.png song.mp3 - -``` - -Now, let us create a new tar archive of the the directory ostechnix. -``` -$ tar cf ostechnix.tar ostechnix/ - -``` - -Here, **c** flag refers create new archive and **f** refers the file name. - -Similarly, to create an archive from a set of files in the current working directory, use this command: -``` -$ tar cf archive.tar file1 file2 file 3 - -``` - -**Extract archives** - -To extract an archive in the current directory, simply do: -``` -$ tar xf ostechnix.tar - -``` - -We can also extract the archive in a different directory using **C** flag(capital c). For example, the following command extracts the given archive file in **Downloads** directory. -``` -$ tar xf ostechnix.tar -C Downloads/ - -``` - -Alternatively, go to the Downloads folder and extract the archive inside it like below. -``` -$ cd Downloads/ - -$ tar xf ../ostechnix.tar - -``` - -Some times you may want to extract files of a specific type. For example, the following command extracts the “.png” type files. -``` -$ tar xf ostechnix.tar --wildcards "*.png" - -``` - -**Create gzipped and bzipped archives** - -By default, Tar creates the archive file ends with **.tar**. Also, tar command can be used in conjunction with the compression utilities **gzip** and **bzip2**. The files ends with **.tar** extensions refer the plain tar archive, the files ends with **tar.gz** or **.tgz** refers a **gzipped** archive, and the tar files ends with **tar.bz2** or **.tbz** refers **bzipped** archive, respectively. - -First, let us **create a gzipped** archive: -``` -$ tar czf ostechnix.tar.gz ostechnix/ - -``` - -Or, -``` -$ tar czf ostechnix.tgz ostechnix/ - -``` - -Here, we use **z** flag to compress the archive using gzip compression method. - -You can use **v** flag to view the progress while creating the archive. -``` -$ tar czvf ostechnix.tar.gz ostechnix/ -ostechnix/ -ostechnix/file.odt -ostechnix/image.png -ostechnix/song.mp3 - -``` - -Here, **v** refers verbose. - -To create gzipped archive from a list of files: -``` -$ tar czf archive.tgz file1 file2 file3 - -``` - -To extract the gzipped archive in the current directory, use: -``` -$ tar xzf ostechnix.tgz - -``` - -To extract the archive in a different folder, use -C flag. -``` -$ tar xzf ostechnix.tgz -C Downloads/ - -``` - -Now, let us create **bzipped archive**. - -To do so, use **j** flag like below. - -Create an archive of a directory: -``` -$ tar cjf ostechnix.tar.bz2 ostechnix/ - -``` - -Or, -``` -$ tar cjf ostechnix.tbz ostechnix/ - -``` - -Create archive from list of files: -``` -$ tar cjf archive.tar.bz2 file1 file2 file3 - -``` - -Or, -``` -$ tar cjf archive.tbz file1 file2 file3 - -``` - -To display the progress, use **v** flag. - -Now, let us extract bzipped archive in the current directory. To do so, we do: -``` -$ tar xjf ostechnix.tar.bz2 - -``` - -Or, extract the archive to some other directory: -``` -$ tar xjf ostechnix.tar.bz2 -C Downloads - -``` - -**Create archive of multiple directories and/or files at a time** - -This is another coolest feature of tar command. To create an gzipped archive of multiple directories or files at once, use this command: -``` -$ tar czvf ostechnix.tgz Downloads/ Documents/ ostechnix/file.odt - -``` - -The above command will create an archive of **Downloads** , **Documents** directories and **file.odt** file in **ostechnix** directory and save the archive in the current working directory. - -**Exclude directories and/or files from while creating an archive** - -This is quite useful when backing up your data. You can exclude the non-important files or directories from your backup. This is where **–exclude** switch comes in help. For example, you want to create an archive of your /home directory, but exclude Downloads, Documents, Pictures, Music directories. - -This is how we do it. -``` -$ tar czvf ostechnix.tgz /home/sk --exclude=/home/sk/Downloads --exclude=/home/sk/Documents --exclude=/home/sk/Pictures --exclude=/home/sk/Music - -``` - -The above command will create an gzipped archive of my $HOME directory, excluding Downloads, Documents, Pictures and Music folders. To create bzipped archive, replace **z** with **j** and use the extension .bz2 in the above example. - -**List contents of archive files without extracting them** - -To list the contents of an archive file, we use **t** flag. -``` -$ tar tf ostechnix.tar -ostechnix/ -ostechnix/file.odt -ostechnix/image.png -ostechnix/song.mp3 - -``` - -To view the verbose output, use **v** flag. -``` -$ tar tvf ostechnix.tar -drwxr-xr-x sk/users 0 2018-03-26 19:52 ostechnix/ --rw-r--r-- sk/users 9942 2018-03-24 13:49 ostechnix/file.odt --rw-r--r-- sk/users 36013 2015-09-30 11:52 ostechnix/image.png --rw-r--r-- sk/users 112383 2018-02-22 14:35 ostechnix/song.mp3 - -``` - -**Append files to existing archives** - -Files or directories can be added/updated to the existing archives using **r** flag. Take a look at the following command. -``` -$ tar rf ostechnix.tar ostechnix/ sk/ example.txt - -``` - -The above command will add the directory named **sk** and a file named **example.txt** to ostechnix.tar archive. - -You can verify if the files are added or not using command: -``` -$ tar tvf ostechnix.tar -drwxr-xr-x sk/users 0 2018-03-26 19:52 ostechnix/ --rw-r--r-- sk/users 9942 2018-03-24 13:49 ostechnix/file.odt --rw-r--r-- sk/users 36013 2015-09-30 11:52 ostechnix/image.png --rw-r--r-- sk/users 112383 2018-02-22 14:35 ostechnix/song.mp3 -drwxr-xr-x sk/users 0 2018-03-26 19:52 sk/ --rw-r--r-- sk/users 0 2018-03-26 19:39 sk/linux.txt --rw-r--r-- sk/users 0 2018-03-26 19:56 example.txt - -``` - -##### **TL;DR** - -**Create tar archives:** - - * **Plain tar archive:** tar -cf archive.tar file1 file2 file3 - * **Gzipped tar archive:** tar -czf archive.tgz file1 file2 file3 - * **Bzipped tar archive:** tar -cjf archive.tbz file1 file2 file3 - - - -**Extract tar archives:** - - * **Plain tar archive:** tar -xf archive.tar - * **Gzipped tar archive:** tar -xzf archive.tgz - * **Bzipped tar archive:** tar -xjf archive.tbz - - - -We just have covered the basic usage of tar command. It is enough to get started with tar command. However, if you to know more details, refer the man pages. -``` -$ man tar - -``` - -And, that’s all for now. In the next part, we will see how to archives files and directories using Zip utility. - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-archive-files-and-directories-in-linux-part-1/ - -作者:[SK][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://www.ostechnix.com/author/sk/ -[1]:https://www.ostechnix.com/how-to-compress-and-decompress-files-in-linux/ From 6e0465ac0732c8f95b2c1e77595128a83276a360 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Mon, 21 May 2018 23:09:30 +0800 Subject: [PATCH 1025/1057] Create 20180326 How To Archive Files And Directories In Linux.md --- ... Archive Files And Directories In Linux.md | 240 ++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 translated/tech/20180326 How To Archive Files And Directories In Linux.md diff --git a/translated/tech/20180326 How To Archive Files And Directories In Linux.md b/translated/tech/20180326 How To Archive Files And Directories In Linux.md new file mode 100644 index 0000000000..0c1c211b31 --- /dev/null +++ b/translated/tech/20180326 How To Archive Files And Directories In Linux.md @@ -0,0 +1,240 @@ +在 Linux 中如何归档文件和目录 +===== +![](https://www.ostechnix.com/wp-content/uploads/2018/03/Archive-Files-And-Directories-In-Linux-720x340.png) +在我们之前的教程中,我们讨论了如何[使用 gzip 和 bzip2 压缩和解压缩文件][1]。在本教程中,我们将学习如何在 Linux 归档文件。归档和压缩有什么不同吗?你们中的一些人可能经常认为这些术语有相同的含义。但是,这两者完全不同。归档是将多个文件和目录(相同或不同大小)组合成一个文件的过程。另一方面,压缩是减小文件或目录大小的过程。归档通常用作系统备份的一部分,或者将数据从一个系统移至另一个系统时。希望你了解归档和压缩之间的区别。现在,让我们进入主题。 + +### 归档文件和目录 + +归档文件和目录最常见的程序是: + 1. tar + 2. zip + +这是一个很大的话题,所以,我将分两部分发表这篇文章。在第一部分中,我们将看到如何使用 tar 命令来归档文件和目录。 + +##### 使用 tar 命令归档文件和目录 + +**Tar** 是一个 Unix 命令,代表 **T**ape **A**rchive(这里我将其翻译为 磁带归档,希望校正者修正以下)。它用于将多个文件(相同或不同大小)组合或存储到一个文件中。在 tar 实用程序中有 4 种主要的操作模式。 + + 1. **c** – 从文件或目录中建立归档 + 2. **x** – 提取归档 + 3. **r** – 将文件追加到归档 + 4. **t** – 列出归档的内容 + +有关完整的模式列表,参阅 man 手册页。 + +**创建一个新的归档** + +为了本指南,我将使用名为 **ostechnix** 的文件夹,其中包含三种不同类型的文件。 +``` +$ ls ostechnix/ +file.odt image.png song.mp3 +``` + +现在,让我们为 ostechnix 目录创建一个新的 tar 归档。 +``` +$ tar cf ostechnix.tar ostechnix/ +``` + +这里,**c**标志指的是创建新的归档,**f** 是指定归档文件。 + +同样,对当前工作目录中的一组文件创建归档文件,使用以下命令: +``` +$ tar cf archive.tar file1 file2 file 3 +``` + +**提取归档** + +要在当前目录中提取归档文件,只需执行以下操作: +``` +$ tar xf ostechnix.tar +``` + +我们还可以使用 **C** 标志(大写字母 C)将归档提取到不同的目录中。例如,以下命令在 **Downloads** 目录中提取给定的归档文件。 +``` +$ tar xf ostechnix.tar -C Downloads/ +``` + +或者,转到 Downloads 文件夹并像下面一样提取其中的归档。 +``` +$ cd Downloads/ + +$ tar xf ../ostechnix.tar +``` + +有时,你可能想要提取特定类型的文件。例如,以下命令提取 “.png” 类型的文件。 +``` +$ tar xf ostechnix.tar --wildcards "*.png" +``` + +**创建 gzip 和 bzip 格式的压缩归档** + +默认情况下,tar 创建归档文件以 **.tar** 结尾。另外,tar 命令可以与压缩实用程序 **gzip** 和 **bzip** 结合使用。文件结尾以 **.tar** 为扩展名使用普通 tar 归档文件,文件以 **tar.gz** 或 **.tgz** 结尾使用 **gzip** 归档并压缩文件,tar 文件以 **tar.bz2** 或 **.tbz** 结尾使用 **bzip** 归档并压缩。 + +首先,让我们来**创建一个 gzip 归档**: +``` +$ tar czf ostechnix.tar.gz ostechnix/ +``` + +或者 +``` +$ tar czf ostechnix.tgz ostechnix/ +``` + +这里,我们使用 **z** 标志来使用 gzip 压缩方法压缩归档文件。 + +你可以使用 **v** 标志在创建归档时查看进度。 +``` +$ tar czvf ostechnix.tar.gz ostechnix/ +ostechnix/ +ostechnix/file.odt +ostechnix/image.png +ostechnix/song.mp3 +``` + +这里,**v** 指显示进度。 + +从一个文件列表创建 gzip 归档文件: +``` +$ tar czf archive.tgz file1 file2 file3 +``` + +要提取当前目录中的 gzip 归档文件,使用: +``` +$ tar xzf ostechnix.tgz +``` + +要提取其他文件夹中的归档,使用 -C 标志: +``` +$ tar xzf ostechnix.tgz -C Downloads/ +``` + +现在,让我们创建 **bzip 归档**。为此,请使用下面的 **j** 标志。 + +创建一个目录的归档: + +``` +$ tar cjf ostechnix.tar.bz2 ostechnix/ +``` +或 +``` +$ tar cjf ostechnix.tbz ostechnix/ +``` + +从一个列表文件中创建归档: +``` +$ tar cjf archive.tar.bz2 file1 file2 file3 +``` + +或 +``` +$ tar cjf archive.tbz file1 file2 file3 +``` + +为了显示进度,使用 **v** 标志。 + +现在,在当前目录下,让我们提取一个 bzip 归档。这样做: +``` +$ tar xjf ostechnix.tar.bz2 +``` + +或者,提取归档文件到其他目录: +``` +$ tar xjf ostechnix.tar.bz2 -C Downloads +``` + +**一次创建多个目录和/或文件的归档** + +这是 tar 命令的另一个最酷的功能。要一次创建多个目录或文件的 gzip 归档文件,使用以下文件: +``` +$ tar czvf ostechnix.tgz Downloads/ Documents/ ostechnix/file.odt +``` + +上述命令创建 **Downloads**, **Documents** 目录和 **ostechnix** 目录下的 **file.odt** 文件的归档,并将归档保存在当前工作目录中。 + +**在创建归档时跳过目录和/或文件** + +这在备份数据时非常有用。你可以在备份中排除不重要的文件或目录,这是 **–exclude** 选项所能帮助的。例如你想要创建 /home 目录的归档,但不希望包括 Downloads, Documents, Pictures, Music 这些目录。 + +这是我们的做法: +``` +$ tar czvf ostechnix.tgz /home/sk --exclude=/home/sk/Downloads --exclude=/home/sk/Documents --exclude=/home/sk/Pictures --exclude=/home/sk/Music +``` + +上述命令将对我的 $HOME 目录创建一个 gzip 归档,其中不包括 Downloads, Documents, Pictures 和 Music 目录。要创建 bzip 归档,将 **z** 替换为 **j**,并在上例中使用扩展名 .bz2。 + +**列出归档文件但不提取它们** + +要列出归档文件的内容,我们使用 **t** 标志。 +``` +$ tar tf ostechnix.tar +ostechnix/ +ostechnix/file.odt +ostechnix/image.png +ostechnix/song.mp3 +``` + +要查看详细输出,使用 **v** 标志。 +``` +$ tar tvf ostechnix.tar +drwxr-xr-x sk/users 0 2018-03-26 19:52 ostechnix/ +-rw-r--r-- sk/users 9942 2018-03-24 13:49 ostechnix/file.odt +-rw-r--r-- sk/users 36013 2015-09-30 11:52 ostechnix/image.png +-rw-r--r-- sk/users 112383 2018-02-22 14:35 ostechnix/song.mp3 +``` + +**追加文件到归档** + +文件或目录可以使用 **r** 标志添加/更新到现有的归档。看看下面的命令: +``` +$ tar rf ostechnix.tar ostechnix/ sk/ example.txt +``` + +上面的命令会将名为 **sk** 的目录和名为 **exmple.txt** 添加到 ostechnix.tar 归档文件中。 + +你可以使用以下命令验证文件是否已添加: +``` +$ tar tvf ostechnix.tar +drwxr-xr-x sk/users 0 2018-03-26 19:52 ostechnix/ +-rw-r--r-- sk/users 9942 2018-03-24 13:49 ostechnix/file.odt +-rw-r--r-- sk/users 36013 2015-09-30 11:52 ostechnix/image.png +-rw-r--r-- sk/users 112383 2018-02-22 14:35 ostechnix/song.mp3 +drwxr-xr-x sk/users 0 2018-03-26 19:52 sk/ +-rw-r--r-- sk/users 0 2018-03-26 19:39 sk/linux.txt +-rw-r--r-- sk/users 0 2018-03-26 19:56 example.txt +``` + +##### **TL;DR** + +**创建 tar 归档:** + * **普通 tar 归档:** tar -cf archive.tar file1 file2 file3 + * **Gzip tar 归档:** tar -czf archive.tgz file1 file2 file3 + * **Bzip tar 归档:** tar -cjf archive.tbz file1 file2 file3 + +**提取 tar 归档:** + * **普通 tar 归档:** tar -xf archive.tar + * **Gzip tar 归档:** tar -xzf archive.tgz + * **Bzip tar 归档:** tar -xjf archive.tbz + +我们只介绍了 tar 命令的基本用法,这些对于开始使用 tar 命令足够了。但是,如果你想了解更多详细信息,参阅 man 手册页。 +``` +$ man tar + +``` + +好吧,这就是全部了。在下一部分中,我们将看到如何使用 Zip 实用程序来归档文件和目录。 + +干杯! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-archive-files-and-directories-in-linux-part-1/ + +作者:[SK][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/how-to-compress-and-decompress-files-in-linux/ From ca8c4876e4cce4431ba5ca7bbf661a38053db262 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 22 May 2018 08:40:22 +0800 Subject: [PATCH 1026/1057] translated --- ...for creators of openly licensed content.md | 49 ------------------- ...for creators of openly licensed content.md | 47 ++++++++++++++++++ 2 files changed, 47 insertions(+), 49 deletions(-) delete mode 100644 sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md create mode 100644 translated/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 deleted file mode 100644 index f08c81b10e..0000000000 --- a/sources/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md +++ /dev/null @@ -1,49 +0,0 @@ -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) - -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 diff --git a/translated/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md b/translated/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md new file mode 100644 index 0000000000..4fd5070aed --- /dev/null +++ b/translated/tech/20180514 LikeCoin, a cryptocurrency for creators of openly licensed content.md @@ -0,0 +1,47 @@ +LikeCoin,一种给创作者的开放内容许可的加密货币 +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_whitehurst_money.png?itok=ls-SOzM0) + +传统观点表明,作家、摄影师、艺术家和其他创作者在 Creative Commons 和其他开放许可下免费共享内容的不会得到报酬。这意味着大多数独立创作者无法通过在互联网上发布他们的作品来赚钱。输入 [LikeCoin][1]:一个新的开源项目,旨在制定这个惯例,艺术家经常为了分发而不得不妥协或牺牲,这是过去的事情。 + +LikeCoin 协议旨在通过创意内容获利,因此创作者可以专注于创造出色的内容而不是出售。 + +协议同样基于去中心化技术,它可以跟踪何时使用内容,并使用 LikeCoin,一种 [Ethereum ERC-20][2] 加密货币令牌奖励其创作者。它通过“创造性证明”算法进行操作,该算法一部分根据作品收到多少个“喜欢”,一部分根据有多少作品衍生自它而分配 LikeCoin。由于开放授权内容有更多机会被重复使用并获得 LikeCoin 令牌,因此系统鼓励内容创作者在 Creative Commons 许可下发布。 + +### 如何运行 + +当通过 LikeCoin 协议上传创意片段时,内容创作者将包括作品的元数据,包括作者信息及其 InterPlanetary 关联数据([IPLD][3])。这些数据构成了衍生作品的家族图表;我们称作品与其衍生品之间的关系为“内容足迹”。这种结构使得内容的继承树可以很容易地追溯到原始作品。 + +LikeCoin 令牌将作品衍生历史记录的信息分发给创作者。由于所有创意作品都包含作者钱包的元数据,因此相应的 LikeCoin 份额可以通过算法计算并分发。 + +LikeCoin 可以通过两种方式获得奖励:直接由想要通过支付内容创建者来表示赞赏的个人或通过 Creators Pool 收集观众的“赞”的并根据内容的 LikeRank 分配 LikeCoin。基于在 LikeCoin 协议中的内容追踪,LikeRank 衡量作品重要性(或者我们在这定义的创造性)。一般来说,一副作品有越多的衍生作品,创意内容的创新越多,内容就会有更高的 LikeRank。 LikeRank 是内容创新性的量化者。 + +### 如何参与? + +LikeCoin 仍然非常新,我们期望在 2018 年晚些时候推出我们的第一个去中心化程序来奖励 Creative Commons 的内容,并与更大的社区无缝连接。 + +LikeCoin 的大部分代码都可以在 [LikeCoin GitHub][4] 仓库中通过[ GPL 3.0 许可证][5]访问。由于它仍处于积极开发阶段,一些实验代码尚未公开,但我们会尽快完成。 + +我们欢迎功能请求,pull request,fork 和 star。请参与我们在 Github 上的开发,并加入我们在 [Telegram][6] 的讨论组。我们同样在 [Medium][7]、[Facebook][8]、[Twitter][9] 和我们的网站 [like.co][1] 发布关于我们进展的最新消息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/likecoin + +作者:[Kin Ko][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/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 e6a6329f18ad8ea69adccbbe6ec18f0e941b3a97 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 22 May 2018 08:42:49 +0800 Subject: [PATCH 1027/1057] translating --- sources/tech/20180521 Starting user software in X.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180521 Starting user software in X.md b/sources/tech/20180521 Starting user software in X.md index cf4ae850f6..148127c817 100644 --- a/sources/tech/20180521 Starting user software in X.md +++ b/sources/tech/20180521 Starting user software in X.md @@ -1,3 +1,5 @@ +translating---geekpi + Starting user software in X ====== From ec85583945b7dfdcbb051e34fc4e32190d6fd8aa Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 08:51:45 +0800 Subject: [PATCH 1028/1057] PRF:20160325 Network automation with Ansible.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部分校对 --- .../20160325 Network automation with Ansible.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/translated/tech/20160325 Network automation with Ansible.md b/translated/tech/20160325 Network automation with Ansible.md index e7a7469bf6..faa2d41b59 100644 --- a/translated/tech/20160325 Network automation with Ansible.md +++ b/translated/tech/20160325 Network automation with Ansible.md @@ -1,31 +1,33 @@ 用 Ansible 实现网络自动化 ================ + +> 了解 Ansible 的功能,这是一个无代理的、可扩展的配置管理系统。 ### 网络自动化 -随着 IT 行业的技术变化,从服务器虚拟化到公有和私有云,以及自服务能力、容器化应用、平台即服务(Paas)交付,一直以来落后的一个领域是网络。 +随着 IT 行业的技术变化,从服务器虚拟化到公有云和私有云,以及自服务能力、容器化应用、平台即服务(PaaS)交付,有一直以来落后的一个领域就是网络。 在过去的五年多,网络行业似乎有很多新的趋势出现,它们中的很多被归入到软件定义网络(SDN)。 >注意 -> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是需要将控制层和数据层(包转发)物理分离,并且,解耦合的控制层必须管理好各自的设备。 +> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是出于将控制层和数据层(包转发)物理分离的需要,并且,解耦合的控制层必须管理好各自的设备。 -> 如今,_在 SDN_ 旗下已经有许多技术,包括基于控制器的网络controller-based networks、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。 +> 如今,在 SDN 旗下已经有许多技术,包括基于控制器的网络controller-based networks、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。 > 由于这篇报告的目的,我们参考 SDN 的解决方案作为我们的解决方案,其中包括一个网络控制器作为解决方案的一部分,并且提升了该网络的可管理性,但并不需要从数据层解耦控制层。 -这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备在 JSON/XML 中返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。 +这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备以 JSON/XML 返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。 在 API 之前,用于配置和管理网络设备的两个主要机制是命令行接口(CLI)和简单网络管理协议(SNMP)。让我们来了解一下它们,CLI 是一个设备的人机界面,而 SNMP 并不是为设备提供的实时编程接口。 -幸运的是,因为很多供应商争相为设备增加 API,有时候 _正是因为_ 它被放到需求建议书(RFP)中,就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。 +幸运的是,因为很多供应商争相为设备增加 API,有时候 _只是因为_ 它被放到需求建议书(RFP)中,这就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。 > 注意 -> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被测试,并且要做为采购网络设备(虚拟和物理)的关键决策标准。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准/协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。 +> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被做为采购网络设备(虚拟和物理)的关键决策标准而测试和使用。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准/协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。 -总而言之,网络自动化,像大多数的自动化类型一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。 +总而言之,网络自动化,像大多数类型的自动化一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。 包括速度,我们现在看看这些各种类型的 IT 组织逐渐采用网络自动化的几种原因。你应该注意到,同样的原则也适用于其它类型的自动化。 From 9e31860341f9fe9989c52166179de9962a0420aa Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 08:54:34 +0800 Subject: [PATCH 1029/1057] Revert "PRF:20160325 Network automation with Ansible.md" This reverts commit ec85583945b7dfdcbb051e34fc4e32190d6fd8aa. --- .../20160325 Network automation with Ansible.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/translated/tech/20160325 Network automation with Ansible.md b/translated/tech/20160325 Network automation with Ansible.md index faa2d41b59..e7a7469bf6 100644 --- a/translated/tech/20160325 Network automation with Ansible.md +++ b/translated/tech/20160325 Network automation with Ansible.md @@ -1,33 +1,31 @@ 用 Ansible 实现网络自动化 ================ - -> 了解 Ansible 的功能,这是一个无代理的、可扩展的配置管理系统。 ### 网络自动化 -随着 IT 行业的技术变化,从服务器虚拟化到公有云和私有云,以及自服务能力、容器化应用、平台即服务(PaaS)交付,有一直以来落后的一个领域就是网络。 +随着 IT 行业的技术变化,从服务器虚拟化到公有和私有云,以及自服务能力、容器化应用、平台即服务(Paas)交付,一直以来落后的一个领域是网络。 在过去的五年多,网络行业似乎有很多新的趋势出现,它们中的很多被归入到软件定义网络(SDN)。 >注意 -> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是出于将控制层和数据层(包转发)物理分离的需要,并且,解耦合的控制层必须管理好各自的设备。 +> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是需要将控制层和数据层(包转发)物理分离,并且,解耦合的控制层必须管理好各自的设备。 -> 如今,在 SDN 旗下已经有许多技术,包括基于控制器的网络controller-based networks、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。 +> 如今,_在 SDN_ 旗下已经有许多技术,包括基于控制器的网络controller-based networks、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。 > 由于这篇报告的目的,我们参考 SDN 的解决方案作为我们的解决方案,其中包括一个网络控制器作为解决方案的一部分,并且提升了该网络的可管理性,但并不需要从数据层解耦控制层。 -这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备以 JSON/XML 返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。 +这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备在 JSON/XML 中返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。 在 API 之前,用于配置和管理网络设备的两个主要机制是命令行接口(CLI)和简单网络管理协议(SNMP)。让我们来了解一下它们,CLI 是一个设备的人机界面,而 SNMP 并不是为设备提供的实时编程接口。 -幸运的是,因为很多供应商争相为设备增加 API,有时候 _只是因为_ 它被放到需求建议书(RFP)中,这就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。 +幸运的是,因为很多供应商争相为设备增加 API,有时候 _正是因为_ 它被放到需求建议书(RFP)中,就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。 > 注意 -> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被做为采购网络设备(虚拟和物理)的关键决策标准而测试和使用。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准/协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。 +> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被测试,并且要做为采购网络设备(虚拟和物理)的关键决策标准。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准/协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。 -总而言之,网络自动化,像大多数类型的自动化一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。 +总而言之,网络自动化,像大多数的自动化类型一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。 包括速度,我们现在看看这些各种类型的 IT 组织逐渐采用网络自动化的几种原因。你应该注意到,同样的原则也适用于其它类型的自动化。 From f5ed11d3fcd3f713cef03d0158e7ac5069c6372c Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 22 May 2018 09:54:46 +0800 Subject: [PATCH 1030/1057] add translation tag --- ...et - A CLI Downloader To Download Media From 80- Websites.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md b/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md index ef004bc75d..999b29960c 100644 --- a/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md +++ b/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md @@ -1,3 +1,5 @@ +pinewall translating + You-Get – A CLI Downloader To Download Media From 80+ Websites ====== From e7188b193d15b3b2284219ca2ce57d7558ab0507 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 12:57:05 +0800 Subject: [PATCH 1031/1057] PRF:20180427 How to Compile a Linux Kernel.md @icecoobe --- .../20180427 How to Compile a Linux Kernel.md | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/translated/tech/20180427 How to Compile a Linux Kernel.md b/translated/tech/20180427 How to Compile a Linux Kernel.md index 48926a862d..ce37651eb8 100644 --- a/translated/tech/20180427 How to Compile a Linux Kernel.md +++ b/translated/tech/20180427 How to Compile a Linux Kernel.md @@ -1,118 +1,117 @@ 如何编译 Linux 内核 ====== +> Jack 将带你在 Ubuntu 16.04 服务器上走过内核编译之旅。 + ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/chester-alvarez-644-unsplash.jpg?itok=aFxG9kUZ) -曾经一段时间内,升级 Linux 内核让很多用户打心里有所畏惧。在那个时候,升级内核包含了很多步骤以及更多的时间。现在,内核安装可以轻易地通过像 `apt` 这样的包管理器来处理。通过添加特定的仓库,你能很轻易地安装实验版本的或者指定版本的内核 (比如针对音频产品的实时内核)。 +曾经有一段时间,升级 Linux 内核让很多用户打心里有所畏惧。在那个时候,升级内核包含了很多步骤,也需要很多时间。现在,内核的安装可以轻易地通过像 `apt` 这样的包管理器来处理。通过添加特定的仓库,你能很轻易地安装实验版本的或者指定版本的内核(比如针对音频产品的实时内核)。 考虑一下,既然升级内核如此容易,为什么你不愿意自行编译一个呢?这里列举一些可能的原因: - * 你想要简单了解它 (编译内核) 的过程 + + * 你想要简单了解编译内核的过程 * 你需要启用或者禁用内核中特定的选项,因为它们没有出现在标准选项里 * 你想要启用标准内核中可能没有添加的硬件支持 * 你使用的发行版需要你编译内核 * 你是一个学生,而编译内核是你的任务 -不管出于什么原因,懂得如何编译内核是非常有用的,而且可以被视作一个通行权。当我第一次编译一个新的 Linux 内核(很久以前),然后尝试从它启动,我从中 (系统快速地崩溃,然后不断地尝试和失败) 感受到一种特定的兴奋。 -既然这样,让我们来实验一下编译内核的过程。我将使用 `Ubuntu 16.04 Server` 来进行演示。在运行一次常规的 `sudo apt upgrade` 之后,当前安装的内核版本是 `4.4.0-121`。我想要升级内核版本到 `4.17`. 我们小心地开始吧。 +不管出于什么原因,懂得如何编译内核是非常有用的,而且可以被视作一个通行权。当我第一次编译一个新的 Linux 内核(那是很久以前了),然后尝试从它启动,我从中(系统马上就崩溃了,然后不断地尝试和失败)感受到一种特定的兴奋。 -有一个警告:强烈建议你在虚拟机里实验本模块。基于虚拟机,你总能创建一个快照,然后轻松地从任何问题中回退出来。不要在产品机器上使用这种方式升级内核,除非你知道你在做什么。 +既然这样,让我们来实验一下编译内核的过程。我将使用 Ubuntu 16.04 Server 来进行演示。在运行了一次常规的 `sudo apt upgrade` 之后,当前安装的内核版本是 `4.4.0-121`。我想要升级内核版本到 `4.17`, 让我们小心地开始吧。 + +有一个警告:强烈建议你在虚拟机里实验这个过程。基于虚拟机,你总能创建一个快照,然后轻松地从任何问题中回退出来。不要在产品机器上使用这种方式升级内核,除非你知道你在做什么。 ### 下载内核 -我们要做的第一件事是下载内核源码。可以找到所需内核 (在 [Kernel.org][1]) 的 URL 来下载。找到 URL 之后,使用如下命令 (我以 `4.17 RC2` 内核为例) 来下载源码文件: + +我们要做的第一件事是下载内核源码。在 [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 的本地可用磁盘空间来完成内核的编译过程。因此你必须确保有足够的空间。 +务必注意:你将需要至少 128GB 的本地可用磁盘空间来完成内核的编译过程。因此你必须确保有足够的空间。 ### 解压源码 -在新下载的内核所在的文件夹下,使用该命令来解压内核: +在新下载的内核所在的文件夹下,使用该命令来解压内核: + ``` tar xvzf linux-4.17-rc2.tar.gz - ``` 使用命令 `cd linux-4.17-rc2` 进入新生成的文件夹。 ### 配置内核 -在正式编译内核之前,我们首先必须配置需要包含哪些模块。实际上,有一些非常简单的方式来配置。使用一个命令,你能拷贝当前内核的配置文件,然后使用可靠的 `menuconfig` 命令来做任何必要的更改。使用如下命令来完成: +在正式编译内核之前,我们首先必须配置需要包含哪些模块。实际上,有一些非常简单的方式来配置。使用一个命令,你能拷贝当前内核的配置文件,然后使用可靠的 `menuconfig` 命令来做任何必要的更改。使用如下命令来完成: + ``` cp /boot/config-$(uname -r) .config - ``` -现在你有一个配置文件了,输入命令 `make menuconfig`。该命令将打开一个配置工具 (图 1),它可以让你遍历每个可用模块,然后启用或者禁用你需要或者不需要的模块。 - +现在你有一个配置文件了,输入命令 `make menuconfig`。该命令将打开一个配置工具(图 1),它可以让你遍历每个可用模块,然后启用或者禁用你需要或者不需要的模块。 ![menuconfig][3] -图 1: 运行中的 `make menuconfig`. +*图 1: 运行中的 `make menuconfig`* -[Used with permission][4] - -很有可能你会禁用掉内核中的一个重要部分,所以在 `menuconfig` 期间小心地一步步进行。如果你对某个选项不确定,不要去管它。或者更好的方法是使用我们拷贝的当前运行的内核的配置文件 (因为我们知道它可以工作)。一旦你已经遍历了整个配置列表 (它非常长),你就准备好开始编译了。 +很有可能你会禁用掉内核中的一个重要部分,所以在 `menuconfig` 期间小心地一步步进行。如果你对某个选项不确定,不要去管它。或者更好的方法是使用我们拷贝的当前运行的内核的配置文件(因为我们知道它可以工作)。一旦你已经遍历了整个配置列表(它非常长),你就准备好开始编译了。 ### 编译和安装 -现在是时候去实际地编译内核了。第一步是使用 `make` 命令去编译。那么调用 `make` 命令然后回答必要的问题 (图 2)。这些问题取决于你将升级的现有内核以及升级后的内核。相信我,将会有非常多的问题要回答,因此你得预留大量的时间。 +现在是时候去实际地编译内核了。第一步是使用 `make` 命令去编译。调用 `make` 命令然后回答必要的问题(图 2)。这些问题取决于你将升级的现有内核以及升级后的内核。相信我,将会有非常多的问题要回答,因此你得预留大量的时间。 ![make][6] -图 2: 回答 `make` 命令的问题 +*图 2: 回答 `make` 命令的问题* -[Used with permission][4] +回答了长篇累牍的问题之后,你就可以用如下的命令安装那些之前启用的模块: -回答了长篇累牍的问题之后,你就可以用如下的命令安装那些之前启用的模块: ``` make modules_install - ``` -又来了,这个命令将耗费一些时间,所以要么坐下来看着编译输出,或者去做些其他事 (因为编译期间不需要你的输入)。可能的情况是,你想要进行别的任务 (除非你真的喜欢看着终端界面上飞舞的输出)。 +又来了,这个命令将耗费一些时间,所以要么坐下来看着编译输出,或者去做些其他事(因为编译期间不需要你的输入)。可能的情况是,你想要去进行别的任务(除非你真的喜欢看着终端界面上飞舞而过的输出)。 + +现在我们使用这个命令来安装内核: -现在我们使用这个命令来安装内核: ``` sudo make install - ``` -又一次,另一个将要耗费大量可观时间的命令。事实上,`make install` 命令将比 `make modules_install` 命令花费更多的时间。去享用午餐,配置一个路由器,将 Linux 安装在一些服务器上,或者小睡一会。 +又一次,另一个将要耗费大量可观时间的命令。事实上,`make install` 命令将比 `make modules_install` 命令花费更多的时间。去享用午餐,配置一个路由器,将 Linux 安装在一些服务器上,或者小睡一会吧。 ### 启用内核作为引导 -一旦 `make install` 命令完成了,就是时候将内核启用来作为引导。 -使用这个命令来实现: +一旦 `make install` 命令完成了,就是时候将内核启用来作为引导。使用这个命令来实现: + ``` sudo update-initramfs -c -k 4.17-rc2 - ``` -当然,你需要将上述内核版本号替换成你编译完的。当命令执行完毕后,使用如下命令来更新 grub: +当然,你需要将上述内核版本号替换成你编译完的。当命令执行完毕后,使用如下命令来更新 grub: + ``` sudo update-grub - ``` 现在你可以重启系统并且选择新安装的内核了。 ### 恭喜! -你已经编译了一个 Linux 内核!它是一项耗费一些时间的活动;但是,最终你的 Linux 发行版将拥有一个定制的内核,同时你也将拥有一项被许多 Linux 管理员所倾向忽视的重要技能。 +你已经编译了一个 Linux 内核!它是一项耗费时间的活动;但是,最终你的 Linux 发行版将拥有一个定制的内核,同时你也将拥有一项被许多 Linux 管理员所倾向忽视的重要技能。 -从 Linux 基金会和 edX 提供的免费 ["Introduction to Linux" ][7] 课程来学习更多的 Linux 知识。 +从 Linux 基金会和 edX 提供的免费 [“Introduction to Linux”][7] 课程来学习更多的 Linux 知识。 -------------------------------------------------------------------------------- @@ -121,7 +120,7 @@ via: https://www.linux.com/learn/intro-to-linux/2018/4/how-compile-linux-kernel- 作者:[Jack Wallen][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[icecoobe](https://github.com/icecoobe) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2a5bfcc6342fd349f2072e0455c2378e2857eed7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 12:57:29 +0800 Subject: [PATCH 1032/1057] PUB:20180427 How to Compile a Linux Kernel.md @icecoobe https://linux.cn/article-9665-1.html --- .../tech => published}/20180427 How to Compile a Linux Kernel.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180427 How to Compile a Linux Kernel.md (100%) diff --git a/translated/tech/20180427 How to Compile a Linux Kernel.md b/published/20180427 How to Compile a Linux Kernel.md similarity index 100% rename from translated/tech/20180427 How to Compile a Linux Kernel.md rename to published/20180427 How to Compile a Linux Kernel.md From b670de88446fcfa3241152d0d13bcde10d6e04e1 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 22 May 2018 14:03:12 +0800 Subject: [PATCH 1033/1057] submit tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md --- ...der To Download Media From 80- Websites.md | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) rename {sources => translated}/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md (50%) diff --git a/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md b/translated/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md similarity index 50% rename from sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md rename to translated/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md index 999b29960c..089169c66b 100644 --- a/sources/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md +++ b/translated/tech/20180516 You-Get - A CLI Downloader To Download Media From 80- Websites.md @@ -1,53 +1,51 @@ -pinewall translating - -You-Get – A CLI Downloader To Download Media From 80+ Websites +You-Get - 支持 80+ 网站的命令行多媒体下载器 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/05/you-get-1-720x340.jpg) -Most of you may used or heard about **Youtube-dl** , a command line program to download videos from youtube and other 100+ websites. I just stumbled upon a similar utility named **“You-Get”**. It is also a CLI downloader written in Python. It allows you to download images, audios and videos from popular websites like Youtube, Facebook, Twitter and a lot more. Currently, there are 80+ websites are supported. Click [**here**][1] to read the full list of supported sites. +你们大多数人可能用过或听说过 **Youtube-dl**,这个命令行程序可以从包括 Youtube 在内的 100+ 网站下载视频。我偶然发现了一个类似的工具,名字叫做 **"You-Get"**。这是一个 Python 编写的命令行下载器,可以让你从 Youtube,Facebook,Twitter 等很多热门网站下载图片,音频和视频。目前该下载器支持 80+ 站点,点击[**这里**][1]查看所有支持的网站。 -You-Get is not only a downloader, but also can stream the online videos in your media player. It even allows you to search for videos on google. Just pass the search term and You-Get will google it and download the most relevant videos. Another notable feature, it allows you to pause and resume the downloads. It is completely free, open source and cross-platform application that on Linux, Mac OS and Windows. +You-Get 不仅仅是一个下载器,它还可以将在线视频导流至你的视频播放器。更进一步,它还允许你在 Google 上搜索视频,只要给出搜索项,You-Get 使用 Google 搜索并下载相关度最高的视频。另外值得一提的特性是,它允许你暂停和恢复下载过程。它是一个完全自由、开源及跨平台的应用,适用于 Linux,MacOS 及 Windows。 -### Install You-Get +### 安装 You-Get -Make sure you have installed the following prerequisites. +确保你已经安装如下依赖项: + Python 3 -+ FFmpeg (strongly recommended) or Libav -+ (Optional) RTMPDump ++ FFmpeg (强烈推荐) 或 Libav ++ (可选) RTMPDump -You-Get can be installed in many ways. The officially recommended method is using Pip package manager. If you haven’t installed PIP yet, refer the following link. +有多种方式安装 You-Get,其中官方推荐采用 pip 包管理器安装。如果你还没有安装 pip,可以参考如下链接: -[How To Manage Python Packages Using Pip][https://www.ostechnix.com/manage-python-packages-using-pip/] +[如何使用 pip 管理 Python 软件包][2] -Please note that you must install Python 3 version of pip. +需要注意的是,你需要安装 Python 3 版本的 pip。 -Now, run the following command to install You-Get: +接下来,运行如下命令安装 You-Get: ``` $ pip3 install you-get ``` -You can upgrade You-Get to its latest version using command: +可以使用命令升级 You-Get 至最新版本: ``` $ pip3 install --upgrade you-get ``` -### Getting Started With You-Get +### 开始使用 You-Get -The usage is pretty much same as Youtube-dl utility. +使用方式与 Youtube-dl 工具基本一致。 -**Download Videos** +**下载视频** -To download a video, just run: +下载视频,只需运行: ``` $ you-get https://www.youtube.com/watch?v=HXaglTFJLMc ``` -Sample output: +输出示例: ``` site: YouTube title: The Last of The Mohicans by Alexandro Querevalú @@ -63,19 +61,19 @@ Downloading The Last of The Mohicans by Alexandro Querevalú.mp4 ... ``` -You may want to view the details of the video before downloading. You-Get can do that for using **“–info”** or **“-i”** flag. This option will get you all available quality and formats of the given video. +下载视频前,你可能希望查看视频的细节信息。You-Get 提供了 **“–info”** 或 **“-i”** 参数,使用该参数可以获得给定视频所有可用的分辨率和格式。 ``` $ you-get -i https://www.youtube.com/watch?v=HXaglTFJLMc ``` -Or, +或者 ``` -$ you-get -info https://www.youtube.com/watch?v=HXaglTFJLMc +$ you-get --info https://www.youtube.com/watch?v=HXaglTFJLMc ``` -Sample output would be: +输出示例如下: ``` site: YouTube title: The Last of The Mohicans by Alexandro Querevalú @@ -126,15 +124,15 @@ streams: # Available quality and codecs ``` -By default, You-Get will download the format marked with **DEFAULT**. If you don’t like that format or quality, you can pick any other format you like. Use the itag value given in the each format. +默认情况下,You-Get 会下载标记为 **DEFAULT** 的格式。如果你对格式或分辨率不满意,可以选择你喜欢的格式,使用格式对应的 itag 值即可。 ``` $ you-get --itag=244 https://www.youtube.com/watch?v=HXaglTFJLMc ``` -**Download Audios** +**下载音频** -The following command will download an audio from soundcloud website. +执行下面的命令,可以从 soundcloud 网站下载音频: ``` $ you-get 'https://soundcloud.com/uiceheidd/all-girls-are-same-999-prod-nick-mira' Site: SoundCloud.com @@ -147,29 +145,30 @@ Downloading ALL GIRLS ARE THE SAME (PROD. NICK MIRA).mp3 ... ``` -To view the details of the audio file, use **-i** flag. +查看音频文件细节,使用 **-i** 参数: ``` $ you-get -i 'https://soundcloud.com/uiceheidd/all-girls-are-same-999-prod-nick-mira' ``` -**Download Images** +**下载图片** -To download an image, run: +运行如下命令下载图片: ``` $ you-get https://pixabay.com/en/mountain-crumpled-cyanus-montanus-3393209/ ``` +You-Get 也可以下载网页中的全部图片: You-Get can also download all images from a web page. ``` $ you-get https://www.ostechnix.com/pacvim-a-cli-game-to-learn-vim-commands/ ``` -**Search Videos** +**搜索视频** -You-Get doesn’t even a valid URL. You can just pass a random search terms. You-Get will google it and download the most relevant video based on your search string. +你只需向 You-Get 传递一个任意的搜索项,而无需给出有效的 URL;You-Get 会使用 Google 搜索并下载与你给出搜索项最相关的视频。(译者注:Google 的机器人检测机制可能导致 503 报错导致该功能无法使用)。 ``` $ you-get 'Micheal Jackson' Google Videos search: @@ -188,23 +187,23 @@ Downloading Michael Jackson - Beat It (Official Video).webm ... ``` -**Watch Videos** +**观看视频** -You-Get can able to stream the online videos in your media player or browser, just without ads or comment section. +You-Get 可以将在线视频导流至你的视频播放器或浏览器,跳过广告和评论部分。(译者注:使用 -p 参数需要对应的 vlc/chrominum 命令可以调用,一般适用于具有图形化界面的操作系统)。 -To watch videos in a media player, for example VLC, run the following command: +以 VLC 视频播放器为例,使用如下命令在其中观看视频: ``` $ you-get -p vlc https://www.youtube.com/watch?v=HXaglTFJLMc ``` -Or, +或者 ``` $ you-get --player vlc https://www.youtube.com/watch?v=HXaglTFJLMc ``` -Similarly, to stream the videos in your browser, for example chromium, use: +类似地,将视频导流至以 chromium 为例的浏览器中,使用如下命令: ``` $ you-get -p chromium https://www.youtube.com/watch?v=HXaglTFJLMc @@ -212,31 +211,31 @@ $ you-get -p chromium https://www.youtube.com/watch?v=HXaglTFJLMc ![][3] -As you can see in the above screenshot, there is no ads, comment section. Just a plain page with the video. +在上述屏幕截图中,可以看到并没有广告和评论部分,只是一个包含视频的简单页面。 -**Set path and file name for downloaded videos** +**设置下载视频的路径及文件名** -By default, the videos will be downloaded in the current working directory with default video titles. You can, of course, change them as per your liking using **–output-dir/-o** flag to set the path and **–output-filename/-O** to set the name of the downloaded file. +默认情况下,使用视频标题作为默认文件名,下载至当前工作目录。当然,你可以按照你的喜好进行更改,使用 **–output-dir/-o** 参数可以指定路径,使用 **–output-filename/-O** 参数可以指定下载文件的文件名。 ``` $ you-get -o ~/Videos -O output.mp4 https://www.youtube.com/watch?v=HXaglTFJLMc ``` -**Pause and resume downloads** +**暂停和恢复下载** -Press **CTRL+C** to cancel a download. A temporary **.download** file will be saved in the output directory. Next time you run you-get with the same arguments, the download process will resume from the last session. +按 **CTRL+C** 可以取消下载。一个以 **.download** 为扩展名的临时文件会保存至输出路径。下次你使用相同的参数下载时,下载过程将延续上一次的过程。 -In case the file is completely downloaded, the temporary .download extension will be gone, and you-get will just skip the download. To enforce re-downloading, use the **–force/-f** option. +当文件下载完成后,以 .download 为扩展名的临时文件会自动消失。如果这时你使用同样参数下载,You-Get 会跳过下载;如果你想强制重新下载,可以使用 **–force/-f** 参数。 -For more details, refer the help section by running the following command. +查看命令的帮助部分可以获取更多细节,命令如下: ``` $ you-get --help ``` -And, that’s all for now. More good stuffs to come. Stay tuned! +这次的分享到此结束,后续还会介绍更多的优秀工具,敬请期待! -Cheers! +感谢各位阅读! @@ -246,11 +245,12 @@ via: https://www.ostechnix.com/you-get-a-cli-downloader-to-download-media-from-8 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[pinewall](https://github.com/pinewall) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://www.ostechnix.com/author/sk/ [1]:https://you-get.org/#supported-sites +[2]:https://www.ostechnix.com/manage-python-packages-using-pip/ [3]:http://www.ostechnix.com/wp-content/uploads/2018/05/you-get.jpg From 44a00d164f6161be1a97f9cd927ab6777d4dba61 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 16:14:16 +0800 Subject: [PATCH 1034/1057] PRF:20180419 6 Python datetime libraries - Opensource.com.md @MjSeven --- ...hon datetime libraries - Opensource.com.md | 122 +++++++----------- 1 file changed, 44 insertions(+), 78 deletions(-) diff --git a/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md b/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md index dc637b3543..b76d8e088a 100644 --- a/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md +++ b/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md @@ -1,22 +1,24 @@ -6 个 Python 日期库 +6 个 Python 的日期时间库 ===== -### 在 Python 中有许多库可以很容易地测试,转换和读取日期和时间信息。 +> 在 Python 中有许多库可以很容易地测试、转换和读取日期和时间信息。 + ![6 Python datetime libraries ](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd "6 Python datetime libraries ") 图片由 [WOCinTech Chat][1] 提供,根据 Opensource.com 修改。[CC BY-SA 4.0][2] _这篇文章是与 [Jeff Triplett][3] 一起合写的。_ -曾几何时,我们中的一个人(Lacey)花了超过一个小时盯着 [Python 文档][4]中描述日期和时间格式化字符串的表格。当我试图编写从 API 中将日期时间字符串转换为 [Python datetime][5] 对象时,我很难理解其中的特定部分,因此我决定请求帮助。 +曾几何时,我们中的一个人(Lacey)盯了一个多小时的 [Python 文档][4]中描述日期和时间格式化字符串的表格。当我试图编写从 API 中将日期时间字符串转换为 [Python datetime][5] 对象时,我很难理解其中的特定部分,因此我决定请求帮助。 -有人问道:“为什么你不使用 dateutil 呢?” +有人问道:“为什么你不使用 `dateutil` 呢?” -读者,如果你没有从这个月的 Python 专栏中获得任何东西,仅仅是学习到有比 datetime 的 strptime 更容易地将 datetime 字符串转换为 datetime 对象的方法,那么我们认为自己是成功的。 +读者,如果你没有从这个月的 Python 专栏中获得任何东西,只是学习到有比 datetime 的 `strptime` 更容易地将 datetime 字符串转换为 datetime 对象的方法,那么我们觉得就已经成功了。 -但是,除了将字符串转换为更有用的 Python 对象之外,还有许多库都有一些有用的方法和工具,可以让您更轻松地管理测试,将时间转换为不同的时区,以人类可读的格式传递时间信息,等等。如果这是你在 Python 中第一次尝试日期和时间,请暂停并阅读 _[如何使用 Python][6]的日期和时间_ 。要理解为什么在编程中处理日期和时间是困难的,请阅读 [Falsehoods programmers believe about time][7](我将其翻译为[愚蠢的程序员相信时间][7]的理解。 +但是,除了将字符串转换为更有用的 Python 对象之外,还有许多库都有一些有用的方法和工具,可以让您更轻松地进行时间测试、将时间转换为不同的时区、以人类可读的格式传递时间信息,等等。如果这是你在 Python 中第一次接触日期和时间,请暂停并阅读 _[如何使用 Python的日期和时间][6]_ 。要理解为什么在编程中处理日期和时间是困难的,请阅读 [愚蠢的程序员相信时间][7]。 这篇文章将会向你介绍以下库: + * [Dateutil][8] * [Arrow][9] * [Moment][10] @@ -26,117 +28,97 @@ _这篇文章是与 [Jeff Triplett][3] 一起合写的。_ 随意跳过那些你已经熟悉的库,专注于那些对你而言是新的库。 -### 内建 datetime 模块 +### 内建的 datetime 模块 -(以下这段是原文中侧面的链接,认为i还是不翻译为好,可以考虑将其删除) -More Python Resources - -* [What is Python?][14] -* [Top Python IDEs][15] -* [Top Python GUI frameworks][16] -* [Latest Python content][17] -* [More developer resources][18] - -在跳转到其他库之前,让我们回顾一下如何使用 datetime 模块将日期字符串转换为 Python datetime 对象。 +在跳转到其他库之前,让我们回顾一下如何使用 `datetime` 模块将日期字符串转换为 Python datetime 对象。 假设我们从 API 接受到一个日期字符串,并且需要它作为 Python datetime 对象存在: +``` 2018-04-29T17:45:25Z +``` 这个字符串包括: -* 日期是 YYYY-MM-DD 格式的 -* 字母 “T” 表示时间即将到来 -* 时间是 HH:II:SS 格式的 -* 表示此时间的时区指示符 “Z” 采用 UTC (详细了解[日期时间字符格式][19]) +* 日期是 `YYYY-MM-DD` 格式的 +* 字母 `T` 表示时间即将到来 +* 时间是 `HH:II:SS` 格式的 +* 表示此时间的时区指示符 `Z` 采用 UTC (详细了解[日期时间字符格式][19]) -要使用 datetime 模块将此字符串转换为 Python datetime 对象,你应该从 strptime 开始。 datetime.strptime 接受日期字符串和格式化字符并返回一个 Python datetime 对象。 +要使用 `datetime` 模块将此字符串转换为 Python datetime 对象,你应该从 `strptime` 开始。 `datetime.strptime` 接受日期字符串和格式化字符并返回一个 Python datetime 对象。 -我们必须手动将日期时间字符串的每个部分转换为 Python 的 datetime.strptime 可以理解的合适的格式化字符串。四位数年份由 %Y 表示,两位数月份是 %m,两位数的日期是 %d。在 24 小时制中,小时是 %H,分钟是 %M,秒是 %S。 +我们必须手动将日期时间字符串的每个部分转换为 Python 的 `datetime.strptime` 可以理解的合适的格式化字符串。四位数年份由 `%Y` 表示,两位数月份是 `%m`,两位数的日期是 `%d`。在 24 小时制中,小时是 `%H`,分钟是 `%M`,秒是 `%S`。 为了得出这些结论,需要在[Python 文档][20]的表格中多加注意。 -由于字符串中的 “Z” 表示此日期时间字符串采用 UTC,所以我们可以在格式中忽略此项。(现在,我们不会担心时区。) +由于字符串中的 `Z` 表示此日期时间字符串采用 UTC,所以我们可以在格式中忽略此项。(现在,我们不会担心时区。) 转换的代码是这样的: ``` $ from datetime import datetime - $ datetime.strptime('2018-04-29T17:45:25Z', '%Y-%m-%dT%H:%M:%SZ') - datetime.datetime(2018, 4, 29, 17, 45, 25) ``` -格式化字符串很难阅读和理解。我必须手动计算原始字符串中的字母 “T” 和 “Z”,以及标点符号和格式化字符串,如 %S 和 %m。有些不太了解 datetime 的人阅读我的代码可能会发现它很难理解,尽管其含义已有文档记载,但它仍然很难阅读。 +格式字符串很难阅读和理解。我必须手动计算原始字符串中的字母 `T` 和 “Z”的位置,以及标点符号和格式化字符串,如 `%S` 和 `%m`。有些不太了解 datetime 的人阅读我的代码可能会发现它很难理解,尽管其含义已有文档记载,但它仍然很难阅读。 让我们看看其他库是如何处理这种转换的。 ### Dateutil -[dateutil 模块][21]对 datetime 模块做了一些扩展。 +[dateutil 模块][21]对 `datetime` 模块做了一些扩展。 -继续使用上面的解析示例,使用 dateutil 实现相同的结果要简单得多: +继续使用上面的解析示例,使用 `dateutil` 实现相同的结果要简单得多: ``` $ from dateutil.parser import parse - $ parse('2018-04-29T17:45:25Z') - datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc()) ``` -如果字符串包含时区,那么 dateutil 解析器会自动返回字符串的时区。由于我们在 UTC,你可以看到一个 datetime 对象返回了。如果你想解析完全忽略时区信息并返回原生的 datetime 对象,你可以传递 ignoretz=True 来解析,如下所示: +如果字符串包含时区,那么 `dateutil` 解析器会自动返回字符串的时区。由于我们在 UTC 时区,你可以看到返回来一个 datetime 对象。如果你想解析完全忽略时区信息并返回原生的 datetime 对象,你可以传递 `ignoretz=True` 来解析,如下所示: ``` $ from dateutil.parser import parse - $ parse('2018-04-29T17:45:25Z', ignoretz=True) - datetime.datetime(2018, 4, 29, 17, 45, 25) ``` -Dateutil 还可以解析其他人类可读的日期字符串: +`dateutil` 还可以解析其他人类可读的日期字符串: ``` $ parse('April 29th, 2018 at 5:45 pm') - datetime.datetime(2018, 4, 29, 17, 45) ``` -Dateutil 还提供了像 [relativedelta][22] 的工具,它用于计算两个日期时间之间的时间差或向日期时间添加或删除时间,[rrule][23] 创建重复日期时间,[tz][24] 用于解决时区以及其他工具。 +`dateutil` 还提供了像 [relativedelta][22] 的工具,它用于计算两个日期时间之间的时间差或向日期时间添加或删除时间,[rrule][23] 创建重复日期时间,[tz][24] 用于解决时区以及其他工具。 ### Arrow -[Arrow][25] 是另一个库,其目标是进行操作,格式化,以及处理对人类更友好的日期和时间。它包含 dateutil,根据其[文档][26],它旨在“帮助你使用更少的包导入和更少的代码来处理日期和时间”。 +[Arrow][25] 是另一个库,其目标是操作、格式化,以及处理对人类更友好的日期和时间。它包含 `dateutil`,根据其[文档][26],它旨在“帮助你使用更少的包导入和更少的代码来处理日期和时间”。 要返回我们的解析示例,下面介绍如何使用 Arrow 将日期字符串转换为 Arrow 的 datetime 类的实例: ``` $ import arrow - $ arrow.get('2018-04-29T17:45:25Z') - ``` -你也可以在 get() 的第二个参数中指定格式,就像使用 strptime 一样,但是 Arrow 会尽力解析你给出的字符串,get() 返回 Arrow 的 datetime 类的一个实例。要使用 Arrow 来获取 Python datetime 对象,按照如下所示链式 datetime: +你也可以在 `get()` 的第二个参数中指定格式,就像使用 `strptime` 一样,但是 Arrow 会尽力解析你给出的字符串,`get()` 返回 Arrow 的 `datetime` 类的一个实例。要使用 Arrow 来获取 Python datetime 对象,按照如下所示链式 datetime: ``` $ arrow.get('2018-04-29T17:45:25Z').datetime - datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc()) ``` -通过 Arrow datetime 类的实例,你可以访问 Arrow 的其他有用方法。例如,它的 humanize() 方法将日期时间翻译成人类可读的短语,就像这样: +通过 Arrow datetime 类的实例,你可以访问 Arrow 的其他有用方法。例如,它的 `humanize()` 方法将日期时间翻译成人类可读的短语,就像这样: ``` $ import arrow - $ utc = arrow.utcnow() - $ utc.humanize() - 'seconds ago' ``` @@ -144,23 +126,20 @@ $ utc.humanize() ### Moment -[Moment][28] 的作者认为它是"内部测试版",但即使它处于早期阶段,它也是非常受欢迎的,我们想来讨论它。 +[Moment][28] 的作者认为它是“内部测试版”,但即使它处于早期阶段,它也是非常受欢迎的,我们想来讨论它。 Moment 的方法将字符转换为其他更有用的东西很简单,类似于我们之前提到的库: ``` $ import moment - $ moment.date('2018-04-29T17:45:25Z') - ``` -就像其他库一样,它最初返回它自己的 datetime 类的实例,要返回 Python datetime 对象,添加额外的 date() 调用即可。 +就像其他库一样,它最初返回它自己的 datetime 类的实例,要返回 Python datetime 对象,添加额外的 `date()` 调用即可。 ``` $ moment.date('2018-04-29T17:45:25Z').date - datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=) ``` @@ -170,71 +149,60 @@ Moment 还提供了使用人类可读的语言创建新日期的方法。例如 ``` $ moment.date("tomorrow") - ``` -它的 add 和 subtract 命令使用关键字参数来简化日期的操作。为了获得后天,Moment 会使用下面的代码: +它的 `add()` 和 `subtract()` 命令使用关键字参数来简化日期的操作。为了获得后天,Moment 会使用下面的代码: ``` $ moment.date("tomorrow").add(days=1) - ``` ### Maya -[Maya][29] 包含其他流行的库,它们处理 Python 中的日期时间,包括 Humanize, pytz 和 pendulum 等等。这个项目旨在让人们更容易处理日期。 +[Maya][29] 包含了 Python 中其他流行处理日期时间的库,包括 Humanize、 pytz 和 pendulum 等等。这个项目旨在让人们更容易处理日期。 Maya 的 README 包含几个有用的实例。以下是如何使用 Maya 来重新处理以前的解析示例: ``` $ import maya - $ maya.parse('2018-04-29T17:45:25Z').datetime() - datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=) ``` -注意我们必须在 maya.parse() 之后调用 .datetime()。如果我们跳过这一步,Maya 将会返回一个 MayaDT 类的示例:。 +注意我们必须在 `maya.parse()` 之后调用 `datetime()`。如果我们跳过这一步,Maya 将会返回一个 MayaDT 类的示例:``。 -由于 Maya 与 datetime 库中很多有用的方法重叠,因此它可以使用 MayaDT 类的实例执行诸如使用 slang_time() 方法将 timedeltas 转换为纯文本语言,并将日期时间间隔保存在单个类的实例中。以下是如何使用 Maya 将日期时间表示为人类可读的短语: +由于 Maya 与 datetime 库中很多有用的方法重叠,因此它可以使用 MayaDT 类的实例执行诸如使用 `slang_time()` 方法将时间偏移量转换为纯文本语言,并将日期时间间隔保存在单个类的实例中。以下是如何使用 Maya 将日期时间表示为人类可读的短语: ``` $ import maya - $ maya.parse('2018-04-29T17:45:25Z').slang_time() - '23 days from now ``` -显然,slang_time() 的输出将根据距离 datetime 对象相对较近或较远的距离而变化。 +显然,`slang_time()` 的输出将根据距离 datetime 对象相对较近或较远的距离而变化。 ### Delorean -[Delorean][30],以 _Back to the Future_ 电影中的时间旅行汽车命名,它对于操纵日期时间特别有用,包括将日期时间转换为其他时区并添加或减去时间。 +[Delorean][30],以 《返回未来》 电影中的时间旅行汽车命名,它对于操纵日期时间特别有用,包括将日期时间转换为其他时区并添加或减去时间。 Delorean 需要有效的 Python datetime 对象才能工作,所以如果你需要使用时间字符串,最好将其与上述库中的一个配合使用。例如,将 Maya 与 Delorean 一起使用: ``` $ import maya - $ d_t = maya.parse('2018-04-29T17:45:25Z').datetime() ``` -现在,随着 datetime 对象 d_t 在你掌控之中,你可以使用 Delorean 来搞一些事情,例如将日期时间转换为美国东部时区: +现在,你有了一个 datetime 对象 d_t,你可以使用 Delorean 来做一些事情,例如将日期时间转换为美国东部时区: + ``` $ from delorean import Delorean - $ d = Delorean(d_t) - $ d - Delorean(datetime=datetime.datetime(2018, 4, 29, 17, 45, 25), timezone='UTC') - $ d.shift('US/Eastern') - Delorean(datetime=datetime.datetime(2018, 4, 29, 13, 45, 25), timezone='US/Eastern') ``` @@ -244,7 +212,6 @@ Delorean(datetime=datetime.datetime(2018, 4, 29, 13, 45, 25), timezone='US/Easte ``` $ d.next_friday() - Delorean(datetime=datetime.datetime(2018, 5, 4, 13, 45, 25), timezone='US/Eastern') ``` @@ -252,7 +219,7 @@ Delorean(datetime=datetime.datetime(2018, 5, 4, 13, 45, 25), timezone='US/Easter ### Freezegun -[Freezegun][32] 是一个可以帮助你在 Python 代码中测试特定日期的库。使用 @freeze_time 装饰器,你可以为测试用例设置特定的日期和时间,并且所有对 datetime.datetime.now(), datetime.datetime.utcnow() 等的调用都将返回你指定的日期和时间。例如: +[Freezegun][32] 是一个可以帮助你在 Python 代码中测试特定日期的库。使用 `@freeze_time` 装饰器,你可以为测试用例设置特定的日期和时间,并且所有对 `datetime.datetime.now()`、 `datetime.datetime.utcnow()` 等的调用都将返回你指定的日期和时间。例如: ``` @@ -264,7 +231,7 @@ def test():  assert datetime.datetime.now() == datetime.datetime(2017, 4, 14) ``` -要跨时区进行测试,你可以将 tz_offset 参数传递给装饰器。freeze_time 装饰器也接受更简单的口语化日期,例如 @freeze_time('April 4, 2017')。 +要跨时区进行测试,你可以将 `tz_offset` 参数传递给装饰器。`freeze_time` 装饰器也接受更简单的口语化日期,例如 `@freeze_time('April 4, 2017')`。 --- @@ -276,8 +243,10 @@ def test():  via: [https://opensource.com/article/18/4/python-datetime-libraries][34] -作者: [Lacey Williams Hensche][35] 选题者: [@lujun9972][36] -译者: [MjSeven][37] 校对: [校对者ID][38] +作者: [Lacey Williams Hensche][35] +选题: [lujun9972](https://github.com/lujun9972) +译者: [MjSeven](https://github.com/MjSeven) +校对: [wxy](https://github.com/wxy) 本文由 [LCTT][39] 原创编译,[Linux中国][40] 荣誉推出 @@ -316,8 +285,5 @@ via: [https://opensource.com/article/18/4/python-datetime-libraries][34] [33]: https://github.com/kennethreitz/maya [34]: https://opensource.com/article/18/4/python-datetime-libraries [35]: https://opensource.com/users/laceynwilliams -[36]: https://github.com/lujun9972 -[37]: https://github.com/MjSeven -[38]: https://github.com/校对者ID [39]: https://github.com/LCTT/TranslateProject [40]: https://linux.cn/ From 4b5d73e4c84757d995fe80e2e9d8b18bfa3ff9bc Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 16:14:36 +0800 Subject: [PATCH 1035/1057] PUB:20180419 6 Python datetime libraries - Opensource.com.md @MjSeven https://linux.cn/article-9666-1.html --- .../20180419 6 Python datetime libraries - Opensource.com.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180419 6 Python datetime libraries - Opensource.com.md (100%) diff --git a/translated/tech/20180419 6 Python datetime libraries - Opensource.com.md b/published/20180419 6 Python datetime libraries - Opensource.com.md similarity index 100% rename from translated/tech/20180419 6 Python datetime libraries - Opensource.com.md rename to published/20180419 6 Python datetime libraries - Opensource.com.md From 0184459bbea1d81f48b9daa168be7c58df2a1ce6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 16:32:04 +0800 Subject: [PATCH 1036/1057] PRF:20180410 Bootiso Lets You Safely Create Bootable USB Drive.md @kennethXia --- ...ts You Safely Create Bootable USB Drive.md | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md b/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md index b0d6f088f5..dca7ede7a4 100644 --- a/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md +++ b/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md @@ -1,17 +1,18 @@ -Bootiso 让你安全地创建 USB 启动设备 +Bootiso :让你安全地创建 USB 启动设备 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/04/USB-drive-720x340.png) -你好,新兵!你们有些人经常使用 **dd 命令**做各种各样的事,比如创建 USB 启动盘或者克隆硬盘分区。不过请牢记,dd 是一个危险且有毁灭性的命令。如果你是个 Linux 的新手,最好避免使用 dd 命令。如果你不知道你在做什么,你可能会在几分钟里把硬盘擦掉。从原理上说,dd 只是从 **“if”** 读取然后写到 **“of”** 上。它才不管往哪里写呢。它根本不关心那里是否有分区表、引导区、家目录或是其他重要的东西。你叫它做什么它就做什么。可以使用像 [**Etcher**][1] 这样的用户友好的应用来代替它。这样你就可以在创建 USB 引导设备之前知道你将要格式化的是哪块盘。 -今天,我发现了另一个可以安全创建 USB 引导设备的工具 **Bootiso** 。它实际上是一个 BASH 脚本,但真的很智能!它有很多额外的功能来帮我们安全创建 USB 引导盘。如果你想确定你的目标是 USB 设备(而不是内部驱动器),或者如果你想检测 USB 设备,你可以使用 Bootiso。下面是使用此脚本的显著优点: +你好,新兵!你们有些人经常使用 `dd` 命令做各种各样的事,比如创建 USB 启动盘或者克隆硬盘分区。不过请牢记,`dd` 是一个危险且有毁灭性的命令。如果你是个 Linux 的新手,最好避免使用 `dd` 命令。如果你不知道你在做什么,你可能会在几分钟里把硬盘擦掉。从原理上说,`dd` 只是从 `if` 读取然后写到 `of` 上。它才不管往哪里写呢。它根本不关心那里是否有分区表、引导区、家目录或是其他重要的东西。你叫它做什么它就做什么。可以使用像 [Etcher][1] 这样的用户友好的应用来代替它。这样你就可以在创建 USB 引导设备之前知道你将要格式化的是哪块盘。 + +今天,我发现了另一个可以安全创建 USB 引导设备的工具 Bootiso 。它实际上是一个 BASH 脚本,但真的很智能!它有很多额外的功能来帮我们安全创建 USB 引导盘。如果你想确保你的目标是 USB 设备(而不是内部驱动器),或者如果你想检测 USB 设备,你可以使用 Bootiso。下面是使用此脚本的显著优点: * 如果只有一个 USB 驱动器,Bootiso 会自动选择它。 * 如果有一个以上的 USB 驱动器存在,它可以让你从列表中选择其中一个。 * 万一你错误地选择一个内部硬盘驱动器,它将退出而不做任何事情。 * 它检查选定的 ISO 是否具有正确的 MIME 类型。如果 MIME 类型不正确,它将退出。 * 它判定所选的项目不是分区,如果判定失败则退出。 - * 它将在擦除和分区 USB 驱动器之前提示用户确认。 + * 它将在擦除和对 USB 驱动器分区之前提示用户确认。 * 列出可用的 USB 驱动器。 * 安装 syslinux 引导系统 (可选)。 * 自由且开源。 @@ -19,46 +20,48 @@ Bootiso 让你安全地创建 USB 启动设备 ### 使用 Bootiso 安全地创建 USB 驱动器 安装 Bootiso 非常简单。用这个命令下载最新版本: + ``` $ curl -L https://rawgit.com/jsamr/bootiso/latest/bootiso -O - ``` -把下载的文件加到 **$PATH** 目录中,比如 /usr/local/bin/. +把下载的文件加到 `$PATH` 目录中,比如 `/usr/local/bin/`。 + ``` $ sudo cp bootiso /usr/local/bin/ - ``` 最后,添加运行权限: + ``` $ sudo chmod +x /usr/local/bin/bootiso ``` 搞定!现在就可以创建 USB 引导设备了。首先,让我们用命令看看现在有哪些 USB 驱动器: + ``` $ bootiso -l - ``` 输出: + ``` Listing USB drives available in your system: NAME HOTPLUG SIZE STATE TYPE sdb 1 7.5G running disk - ``` 如你所见,我只有一个 USB 驱动器。让我们继续通过命令用 ISO 文件创建 USB 启动盘: + ``` $ bootiso bionic-desktop-amd64.iso - ``` -这个命令会提示你输入 SUDO 密码。输入密码并回车来安装缺失的组件(如果有的话),然后创建 USB 启动盘。 +这个命令会提示你输入 `sudo` 密码。输入密码并回车来安装缺失的组件(如果有的话),然后创建 USB 启动盘。 输出: + ``` [...] Listing USB drives available in your system: @@ -79,77 +82,78 @@ ISO succesfully unmounted. USB device succesfully unmounted. USB device succesfully ejected. You can safely remove it ! - ``` -如果你的 ISO 文件 mine 类型不对,你会得到下列错误信息: +如果你的 ISO 文件 MIME 类型不对,你会得到下列错误信息: + ``` Provided file `bionic-desktop-amd64.iso' doesn't seem to be an iso file (wrong mime type: `application/octet-stream'). Exiting bootiso... - ``` -当然,你也能像下面那样使用 **–no-mime-check** 选项来跳过 mime 类型检查。 +当然,你也能像下面那样使用 `–no-mime-check` 选项来跳过 MIME 类型检查。 + ``` $ bootiso --no-mime-check bionic-desktop-amd64.iso - ``` -就像我前面提到的,如果系统里只有1个 USB 设备 Bootiso 将自动选中它。所以我们不需要告诉它 USB 设备路径。如果你连接了多个设备,你可以像下面这样使用 **-d** 来指明 USB 设备。 +就像我前面提到的,如果系统里只有 1 个 USB 设备 Bootiso 将自动选中它。所以我们不需要告诉它 USB 设备路径。如果你连接了多个设备,你可以像下面这样使用 `-d` 来指明 USB 设备。 + ``` $ bootiso -d /dev/sdb bionic-desktop-amd64.iso - ``` -用你自己的设备路径来换掉 “/dev/sdb”. +用你自己的设备路径来换掉 `/dev/sdb`。 -在多个设备情况下,如果你没有使用 **-d** 来指明要使用的设备,Bootiso 会提示你选择可用的 USB 设备。 +在多个设备情况下,如果你没有使用 `-d` 来指明要使用的设备,Bootiso 会提示你选择可用的 USB 设备。 + +Bootiso 在擦除和改写 USB 盘分区前会要求用户确认。使用 `-y` 或 `–assume-yes` 选项可以跳过这一步。 -Bootiso 在擦除和改写 USB 盘分区前会要求用户确认。使用 **-y** 或 **–assume-yes** 选项可以跳过这一步。 ``` $ bootiso -y bionic-desktop-amd64.iso - ``` -您也可以把自动选择 USB 设备与 **-y** 选项连用,如下所示。 +您也可以把自动选择 USB 设备与 `-y` 选项连用,如下所示。 + ``` $ bootiso -y -a bionic-desktop-amd64.iso - ``` 或者, + ``` $ bootiso?--assume-yes?--autoselect bionic-desktop-amd64.iso - ``` 请记住,当你只连接一个 USB 驱动器时,它才会起作用。 -Bootiso 会默认创建一个 **FAT 32** 分区,挂载后用 **“rsync”** 程序把 ISO 的内容拷贝到 USB 盘里。 如果你愿意也可以使用 “dd” 代替 “rsync” 。 +Bootiso 会默认创建一个 FAT 32 分区,挂载后用 `rsync` 程序把 ISO 的内容拷贝到 USB 盘里。 如果你愿意也可以使用 `dd` 代替 `rsync` 。 + ``` $ bootiso --dd -d /dev/sdb bionic-desktop-amd64.iso - ``` -如果你想增加 USB 引导的成功概率,请使用 **“-b”** 或 **“–bootloader”** 选项。 +如果你想增加 USB 引导的成功概率,请使用 `-b` 或 `–bootloader` 选项。 + ``` $ bootiso -b bionic-desktop-amd64.iso - ``` -上面这条命令会安装 **syslinux** 引导程序(安全模式)。注意,“–dd” 选项不可用. +上面这条命令会安装 `syslinux` 引导程序(安全模式)。注意,此时 `–dd` 选项不可用。 + +在创建引导设备后,Bootiso 会自动弹出 USB 设备。如果不想自动弹出,请使用 `-J` 或 `–no-eject` 选项。 -在创建引导设备后,Bootiso 会自动弹出 USB 设备。如果不想自动弹出,请使用 **-J** 或 **–no-eject** 选项。 ``` $ bootiso -J bionic-desktop-amd64.iso - ``` -现在,USB 设备依然连接中。你可以使用 “umount” 命令随时卸载它。 +现在,USB 设备依然连接中。你可以使用 `umount` 命令随时卸载它。 需要完整帮助信息,请输入: + ``` $ bootiso -h +``` 好,今天就到这里。希望这个脚本对你有帮助。好货不断,不要走开哦! @@ -160,9 +164,9 @@ $ bootiso -h via: https://www.ostechnix.com/bootiso-lets-you-safely-create-bootable-usb-drive/ 作者:[SK][a] -译者:[kennethXia](https://github.com/kennethXia) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[kennethXia](https://github.com/kennethXia) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d7c8d2b5d9b97425f14109ea45e8b0354c5ef12f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 16:32:31 +0800 Subject: [PATCH 1037/1057] PUB:20180410 Bootiso Lets You Safely Create Bootable USB Drive.md @kennethXia https://linux.cn/article-9667-1.html --- .../20180410 Bootiso Lets You Safely Create Bootable USB Drive.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md (100%) diff --git a/translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md b/published/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md similarity index 100% rename from translated/tech/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md rename to published/20180410 Bootiso Lets You Safely Create Bootable USB Drive.md From b80203d4d9853fd4b9af00b7280b8620c1f96355 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 17:16:25 +0800 Subject: [PATCH 1038/1057] PRF:20180116 Why building a community is worth the extra effort.md @geekpi --- ...g a community is worth the extra effort.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/translated/tech/20180116 Why building a community is worth the extra effort.md b/translated/tech/20180116 Why building a community is worth the extra effort.md index 6ff0d4d213..503712cf1a 100644 --- a/translated/tech/20180116 Why building a community is worth the extra effort.md +++ b/translated/tech/20180116 Why building a community is worth the extra effort.md @@ -1,23 +1,25 @@ 为什么建设一个社区值得额外的努力 ====== +> 建立 NethServer 社区是有风险的。但是我们从这些激情的人们所带来的力量当中学习到了很多。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_brandbalance.png?itok=XSQ1OU16) -当我们在 2003 年推出 [Nethesis][1] 时,我们还只是系统集成商。我们只使用现有的开源项目。我们的业务模式非常明确:为这些项目增加多种形式的价值:实践知识、针对意大利市场的文档、额外模块、专业支持和培训课程。我们还通过向上游贡献代码并参与其社区来回馈上游项目。 +当我们在 2003 年推出 [Nethesis][1] 时,我们还只是系统集成商。我们只使用已有的开源项目。我们的业务模式非常明确:为这些项目增加多种形式的价值:实践知识、针对意大利市场的文档、额外模块、专业支持和培训课程。我们还通过向上游贡献代码并参与其社区来回馈上游项目。 -那时时代不同。我们不能太张扬地使用“开源”这个词。人们将它与诸如“书呆子”,“没有价值”而最糟糕的是“自由”这些词联系起来。这些不太适合生意。 +那时时代不同。我们不能太张扬地使用“开源”这个词。人们将它与诸如“书呆子”,“没有价值”以及最糟糕的“免费”这些词联系起来。这些不太适合生意。 -在 2010 年的一个星期六,Nethesis 的工作人员,他们手中拿着馅饼和浓咖啡,正在讨论如何推进事情发展(嘿,我们喜欢在创新的同时吃喝东西!)。尽管势头对我们不利,但我们决定不改变方向。事实上,我们决定加大力度 - 去做开源和开放的工作方式,这是一个成功运营企业的模式。 +在 2010 年的一个星期六,Nethesis 的工作人员,他们手中拿着馅饼和浓咖啡,正在讨论如何推进事情发展(嘿,我们喜欢在创新的同时吃喝东西!)。尽管势头对我们不利,但我们决定不改变方向。事实上,我们决定加大力度 —— 去做开源和开放的工作方式,这是一个成功运营企业的模式。 多年来,我们已经证明了该模型的潜力。有一件事是我们成功的关键:社区。 -在这个由三部分组成的系列文章中,我将解释社区在开放组织的存在中扮演的重要角色。我将探讨为什么一个组织希望建立一个社区,并讨论如何建立一个社区 - 因为我确实认为这是如今产生新创新的最佳方式。 +在这个由三部分组成的系列文章中,我将解释社区在开放组织的存在中扮演的重要角色。我将探讨为什么一个组织希望建立一个社区,并讨论如何建立一个社区 —— 因为我确实认为这是如今产生新创新的最佳方式。 ### 这个疯狂的想法 与 Nethesis 伙伴一起,我们决定构建自己的开源项目:我们自己的操作系统,它建立在 CentOS 之上(因为我们不想重新发明轮子)。我们假设我们拥有实现它的经验、实践知识和人力。我们感到很勇敢。 -我们非常希望构建一个名为 [NethServer][2] 的操作系统,其使命是:通过开源使系统管理员的生活更轻松。我们知道我们可以为服务器创建一个 Linux 发行版,与当前提供的任何东西相比,这些发行版更容易获取、更易于使用,并且更易于理解。 +我们非常希望构建一个名为 [NethServer][2] 的操作系统,其使命是:通过开源使系统管理员的生活更轻松。我们知道我们可以为服务器创建一个 Linux 发行版,与当前已有的相比,它更容易使用、更易于部署,并且更易于理解。 不过,最重要的是,我们决定创建一个真正的,100% 开放的项目,其主要规则有三条: @@ -25,13 +27,11 @@ * 开发公开 * 社区驱动 - - 最后一个很重要。我们是一家公司。我们能够自己开发它。如果我们在内部完成这项工作,我们将会更有效(并且做出更快的决定)。与其他任何意大利公司一样,这将非常简单。 但是我们已经如此深入到开源文化中,所以我们选择了不同的路径。 -我们确实希望有尽可能多的人围绕着我们、围绕着产品、围绕着公司周围。我们希望对工作有尽可能多的视角。我们意识到:独自一人,你可以走得快 - 但是如果你想走很远,你需要一起走。 +我们确实希望有尽可能多的人围绕着我们、围绕着产品、围绕着公司周围。我们希望对工作有尽可能多的视角。我们意识到:独自一人,你可以走得快 —— 但是如果你想走很远,你需要一起走。 所以我们决定建立一个社区。 @@ -41,11 +41,11 @@ 但是很快就出现了这样一个问题:我们如何建立一个社区?我们不知道如何实现这一点。我们参加了很多社区,但我们从未建立过一个社区。 -我们擅长编码 - 而不是人。我们是一家公司,是一个有非常具体优先事项的组织。那么我们如何建立一个社区,并在公司和社区之间建立良好的关系呢? +我们擅长编码 —— 而不是人。我们是一家公司,是一个有非常具体优先事项的组织。那么我们如何建立一个社区,并在公司和社区之间建立良好的关系呢? 我们做了你必须做的第一件事:学习。我们从专家、博客和许多书中学到了知识。我们进行了实验。我们失败了多次,从结果中收集数据,并再次进行测试。 -最终我们学到了社区管理的黄金法则:没有社区管理的黄金法则。 +最终我们学到了社区管理的黄金法则:**没有社区管理的黄金法则。** 人们太复杂了,社区无法用一条规则来“统治他们”。 @@ -57,7 +57,7 @@ via: https://opensource.com/open-organization/18/1/why-build-community-1 作者:[Alessio Fattorini][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 9ad3a60fe22ab9cc3f60dbc1897d54430e1b1ece Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 22 May 2018 17:16:46 +0800 Subject: [PATCH 1039/1057] PUB:20180116 Why building a community is worth the extra effort.md @geekpi --- ...20180116 Why building a community is worth the extra effort.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180116 Why building a community is worth the extra effort.md (100%) diff --git a/translated/tech/20180116 Why building a community is worth the extra effort.md b/published/20180116 Why building a community is worth the extra effort.md similarity index 100% rename from translated/tech/20180116 Why building a community is worth the extra effort.md rename to published/20180116 Why building a community is worth the extra effort.md From f0576b4377b4600e50ad0ebeed6a86f1752dde76 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 22 May 2018 18:25:39 +0800 Subject: [PATCH 1040/1057] add translation tag --- .../20180131 A history of low-level Linux container runtimes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180131 A history of low-level Linux container runtimes.md b/sources/tech/20180131 A history of low-level Linux container runtimes.md index e83477249d..3cd7cafdf0 100644 --- a/sources/tech/20180131 A history of low-level Linux container runtimes.md +++ b/sources/tech/20180131 A history of low-level Linux container runtimes.md @@ -1,3 +1,5 @@ +pinewall translating + A history of low-level Linux container runtimes ====== From 0b0cdaf48a8ace9d683a3a51631b005176cf4c3a Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 22 May 2018 18:27:00 +0800 Subject: [PATCH 1041/1057] add translation tag --- ...nerization, Atomic Distributions, and the Future of Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180404 Containerization, Atomic Distributions, and the Future of Linux.md b/sources/tech/20180404 Containerization, Atomic Distributions, and the Future of Linux.md index 8111e01a10..1fa68f3778 100644 --- a/sources/tech/20180404 Containerization, Atomic Distributions, and the Future of Linux.md +++ b/sources/tech/20180404 Containerization, Atomic Distributions, and the Future of Linux.md @@ -1,3 +1,5 @@ +pinewall translating + Containerization, Atomic Distributions, and the Future of Linux ====== From 0ee90595b74478dfd58e1346ed22be92a196481a Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Tue, 22 May 2018 22:45:15 +0800 Subject: [PATCH 1042/1057] Update 20180116 How to Install and Optimize Apache on Ubuntu - ThisHosting.Rocks.md --- ...nstall and Optimize Apache on Ubuntu - ThisHosting.Rocks.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180116 How to Install and Optimize Apache on Ubuntu - ThisHosting.Rocks.md b/sources/tech/20180116 How to Install and Optimize Apache on Ubuntu - ThisHosting.Rocks.md index eba7ce9c54..4d54597f3a 100644 --- a/sources/tech/20180116 How to Install and Optimize Apache on Ubuntu - ThisHosting.Rocks.md +++ b/sources/tech/20180116 How to Install and Optimize Apache on Ubuntu - ThisHosting.Rocks.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + How to Install and Optimize Apache on Ubuntu ====== From ccf4b6752b720c10ee86ed467f1fb1f55a0302d8 Mon Sep 17 00:00:00 2001 From: Kevin Sicong Jiang Date: Tue, 22 May 2018 17:43:08 -0500 Subject: [PATCH 1043/1057] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90?= =?UTF-8?q?=20052218?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 How To Display Images In The Terminal.md | 96 +++++++++---------- 1 file changed, 44 insertions(+), 52 deletions(-) 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 8ecf430ad0..92f874f1fe 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,126 +1,118 @@ -Translating KevinSJ -- 05142018 -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. +Linux 上用许多 GUI 图片浏览器。但我尚未听说或使用过任何在终端中显示图片的应用程序。幸运的是,我刚刚发现了一个可用于在终端中显示图像的名叫 ** FIM ** 的图像查看器。FIM 引起了我的注意,是因为与大多数 GUI 图片浏览器相比,它非常轻巧。毫不迟疑,让我们来看看它能做什么。 -### Display Images In the Terminal Using FIM +###使用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** stands for **F**bi **IM**proved. 对于那些不知道的人,**Fbi**是指 linux 中的 **f**rame **b**uffer **i**mageviewer。它使用系统的帧缓冲器直接从命令行显示图像。默认情况下,它能用终端显示bmp,gif,jpeg,PhotoCD,png,ppm,tiff 和 xwd。对于其他格式,它会尝试使用 ImageMagick 的转换。 -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: +FIM 基于 Fbi,它是一款高度可高度定制及脚本化的图像浏览器,非常适合使用 Vim 文本编辑器或 Mutt 等软件的用户。它会以全屏显示图像,并可通过键盘快捷键控制(如调整大小,翻转,缩放)。与fbi不同的是,FIM 是通用的:它可以打开许多文件格式,并且可以在以下视频模式下显示图片: - * 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. +*使用 Linux framebuffer 设备,以图形方式呈现 +*在 X / Xorg 下,使用 SDL 库。以图形方式呈现 +*在 X / Xorg 下,使用 Imlib2 库。以图形方式呈现。 +*在任何文本控制台中使用 AAlib 库呈现为 ASCII 字符画 。 -FIM is completely free and open source. +FIM是完全免费且开源的。 -### Install FIM +###安装FIM + +基于 DEB 的系统,如 Ubuntu,Linux Mint, 可从默认的仓库中获取 FIM 图像查看器。因此,你可以使用如下命令安装fbi: -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. +如果它在你使用的 Linux 发行版的仓库中不包含 FIM,则可以下载源代码进行编译和安装,如下所示。 ``` 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 --help = short的输出:你可以在 ./configure 中添加选项 ./configure make -su -c "make install" - +su -c“make install” ``` -### FIM Usage +### FIM用法 -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. +这里是我的 Ubuntu 主机的示例输出。 ![][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. +正如你在上面的屏幕截图中看到的,FIM 没有使用任何外部 GUI 图片浏览器。相反,它使用我们系统的帧缓冲器来显示图像。 -If you have multiple .jpg files in the current directory, you could use wildcard to open all of them as shown below. +如果当前目录中有多个.jpg文件,可以使用通配符打开所有文件,如下所示。 ``` -$ fim -a *.jpg - +$ fim -a * .jpg ``` -To open all images in a directory, for example **Pictures** , run: +要打开目录中的所有图像,例如 **Pictures**,请运行: ``` $ 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. +要以 ASCII 格式渲染图像,可以使用 **-t** 标志。 ``` $ fim -t dog.jpg - ``` -To quit Fim, press **ESC** or **q**. +要退出 Fim,请按 **ESC** 或 **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. +您可以使用各种键盘快捷键来管理图像。例如,要加载下一张图像和之前的图像,请按下 PgUp / PgDown 键。成倍放大或缩小,请使用 +/- 键。以下是用于在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 +* **PageUp/Down**:上一张/下一张图片 +* **+/-**:放大/缩小 +* **a**:自动缩放 +* **w**:自适应宽度 +* **h**:自适应高度 +* **j/k**:平移/向上 +* **f/m**:翻转/镜像 +* **r/R**:旋转(顺时针/逆时针) +* **ESC/q**:退出 -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] +作者:[SK] [A] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[译者KevinSJ](https://github.com/KevinSJ) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0d1118239abc083e8cd9392c1899151e855ae931 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 23 May 2018 08:42:04 +0800 Subject: [PATCH 1044/1057] translated --- ...gs you can do with the IP tool in Linux.md | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) 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 index 8a1f8c426f..b2c2615edd 100644 --- 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 @@ -1,13 +1,11 @@ -translating---geekpi - -3 useful things you can do with the IP tool in Linux +你可以用 Linux 中的 IP 工具做 3 件有用的事情 ====== ![](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. +`ifconfig` 命令在 Linux 上被弃用已有十多年的时间了,而 `iproute2` 项目包含了神奇的工具 `ip`。许多在线教程资源仍然采用旧的命令行工具,如 `ifconfig`、`route` 和 `netstat`。本教程的目标是分享一些可以使用 `ip` 工具轻松完成的网络相关的事情。 -### Find your IP address +### 找出你的 IP 地址 ``` [dneary@host]$ ip addr show @@ -27,11 +25,11 @@ It has been more than a decade since the `ifconfig` command has been deprecated ``` -`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. +`ip addr show` 会告诉你很多关于你的所有网络链接设备的信息。在这里,我的无线以太网卡(wlp4s0)是 IPv4 地址(`inet` 字段)`10.16.196.113/23`。 `/23` 表示 32 位 IP 地址中的 23 位将被该子网中的所有 IP 地址共享。子网中的 IP 地址范围从 `10.16.196.0 到 10.16.197.254`。子网的广播地址(IP 地址后面的 `brd` 字段)`10.16.197.255` 保留给子网上所有主机的广播流量。 -We can show only the information about a single device using `ip addr show dev wlp4s0`, for example. +例如,我们只能使用 `ip addr show dev wlp4s0` 来显示单个设备的信息。 -### Display your routing table +### 显示你的路由表 ``` [dneary@host]$ ip route list @@ -43,13 +41,13 @@ default via 10.16.197.254 dev wlp4s0 proto static metric 600 ``` -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. +如果你运行任何虚拟机或容器,它们将获得自己的 IP 地址和子网,这可能会使这些路由表非常复杂,但在单个主机中,通常有两条指令。对于本地流量,将其发送到本地以太网上,并且网络交换机将找出(使用称为 ARP 的协议)哪个主机拥有目标 IP 地址,并且要将流量发送到哪里。对于到互联网的流量,将其发送到本地网关节点,它将更好地了解如何到达目的地。 -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 @@ -57,19 +55,17 @@ In the situation above, the first line represents the external gateway for exter ``` -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. +`ip monitor` 命令可用于监视路由表中的更改,网络接口上的网络寻址或本地主机上 ARP 表的更改。此命令在调试与容器和网络相关的网络问题时特别有用,如当两个虚拟机应该能彼此通信,但实际不能。 -`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). +在使用 all 时,ip monitor 会报告报告以 [LINK](网络接口更改),[ROUTE](更改路由表)、[ADDR](IP 地址更改)或 [NEIGH](与马无关 - 与邻居的 ARP 地址相关的变化)。 -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). +你还可以监视特定对象上的更改(例如,特定的路由表或 IP 地址)。 -You can also monitor changes on specific objects (for example, a specific routing table or an IP address). +另一个适用于许多命令的有用选项是 `ip -s`,它提供了一些统计信息。添加第二个 `-s` 选项可以添加更多统计信息。上面的 `ip -s link list wlp4s0` 会给出很多关于接收和发送的数据包的信息、丢弃的数据包数量、检测到的错误等等。 -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]. +一般来说,对于 `ip` 工具,你只需要包含足够的字母来唯一标识你想要做的事情。你可以使用 `ip mon` 来代替 `ip monitor`。你可以使用 `ip a l`,,而不是 `ip addr list`,并且可以使用 `ip r`来代替 `ip route`。`ip link list` 可以缩写为 `ip l ls`。要了解可用于更改命令行为的许多选项,请浏览[ ip 手册页][1]。 -------------------------------------------------------------------------------- @@ -77,7 +73,7 @@ via: https://opensource.com/article/18/5/useful-things-you-can-do-with-IP-tool-L 作者:[Dave Neary][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From cac4ff4274cb94acf6ce30c56ed7c0483e4a0d5e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 23 May 2018 08:43:14 +0800 Subject: [PATCH 1045/1057] PRF:20171221 A Commandline Food Recipes Manager.md @geekpi --- ...1221 A Commandline Food Recipes Manager.md | 70 +++++++++++-------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/translated/tech/20171221 A Commandline Food Recipes Manager.md b/translated/tech/20171221 A Commandline Food Recipes Manager.md index 95771a3b2c..b9754014d0 100644 --- a/translated/tech/20171221 A Commandline Food Recipes Manager.md +++ b/translated/tech/20171221 A Commandline Food Recipes Manager.md @@ -1,46 +1,54 @@ -HeRM’s - 一个命令行食谱管理器 +HeRM's :一个命令行食谱管理器 ====== + ![配图](https://www.ostechnix.com/wp-content/uploads/2017/12/herms-720x340.jpg) -烹饪让爱变得可见,不是吗?确实!烹饪也许是你的热情或爱好或职业,我相信你会维护一份烹饪日记。保持写烹饪日记是改善烹饪习惯的一种方法。有很多方法可以记录食谱。你可以维护一份小日记/笔记或将配方的笔记存储在智能手机中,或将它们保存在计算机中文档中。这有很多选择。今天,我介绍 **HeRM 's**,一个基于 Haskell 的命令行食谱管理器,能为你的美食食谱做笔记。使用 Herm's,你可以添加、查看、编辑和删除食物配方,甚至可以制作购物清单。这些全部来自你的终端!它是免费的,并使用 Haskell 语言编写的开源程序。源代码在 GitHub 中免费提供,因此你可以 fork 它,添加更多功能或改进它。 +烹饪让爱变得可见,不是吗?确实!烹饪也许是你的热情或爱好或职业,我相信你会维护一份烹饪日记。保持写烹饪日记是改善烹饪习惯的一种方法。有很多方法可以记录食谱。你可以维护一份小日记/笔记或将配方的笔记存储在智能手机中,或将它们保存在计算机中文档中。这有很多选择。今天,我介绍 **HeRM's**,这是一个基于 Haskell 的命令行食谱管理器,能为你的美食食谱做笔记。使用 Herm's,你可以添加、查看、编辑和删除食物配方,甚至可以制作购物清单。这些全部来自你的终端!它是免费的,是使用 Haskell 语言编写的开源程序。源代码在 GitHub 中免费提供,因此你可以复刻它,添加更多功能或改进它。 ### HeRM's - 一个命令食谱管理器 -#### **安装 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** : +安装 Cabal 后,确保你已经添加了 `PATH`。为此,请编辑你的 `~/.bashrc`: + ``` vi ~/.bashrc ``` 添加下面这行: + ``` PATH=$PATH:~/.cabal/bin ``` -按 **:wq** 保存并退出文件。然后,运行以下命令更新所做的更改。 +按 `:wq` 保存并退出文件。然后,运行以下命令更新所做的更改。 + ``` source ~/.bashrc ``` -安装 cabal 后,运行以下命令安装 herms: +安装 cabal 后,运行以下命令安装 `herms`: + ``` cabal install herms ``` 喝一杯咖啡!这将需要一段时间。几分钟后,你会看到一个输出,如下所示。 + ``` [...] Linking dist/build/herms/herms ... @@ -50,71 +58,77 @@ Installed herms-1.8.1.2 恭喜! Herms 已经安装完成。 -#### **添加食谱** +#### 添加食谱 -让我们添加一个食谱,例如 **Dosa**。对于那些想知道的,Dosa 是一种受欢迎的南印度食物,配以 **sambar** 和**酸辣酱**。这是一种健康的,可以说是最美味的食物。它不含添加的糖或饱和脂肪。制作一个也很容易。有几种不同的 Dosas,在我们家中最常见的是 Plain Dosa。 +让我们添加一个食谱,例如 Dosa。对于那些想知道的,Dosa 是一种受欢迎的南印度食物,配以 sambar(LCTT 译注:扁豆和酸豆炖菜,像咖喱汤) 和**酸辣酱**。这是一种健康的,可以说是最美味的食物。它不含添加的糖或饱和脂肪。制作一个也很容易。有几种不同的 Dosas,在我们家中最常见的是 Plain Dosa。 要添加食谱,请输入: + ``` herms add ``` 你会看到一个如下所示的屏幕。开始输入食谱的详细信息。 -[![][1]][2] +![][2] 要变换字段,请使用以下键盘快捷键: - * **Tab / Shift+Tab** - 下一个/前一个字段 - * **Ctrl + <箭头键>** - 导航字段 - * **[Meta 或者 Alt] + ** - 导航字段 - * **Esc** - 保存或取消。 + * `Tab` / `Shift+Tab` - 下一个/前一个字段 + * `Ctrl + <箭头键>` - 导航字段 + * `[Meta 或者 Alt] + ` - 导航字段 + * `Esc` - 保存或取消。 - -添加完配方的详细信息后,按下 ESC 键并点击 Y 保存。同样,你可以根据需要添加尽可能多的食谱。 +添加完配方的详细信息后,按下 `ESC` 键并点击 `Y` 保存。同样,你可以根据需要添加尽可能多的食谱。 要列出添加的食谱,输入: + ``` herms list ``` -[![][1]][3] +![][3] 要查看上面列出的任何食谱的详细信息,请使用下面的相应编号。 + ``` herms view 1 ``` -[![][1]][4] +![][4] 要编辑任何食谱,使用: + ``` herms edit 1 ``` -完成更改后,按下 ESC 键。系统会询问你是否要保存。你只需选择适当的选项。 +完成更改后,按下 `ESC` 键。系统会询问你是否要保存。你只需选择适当的选项。 -[![][1]][5] +![][5] 要删除食谱,命令是: + ``` herms remove 1 ``` 要为指定食谱生成购物清单,运行: + ``` herms shopping 1 ``` -[![][1]][6] +![][6] 要获得帮助,运行: + ``` herms -h ``` -当你下次听到你的同事、朋友或其他地方谈到好的食谱时,只需打开 Herms,并快速记下,并将它们分享给你的配偶。她会很高兴! +当你下次听到你的同事、朋友或其他地方谈到好的食谱时,只需打开 Herm's,并快速记下,并将它们分享给你的配偶。她会很高兴! 今天就是这些。还有更好的东西。敬请关注! @@ -126,16 +140,16 @@ herms -h via: https://www.ostechnix.com/herms-commandline-food-recipes-manager/ -作者:[][a] +作者:[SK][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/) 荣誉推出 [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 () +[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 1a4ba0ee6448571978d5d0a99f55cf1c7c61cdb5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 23 May 2018 08:43:54 +0800 Subject: [PATCH 1046/1057] PUB:20171221 A Commandline Food Recipes Manager.md @geekpi https://linux.cn/article-9669-1.html --- .../20171221 A Commandline Food Recipes Manager.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171221 A Commandline Food Recipes Manager.md (100%) diff --git a/translated/tech/20171221 A Commandline Food Recipes Manager.md b/published/20171221 A Commandline Food Recipes Manager.md similarity index 100% rename from translated/tech/20171221 A Commandline Food Recipes Manager.md rename to published/20171221 A Commandline Food Recipes Manager.md From 7ad0567a68988d915d2fd58cdff1de2954fcfe8d Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 23 May 2018 08:43:59 +0800 Subject: [PATCH 1047/1057] translated --- ...180511 3 useful things you can do with the IP tool in Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20180511 3 useful things you can do with the IP tool in Linux.md (100%) diff --git a/sources/tech/20180511 3 useful things you can do with the IP tool in Linux.md b/translated/tech/20180511 3 useful things you can do with the IP tool in Linux.md similarity index 100% rename from sources/tech/20180511 3 useful things you can do with the IP tool in Linux.md rename to translated/tech/20180511 3 useful things you can do with the IP tool in Linux.md From cdd37eb485ff39eb1b943315fd4f34300f5e89e4 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 23 May 2018 08:47:58 +0800 Subject: [PATCH 1048/1057] translating --- sources/tech/20180510 Analyzing Ansible runs using ARA.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180510 Analyzing Ansible runs using ARA.md b/sources/tech/20180510 Analyzing Ansible runs using ARA.md index c3f22ad914..a76c8b8106 100644 --- a/sources/tech/20180510 Analyzing Ansible runs using ARA.md +++ b/sources/tech/20180510 Analyzing Ansible runs using ARA.md @@ -1,3 +1,5 @@ +translating---geeekpi + Analyzing Ansible runs using ARA ====== From 6ff6b38dde0db522709e8d95d2bec1ee173864f6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 23 May 2018 11:06:32 +0800 Subject: [PATCH 1049/1057] PRF:20170320 Education of a Programmer.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @explosic4 翻译的很棒,辛苦了! --- .../20170320 Education of a Programmer.md | 102 ++++++++---------- 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/translated/talk/20170320 Education of a Programmer.md b/translated/talk/20170320 Education of a Programmer.md index 84762b8655..0837bd4c0c 100644 --- a/translated/talk/20170320 Education of a Programmer.md +++ b/translated/talk/20170320 Education of a Programmer.md @@ -1,122 +1,116 @@ 程序员的学习之路 ============================================================ -*2016 年 10 月,当我从微软离职时,我已经在微软工作了近 21 年,在工业界也快 35 年了。我花了一些时间反思我这些年来学到的东西,这些文字是那篇帖子稍加修改后得到。请见谅,文章有一点长。* +*2016 年 10 月,当我从微软离职时,我已经在微软工作了近 21 年,在业界也快 35 年了。我花了一些时间反思我这些年来学到的东西,这些文字是那篇帖子稍加修改后得到。请见谅,文章有一点长。* -要成为一名专业的程序员,你需要知道的事情多得令人吃惊:语言的细节,API,算法,数据结构,系统和工具。这些东西一直在随着时间变化——新的语言和编程环境不断出现,似乎总有热门的新工具或新语言是“每个人”都在使用的。紧跟潮流,保持专业,这很重要。木匠需要知道如何为工作选择合适的锤子和钉子,并且要有能力笔直精准地钉入钉子。 +要成为一名专业的程序员,你需要知道的事情多得令人吃惊:语言的细节、API、算法、数据结构、系统和工具。这些东西一直在随着时间变化——新的语言和编程环境不断出现,似乎总有一些“每个人”都在使用的热门的新工具或新语言。紧跟潮流,保持专业,这很重要。木匠需要知道如何为工作选择合适的锤子和钉子,并且要有能力笔直精准地钉入钉子。 与此同时,我也发现有一些理论和方法有着广泛的应用场景,它们能使用几十年。底层设备的性能和容量在这几十年来增长了几个数量级,但系统设计的思考方式还是互相有关联的,这些思考方式比具体的实现更根本。理解这些重复出现的主题对分析与设计我们所负责的系统大有帮助。 -谦卑和自我 +### 谦卑和自我 -这不仅仅局限于编程,但在编程这个持续发展的领域,一个人需要在谦卑和自我中保持平衡。总有新的东西需要学习,并且总有人能帮助你学习——如果你愿意学习的话。一个人即需要保持谦卑,认识到自己不懂并承认它,也要保持自我,相信自己能掌握一个新的领域,并且能运用你已经掌握的知识。我见过的最大的挑战就是一些人在某个领域深入专研了很长时间,“忘记”了自己擅长学习新的东西。最好的学习来自放手去做,建造一些东西,即便只是一个原型或者 hack。我知道的最好的程序员对技术有广泛的认识,但同时他们对某个技术深入研究,成为了专家。而深入的学习来自努力解决真正困难的问题。 +这不仅仅局限于编程,但在编程这个持续发展的领域,一个人需要在谦卑和自我中保持平衡。总有新的东西需要学习,并且总有人能帮助你学习——如果你愿意学习的话。一个人即需要保持谦卑,认识到自己不懂并承认它,也要保持自我,相信自己能掌握一个新的领域,并且能运用你已经掌握的知识。我见过的最大的挑战就是一些人在某个领域深入专研了很长时间,“忘记”了自己擅长学习新的东西。最好的学习来自放手去做,建造一些东西,即便只是一个原型或者 hack。我知道的最好的程序员对技术有广泛的认识,但同时他们对某个技术深入研究,成为了专家。而深入的学习来自努力解决真正困难的问题。 -端到端观点 +### 端到端观点 -1981 年,Jerry Saltzer, Dave Reed 和 Dave Clark 在做因特网和分布式系统的早期工作,他们提出了端到端观点,并作出了[经典的阐述][4]。网络上的文章有许多误传,所以更应该阅读论文本身。论文的作者很谦虚,没有声称这是他们自己的创造——从他们的角度看,这只是一个常见的工程策略,不只在通讯领域中,在其他领域中也有运用。他们只是将其写下来并收集了一些例子。下面是文章的一个小片段: +1981 年,Jerry Saltzer、 Dave Reed 和 Dave Clark 在做因特网和分布式系统的早期工作,他们提出了端到端end to end观点,并作出了[经典的阐述][4]。网络上的文章有许多误传,所以更应该阅读论文本身。论文的作者很谦虚,没有声称这是他们自己的创造——从他们的角度看,这只是一个常见的工程策略,不只在通讯领域中,在其他领域中也有运用。他们只是将其写下来并收集了一些例子。下面是文章的一个小片段: > 当我们设计系统的一个功能时,仅依靠端点的知识和端点的参与,就能正确地完整地实现这个功能。在一些情况下,系统的内部模块局部实现这个功能,可能会对性能有重要的提升。 -论文称这是一个“观点”,虽然在维基百科和其他地方它已经被上升成“原则”。实际上,还是把它看作一个观点比较好,正如作者们所说,系统设计者面临的最难的问题之一就是如何在系统组件之间划分责任,这会引发不断的讨论:怎样在划分功能时权衡利弊,怎样隔离复杂性,怎样设计一个灵活的高性能系统来满足不断变化的需求。没有简单的原则可以直接遵循。 +该论文称这是一个“观点”,虽然在维基百科和其他地方它已经被上升成“原则”。实际上,还是把它看作一个观点比较好,正如作者们所说,系统设计者面临的最难的问题之一就是如何在系统组件之间划分责任,这会引发不断的讨论:怎样在划分功能时权衡利弊,怎样隔离复杂性,怎样设计一个灵活的高性能系统来满足不断变化的需求。没有简单的原则可以直接遵循。 -互联网上的大部分讨论集中在通信系统上,但端到端观点的适用范围其实更广泛。分布式系统中的“最终一致性”就是一个例子。一个满足“最终一致性”的系统,可以让系统中的元素暂时进入不一致的状态,从而简化系统,优化性能,因为有一个更大的端到端过程来解决不一致的状态。我喜欢横向拓展的订购系统的例子(例如亚马逊),它不要求每个请求都通过中央库存的控制点。缺少中央控制点可能允许两个终端出售相同的最后一本书,所以系统需要用某种方法来解决这个问题,如通知客户该书会延期交货。不论怎样设计,想购买的最后一本书在订单完成前都有可能被仓库中的叉车运出厍(译者注:比如被其他人下单购买)。一旦你意识到你需要一个端到端的解决方案,并实现了这个方案,那系统内部的设计就可以被优化,并利用这个解决方案。 +互联网上的大部分讨论集中在通信系统上,但端到端观点的适用范围其实更广泛。分布式系统中的“最终一致性eventual consistency”就是一个例子。一个满足“最终一致性”的系统,可以让系统中的元素暂时进入不一致的状态,从而简化系统,优化性能,因为有一个更大的端到端过程来解决不一致的状态。我喜欢横向拓展的订购系统的例子(例如亚马逊),它不要求每个请求都通过中央库存的控制点。缺少中央控制点可能允许两个终端出售相同的最后一本书,所以系统需要用某种方法来解决这个问题,如通知客户该书会延期交货。不论怎样设计,想购买的最后一本书在订单完成前都有可能被仓库中的叉车运出厍(LCTT 译注:比如被其他人下单购买)。一旦你意识到你需要一个端到端的解决方案,并实现了这个方案,那系统内部的设计就可以被优化以利用这个解决方案。 事实上,这种设计上的灵活性可以优化系统的性能,或者提供其他的系统功能,从而使得端到端的方法变得如此强大。端到端的思考往往允许内部进行灵活的操作,使整个系统更加健壮,并且能适应每个组件特性的变化。这些都让端到端的方法变得健壮,并能适应变化。 -端到端方法意味着,添加会牺牲整体性能灵活性的抽象层和功能时要非常小心(也可能是其他的灵活性,但性能,特别是延迟,往往是特殊的)。如果你展示出底层的原始性能(performance, 也可能指操作),端到端的方法可以根据这个性能(操作)来优化,实现特定的需求。如果你破坏了底层性能(操作),即使你实现了重要的有附加价值的功能,你也牺牲了设计灵活性。 +端到端方法意味着,添加会牺牲整体性能灵活性的抽象层和功能时要非常小心(也可能是其他的灵活性,但性能,特别是延迟,往往是特殊的)。如果你展示出底层的原始性能(LCTT 译注:performance,也可能指操作,下同),端到端的方法可以根据这个性能(操作)来优化,实现特定的需求。如果你破坏了底层性能(操作),即使你实现了重要的有附加价值的功能,你也牺牲了设计灵活性。 如果系统足够庞大而且足够复杂,需要把整个开发团队分配给系统内部的组件,那么端到端观点可以和团队组织相结合。这些团队自然要扩展这些组件的功能,他们通常从牺牲设计上的灵活性开始,尝试在组件上实现端到端的功能。 应用端到端方法面临的挑战之一是确定端点在哪里。 俗话说,“大跳蚤上有小跳蚤,小跳蚤上有更少的跳蚤……等等”。 -关注复杂性 +### 关注复杂性 -编程是一门精确的艺术,每一行代码都要确保程序的正确执行。但这是带有误导的。编程的复杂性不在于各个部分的整合,也不在于各个部分之间如何相互交互。最健壮的程序将复杂性隔离开,让最重要的部分变的简单直接,通过简单的方式与其他部分交互。虽然隐藏复杂性和信息隐藏、数据抽象等其他设计方法一样,但我仍然觉得,如果你真的要定位出系统的复杂所在,并将其隔离开,那你需要对设计特别敏锐。 +编程是一门精确的艺术,每一行代码都要确保程序的正确执行。但这是带有误导的。编程的复杂性不在于各个部分的整合,也不在于各个部分之间如何相互交互。最健壮的程序会将复杂性隔离开,让最重要的部分变的简单直接,通过简单的方式与其他部分交互。虽然隐藏复杂性和信息隐藏、数据抽象等其他设计方法一样,但我仍然觉得,如果你真的要定位出系统的复杂所在,并将其隔离开,那你需要对设计特别敏锐。 -在我的[文章][5]中反复提到的例子是早期的终端编辑器 VI 和 Emacs 中使用的屏幕重绘算法。早期的视频终端实现了控制序列,来控制绘制字符核心操作,也实现了附加的显示功能,来优化重新绘制屏幕,如向上向下滚动当前行,或者插入新行,或在当前行中移动字符。这些命令都具有不同的开销,并且这些开销在不同制造商的设备中也是不同的。(参见[TERMCAP][6]以获取代码链接和更完整的历史记录。)像文本编辑器这样的全屏应用程序希望尽快更新屏幕,因此需要优化使用这些控制序列来转换屏幕从一个状态到另一个状态。 +在我的[文章][5]中反复提到的例子是早期的终端编辑器 VI 和 Emacs 中使用的屏幕重绘算法。早期的视频终端实现了控制序列,来控制绘制字符核心操作,也实现了附加的显示功能,来优化重新绘制屏幕,如向上向下滚动当前行,或者插入新行,或在当前行中移动字符。这些命令都具有不同的开销,并且这些开销在不同制造商的设备中也是不同的。(参见[TERMCAP][6] 以获取代码和更完整的历史记录的链接。)像文本编辑器这样的全屏应用程序希望尽快更新屏幕,因此需要优化使用这些控制序列来从一个状态到另一个状态屏幕转换。 -这些程序在设计上隐藏了底层的复杂性。系统中修改文本缓冲区的部分(功能上大多数创新都在这里)完全忽略了这些改变如何被转换成屏幕更新命令。这是可以接受的,因为针对*任何*内容的改变计算最佳命令所消耗的性能代价,远不及被终端本身实际执行这些更新命令的性能代价。在确定如何隐藏复杂性,以及隐藏哪些复杂性时,性能分析扮演着重要的角色,这一点在系统设计中非常常见。屏幕的更新与底层文本缓冲区的更改是异步的,并且可以独立于缓冲区的实际历史变化顺序。缓冲区*怎样*改变的并不重要,重要的是改变了*什么*。异步耦合,在组件交互时消除组件对历史路径依赖的组合,以及用自然的交互方式以有效地将组件组合在一起是隐藏耦合复杂度的常见特征。 +这些程序在设计上隐藏了底层的复杂性。系统中修改文本缓冲区的部分(功能上大多数创新都在这里)完全忽略了这些改变如何被转换成屏幕更新命令。这是可以接受的,因为针对*任何*内容的改变计算最佳命令所消耗的性能代价,远不及被终端本身实际执行这些更新命令的性能代价。在确定如何隐藏复杂性,以及隐藏哪些复杂性时,性能分析扮演着重要的角色,这一点在系统设计中非常常见。屏幕的更新与底层文本缓冲区的更改是异步的,并且可以独立于缓冲区的实际历史变化顺序。缓冲区是*怎样*改变的并不重要,重要的是改变了*什么*。异步耦合,在组件交互时消除组件对历史路径依赖的组合,以及用自然的交互方式以有效地将组件组合在一起是隐藏耦合复杂度的常见特征。 隐藏复杂性的成功不是由隐藏复杂性的组件决定的,而是由使用该模块的使用者决定的。这就是为什么组件的提供者至少要为组件的某些端到端过程负责。他们需要清晰的知道系统的其他部分如何与组件相互作用,复杂性是如何泄漏出来的(以及是否泄漏出来)。这常常表现为“这个组件很难使用”这样的反馈——这通常意味着它不能有效地隐藏内部复杂性,或者没有选择一个隐藏复杂性的功能边界。 -分层与组件化 +### 分层与组件化 -系统设计人员的一个基本工作是确定如何将系统分解成组件和层;决定自己要开发什么,以及从别的地方获取什么。开源项目在决定自己开发组件还是购买服务时,大多会选择自己开发,但组件之间交互的过程是一样的。在大规模工程中,理解这些决策将如何随着时间的推移而发挥作用是非常重要的。从根本上说,变化是程序员所做的一切的基础,所以这些设计决定不仅在当下被评估,还要随着产品的不断发展而在未来几年得到评估。 +系统设计人员的一个基本工作是确定如何将系统分解成组件和层;决定自己要开发什么,以及从别的地方获取什么。开源项目在决定自己开发组件还是购买服务时,大多会选择自己开发,但组件之间交互的过程是一样的。在大规模工程中,理解这些决策将如何随着时间的推移而发挥作用是非常重要的。从根本上说,变化是程序员所做的一切的基础,所以这些设计决定不仅要在当下评估,还要随着产品的不断发展而在未来几年得到评估。 以下是关于系统分解的一些事情,它们最终会占用大量的时间,因此往往需要更长的时间来学习和欣赏。 -* 层泄漏。层(或抽象)[基本上是泄漏的][1]。这些泄漏会立即产生后果,也会随着时间的推移而产生两方面的后果。其中一方面就是该抽象层的特性渗透到了系统的其他部分,渗透的程度比你意识到得更深入。这些渗透可能是关于具体的性能特征的假设,以及抽象层的文档中没有明确的指出的行为发生的顺序。这意味着假如内部组件的行为发生变化,你的系统会比想象中更加脆弱。第二方面是你比表面上看起来更依赖组件内部的行为,所以如果你考虑改变这个抽象层,后果和挑战可能超出你的想象。 +* **层泄漏。**层(或抽象)[基本上是泄漏的][1]。这些泄漏会立即产生后果,也会随着时间的推移而产生两方面的后果。其中一方面就是该抽象层的特性渗透到了系统的其他部分,渗透的程度比你意识到得更深入。这些渗透可能是关于具体的性能特征的假设,以及抽象层的文档中没有明确的指出的行为发生的顺序。这意味着假如内部组件的行为发生变化,你的系统会比想象中更加脆弱。第二方面是你比表面上看起来更依赖组件内部的行为,所以如果你考虑改变这个抽象层,后果和挑战可能超出你的想象。 +* **层具有太多功能。**您所采用的组件具有比实际需要更多的功能,这几乎是一个真理。在某些情况下,你决定采用这个组件是因为你想在将来使用那些尚未用到的功能。有时,你采用组件是想“上快车”,利用组件完成正在进行的工作。在功能强大的抽象层上开发会带来一些后果。 + 1. 组件往往会根据你并不需要的功能作出取舍。 + 2. 为了实现那些你并不没有用到的功能,组件引入了复杂性和约束,这些约束将阻碍该组件的未来的演变。 + 3. 层泄漏的范围更大。一些泄漏是由于真正的“抽象泄漏”,另一些是由于明显的,逐渐增加的对组件全部功能的依赖(但这些依赖通常都没有处理好)。Office 软件太大了,我们发现,对于我们建立的任何抽象层,我们最终都在系统的某个部分完全运用了它的功能。虽然这看起来是积极的(我们完全地利用了这个组件),但并不是所用的使用都有同样的价值。所以,我们最终要付出巨大的代价才能从一个抽象层往另一个抽象层迁移,这种“长尾”没什么价值,并且对使用场景认识不足。 + 4. 附加的功能会增加复杂性,并增加功能滥用的可能。如果将验证 XML 的 API 指定为 XML 树的一部分,那这个 API 可以选择动态下载 XML 的模式定义。这在我们的基本文件解析代码中被错误地执行,导致 w3c.org 服务器上的大量性能下降以及(无意)分布式拒绝服务攻击。(这些被通俗地称为“地雷”API)。 +* **抽象层被更换。**需求在进化,系统在进化,组件被放弃。您最终需要更换该抽象层或组件。不管是对外部组件的依赖还是对内部组件的依赖都是如此。这意味着上述问题将变得重要起来。 +* **自己构建还是购买的决定将会改变。**这是上面几方面的必然结果。这并不意味着自己构建还是购买的决定在当时是错误的。一开始时往往没有合适的组件,一段时间之后才有合适的组件出现。或者,也可能你使用了一个组件,但最终发现它不符合您不断变化的要求,而且你的要求非常窄、很好理解,或者对你的价值体系来说是非常重要的,以至于拥有自己的模块是有意义的。这意味着你像关心自己构造的模块一样,关心购买的模块,关心它们是怎样泄漏并深入你的系统中的。 +* **抽象层会变臃肿。**一旦你定义了一个抽象层,它就开始增加功能。层是对使用模式优化的自然分界点。臃肿的层的困难在于,它往往会降低您利用底层的不断创新的能力。从某种意义上说,这就是操作系统公司憎恨构建在其核心功能之上的臃肿的层的原因——采用创新的速度放缓了。避免这种情况的一种比较规矩的方法是禁止在适配器层中进行任何额外的状态存储。微软基础类在 Win32 上采用这个一般方法。在短期内,将功能集成到现有层(最终会导致上述所有问题)而不是重构和重新推导是不可避免的。理解这一点的系统设计人员寻找分解和简化组件的方法,而不是在其中增加越来越多的功能。 -* 层具有太多功能了。您所采用的组件具有比实际需要更多的功能,这几乎是一个真理。在某些情况下,你决定采用这个组件是因为你想在将来使用那些尚未用到的功能。有时,你采用组件是想“上快车”,利用组件完成正在进行的工作。在功能强大的抽象层上开发会带来一些后果。1) 组件往往会根据你并不需要的功能作出取舍。 2) 为了实现那些你并不没有用到的功能,组件引入了复杂性和约束,这些约束将阻碍该组件的未来的演变。3) 层泄漏的范围更大。一些泄漏是由于真正的“抽象泄漏”,另一些是由于明显的,逐渐增加的对组件全部功能的依赖(但这些依赖通常都没有处理好)。Office 太大了,我们发现,对于我们建立的任何抽象层,我们最终都在系统的某个部分完全运用了它的功能。虽然这看起来是积极的(我们完全地利用了这个组件),但并不是所用的使用都有同样的价值。所以,我们最终要付出巨大的代价才能从一个抽象层往另一个抽象层迁移,这种“长尾巴”没什么价值,并且对使用场景认识不足。4) 附加的功能会增加复杂性,并增加功能滥用的可能。如果将验证 XML 的 API 指定为 XML 树的一部分,那这个 API 可以选择动态下载 XML 的模式定义。这在我们的基本文件解析代码中被错误地执行,导致 w3c.org 服务器上的大量性能下降以及(无意)分布式拒绝服务攻击。(这些被通俗地称为“地雷”API)。 +### 爱因斯坦宇宙 -* 抽象层被更换。需求发展,系统发展,组件被放弃。您最终需要更换该抽象层或组件。不管是对外部组件的依赖还是对内部组件的依赖都是如此。这意味着上述问题将变得重要起来。 - -* 自己构建还是购买的决定将会改变。这是上面几方面的必然结果。这并不意味着自己构建还是购买的决定在当时是错误的。一开始时往往没有合适的组件,一段时间之后才有合适的组件出现。或者,也可能你使用了一个组件,但最终发现它不符合您不断变化的要求,而且你的要求非常窄,能被理解,或着对你的价值体系来说是非常重要的,以至于拥有自己的模块是有意义的。这意味着你像关心自己构造的模块一样,关心购买的模块,关心它们是怎样泄漏并深入你的系统中的。 - -* 抽象层会变臃肿。一旦你定义了一个抽象层,它就开始增加功能。层是对使用模式优化的自然分界点。臃肿的层的困难在于,它往往会降低您利用底层的不断创新的能力。从某种意义上说,这就是操作系统公司憎恨构建在其核心功能之上的臃肿的层的原因——采用创新的速度放缓了。避免这种情况的一种比较规矩的方法是禁止在适配器层中进行任何额外的状态存储。微软基础类在 Win32 上采用这个一般方法。在短期内,将功能集成到现有层(最终会导致上述所有问题)而不是重构和重新推导是不可避免的。理解这一点的系统设计人员寻找分解和简化组件的方法,而不是在其中增加越来越多的功能。 - -爱因斯坦宇宙 - -几十年来,我一直在设计异步分布式系统,但是在微软内部的一次演讲中,SQL 架构师 Pat Helland 的一句话震惊了我。 “我们生活在爱因斯坦的宇宙中,没有同时性。”在构建分布式系统时(基本上我们构建的都是分布式系统),你无法隐藏系统的分布式特性。这是物理的。我一直感到远程过程调用在根本上错误的,这是一个原因,尤其是那些“透明的”远程过程调用,它们就是想隐藏分布式的交互本质。你需要拥抱系统的分布式特性,因为这些意义几乎总是需要通过系统设计和用户体验来完成。 +几十年来,我一直在设计异步分布式系统,但是在微软内部的一次演讲中,SQL 架构师 Pat Helland 的一句话震惊了我。 “我们生活在爱因斯坦的宇宙中,没有同时性这种东西。”在构建分布式系统时(基本上我们构建的都是分布式系统),你无法隐藏系统的分布式特性。这是物理的。我一直感到远程过程调用在根本上错误的,这是一个原因,尤其是那些“透明的”远程过程调用,它们就是想隐藏分布式的交互本质。你需要拥抱系统的分布式特性,因为这些意义几乎总是需要通过系统设计和用户体验来完成。 拥抱分布式系统的本质则要遵循以下几个方面: * 一开始就要思考设计对用户体验的影响,而不是试图在处理错误,取消请求和报告状态上打补丁。 - * 使用异步技术来耦合组件。同步耦合是*不可能*的。如果某些行为看起来是同步的,是因为某些内部层尝试隐藏异步,这样做会遮蔽(但绝对不隐藏)系统运行时的基本行为特征。 - * 认识到并且明确设计了交互状态机,这些状态表示长期的可靠的内部系统状态(而不是由深度调用堆栈中的变量值编码的临时,短暂和不可发现的状态)。 - * 认识到失败是在所难免的。要保证能检测出分布式系统中的失败,唯一的办法就是直接看你的等待时间是否“太长”。这自然意味着[取消的等级最高][2]。系统的某一层(可能直接通向用户)需要决定等待时间是否过长,并取消操作。取消只是为了重建局部状态,回收局部的资源——没有办法在系统内广泛使用取消机制。有时用一种低成本,不可靠的方法广泛使用取消机制对优化性能可能有用。 - * 认识到取消不是回滚,因为它只是回收本地资源和状态。如果回滚是必要的,它必须实现成一个端到端的功能。 - * 承认永远不会真正知道分布式组件的状态。只要你发现一个状态,它可能就已经改变了。当你发送一个操作时,请求可能在传输过程中丢失,也可能被处理了但是返回的响应丢失了,或者请求需要一定的时间来处理,这样远程状态最终会在未来的某个任意的时间转换。这需要像幂等操作这样的方法,并且要能够稳健有效地重新发现远程状态,而不是期望可靠地跟踪分布式组件的状态。“[最终一致性][3]”的概念简洁地捕捉了这其中大多数想法。 我喜欢说你应该“陶醉在异步”。与其试图隐藏异步,不如接受异步,为异步而设计。当你看到像幂等性或不变性这样的技术时,你就认识到它们是拥抱宇宙本质的方法,而不仅仅是工具箱中的一个设计工具。 -性能 +### 性能 -我确信 Don Knuth 会对人们怎样误解他的名言“过早的优化是一切罪恶的根源”而感到震惊。事实上,性能,及性能持续超过60年的指数增长(或超过10年,取决于您是否愿意将晶体管,真空管和机电继电器的发展算入其中),为所有行业内的惊人创新和影响经济的“软件吃遍世界”的变化打下了基础。 +我确信 Don Knuth 会对人们怎样误解他的名言“过早的优化是一切罪恶的根源”而感到震惊。事实上,性能,及性能的持续超过 60 年的指数增长(或超过 10 年,取决于您是否愿意将晶体管,真空管和机电继电器的发展算入其中),为所有行业内的惊人创新和影响经济的“软件吃掉全世界”的变化打下了基础。 -要认识到这种指数变化的一个关键是,虽然系统的所有组件正在经历指数变化,但这些指数是不同的。硬盘容量的增长速度与内存容量的增长速度不同,与 CPU 的增长速度不同,与内存 CPU 之间的延迟的性能改善速度也不用。即使性能发展的趋势是由相同的基础技术驱动的,增长的指数也会有分歧。[延迟的改进从根本上改善了带宽][7]。指数变化在近距离或者短期内看起来是线性的,但随着时间的推移可能是压倒性的。系统不同组件的性能的增长不同,会出现压倒性的变化,并迫使对设计决策定期进行重新评估。 +要认识到这种指数变化的一个关键是,虽然系统的所有组件正在经历指数级变化,但这些指数是不同的。硬盘容量的增长速度与内存容量的增长速度不同,与 CPU 的增长速度不同,与内存 CPU 之间的延迟的性能改善速度也不用。即使性能发展的趋势是由相同的基础技术驱动的,增长的指数也会有分歧。[延迟的改进从根本上改善了带宽][7]。指数变化在近距离或者短期内看起来是线性的,但随着时间的推移可能是压倒性的。系统不同组件的性能的增长不同,会出现压倒性的变化,并迫使对设计决策定期进行重新评估。 -这样做的结果是,几年后,一度有意义的设计决定就不再有意义了。或者在某些情况下,二十年前有意义的方法又开始变成一个好的决定。现代内存映射的特点看起来更像是早期分时的进程切换,而不像分页那样。 (这样做有时会让我这样的老人说“这就是我们在 1975 年时用的方法”——忽略了这种方法在 40 年都没有意义,但现在又重新成为好的方法,因为两个组件之间的关系——可能是闪存和 NAND 而不是磁盘和核心内存——已经变得像以前一样了)。 +这样做的结果是,几年后,一度有意义的设计决策就不再有意义了。或者在某些情况下,二十年前有意义的方法又开始变成一个好的决策。现代内存映射的特点看起来更像是早期分时的进程切换,而不像分页那样。 (这样做有时会让我这样的老人说“这就是我们在 1975 年时用的方法”——忽略了这种方法在 40 年都没有意义,但现在又重新成为好的方法,因为两个组件之间的关系——可能是闪存和 NAND 而不是磁盘和核心内存——已经变得像以前一样了)。 -当这些指数超越人自身的限制时,重要的转变就发生了。你能从 2 的 16 次方个字符(一个人可以在几个小时打这么多字)过渡到 2 的 3 次方个字符(远超出了一个人打字的范围)。你可以捕捉比人眼能感知的分辨率更高的数字图像。或者你可以将整个音乐专辑存在小巧的磁盘上,放在口袋里。或者你可以将数字化视频录制存储在硬盘上。再通过实时流式传输的能力,可以在一个地方集中存储一次,不需要在数千个本地硬盘上重复记录。 +当这些指数超越人自身的限制时,重要的转变就发生了。你能从 2 的 16 次方个字符(一个人可以在几个小时打这么多字)过渡到 2 的 32 次方个字符(远超出了一个人打字的范围)。你可以捕捉比人眼能感知的分辨率更高的数字图像。或者你可以将整个音乐专辑存在小巧的磁盘上,放在口袋里。或者你可以将数字化视频录制存储在硬盘上。再通过实时流式传输的能力,可以在一个地方集中存储一次,不需要在数千个本地硬盘上重复记录。 -但有的东西仍然是根本的限制条件,那就是空间的三维和光速。我们又回到了爱因斯坦的宇宙。内存的分级结构将始终存在——它是物理定律的基础。稳定的存储和 IO,内存,计算和通信也都将一直存在。这些模块的相对容量,延迟和带宽将会改变,但是系统始终要考虑这些元素如何组合在一起,以及它们之间的平衡和折衷。Jim Gary 是这方面的大师。 +但有的东西仍然是根本的限制条件,那就是空间的三维和光速。我们又回到了爱因斯坦的宇宙。内存的分级结构将始终存在——它是物理定律的基础。稳定的存储和 IO、内存、计算和通信也都将一直存在。这些模块的相对容量,延迟和带宽将会改变,但是系统始终要考虑这些元素如何组合在一起,以及它们之间的平衡和折衷。Jim Gary 是这方面的大师。 -空间和光速的根本限制造成的另一个后果是,性能分析主要是关于三件事:局部化 (locality),局部化,局部化。无论是将数据打包在磁盘上,管理处理器缓存的层次结构,还是将数据合并到通信数据包中,数据如何打包在一起,如何在一段时间内从局部获取数据,数据如何在组件之间传输数据是性能的基础。把重点放在减少管理数据的代码上,增加空间和时间上的局部性,是消除噪声的好办法。 +空间和光速的根本限制造成的另一个后果是,性能分析主要是关于三件事:局部化locality局部化locality局部化locality。无论是将数据打包在磁盘上,管理处理器缓存的层次结构,还是将数据合并到通信数据包中,数据如何打包在一起,如何在一段时间内从局部获取数据,数据如何在组件之间传输数据是性能的基础。把重点放在减少管理数据的代码上,增加空间和时间上的局部性,是消除噪声的好办法。 Jon Devaan 曾经说过:“设计数据,而不是设计代码”。这也通常意味着当查看系统结构时,我不太关心代码如何交互——我想看看数据如何交互和流动。如果有人试图通过描述代码结构来解释一个系统,而不理解数据流的速率和数量,他们就不了解这个系统。 -内存的层级结构也意味着我缓存将会一直存在——即使某些系统层正在试图隐藏它。缓存是根本的,但也是危险的。缓存试图利用代码的运行时行为,来改变系统中不同组件之间的交互模式。它们需要对运行时行为进行建模,即使模型填充缓存并使缓存失效,并测试缓存命中。如果模型由于行为改变而变差或变得不佳,缓存将无法按预期运行。一个简单的指导方针是,缓存必须被检测——由于应用程序行为的改变,事物不断变化的性质和组件之间性能的平衡,缓存的行为将随着时间的推移而退化。每一个老程序员都有缓存变糟的经历。 +内存的层级结构也意味着缓存将会一直存在——即使某些系统层正在试图隐藏它。缓存是根本的,但也是危险的。缓存试图利用代码的运行时行为,来改变系统中不同组件之间的交互模式。它们需要对运行时行为进行建模,即使模型填充缓存并使缓存失效,并测试缓存命中。如果模型由于行为改变而变差或变得不佳,缓存将无法按预期运行。一个简单的指导方针是,缓存必须被检测——由于应用程序行为的改变,事物不断变化的性质和组件之间性能的平衡,缓存的行为将随着时间的推移而退化。每一个老程序员都有缓存变糟的经历。 我很幸运,我的早期职业生涯是在互联网的发源地之一 BBN 度过的。 我们很自然地将将异步组件之间的通信视为系统连接的自然方式。流量控制和队列理论是通信系统的基础,更是任何异步系统运行的方式。流量控制本质上是资源管理(管理通道的容量),但资源管理是更根本的关注点。流量控制本质上也应该由端到端的应用负责,所以用端到端的方式思考异步系统是自然的。[缓冲区膨胀][8]的故事在这种情况下值得研究,因为它展示了当对端到端行为的动态性以及技术“改进”(路由器中更大的缓冲区)缺乏理解时,在整个网络基础设施中导致的长久的问题。 - 我发现“光速”的概念在分析任何系统时都非常有用。光速分析并不是从当前的性能开始分析,而是问“这个设计理论上能达到的最佳性能是多少?”真正传递的信息是什么,以什么样的速度变化?组件之间的底层延迟和带宽是多少?光速分析迫使设计师深入思考他们的方法能否达到性能目标,或者否需要重新考虑设计的基本方法。它也迫使人们更深入地了解性能在哪里损耗,以及损耗是由固有的,还是由于一些不当行为产生的。从构建的角度来看,它迫使系统设计人员了解其构建的模块的真实性能特征,而不是关注其他功能特性。 +我发现“光速light speed”的概念在分析任何系统时都非常有用。光速分析并不是从当前的性能开始分析,而是问“这个设计理论上能达到的最佳性能是多少?”真正传递的信息是什么,以什么样的速度变化?组件之间的底层延迟和带宽是多少?光速分析迫使设计师深入思考他们的方法能否达到性能目标,或者否需要重新考虑设计的基本方法。它也迫使人们更深入地了解性能在哪里损耗,以及损耗是由固有的,还是由于一些不当行为产生的。从构建的角度来看,它迫使系统设计人员了解其构建的模块的真实性能特征,而不是关注其他功能特性。 我的职业生涯大多花费在构建图形应用程序上。用户坐在系统的一端,定义关键的常量和约束。人类的视觉和神经系统没有经历过指数性的变化。它们固有地受到限制,这意味着系统设计者可以利用(必须利用)这些限制,例如,通过虚拟化(限制底层数据模型需要映射到视图数据结构中的数量),或者通过将屏幕更新的速率限制到人类视觉系统的感知限制。 -复杂性的本质 +### 复杂性的本质 我的整个职业生涯都在与复杂性做斗争。为什么系统和应用变得复杂呢?为什么在一个应用领域内进行开发并没有随着时间变得简单,而基础设施却没有变得更复杂,反而变得更强大了?事实上,管理复杂性的一个关键方法就是“走开”然后重新开始。通常新的工具或语言迫使我们从头开始,这意味着开发人员将工具的优点与从新开始的优点结合起来。从新开始是重要的。这并不是说新工具,新平台,或新语言可能不好,但我保证它们不能解决复杂性增长的问题。控制复杂性的最简单的方法就是用更少的程序员,建立一个更小的系统。 -当然,很多情况下“走开”并不是一个选择——Office 建立在有巨大的价值的复杂的资源上。通过 OneNote, Office 从 Word 的复杂性上“走开”,从而在另一个维度上进行创新。Sway 是另一个例子, Office 决定从限制中跳出来,利用关键的环境变化,抓住机会从底层上采取全新的设计方案。我们有 Word,Excel,PowerPoint 这些应用,它们的数据结构非常有价值,我们并不能完全放弃这些数据结构,它们成为了开发中持续的显著的限制条件。 +当然,很多情况下“走开”并不是一个选择——Office 软件建立在有巨大的价值的复杂的资源上。通过 OneNote, Office 从 Word 的复杂性上“走开”,从而在另一个维度上进行创新。Sway 是另一个例子, Office 决定从限制中跳出来,利用关键的环境变化,抓住机会从底层上采取全新的设计方案。我们有 Word、Excel、PowerPoint 这些应用,它们的数据结构非常有价值,我们并不能完全放弃这些数据结构,它们成为了开发中持续的显著的限制条件。 -我受到 Fred Brook 讨论软件开发中的意外和本质的文章[《没有银子弹》][9]的影响,他希望用两个趋势来尽可能地推动程序员的生产力:一是在选择自己开发还是购买时,更多地关注购买——这预示了开源社区和云架构的改变;二是从单纯的构建方法转型到更“有机”或者“生态”的增量开发方法。现代的读者可以认为是向敏捷开发和持续开发的转型。但那篇文章可是写于 1986 年! +我受到 Fred Brook 讨论软件开发中的意外和本质的文章[《没有银弹》][9]的影响,他希望用两个趋势来尽可能地推动程序员的生产力:一是在选择自己开发还是购买时,更多地关注购买——这预示了开源社区和云架构的改变;二是从单纯的构建方法转型到更“有机”或者“生态”的增量开发方法。现代的读者可以认为是向敏捷开发和持续开发的转型。但那篇文章可是写于 1986 年! 我很欣赏 Stuart Kauffman 的在复杂性的基本性上的研究工作。Kauffman 从一个简单的布尔网络模型(“[NK 模型][10]”)开始建立起来,然后探索这个基本的数学结构在相互作用的分子,基因网络,生态系统,经济系统,计算机系统(以有限的方式)等系统中的应用,来理解紧急有序行为的数学基础及其与混沌行为的关系。在一个高度连接的系统中,你固有地有一个相互冲突的约束系统,使得它(在数学上)很难向前发展(这被看作是在崎岖景观上的优化问题)。控制这种复杂性的基本方法是将系统分成独立元素并限制元素之间的相互连接(实质上减少 NK 模型中的“N”和“K”)。当然对那些使用复杂隐藏,信息隐藏和数据抽象,并且使用松散异步耦合来限制组件之间的交互的技术的系统设计者来说,这是很自然的。 - 我们一直面临的一个挑战是,我们想到的许多拓展系统的方法,都跨越了所有的方面。实时共同编辑是 Office 应用程序最近的一个非常具体的(也是最复杂的)例子。 我们的数据模型的复杂性往往等同于“能力”。设计用户体验的固有挑战是我们需要将有限的一组手势,映射到底层数据模型状态空间的转换。增加状态空间的维度不可避免地在用户手势中产生模糊性。这是“[纯数学][11]”,这意味着确保系统保持“易于使用”的最基本的方式常常是约束底层的数据模型。 -管理 +### 管理 -我从高中开始着手一些领导角色(学生会主席!),对承担更多的责任感到理所当然。同时,我一直为自己在每个管理阶段都坚持担任全职程序员而感到自豪。但 Office 的开发副总裁最终还是让我从事管理,离开了日常的编程工作。当我在去年离开那份工作时,我很享受重返编程——这是一个出奇地充满创造力的充实的活动(当修完“最后”的 bug 时,也许也会有一点令人沮丧)。 +我从高中开始担任一些领导角色(学生会主席!),对承担更多的责任感到理所当然。同时,我一直为自己在每个管理阶段都坚持担任全职程序员而感到自豪。但 Office 软件的开发副总裁最终还是让我从事管理,离开了日常的编程工作。当我在去年离开那份工作时,我很享受重返编程——这是一个出奇地充满创造力的充实的活动(当修完“最后”的 bug 时,也许也会有一点令人沮丧)。 尽管在我加入微软前已经做了十多年的“主管”,但是到了 1996 年我加入微软才真正了解到管理。微软强调“工程领导是技术领导”。这与我的观点一致,帮助我接受并承担更大的管理责任。 @@ -124,21 +118,19 @@ Jon Devaan 曾经说过:“设计数据,而不是设计代码”。这也通 我过去说我的工作是设计反馈回路。独立工程师,经理,行政人员,每一个项目的参与者都能通过分析记录的项目数据,推进项目,产出结果,了解自己在整个项目中扮演的角色。最终,透明化最终成为增强能力的一个很好的工具——管理者可以将更多的局部控制权给予那些最接近问题的人,因为他们对所取得的进展有信心。这样的话,合作自然就会出现。 -Key to this is that the goal has actually been properly framed (including key resource constraints like ship schedule). Decision-making that needs to constantly flow up and down the management chain usually reflects poor framing of goals and constraints by management. - 关键需要确定目标框架(包括关键资源的约束,如发布的时间表)。如果决策需要在管理链上下不断流动,那说明管理层对目标和约束的框架不好。 -当我在 Beyond Software 工作时,我真正理解了一个项目拥有一个唯一领导的重要性。原来的项目经理离职了(后来从 FrontPage 雇佣了我)。我们四个主管在是否接任这个岗位上都有所犹豫,这不仅仅由于我们都不知道要在这家公司坚持多久。我们都技术高超,并且相处融洽,所以我们决定以同级的身份一起来领导这个项目。然而这槽糕透了。有一个显而易见的问题,我们没有相应的战略用来在原有的组织之间分配资源——这应当是管理者的首要职责之一!当你知道你是唯一的负责人时,你会有很深的责任感,但在这个例子中,这种责任感缺失了。我们没有真正的领导来负责统一目标和界定约束。 +当我在 Beyond Software 工作时,我真正理解了一个项目拥有一个唯一领导的重要性。原来的项目经理离职了(后来从 FrontPage 团队雇佣了我)。我们四个主管在是否接任这个岗位上都有所犹豫,这不仅仅由于我们都不知道要在这家公司坚持多久。我们都技术高超,并且相处融洽,所以我们决定以同级的身份一起来领导这个项目。然而这槽糕透了。有一个显而易见的问题,我们没有相应的战略用来在原有的组织之间分配资源——这应当是管理者的首要职责之一!当你知道你是唯一的负责人时,你会有很深的责任感,但在这个例子中,这种责任感缺失了。我们没有真正的领导来负责统一目标和界定约束。 -我有清晰地记得,我第一次充分认识到*倾听*对一个领导者的重要性。那时我刚刚担任了 Word,OneNote,Publisher 和 Text Services 团队的开发经理。关于我们如何组织文本服务团队,我们有一个很大的争议,我走到了每个关键参与者身边,听他们想说的话,然后整合起来,写下了我所听到的一切。当我向其中一位主要参与者展示我写下的东西时,他的反应是“哇,你真的听了我想说的话”!作为一名管理人员,我所经历的所有最大的问题(例如,跨平台和转型持续工程)涉及到仔细倾听所有的参与者。倾听是一个积极的过程,它包括:尝试以别人的角度去理解,然后写出我学到的东西,并对其进行测试,以验证我的理解。当一个关键的艰难决定需要发生的时候,在最终决定前,每个人都知道他们的想法都已经被听到并理解(不论他们是否同意最后的决定)。 +我有清晰地记得,我第一次充分认识到*倾听*对一个领导者的重要性。那时我刚刚担任了 Word、OneNote、Publisher 和 Text Services 团队的开发经理。关于我们如何组织文本服务团队,我们有一个很大的争议,我走到了每个关键参与者身边,听他们想说的话,然后整合起来,写下了我所听到的一切。当我向其中一位主要参与者展示我写下的东西时,他的反应是“哇,你真的听了我想说的话”!作为一名管理人员,我所经历的所有最大的问题(例如,跨平台和转型持续工程)涉及到仔细倾听所有的参与者。倾听是一个积极的过程,它包括:尝试以别人的角度去理解,然后写出我学到的东西,并对其进行测试,以验证我的理解。当一个关键的艰难决定需要发生的时候,在最终决定前,每个人都知道他们的想法都已经被听到并理解(不论他们是否同意最后的决定)。 -在 FrontPage 担任开发经理的工作,让我理解了在只有部分信息的情况下做决定的“操作困境”。你等待的时间越长,你就会有更多的信息做出决定。但是等待的时间越长,实际执行的灵活性就越低。在某个时候,你仅需要做出决定。 +在 FrontPage 团队担任开发经理的工作,让我理解了在只有部分信息的情况下做决定的“操作困境”。你等待的时间越长,你就会有更多的信息做出决定。但是等待的时间越长,实际执行的灵活性就越低。在某个时候,你仅需要做出决定。 -设计一个组织涉及类似的两难情形。您希望增加资源领域,以便可以在更大的一组资源上应用一致的优先级划分框架。但资源领域越大,越难获得作出决定所需要的所有信息。组织设计就是要平衡这两个因素。软件复杂化,因为软件的特点可以在任意维度切入设计。Office 已经使用[共享团队][12]来解决这两个问题(优先次序和资源),让跨领域的团队能与需要产品的团队分享工作(增加资源)。 +设计一个组织涉及类似的两难情形。您希望增加资源领域,以便可以在更大的一组资源上应用一致的优先级划分框架。但资源领域越大,越难获得作出决定所需要的所有信息。组织设计就是要平衡这两个因素。软件复杂化,因为软件的特点可以在任意维度切入设计。Office 软件部门已经使用[共享团队][12]来解决这两个问题(优先次序和资源),让跨领域的团队能与需要产品的团队分享工作(增加资源)。 随着管理阶梯的提升,你会懂一个小秘密:你和你的新同事不会因为你现在承担更多的责任,就突然变得更聪明。这强调了整个组织比顶层领导者更聪明。赋予每个级别在一致框架下拥有自己的决定是实现这一目标的关键方法。听取并使自己对组织负责,阐明和解释决策背后的原因是另一个关键策略。令人惊讶的是,害怕做出一个愚蠢的决定可能是一个有用的激励因素,以确保你清楚地阐明你的推理,并确保你听取所有的信息。 -结语 +### 结语 我离开大学寻找第一份工作时,面试官在最后一轮面试时问我对做“系统”和做“应用”哪一个更感兴趣。我当时并没有真正理解这个问题。在软件技术栈的每一个层面都会有趣的难题,我很高兴深入研究这些问题。保持学习。 @@ -146,9 +138,9 @@ Key to this is that the goal has actually been properly framed (including key re via: https://hackernoon.com/education-of-a-programmer-aaecf2d35312 -作者:[ Terry Crowley][a] +作者:[Terry Crowley][a] 译者:[explosic4](https://github.com/explosic4) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d4f35218183490ef5bc880701694242149cc2eb2 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 23 May 2018 11:06:59 +0800 Subject: [PATCH 1050/1057] PUB:20170320 Education of a Programmer.md @explosic4 https://linux.cn/article-9670-1.html --- .../talk => published}/20170320 Education of a Programmer.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20170320 Education of a Programmer.md (100%) diff --git a/translated/talk/20170320 Education of a Programmer.md b/published/20170320 Education of a Programmer.md similarity index 100% rename from translated/talk/20170320 Education of a Programmer.md rename to published/20170320 Education of a Programmer.md From f682cd72123bd179d1c00f571c223b3465323e46 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 23 May 2018 11:43:58 +0800 Subject: [PATCH 1051/1057] PRF:20180405 Getting started with Vagrant.md @MjSeven --- .../20180405 Getting started with Vagrant.md | 144 +++++++----------- 1 file changed, 56 insertions(+), 88 deletions(-) diff --git a/translated/tech/20180405 Getting started with Vagrant.md b/translated/tech/20180405 Getting started with Vagrant.md index b3bdf5b537..4377098e7d 100644 --- a/translated/tech/20180405 Getting started with Vagrant.md +++ b/translated/tech/20180405 Getting started with Vagrant.md @@ -1,157 +1,125 @@ 开始 Vagrant 之旅 ===== +> 用管理虚拟机和容器的工具 Vagrant 清理你的开发环境和依赖。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_scale_performance.jpg?itok=R7jyMeQf) -如果你和我一样,你可能在某一个地方有一个“沙盒”,你可以在那里进行你正在做的任何项目。随着时间的推移,沙箱会变得杂乱无章,充斥着各种想法,工具链元素,你不使用的代码模块,以及其他你不需要的东西。当你完成某件事情时,这会使你的部署变得复杂,因为你可能不确定项目的实际依赖关系 - 随着时间推移你在沙盒中已经有了一些工具,但是你忘了必须安装它。你需要一个干净的环境,将所有的依赖关系放在一个地方,以便以后更方便。 + +如果你和我一样,你可能在某一个地方有一个“沙盒”,你可以在那里进行你正在做的任何项目。随着时间的推移,沙盒会变得杂乱无章,充斥着各种想法、工具链元素、你不使用的代码模块,以及其他你不需要的东西。当你完成某件事情时,这会使你的部署变得复杂,因为你可能不确定项目的实际依赖关系 —— 随着时间推移你在沙盒中已经有了一些工具,但是你忘了必须安装它。你需要一个干净的环境,将所有的依赖关系放在一个地方,以便以后更方便。 或者你可能工作在 DevOps 中,你所服务的开发人员用模糊的依赖关系来编写代码,这使得测试变得更加困难。你需要一种方法来获得一个干净的盒子,将代码放入其中,并通过它运行代码,而且你希望这些环境是一次性的和可重复的。 -那么选择 [Vagrant][1] 吧。由 HashiCorp 根据 [MIT License][2] 创建,Vagrant 可充当 VirtualBox, Microsoft Hyper-V 或 Docker 容器的包装器和前端,并且可以通过[许多其他供应商][3]的插件进行扩展。你可以配置 Vagrant 以提供可重复干净的环境,并且已安装需要的基础架构。配置脚本是可移植的,因此,如果你的仓库和 Vagrant 配置脚本位于基于云存储上,那么你只需要很少的限制就可以启动并在多台机器机器上工作。让我们来看一看。 +那么选择 [Vagrant][1] 吧。由 HashiCorp 在 [MIT 许可证][2]下创建,Vagrant 可充当 VirtualBox、Microsoft Hyper-V 或 Docker 容器的包装器和前端,并且可以通过[许多其他供应商][3]的插件进行扩展。你可以配置 Vagrant 以提供可重复的、干净的环境,并且已安装需要的基础架构。配置脚本是可移植的,因此,如果你的仓库和 Vagrant 配置脚本位于基于云存储上,那么你只需要很少的限制就可以启动并在多台机器机器上工作。让我们来看一看。 ### 安装 -对于本次安装,我的环境是 Linux Mint 桌面,版本是 18.3 Cinnamon 64 位,在其他大多数 Debian 派生系统上安装非常类似。在大多数发行版中,对于基于 RPM 的系统也有类似的安装程序。Vagrant 的[安装页面][4]为 Debian, Windows, CentOS, MacOS 和 Arch Linux 都提供下载,但是我在我的软件包管理器中找到了它,所以我在那进行了安装。 +对于本次安装,我的环境是 Linux Mint 桌面,版本是 18.3 Cinnamon 64 位,在其他大多数 Debian 派生系统上安装非常类似。在大多数发行版中,对于基于 RPM 的系统也有类似的安装程序。Vagrant 的[安装页面][4]为 Debian、 Windows、 CentOS、 MacOS 和 Arch Linux 都提供下载,但是我在我的软件包管理器中找到了它,所以我在那进行了安装。 最简单的安装使用了 VirtualBox 作为虚拟化提供者,所以我需要安装它: + ``` sudo apt-get install virtualbox vagrant - ``` -安装程序将会获取依赖项 - 主要是 Ruby 一些东西,安装它们。 +安装程序将会获取依赖项 —— 主要是 Ruby 的一些东西,安装它们。 ### 建立一个项目 -在设置你的项目之前,你需要了解一些你想要运行它的环境。你可以在 [Vagrant Boxes 仓库][5]中为许多虚拟化提供者找到大量预配置的盒子。许多会预先配置一些你可能需要的核心基础设置,比如 PHP, MySQL 和 Apache,但是对于本次测试,我将安装一个 Debian 8 64 位裸机 "Jessie" 沙盒并手动安装一些东西,这样你就可以看到具体过程了。 +在设置你的项目之前,你需要了解一些你想要运行它的环境。你可以在 [Vagrant Boxes 仓库][5]中找到为许多虚拟化供应商提供的大量预配置的系统box。许多会预先配置一些你可能需要的核心基础设置,比如 PHP、 MySQL 和 Apache,但是对于本次测试,我将安装一个 Debian 8 64 位 “Jessie” 裸机沙盒并手动安装一些东西,这样你就可以看到具体过程了。 + ``` mkdir ~/myproject - cd ~/myproject - vagrant init debian/contrib-jessie64 - vagrant up - ``` -最后一条命令将根据需要从仓库中获取或更新 VirtualBox 镜像,然后拉起启动器,你的系统上会出现一个运行框!下次启动这个项目时,除非镜像已经在仓库中更新,否则不会花费太长时间。 +最后一条命令将根据需要从仓库中获取或更新 VirtualBox 镜像,然后运行启动器,你的系统上会出现一个运行的系统!下次启动这个项目时,除非镜像已经在仓库中更新,否则不会花费太长时间。 -要访问沙盒,只需要输入 `vagrant ssh`,你将被放到虚拟机的全功能 SSH 会话中,你将会是 `vagrant` 用户,但你是 `sudo` 组的成员,所以你可以切换到 root,并在这里做你想做的任何事情。 +要访问该沙盒,只需要输入 `vagrant ssh`,你将进入虚拟机的全功能 SSH 会话中,你将会是 `vagrant` 用户,但也是 `sudo` 组的成员,所以你可以切换到 root,并在这里做你想做的任何事情。 -你会在沙盒中看到一个名为 `/vagrant` 目录,对这个目录小心点,因为它与你主机上的 `~/myproject` 文件夹保持同步。在虚拟机 `/vagrant` 下建立一个文件它会立即复制到主机上,反之亦然。注意,有些沙盒并没有安装 VirtualBox 的附加功能,所以拷贝只能在启动时才起作用。有一些用于手动同步的命令行工具,这可能是测试环境中非常有用的特性。我倾向于坚持使用那些有附加功能的沙盒,所以这个目录正常工作,不必考虑它。 +你会在沙盒中看到一个名为 `/vagrant` 目录,对这个目录小心点,因为它与你主机上的 `~/myproject` 文件夹保持同步。在虚拟机 `/vagrant` 下建立一个文件它会立即复制到主机上,反之亦然。注意,有些沙盒并没有安装 VirtualBox 的附加功能,所以拷贝只能在启动时才起作用。有一些用于手动同步的命令行工具,这可能是测试环境中非常有用的特性。我倾向于坚持使用那些有附加功能的沙盒,所以这个目录可以正常工作,不必考虑它。 -这个方案的好处很快显现出来了: 如果你在主机上有一个代码编辑工具链,并处于某种原因不希望它出现在虚拟机上,那么这不是问题 - 在主机上进行编辑,虚拟机会立刻更改。快速更改虚拟机,它也将其同步到主机上的“官方”副本 +这个方案的好处很快显现出来了: 如果你在主机上有一个代码编辑工具链,并处于某种原因不希望它出现在虚拟机上,那么这不是问题 —— 在主机上进行编辑,虚拟机会立刻更改。快速更改虚拟机,它也将其同步到主机上的“官方”副本 。 -让我们关闭这个盒子,这样我们就可以在这个盒子里提供一些我们需要的东西:`vagrant halt`。 +让我们关闭这个系统,这样我们就可以在这个系统里提供一些我们需要的东西: -### 在 Vm 上安装额外的软件 +``` +vagrant halt +``` + +### 在虚拟机上安装额外的软件 + +对于这个例子,我将使用 [Apache][6]、 [PostgreSQL][7] 和 Perl 的 [Dancer][8] web 框架进行项目开发。我将修改Vagrant 配置脚本,以便我需要的东西已经安装。 为了使之稍后更容易保持更新,我将在项目根目录下创建一个脚本`~/myproject/Vagrantfile`: -对于这个例子,我将使用 [Apache][6], [PostgreSQL][7] 和 [Dancer][8] web 框架为 Perl 的一个项目开发。我将修改Vagrant配置脚本,以便我需要的东西已经安装。 为了使事情更容易保持稍后更新,我将在项目根目录下创建一个脚本`~/myproject/Vagrantfile`: ``` $provision_script = <